From 1201af682c2a7e34d4d598e62718306b885a187e Mon Sep 17 00:00:00 2001 From: Philipp Takacs Date: Sun, 22 Feb 2015 14:26:27 +0100 Subject: [PATCH] nonstatic function for atexit, check if atexit fails atexit needs nonstatic functions to work correct. The error check is importent, because atexit can fail for some reasons and the cleanup woulden't work. --- uip/inc.c | 8 +++++--- uip/mhbuild.c | 8 +++++--- uip/mhlist.c | 4 +++- uip/mhshow.c | 4 +++- uip/mhstore.c | 4 +++- uip/mhtest.c | 4 +++- uip/pick.c | 8 +++++--- uip/rcvdist.c | 8 +++++--- uip/rcvstore.c | 8 +++++--- 9 files changed, 37 insertions(+), 19 deletions(-) diff --git a/uip/inc.c b/uip/inc.c index 213cc5d..8a05c6a 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -119,7 +119,7 @@ static FILE *in; /* ** prototypes */ -static void inc_done(); +void inc_done(); int @@ -143,7 +143,9 @@ main(int argc, char **argv) /* copy of mail directory because the static gets overwritten */ char *maildir_copy = NULL; - atexit(inc_done); + if (atexit(inc_done) != 0) { + adios(NULL, "atexit failed"); + } /* ** absolutely the first thing we do is save our privileges, @@ -484,7 +486,7 @@ main(int argc, char **argv) return 0; } -static void +void inc_done() { if (locked) { diff --git a/uip/mhbuild.c b/uip/mhbuild.c index 6e0861e..ba0d978 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -92,7 +92,7 @@ static int unlink_infile = 0; static char outfile[BUFSIZ]; static int unlink_outfile = 0; -static void unlink_done(); +void unlink_done(); /* mhoutsbr.c */ int output_message(CT, char *); @@ -115,7 +115,9 @@ main(int argc, char **argv) FILE *fp = NULL; FILE *fp_out = NULL; - atexit(unlink_done); + if (atexit(unlink_done) != 0) { + adios(NULL, "atexit failed"); + } setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); @@ -284,7 +286,7 @@ main(int argc, char **argv) } -static void +void unlink_done() { /* diff --git a/uip/mhlist.c b/uip/mhlist.c index 8c7e51d..cf55c4c 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -92,7 +92,9 @@ main(int argc, char **argv) struct msgs *mp = NULL; CT ct, *ctp; - atexit(freects_done); + if (atexit(freects_done) != 0) { + adios(NULL, "atexit failed"); + } setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); diff --git a/uip/mhshow.c b/uip/mhshow.c index 9bc7ed3..e56b612 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -98,7 +98,9 @@ main(int argc, char **argv) FILE *fp; int ontty = 0; - atexit(freects_done); + if (atexit(freects_done) != 0) { + adios(NULL, "atexit failed"); + } setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); diff --git a/uip/mhstore.c b/uip/mhstore.c index 6a268f2..63fa5ab 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -129,7 +129,9 @@ main(int argc, char **argv) CT ct, *ctp; FILE *fp; - atexit(freects_done); + if (atexit(freects_done) != 0) { + adios(NULL, "atexit failed"); + } setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); diff --git a/uip/mhtest.c b/uip/mhtest.c index a1718db..aa7e411 100644 --- a/uip/mhtest.c +++ b/uip/mhtest.c @@ -95,7 +95,9 @@ main(int argc, char **argv) struct msgs *mp = NULL; CT ct, *ctp; - atexit(freects_done); + if (atexit(freects_done) != 0) { + adios(NULL, "atexit failed"); + } setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); diff --git a/uip/pick.c b/uip/pick.c index 6c59add..d31f9b8 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -76,7 +76,7 @@ static int pmatches(FILE *, int, long, long); static int listsw = -1; -static void putzero_done(); +void putzero_done(); int main(int argc, char **argv) @@ -91,7 +91,9 @@ main(int argc, char **argv) struct msgs *mp; register FILE *fp; - atexit(putzero_done); + if (atexit(putzero_done) != 0) { + adios(NULL, "atexit failed"); + } setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); @@ -307,7 +309,7 @@ main(int argc, char **argv) } -static void +void putzero_done() { if (listsw && !isatty(fileno(stdout))) diff --git a/uip/rcvdist.c b/uip/rcvdist.c index d3e4100..c365059 100644 --- a/uip/rcvdist.c +++ b/uip/rcvdist.c @@ -30,7 +30,7 @@ static char tmpfil[BUFSIZ] = ""; ** prototypes */ static void rcvdistout(FILE *, char *, char *); -static void unlink_done(); +void unlink_done(); int @@ -42,7 +42,9 @@ main(int argc, char **argv) FILE *fp; char *tfile = NULL; - atexit(unlink_done); + if (atexit(unlink_done) != 0) { + adios(NULL, "atexit failed"); + } setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); @@ -275,7 +277,7 @@ finished: ; } -static void +void unlink_done() { if (*backup) { diff --git a/uip/rcvstore.c b/uip/rcvstore.c index fbddda7..0b5ad85 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -44,7 +44,7 @@ static struct swit switches[] = { */ static char *tmpfilenam = NULL; -static void unlink_done(); +void unlink_done(); int main(int argc, char **argv) @@ -58,7 +58,9 @@ main(int argc, char **argv) struct msgs *mp; struct stat st; - atexit(unlink_done); + if (atexit(unlink_done) != 0) { + adios(NULL, "atexit failed"); + } setlocale(LC_ALL, ""); invo_name = mhbasename(argv[0]); @@ -226,7 +228,7 @@ main(int argc, char **argv) /* ** Clean up and exit */ -static void +void unlink_done() { if (tmpfilenam && *tmpfilenam) { -- 1.7.10.4