commit 3212ea53fde91e4394a5195b5fcd2d48d447735d parent cff53ac08dadec27debcbfe6ea9bf76ae979247c Author: Rolf Eike Beer <eike@sf-mail.de> Date: Sun, 24 May 2020 15:50:49 +0200 make all main() functions return int While at it change them to C89 function signatures. Add a few tests for argc so there is no warning about that being unused. Diffstat:
56 files changed, 79 insertions(+), 122 deletions(-)
diff --git a/auto-int.c b/auto-int.c @@ -13,15 +13,14 @@ char *s; if (substdio_puts(&ss1,s) == -1) _exit(111); } -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { char *name; char *value; unsigned long num; char strnum[FMT_ULONG]; + if (argc != 3) _exit(100); name = argv[1]; if (!name) _exit(100); value = argv[2]; diff --git a/auto-int8.c b/auto-int8.c @@ -13,15 +13,14 @@ char *s; if (substdio_puts(&ss1,s) == -1) _exit(111); } -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { char *name; char *value; unsigned long num; char strnum[FMT_ULONG]; + if (argc != 3) _exit(100); name = argv[1]; if (!name) _exit(100); value = argv[2]; diff --git a/auto-str.c b/auto-str.c @@ -23,15 +23,14 @@ static int is_legible(unsigned char ch) return 0; } -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { char *name; char *value; unsigned char ch; char octal[4]; + if (argc != 3) _exit(100); name = argv[1]; if (!name) _exit(100); value = argv[2]; diff --git a/bouncesaying.c b/bouncesaying.c @@ -7,14 +7,12 @@ #define FATAL "bouncesaying: fatal: " -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { int pid; int wstat; - if (!argv[1]) + if (argc == 1) strerr_die1x(100,"bouncesaying: usage: bouncesaying error [ program [ arg ... ] ]"); if (argv[2]) { diff --git a/chkbiofl.c b/chkbiofl.c @@ -1,4 +1,4 @@ -int main() +int main(void) { unsigned int a = 0x80000000, b = 0x80000000, c; return !__builtin_add_overflow(a, b, &c) && !__builtin_mul_overflow(a, b, &c); diff --git a/chkspawn.c b/chkspawn.c @@ -8,7 +8,7 @@ char num[FMT_ULONG]; fd_set fds; -void main() +int main(void) { unsigned long hiddenlimit; unsigned long maxnumd; diff --git a/condredirect.c b/condredirect.c @@ -28,9 +28,7 @@ substdio ssout = SUBSTDIO_FDBUF(mywrite,-1,outbuf,sizeof outbuf); char num[FMT_ULONG]; -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { char *sender; char *dtline; @@ -38,7 +36,7 @@ char **argv; int wstat; char *qqx; - if (!argv[1] || !argv[2]) + if (argc < 3) strerr_die1x(100,"condredirect: usage: condredirect newaddress program [ arg ... ]"); pid = fork(); diff --git a/dnsfq.c b/dnsfq.c @@ -10,11 +10,9 @@ stralloc sa = {0}; ipalloc ia = {0}; -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { - if (!argv[1]) _exit(100); + if (argc == 1) _exit(100); if (!stralloc_copys(&sa,argv[1])) { substdio_putsflush(subfderr,"out of memory\n"); _exit(111); } diff --git a/dnsip.c b/dnsip.c @@ -12,13 +12,11 @@ char temp[IPFMT]; stralloc sa = {0}; ipalloc ia = {0}; -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { int j; - if (!argv[1]) _exit(100); + if (argc == 1) _exit(100); if (!stralloc_copys(&sa,argv[1])) { substdio_putsflush(subfderr,"out of memory\n"); _exit(111); } diff --git a/dnsptr.c b/dnsptr.c @@ -11,11 +11,9 @@ stralloc sa = {0}; struct ip_address ip; -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { - if (!argv[1]) _exit(100); + if (argc == 1) _exit(100); ip_scan(argv[1],&ip); diff --git a/except.c b/except.c @@ -6,14 +6,12 @@ #define FATAL "except: fatal: " -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { int pid; int wstat; - if (!argv[1]) + if (argc == 1) strerr_die1x(100,"except: usage: except program [ arg ... ]"); pid = fork(); diff --git a/forward.c b/forward.c @@ -25,13 +25,12 @@ substdio ssout = SUBSTDIO_FDBUF(mywrite,-1,outbuf,sizeof outbuf); char num[FMT_ULONG]; -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { char *sender; char *dtline; char *qqx; + int i; sig_pipeignore(); @@ -52,7 +51,8 @@ char **argv; num[fmt_ulong(num,qmail_qp(&qqt))] = 0; qmail_from(&qqt,sender); - while (*++argv) qmail_to(&qqt,*argv); + for (i = 1; i < argc; i++) + qmail_to(&qqt,argv[i]); qqx = qmail_close(&qqt); if (*qqx) strerr_die2x(*qqx == 'D' ? 100 : 111,FATAL,qqx + 1); strerr_die2x(0,"forward: qp ",num); diff --git a/hostname.c b/hostname.c @@ -5,7 +5,7 @@ char host[256]; -void main() +int main(void) { host[0] = 0; /* sigh */ gethostname(host,sizeof(host)); diff --git a/instcheck.c b/instcheck.c @@ -77,7 +77,7 @@ void z(char *home, char *file, int len, uid_t uid, gid_t gid, int mode) perm("",home,"/",file,S_IFREG,uid,gid,mode); } -void main() +int main(void) { init_uidgid(); hier(); diff --git a/instchown.c b/instchown.c @@ -69,7 +69,7 @@ void z(char *home, char *file, int len, uid_t uid, gid_t gid, int mode) strerr_die6sys(111,FATAL,"unable to chmod ",home,"/",file,": "); } -void main() +int main(void) { umask(077); init_uidgid(); diff --git a/instpackage.c b/instpackage.c @@ -205,7 +205,7 @@ uid_t auto_uids = -1; gid_t auto_gidq = -1; -void main() +int main(void) { fdsourcedir = open_read("."); if (fdsourcedir == -1) diff --git a/ipmeprint.c b/ipmeprint.c @@ -6,7 +6,7 @@ char temp[IPFMT]; -void main() +int main(void) { int j; switch(ipme_init()) diff --git a/maildir2mbox.c b/maildir2mbox.c @@ -36,7 +36,7 @@ char outbuf[SUBSTDIO_OUTSIZE]; void die_nomem() { strerr_die2x(111,FATAL,"out of memory"); } -void main() +int main(void) { substdio ssin; substdio ssout; diff --git a/maildirmake.c b/maildirmake.c @@ -4,9 +4,7 @@ #define FATAL "maildirmake: fatal: " -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { umask(077); if (!argv[1]) diff --git a/maildirwatch.c b/maildirwatch.c @@ -57,7 +57,7 @@ prioq pq = {0}; char inbuf[SUBSTDIO_INSIZE]; substdio ssin; -void main() +int main(void) { struct prioq_elt pe; int fd; diff --git a/predate.c b/predate.c @@ -21,9 +21,7 @@ static char *montab[12] = { char num[FMT_ULONG]; char outbuf[1024]; -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { time_t now; struct tm *tm; diff --git a/preline.c b/preline.c @@ -26,9 +26,7 @@ char inbuf[SUBSTDIO_INSIZE]; substdio ssout = SUBSTDIO_FDBUF(write,1,outbuf,sizeof outbuf); substdio ssin = SUBSTDIO_FDBUF(read,0,inbuf,sizeof inbuf); -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { int opt; int pi[2]; diff --git a/qbiff.c b/qbiff.c @@ -40,7 +40,7 @@ void doheader(h) stralloc *h; } void finishheader() { ; } -void main() +int main(void) { char *user; char *sender; diff --git a/qmail-clean.c b/qmail-clean.c @@ -49,7 +49,7 @@ char fnbuf[FMTQFN]; void respond(s) char *s; { if (substdio_putflush(subfdoutsmall,s,1) == -1) _exit(100); } -void main() +int main(void) { int i; int match; diff --git a/qmail-getpw.c b/qmail-getpw.c @@ -55,12 +55,10 @@ int userext() char num[FMT_ULONG]; -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { + if (argc == 1) _exit(100); local = argv[1]; - if (!local) _exit(100); if (!userext()) { extension = local; diff --git a/qmail-inject.c b/qmail-inject.c @@ -684,9 +684,7 @@ void getcontrols() #define RECIP_HEADER 3 #define RECIP_AH 4 -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { int i; int opt; diff --git a/qmail-local.c b/qmail-local.c @@ -442,9 +442,7 @@ void sayit(char *type, char *cmd, unsigned int len) substdio_putsflush(subfdoutsmall,"\n"); } -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { int opt; unsigned int i; diff --git a/qmail-newmrh.c b/qmail-newmrh.c @@ -33,7 +33,7 @@ struct cdbmss cdbmss; stralloc line = {0}; int match; -void main() +int main(void) { umask(033); if (chdir(auto_qmail) == -1) diff --git a/qmail-newu.c b/qmail-newu.c @@ -72,7 +72,7 @@ int match; stralloc wildchars = {0}; -void main() +int main(void) { int i; int numcolons; diff --git a/qmail-pop3d.c b/qmail-pop3d.c @@ -299,9 +299,7 @@ struct commands pop3commands[] = { , { 0, err_unimpl, 0 } } ; -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { sig_alarmcatch(die); sig_pipeignore(); diff --git a/qmail-popup.c b/qmail-popup.c @@ -164,9 +164,7 @@ struct commands pop3commands[] = { , { 0, err_authoriz, 0 } } ; -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { sig_alarmcatch(die); sig_pipeignore(); diff --git a/qmail-pw2u.c b/qmail-pw2u.c @@ -230,9 +230,7 @@ int fd; substdio ss; char ssbuf[SUBSTDIO_INSIZE]; -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { int opt; int match; diff --git a/qmail-qmqpc.c b/qmail-qmqpc.c @@ -135,7 +135,7 @@ char *server; stralloc servers = {0}; -void +int main() { int i; diff --git a/qmail-qmqpd.c b/qmail-qmqpd.c @@ -107,7 +107,7 @@ int getbuf() int flagok = 1; -void +int main() { char *result; diff --git a/qmail-qmtpd.c b/qmail-qmtpd.c @@ -76,7 +76,7 @@ stralloc failure = {0}; char *relayclient; int relayclientlen; -void +int main() { char ch; diff --git a/qmail-qread.c b/qmail-qread.c @@ -105,7 +105,7 @@ void putstats() stralloc line = {0}; -void main() +int main(void) { int channel; int match; diff --git a/qmail-queue.c b/qmail-queue.c @@ -157,7 +157,7 @@ void pidopen() char tmp[FMT_ULONG]; -void main() +int main(void) { unsigned int len; char ch; diff --git a/qmail-remote.c b/qmail-remote.c @@ -325,9 +325,7 @@ void getcontrols() } } -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { static ipalloc ip = {0}; int i; diff --git a/qmail-send.c b/qmail-send.c @@ -1510,7 +1510,7 @@ void reread() } } -void main() +int main(void) { int fd; datetime_sec wakeup; diff --git a/qmail-showctl.c b/qmail-showctl.c @@ -150,7 +150,7 @@ char *post; } } -void main() +int main(void) { DIR *dir; direntry *d; diff --git a/qmail-smtpd.c b/qmail-smtpd.c @@ -408,7 +408,7 @@ struct commands smtpcommands[] = { , { 0, err_unimpl, flush } } ; -void main() +int main(void) { sig_pipeignore(); if (chdir(auto_qmail) == -1) die_control(); diff --git a/qmail-start.c b/qmail-start.c @@ -38,9 +38,7 @@ void closepipes() { close(pi5[0]); close(pi5[1]); close(pi6[0]); close(pi6[1]); } -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { if (chdir("/") == -1) die(); umask(077); diff --git a/qmail-tcpok.c b/qmail-tcpok.c @@ -11,7 +11,7 @@ char buf[1024]; /* XXX: must match size in tcpto_clean.c, tcpto.c */ substdio ss; -void main() +int main(void) { int fd; int i; diff --git a/qmail-tcpto.c b/qmail-tcpto.c @@ -34,7 +34,7 @@ char tcpto_buf[1024]; char tmp[FMT_ULONG + IPFMT]; -void main() +int main(void) { int fdlock; int fd; diff --git a/qreceipt.c b/qreceipt.c @@ -118,12 +118,11 @@ stralloc *h; void dobody(h) stralloc *h; { ; } -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { sig_pipeignore(); - if (!(target = argv[1])) die_usage(); + if (argc == 1) die_usage(); + target = argv[1]; if (!(returnpath = env_get("SENDER"))) die_usage(); if (headerbody(subfdin,doheaderfield,finishheader,dobody) == -1) die_read(); die_noreceipt(); diff --git a/sendmail.c b/sendmail.c @@ -80,9 +80,7 @@ const char *s; int flagh; char *sender; -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { int opt; char **qiargv; diff --git a/spawn.c b/spawn.c @@ -176,9 +176,7 @@ void getcmd() char inbuf[128]; -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { char ch; int i; diff --git a/splogger.c b/splogger.c @@ -45,14 +45,12 @@ void flush() bufpos = 0; } -void main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { char ch; - if (argv[1]) - if (argv[2]) { + if (argc > 1) + if (argc > 2) { unsigned long facility; scan_ulong(argv[2],&facility); openlog(argv[1],0,facility << 3); diff --git a/tcp-env.c b/tcp-env.c @@ -30,9 +30,7 @@ stralloc remotename = {0}; char temp[IPFMT + FMT_ULONG]; -void main(argc,argv) -int argc; -char *argv[]; +int main(int argc, char **argv) { int dummy; char *proto; diff --git a/tryflock.c b/tryflock.c @@ -2,7 +2,7 @@ #include <sys/file.h> #include <fcntl.h> -void main() +int main(void) { - flock(0,LOCK_EX | LOCK_UN | LOCK_NB); + return flock(0,LOCK_EX | LOCK_UN | LOCK_NB); } diff --git a/trymkffo.c b/trymkffo.c @@ -1,7 +1,7 @@ #include <sys/types.h> #include <sys/stat.h> -void main() +int main(void) { - mkfifo("temp-trymkffo",0); + return mkfifo("temp-trymkffo",0); } diff --git a/trynpbg1.c b/trynpbg1.c @@ -4,7 +4,7 @@ #define FN "temp-trynpbg1.fifo" -int main() +int main(void) { int flagbug; struct timeval instant; diff --git a/trysgact.c b/trysgact.c @@ -1,10 +1,11 @@ #include <signal.h> -void main() +int main(void) { struct sigaction sa; sa.sa_handler = 0; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); sigaction(0,&sa,(struct sigaction *) 0); + return 0; } diff --git a/trysgprm.c b/trysgprm.c @@ -1,10 +1,11 @@ #include <signal.h> -void main() +int main(void) { sigset_t ss; sigemptyset(&ss); sigaddset(&ss,SIGCHLD); sigprocmask(SIG_SETMASK,&ss,(sigset_t *) 0); + return 0; } diff --git a/tryutmpx.c b/tryutmpx.c @@ -1,7 +1,8 @@ #include <utmpx.h> -void main() +int main(void) { struct utmpx ut; ut.ut_type = sizeof(ut.ut_line) + sizeof(ut.ut_user); + return 0; } diff --git a/trywaitp.c b/trywaitp.c @@ -1,7 +1,7 @@ #include <sys/types.h> #include <sys/wait.h> -void main() +int main(void) { - waitpid(0,0,0); + return waitpid(0,0,0); }