commit 80e4f07acaba708d288ffafbef418ed14a350458
parent 7b0205f00d883bf0c4b752e94c493251f1e40fd5
Author: Rolf Eike Beer <eike@sf-mail.de>
Date: Mon, 9 Nov 2020 17:51:34 +0100
replace "sizeof foo" with sizeof(foo)
Both styles were used in the codebase, stick to one that seems less fragile.
Diffstat:
15 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/condredirect.c b/condredirect.c
@@ -19,8 +19,8 @@ GEN_QMAILPUT_WRITE(&qqt)
char inbuf[SUBSTDIO_INSIZE];
char outbuf[1];
-substdio ssin = SUBSTDIO_FDBUF(read,0,inbuf,sizeof inbuf);
-substdio ssout = SUBSTDIO_FDBUF(qmail_put_write,-1,outbuf,sizeof outbuf);
+substdio ssin = SUBSTDIO_FDBUF(read,0,inbuf,sizeof(inbuf));
+substdio ssout = SUBSTDIO_FDBUF(qmail_put_write,-1,outbuf,sizeof(outbuf));
char num[FMT_ULONG];
diff --git a/forward.c b/forward.c
@@ -16,8 +16,8 @@ GEN_QMAILPUT_WRITE(&qqt)
char inbuf[SUBSTDIO_INSIZE];
char outbuf[1];
-substdio ssin = SUBSTDIO_FDBUF(read,0,inbuf,sizeof inbuf);
-substdio ssout = SUBSTDIO_FDBUF(qmail_put_write,-1,outbuf,sizeof outbuf);
+substdio ssin = SUBSTDIO_FDBUF(read,0,inbuf,sizeof(inbuf));
+substdio ssout = SUBSTDIO_FDBUF(qmail_put_write,-1,outbuf,sizeof(outbuf));
char num[FMT_ULONG];
diff --git a/instpackage.c b/instpackage.c
@@ -132,7 +132,7 @@ void c(char *home, char *subdir, char *file, uid_t uid, gid_t gid, int mode)
ddhome(&dh, home);
home=dh.s;
- substdio_fdbuf(&ssin,read,fdin,inbuf,sizeof inbuf);
+ substdio_fdbuf(&ssin,read,fdin,inbuf,sizeof(inbuf));
if (chdir(home) == -1)
strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
@@ -142,7 +142,7 @@ void c(char *home, char *subdir, char *file, uid_t uid, gid_t gid, int mode)
fdout = open_trunc(file);
if (fdout == -1)
strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
- substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof outbuf);
+ substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof(outbuf));
switch(substdio_copy(&ssout,&ssin)) {
case -2:
@@ -177,7 +177,7 @@ void z(char *home, char *file, int len, uid_t uid, gid_t gid, int mode)
fdout = open_trunc(file);
if (fdout == -1)
strerr_die6sys(111,FATAL,"unable to write ",home,"/",file,": ");
- substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof outbuf);
+ substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof(outbuf));
while (len-- > 0)
if (substdio_put(&ssout,"",1) == -1)
diff --git a/preline.c b/preline.c
@@ -22,8 +22,8 @@ int flagdtline = 1; char *dtline;
char outbuf[SUBSTDIO_OUTSIZE];
char inbuf[SUBSTDIO_INSIZE];
-substdio ssout = SUBSTDIO_FDBUF(write,1,outbuf,sizeof outbuf);
-substdio ssin = SUBSTDIO_FDBUF(read,0,inbuf,sizeof inbuf);
+substdio ssout = SUBSTDIO_FDBUF(write,1,outbuf,sizeof(outbuf));
+substdio ssin = SUBSTDIO_FDBUF(read,0,inbuf,sizeof(inbuf));
int main(int argc, char **argv)
{
diff --git a/qmail-newmrh.c b/qmail-newmrh.c
@@ -42,7 +42,7 @@ int main(void)
fd = open_read("control/morercpthosts");
if (fd == -1) die_read();
- substdio_fdbuf(&ssin,read,fd,inbuf,sizeof inbuf);
+ substdio_fdbuf(&ssin,read,fd,inbuf,sizeof(inbuf));
fdtemp = open_trunc("control/morercpthosts.tmp");
if (fdtemp == -1) die_write();
diff --git a/qmail-pop3d.c b/qmail-pop3d.c
@@ -28,13 +28,13 @@ GEN_SAFE_TIMEOUTREAD(saferead,1200,fd,die())
GEN_SAFE_TIMEOUTWRITE(safewrite,1200,fd,die())
char sserrbuf[128];
-substdio sserr = SUBSTDIO_FDBUF(safewrite,2,sserrbuf,sizeof sserrbuf);
+substdio sserr = SUBSTDIO_FDBUF(safewrite,2,sserrbuf,sizeof(sserrbuf));
char ssoutbuf[1024];
-substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof ssoutbuf);
+substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof(ssoutbuf));
char ssinbuf[128];
-substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf);
+substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof(ssinbuf));
void put(buf,len) char *buf; int len;
{
diff --git a/qmail-popup.c b/qmail-popup.c
@@ -20,10 +20,10 @@ GEN_SAFE_TIMEOUTREAD(saferead,1200,fd,die())
GEN_SAFE_TIMEOUTWRITE(safewrite,1200,fd,die())
char ssoutbuf[128];
-substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof ssoutbuf);
+substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof(ssoutbuf));
char ssinbuf[128];
-substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf);
+substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof(ssinbuf));
void puts(s) char *s;
{
@@ -88,7 +88,7 @@ char *pass;
_exit(1);
}
close(pi[0]);
- substdio_fdbuf(&ssup,write,pi[1],upbuf,sizeof upbuf);
+ substdio_fdbuf(&ssup,write,pi[1],upbuf,sizeof(upbuf));
if (substdio_put(&ssup,user,userlen) == -1) die_write();
if (substdio_put(&ssup,pass,str_len(pass) + 1) == -1) die_write();
if (substdio_puts(&ssup,"<") == -1) die_write();
@@ -98,7 +98,7 @@ char *pass;
if (substdio_flush(&ssup) == -1) die_write();
close(pi[1]);
byte_zero(pass,str_len(pass));
- byte_zero(upbuf,sizeof upbuf);
+ byte_zero(upbuf,sizeof(upbuf));
if (wait_pid(&wstat,child) == -1) die();
if (wait_crashed(wstat)) die_childcrashed();
if (wait_exitcode(wstat)) die_badauth();
diff --git a/qmail-qmqpc.c b/qmail-qmqpc.c
@@ -38,9 +38,9 @@ GEN_SAFE_TIMEOUTREAD(saferead,60,qmqpfd,die_conn())
GEN_SAFE_TIMEOUTWRITE(safewrite,60,qmqpfd,die_conn())
char buf[1024];
-substdio to = SUBSTDIO_FDBUF(safewrite,-1,buf,sizeof buf);
-substdio from = SUBSTDIO_FDBUF(saferead,-1,buf,sizeof buf);
-substdio envelope = SUBSTDIO_FDBUF(read,1,buf,sizeof buf);
+substdio to = SUBSTDIO_FDBUF(safewrite,-1,buf,sizeof(buf));
+substdio from = SUBSTDIO_FDBUF(saferead,-1,buf,sizeof(buf));
+substdio envelope = SUBSTDIO_FDBUF(read,1,buf,sizeof(buf));
/* WARNING: can use only one of these at a time! */
stralloc beforemessage = {0};
diff --git a/qmail-qmqpd.c b/qmail-qmqpd.c
@@ -29,9 +29,9 @@ ssize_t saferead(int fd, void *buf, size_t len)
}
char ssinbuf[512];
-substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf);
+substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof(ssinbuf));
char ssoutbuf[256];
-substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof ssoutbuf);
+substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof(ssoutbuf));
unsigned long bytesleft = 100;
diff --git a/qmail-qmtpd.c b/qmail-qmtpd.c
@@ -26,7 +26,7 @@ ssize_t safewrite(int fd, const void *buf, size_t len)
}
char ssoutbuf[256];
-substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof ssoutbuf);
+substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof(ssoutbuf));
ssize_t saferead(int fd, void *buf, size_t len)
{
@@ -38,7 +38,7 @@ ssize_t saferead(int fd, void *buf, size_t len)
}
char ssinbuf[512];
-substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf);
+substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof(ssinbuf));
unsigned long getlen()
{
diff --git a/qmail-remote.c b/qmail-remote.c
@@ -110,11 +110,11 @@ GEN_SAFE_TIMEOUTREAD(saferead,timeout,smtpfd,dropped())
GEN_SAFE_TIMEOUTWRITE(safewrite,timeout,smtpfd,dropped())
char inbuf[1024];
-substdio ssin = SUBSTDIO_FDBUF(read,0,inbuf,sizeof inbuf);
+substdio ssin = SUBSTDIO_FDBUF(read,0,inbuf,sizeof(inbuf));
char smtptobuf[1024];
-substdio smtpto = SUBSTDIO_FDBUF(safewrite,-1,smtptobuf,sizeof smtptobuf);
+substdio smtpto = SUBSTDIO_FDBUF(safewrite,-1,smtptobuf,sizeof(smtptobuf));
char smtpfrombuf[128];
-substdio smtpfrom = SUBSTDIO_FDBUF(saferead,-1,smtpfrombuf,sizeof smtpfrombuf);
+substdio smtpfrom = SUBSTDIO_FDBUF(saferead,-1,smtpfrombuf,sizeof(smtpfrombuf));
stralloc smtptext = {0};
diff --git a/qmail-smtpd.c b/qmail-smtpd.c
@@ -32,7 +32,7 @@ int timeout = 1200;
GEN_SAFE_TIMEOUTWRITE(safewrite,timeout,fd,_exit(1))
char ssoutbuf[512];
-substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof ssoutbuf);
+substdio ssout = SUBSTDIO_FDBUF(safewrite,1,ssoutbuf,sizeof(ssoutbuf));
void flush() { substdio_flush(&ssout); }
void out(s) char *s; { substdio_puts(&ssout,s); }
@@ -270,7 +270,7 @@ ssize_t saferead(int fd, void *buf, size_t len)
}
char ssinbuf[1024];
-substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof ssinbuf);
+substdio ssin = SUBSTDIO_FDBUF(saferead,0,ssinbuf,sizeof(ssinbuf));
struct qmail qqt;
unsigned int bytestooverflow = 0;
diff --git a/qmail-tcpok.c b/qmail-tcpok.c
@@ -26,8 +26,8 @@ int main(void)
if (lock_ex(fd) == -1)
strerr_die4sys(111,FATAL,"unable to lock ",auto_qmail,"/queue/lock/tcpto: ");
- substdio_fdbuf(&ss,write,fd,buf,sizeof buf);
- for (i = 0;i < sizeof buf;++i) substdio_put(&ss,"",1);
+ substdio_fdbuf(&ss,write,fd,buf,sizeof(buf));
+ for (i = 0;i < sizeof(buf);++i) substdio_put(&ss,"",1);
if (substdio_flush(&ss) == -1)
strerr_die4sys(111,FATAL,"unable to clear ",auto_qmail,"/queue/lock/tcpto: ");
return 0;
diff --git a/remoteinfo.c b/remoteinfo.c
@@ -59,10 +59,10 @@ int timeout;
len += fmt_ulong(line + len,lp);
len += fmt_str(line + len,"\r\n");
- substdio_fdbuf(&ss,mywrite,s,buf,sizeof buf);
+ substdio_fdbuf(&ss,mywrite,s,buf,sizeof(buf));
if (substdio_putflush(&ss,line,len) == -1) { close(s); return 0; }
- substdio_fdbuf(&ss,myread,s,buf,sizeof buf);
+ substdio_fdbuf(&ss,myread,s,buf,sizeof(buf));
x = line;
numcolons = 0;
for (;;) {
diff --git a/tests/unittest_blast.c b/tests/unittest_blast.c
@@ -55,8 +55,8 @@ int writestub(int fd, const char *buf, int len)
static void ssin_setup(const char *indata, const char *outdata)
{
- substdio tmpin = SUBSTDIO_FDBUF(readstub,-1,inbuf,sizeof inbuf);
- substdio tmpto = SUBSTDIO_FDBUF(writestub,-1,smtptobuf,sizeof smtptobuf);
+ substdio tmpin = SUBSTDIO_FDBUF(readstub,-1,inbuf,sizeof(inbuf));
+ substdio tmpto = SUBSTDIO_FDBUF(writestub,-1,smtptobuf,sizeof(smtptobuf));
ssin = tmpin;
smtpto = tmpto;