nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 23acf56fffa0b317acdf5fad76387a9bda838f1c
parent 3212ea53fde91e4394a5195b5fcd2d48d447735d
Author: Rolf Eike Beer <eike@sf-mail.de>
Date:   Sun, 24 May 2020 16:58:24 +0200

use "return" to leave main() instead of _exit()

This may also flush file descriptors, but that is fine. Programs that use
signals are not changed.

Diffstat:
MMakefile | 24++++++++++++------------
Mauto-int.c | 10+++++-----
Mauto-int8.c | 10+++++-----
Mauto-str.c | 10+++++-----
Mchkspawn.c | 9++++-----
Mdnsfq.c | 9++++-----
Mdnsip.c | 7+++----
Mdnsptr.c | 5++---
Mhostname.c | 3+--
Minstcheck.c | 3+--
Minstchown.c | 2+-
Minstpackage.c | 2+-
Mipmeprint.c | 7+++----
Mmaildir2mbox.c | 5++---
Mmaildirmake.c | 4++--
Mpredate.c | 3+--
Mpreline.c | 3+--
Mqbiff.c | 36++++++++++++++++++------------------
Mqmail-clean.c | 8++++----
Mqmail-getpw.c | 6+++---
Mqmail-newmrh.c | 2+-
Mqmail-newu.c | 2+-
Mqmail-pw2u.c | 4++--
Mqmail-qmqpc.c | 2+-
Mqmail-queue.c | 2+-
Mqmail-tcpok.c | 3+--
Msendmail.c | 6+++---
27 files changed, 88 insertions(+), 99 deletions(-)

diff --git a/Makefile b/Makefile @@ -333,7 +333,7 @@ load chkspawn.o substdio.a error.a str.a fs.a auto_spawn.o chkspawn.o: \ compile chkspawn.c substdio.h subfd.h substdio.h fmt.h select.h \ -exit.h auto_spawn.h +auto_spawn.h ./compile chkspawn.c clean: \ @@ -454,7 +454,7 @@ substdio.a error.a str.a fs.a dns.lib socket.lib dnsfq.o: \ compile dnsfq.c substdio.h subfd.h substdio.h stralloc.h gen_alloc.h \ -dns.h dnsdoe.h ip.h ipalloc.h ip.h gen_alloc.h exit.h +dns.h dnsdoe.h ip.h ipalloc.h ip.h gen_alloc.h ./compile dnsfq.c dnsip: \ @@ -465,7 +465,7 @@ substdio.a error.a str.a fs.a dns.lib socket.lib dnsip.o: \ compile dnsip.c substdio.h subfd.h substdio.h stralloc.h gen_alloc.h \ -dns.h dnsdoe.h ip.h ipalloc.h ip.h gen_alloc.h exit.h +dns.h dnsdoe.h ip.h ipalloc.h ip.h gen_alloc.h ./compile dnsip.c dnsptr: \ @@ -476,7 +476,7 @@ substdio.a error.a str.a fs.a dns.lib socket.lib dnsptr.o: \ compile dnsptr.c substdio.h subfd.h substdio.h stralloc.h gen_alloc.h \ -str.h scan.h dns.h dnsdoe.h ip.h exit.h +str.h scan.h dns.h dnsdoe.h ip.h ./compile dnsptr.c dot-qmail.0: \ @@ -702,7 +702,7 @@ load hostname.o substdio.a error.a str.a dns.lib socket.lib `cat socket.lib` hostname.o: \ -compile hostname.c substdio.h subfd.h substdio.h readwrite.h exit.h +compile hostname.c substdio.h subfd.h substdio.h readwrite.h ./compile hostname.c install: @@ -719,7 +719,7 @@ auto_users.o auto_groupq.o strerr.a substdio.a error.a str.a fs.a str.a fs.a instcheck.o: \ -compile instcheck.c strerr.h error.h readwrite.h exit.h hier.h +compile instcheck.c strerr.h error.h readwrite.h hier.h ./compile instcheck.c instchown: \ @@ -771,7 +771,7 @@ error.a str.a fs.a socket.lib ipmeprint.o: \ compile ipmeprint.c subfd.h substdio.h substdio.h ip.h ipme.h ip.h \ -ipalloc.h ip.h gen_alloc.h exit.h +ipalloc.h ip.h gen_alloc.h ./compile ipmeprint.c it: \ @@ -831,7 +831,7 @@ maildir2mbox.1 maildir2mbox.o: \ compile maildir2mbox.c readwrite.h prioq.h datetime.h gen_alloc.h \ env.h stralloc.h gen_alloc.h subfd.h substdio.h substdio.h getln.h \ -error.h open.h lock.h gfrom.h str.h exit.h myctime.h maildir.h \ +error.h open.h lock.h gfrom.h str.h myctime.h maildir.h \ strerr.h ./compile maildir2mbox.c @@ -843,7 +843,7 @@ maildirmake.0: \ maildirmake.1 maildirmake.o: \ -compile maildirmake.c strerr.h exit.h +compile maildirmake.c strerr.h ./compile maildirmake.c maildirwatch: \ @@ -982,7 +982,7 @@ error.a str.a fs.a predate.o: \ compile predate.c datetime.h fork.h wait.h fd.h fmt.h strerr.h \ -substdio.h subfd.h substdio.h readwrite.h exit.h sig.h +substdio.h subfd.h substdio.h readwrite.h sig.h ./compile predate.c preline: \ @@ -996,7 +996,7 @@ preline.1 preline.o: \ compile preline.c fd.h sgetopt.h subgetopt.h readwrite.h strerr.h \ -substdio.h exit.h fork.h wait.h env.h sig.h error.h +substdio.h fork.h wait.h env.h sig.h error.h ./compile preline.c prioq.o: \ @@ -1537,7 +1537,7 @@ qmail-tcpok.8 qmail-tcpok.o: \ compile qmail-tcpok.c strerr.h substdio.h lock.h open.h readwrite.h \ -auto_qmail.h exit.h +auto_qmail.h ./compile qmail-tcpok.c qmail-tcpto: \ diff --git a/auto-int.c b/auto-int.c @@ -20,11 +20,11 @@ int main(int argc, char **argv) unsigned long num; char strnum[FMT_ULONG]; - if (argc != 3) _exit(100); + if (argc != 3) return 100; name = argv[1]; - if (!name) _exit(100); + if (!name) return 100; value = argv[2]; - if (!value) _exit(100); + if (!value) return 100; scan_ulong(value,&num); strnum[fmt_ulong(strnum,num)] = 0; @@ -34,6 +34,6 @@ int main(int argc, char **argv) puts(" = "); puts(strnum); puts(";\n"); - if (substdio_flush(&ss1) == -1) _exit(111); - _exit(0); + if (substdio_flush(&ss1) == -1) return 111; + return 0; } diff --git a/auto-int8.c b/auto-int8.c @@ -20,11 +20,11 @@ int main(int argc, char **argv) unsigned long num; char strnum[FMT_ULONG]; - if (argc != 3) _exit(100); + if (argc != 3) return 100; name = argv[1]; - if (!name) _exit(100); + if (!name) return 100; value = argv[2]; - if (!value) _exit(100); + if (!value) return 100; scan_8long(value,&num); strnum[fmt_ulong(strnum,num)] = 0; @@ -34,6 +34,6 @@ int main(int argc, char **argv) puts(" = "); puts(strnum); puts(";\n"); - if (substdio_flush(&ss1) == -1) _exit(111); - _exit(0); + if (substdio_flush(&ss1) == -1) return 111; + return 0; } diff --git a/auto-str.c b/auto-str.c @@ -30,11 +30,11 @@ int main(int argc, char **argv) unsigned char ch; char octal[4]; - if (argc != 3) _exit(100); + if (argc != 3) return 100; name = argv[1]; - if (!name) _exit(100); + if (!name) return 100; value = argv[2]; - if (!value) _exit(100); + if (!value) return 100; puts("char "); puts(name); @@ -55,6 +55,6 @@ int main(int argc, char **argv) } puts("\\\n\";\n"); - if (substdio_flush(&ss1) == -1) _exit(111); - _exit(0); + if (substdio_flush(&ss1) == -1) return 111; + return 0; } diff --git a/chkspawn.c b/chkspawn.c @@ -2,7 +2,6 @@ #include "subfd.h" #include "fmt.h" #include "select.h" -#include "exit.h" #include "auto_spawn.h" char num[FMT_ULONG]; @@ -19,13 +18,13 @@ int main(void) if (auto_spawn < 1) { substdio_puts(subfderr,"Oops. You have set conf-spawn lower than 1.\n"); substdio_flush(subfderr); - _exit(1); + return 1; } if (auto_spawn > 255) { substdio_puts(subfderr,"Oops. You have set conf-spawn higher than 255.\n"); substdio_flush(subfderr); - _exit(1); + return 1; } if (auto_spawn > maxnumd) { @@ -42,7 +41,7 @@ limit in conf-spawn be at most "); substdio_put(subfderr,num,fmt_ulong(num,(unsigned long) auto_spawn)); substdio_puts(subfderr,".\n"); substdio_flush(subfderr); - _exit(1); + return 1; } - _exit(0); + return 0; } diff --git a/dnsfq.c b/dnsfq.c @@ -5,26 +5,25 @@ #include "dnsdoe.h" #include "ip.h" #include "ipalloc.h" -#include "exit.h" stralloc sa = {0}; ipalloc ia = {0}; int main(int argc, char **argv) { - if (argc == 1) _exit(100); + if (argc == 1) return 100; if (!stralloc_copys(&sa,argv[1])) - { substdio_putsflush(subfderr,"out of memory\n"); _exit(111); } + { substdio_putsflush(subfderr,"out of memory\n"); return 111; } dns_init(1); dnsdoe(dns_ip(&ia,&sa)); if (ia.len <= 0) { - substdio_putsflush(subfderr,"no IP addresses\n"); _exit(100); + substdio_putsflush(subfderr,"no IP addresses\n"); return 100; } dnsdoe(dns_ptr(&sa,&ia.ix[0].ip)); substdio_putflush(subfdout,sa.s,sa.len); substdio_putsflush(subfdout,"\n"); - _exit(0); + return 0; } diff --git a/dnsip.c b/dnsip.c @@ -5,7 +5,6 @@ #include "dnsdoe.h" #include "ip.h" #include "ipalloc.h" -#include "exit.h" char temp[IPFMT]; @@ -16,10 +15,10 @@ int main(int argc, char **argv) { int j; - if (argc == 1) _exit(100); + if (argc == 1) return 100; if (!stralloc_copys(&sa,argv[1])) - { substdio_putsflush(subfderr,"out of memory\n"); _exit(111); } + { substdio_putsflush(subfderr,"out of memory\n"); return 111; } dns_init(0); dnsdoe(dns_ip(&ia,&sa)); @@ -28,5 +27,5 @@ int main(int argc, char **argv) substdio_put(subfdout,temp,ip_fmt(temp,&ia.ix[j].ip)); substdio_putsflush(subfdout,"\n"); } - _exit(0); + return 0; } diff --git a/dnsptr.c b/dnsptr.c @@ -6,14 +6,13 @@ #include "dns.h" #include "dnsdoe.h" #include "ip.h" -#include "exit.h" stralloc sa = {0}; struct ip_address ip; int main(int argc, char **argv) { - if (argc == 1) _exit(100); + if (argc == 1) return 100; ip_scan(argv[1],&ip); @@ -21,5 +20,5 @@ int main(int argc, char **argv) dnsdoe(dns_ptr(&sa,&ip)); substdio_putflush(subfdout,sa.s,sa.len); substdio_putsflush(subfdout,"\n"); - _exit(0); + return 0; } diff --git a/hostname.c b/hostname.c @@ -1,7 +1,6 @@ #include "substdio.h" #include "subfd.h" #include "readwrite.h" -#include "exit.h" char host[256]; @@ -13,5 +12,5 @@ int main(void) substdio_puts(subfdoutsmall,host); substdio_puts(subfdoutsmall,"\n"); substdio_flush(subfdoutsmall); - _exit(0); + return 0; } diff --git a/instcheck.c b/instcheck.c @@ -4,7 +4,6 @@ #include "strerr.h" #include "error.h" #include "readwrite.h" -#include "exit.h" #include "hier.h" extern void init_uidgid(); @@ -81,5 +80,5 @@ int main(void) { init_uidgid(); hier(); - _exit(0); + return 0; } diff --git a/instchown.c b/instchown.c @@ -74,5 +74,5 @@ int main(void) umask(077); init_uidgid(); hier(); - _exit(0); + return 0; } diff --git a/instpackage.c b/instpackage.c @@ -213,5 +213,5 @@ int main(void) umask(077); hier(); - _exit(0); + return 0; } diff --git a/ipmeprint.c b/ipmeprint.c @@ -2,7 +2,6 @@ #include "substdio.h" #include "ip.h" #include "ipme.h" -#include "exit.h" char temp[IPFMT]; @@ -11,8 +10,8 @@ int main(void) int j; switch(ipme_init()) { - case 0: substdio_putsflush(subfderr,"out of memory\n"); _exit(111); - case -1: substdio_putsflush(subfderr,"hard error\n"); _exit(100); + case 0: substdio_putsflush(subfderr,"out of memory\n"); return 111; + case -1: substdio_putsflush(subfderr,"hard error\n"); return 100; } for (j = 0;j < ipme.len;++j) { @@ -20,5 +19,5 @@ int main(void) substdio_puts(subfdout,"\n"); } substdio_flush(subfdout); - _exit(0); + return 0; } diff --git a/maildir2mbox.c b/maildir2mbox.c @@ -11,7 +11,6 @@ #include "lock.h" #include "gfrom.h" #include "str.h" -#include "exit.h" #include "myctime.h" #include "maildir.h" @@ -60,7 +59,7 @@ int main(void) if (maildir_scan(&pq,&filenames,1,1) == -1) strerr_die1(111,FATAL,&maildir_scan_err); - if (!prioq_min(&pq,&pe)) _exit(0); /* nothing new */ + if (!prioq_min(&pq,&pe)) return 0; /* nothing new */ fdlock = open_append(mbox); if (fdlock == -1) @@ -161,5 +160,5 @@ int main(void) strerr_warn4(WARNING,"$MAILDIR/",filenames.s + pe.id," will be delivered twice; unable to unlink: ",&strerr_sys); } - _exit(0); + return 0; } diff --git a/maildirmake.c b/maildirmake.c @@ -1,6 +1,6 @@ #include <sys/stat.h> +#include <unistd.h> #include "strerr.h" -#include "exit.h" #define FATAL "maildirmake: fatal: " @@ -19,5 +19,5 @@ int main(int argc, char **argv) strerr_die4sys(111,FATAL,"unable to mkdir ",argv[1],"/new: "); if (mkdir("cur",0700) == -1) strerr_die4sys(111,FATAL,"unable to mkdir ",argv[1],"/cur: "); - _exit(0); + return 0; } diff --git a/predate.c b/predate.c @@ -10,7 +10,6 @@ #include "substdio.h" #include "subfd.h" #include "readwrite.h" -#include "exit.h" #define FATAL "predate: fatal: " @@ -111,5 +110,5 @@ int main(int argc, char **argv) strerr_die2sys(111,FATAL,"wait failed: "); if (wait_crashed(wstat)) strerr_die2x(111,FATAL,"child crashed"); - _exit(wait_exitcode(wstat)); + return wait_exitcode(wstat); } diff --git a/preline.c b/preline.c @@ -3,7 +3,6 @@ #include "readwrite.h" #include "strerr.h" #include "substdio.h" -#include "exit.h" #include "fork.h" #include "wait.h" #include "env.h" @@ -84,5 +83,5 @@ int main(int argc, char **argv) strerr_die2sys(111,FATAL,"wait failed: "); if (wait_crashed(wstat)) strerr_die2x(111,FATAL,"child crashed"); - _exit(wait_exitcode(wstat)); + return wait_exitcode(wstat); } diff --git a/qbiff.c b/qbiff.c @@ -48,35 +48,35 @@ int main(void) struct stat st; int i; - if (chdir("/dev") == -1) _exit(0); + if (chdir("/dev") == -1) return 0; - if (!(user = env_get("USER"))) _exit(0); - if (!(sender = env_get("SENDER"))) _exit(0); - if (!(userext = env_get("LOCAL"))) _exit(0); - if (str_len(user) > sizeof(ut->UTMP_USER)) _exit(0); + if (!(user = env_get("USER"))) return 0; + if (!(sender = env_get("SENDER"))) return 0; + if (!(userext = env_get("LOCAL"))) return 0; + if (str_len(user) > sizeof(ut->UTMP_USER)) return 0; - if (!stralloc_copys(&tofrom,"*** TO <")) _exit(0); - if (!stralloc_cats(&tofrom,userext)) _exit(0); - if (!stralloc_cats(&tofrom,"> FROM <")) _exit(0); - if (!stralloc_cats(&tofrom,sender)) _exit(0); - if (!stralloc_cats(&tofrom,">")) _exit(0); + if (!stralloc_copys(&tofrom,"*** TO <")) return 0; + if (!stralloc_cats(&tofrom,userext)) return 0; + if (!stralloc_cats(&tofrom,"> FROM <")) return 0; + if (!stralloc_cats(&tofrom,sender)) return 0; + if (!stralloc_cats(&tofrom,">")) return 0; for (i = 0;i < tofrom.len;++i) if ((tofrom.s[i] < 32) || (tofrom.s[i] > 126)) tofrom.s[i] = '_'; - if (!stralloc_copys(&text," ")) _exit(0); - if (headerbody(subfdin,doheader,finishheader,dobody) == -1) _exit(0); + if (!stralloc_copys(&text," ")) return 0; + if (headerbody(subfdin,doheader,finishheader,dobody) == -1) return 0; for (i = 0;i < text.len;++i) if ((text.s[i] < 32) || (text.s[i] > 126)) text.s[i] = '/'; - if (!stralloc_copys(&woof,"\015\n\007")) _exit(0); - if (!stralloc_cat(&woof,&tofrom)) _exit(0); - if (!stralloc_cats(&woof,"\015\n")) _exit(0); - if (!stralloc_cat(&woof,&text)) _exit(0); - if (!stralloc_cats(&woof,"\015\n")) _exit(0); + if (!stralloc_copys(&woof,"\015\n\007")) return 0; + if (!stralloc_cat(&woof,&tofrom)) return 0; + if (!stralloc_cats(&woof,"\015\n")) return 0; + if (!stralloc_cat(&woof,&text)) return 0; + if (!stralloc_cats(&woof,"\015\n")) return 0; UTMP_OPEN; @@ -97,5 +97,5 @@ int main(void) substdio_putflush(&sstty,woof.s,woof.len); close(fdtty); } - _exit(0); + return 0; } diff --git a/qmail-clean.c b/qmail-clean.c @@ -56,12 +56,12 @@ int main(void) int cleanuploop; unsigned long id; - if (chdir(auto_qmail) == -1) _exit(111); - if (chdir("queue") == -1) _exit(111); + if (chdir(auto_qmail) == -1) return 111; + if (chdir("queue") == -1) return 111; sig_pipeignore(); - if (!stralloc_ready(&line,200)) _exit(111); + if (!stralloc_ready(&line,200)) return 111; cleanuploop = 0; @@ -94,5 +94,5 @@ if (unlink(fnbuf) == -1) if (errno != error_noent) { respond("!"); continue; } else respond("x"); } - _exit(0); + return 0; } diff --git a/qmail-getpw.c b/qmail-getpw.c @@ -57,7 +57,7 @@ char num[FMT_ULONG]; int main(int argc, char **argv) { - if (argc == 1) _exit(100); + if (argc == 1) return 100; local = argv[1]; if (!userext()) { @@ -66,7 +66,7 @@ int main(int argc, char **argv) pw = getpwnam(auto_usera); } - if (!pw) _exit(QLX_NOALIAS); + if (!pw) return QLX_NOALIAS; substdio_puts(subfdoutsmall,pw->pw_name); substdio_put(subfdoutsmall,"",1); @@ -82,5 +82,5 @@ int main(int argc, char **argv) substdio_put(subfdoutsmall,"",1); substdio_flush(subfdoutsmall); - _exit(0); + return 0; } diff --git a/qmail-newmrh.c b/qmail-newmrh.c @@ -70,5 +70,5 @@ int main(void) if (rename("control/morercpthosts.tmp","control/morercpthosts.cdb") == -1) strerr_die2sys(111,FATAL,"unable to move control/morercpthosts.tmp to control/morercpthosts.cdb"); - _exit(0); + return 0; } diff --git a/qmail-newu.c b/qmail-newu.c @@ -137,5 +137,5 @@ int main(void) if (close(fdtemp) == -1) die_writet(); /* NFS stupidity */ if (rename("users/cdb.tmp","users/cdb") == -1) die_rename(); - _exit(0); + return 0; } diff --git a/qmail-pw2u.c b/qmail-pw2u.c @@ -247,7 +247,7 @@ int main(int argc, char **argv) case 'C': *auto_break = 0; break; case '?': default: - _exit(100); + return 100; } if (chdir(auto_qmail) == -1) die_chdir(); @@ -308,5 +308,5 @@ int main(int argc, char **argv) if (substdio_puts(subfdout,".\n") == -1) die_write(); if (substdio_flush(subfdout) == -1) die_write(); - _exit(0); + return 0; } diff --git a/qmail-qmqpc.c b/qmail-qmqpc.c @@ -156,5 +156,5 @@ main() i = j + 1; } - _exit(lasterror); + return lasterror; } diff --git a/qmail-queue.c b/qmail-queue.c @@ -260,5 +260,5 @@ int main(void) if (link(intdfn,todofn) == -1) die(66); triggerpull(); - die(0); + return 0; } diff --git a/qmail-tcpok.c b/qmail-tcpok.c @@ -4,7 +4,6 @@ #include "open.h" #include "readwrite.h" #include "auto_qmail.h" -#include "exit.h" #define FATAL "qmail-tcpok: fatal: " @@ -31,5 +30,5 @@ int main(void) 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: "); - _exit(0); + return 0; } diff --git a/sendmail.c b/sendmail.c @@ -89,7 +89,7 @@ int main(int argc, char **argv) if (chdir(auto_qmail) == -1) { substdio_putsflush(subfderr,"sendmail: fatal: unable to switch to qmail home directory\n"); - _exit(111); + return 111; } flagh = 0; @@ -136,7 +136,7 @@ int main(int argc, char **argv) if (str_equal(optprogname,"newaliases")) { substdio_putsflush(subfderr,"sendmail: fatal: please use fastforward/newaliases instead\n"); - _exit(100); + return 100; } qiargv = (char **) alloc((argc + 10) * sizeof(char *)); @@ -156,5 +156,5 @@ int main(int argc, char **argv) execv(*qiargv,qiargv); substdio_putsflush(subfderr,"sendmail: fatal: unable to run qmail-inject\n"); - _exit(111); + return 111; }