From: Joel Reicher Date: Sun, 4 Nov 2007 11:54:32 +0000 (+0000) Subject: Return type of (*done)() changed to void. default_done() replaced by X-Git-Tag: nmh-1_3_RC1~7 X-Git-Url: http://git.marmaro.de/?p=mmh;a=commitdiff_plain;h=38615191e71744b066425e0c44412b62dbe49cc2 Return type of (*done)() changed to void. default_done() replaced by exit(). All dead code "return 1" lines removed from *_done()s and replaced by explicit "return 1" following done() calls in main()s (they should never be reached). This should make cleaning up program termination structures easier. --- diff --git a/ChangeLog b/ChangeLog index 1412bf3..2b2254c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-11-04 Joel Reicher + + * Changed done() link overriding to function pointer. Return type + is now void so that exit() can be used as done() callback. Dead + code return from all done()s removed, with return 1 in main() + following done() (should never be reached). + 2007-08-21 Josh Bressers * Red Hat Bug #253342: inc.c, utils.c, utils.h: When inc is run with diff --git a/h/mh.h b/h/mh.h index bcfe6ae..7cdbead 100644 --- a/h/mh.h +++ b/h/mh.h @@ -336,7 +336,7 @@ extern char *vmhproc; extern char *whatnowproc; extern char *whomproc; -extern int (*done) (int); +extern void (*done) (int); #include diff --git a/sbr/done.c b/sbr/done.c index bcc258c..938fdb2 100644 --- a/sbr/done.c +++ b/sbr/done.c @@ -11,11 +11,4 @@ #include -int (*done) (int) = default_done; - -int -default_done (int status) -{ - exit (status); - return 1; /* dead code to satisfy the compiler */ -} +void (*done) (int) = exit; diff --git a/uip/ali.c b/uip/ali.c index a8812c2..8513092 100644 --- a/uip/ali.c +++ b/uip/ali.c @@ -170,7 +170,8 @@ main (int argc, char **argv) } } - return done (0); + done (0); + return 1; } static void diff --git a/uip/anno.c b/uip/anno.c index 86fe3c3..ee9dcd7 100644 --- a/uip/anno.c +++ b/uip/anno.c @@ -236,7 +236,8 @@ main (int argc, char **argv) else annotate (draft, comp, text, inplace, datesw, delete, append); - return (done(0)); + done(0); + return 1; } #ifdef UCI @@ -285,7 +286,8 @@ main (int argc, char **argv) seq_save (mp); /* synchronize message sequences */ folder_free (mp); /* free folder/message structure */ context_save (); /* save the context file */ - return done (0); + done (0); + return 1; } static void diff --git a/uip/ap.c b/uip/ap.c index 85683f9..ea2d36d 100644 --- a/uip/ap.c +++ b/uip/ap.c @@ -151,7 +151,8 @@ main (int argc, char **argv) for (addrp = 0; addrs[addrp]; addrp++) status += process (addrs[addrp], width, normalize); - return done (status); + done (status); + return 1; } struct pqpair { diff --git a/uip/burst.c b/uip/burst.c index 319918b..15756d3 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -189,7 +189,8 @@ main (int argc, char **argv) seq_save (mp); /* synchronize message sequences */ context_save (); /* save the context file */ folder_free (mp); /* free folder/message structure */ - return done (0); + done (0); + return 1; } diff --git a/uip/comp.c b/uip/comp.c index 67cf83b..9c915bf 100644 --- a/uip/comp.c +++ b/uip/comp.c @@ -296,5 +296,6 @@ edit_it: if (nwhat) done (0); what_now (ed, nedit, use, drft, NULL, 0, NULLMP, NULL, 0, cwd); - return done (1); + done (1); + return 1; } diff --git a/uip/conflict.c b/uip/conflict.c index 1713b15..8247ff0 100644 --- a/uip/conflict.c +++ b/uip/conflict.c @@ -139,7 +139,8 @@ main (int argc, char **argv) #endif /* UCI */ maildrops (); - return done (0); + done (0); + return 1; } diff --git a/uip/dist.c b/uip/dist.c index d8c261d..1effbb0 100644 --- a/uip/dist.c +++ b/uip/dist.c @@ -285,5 +285,6 @@ try_it_again: done (0); what_now (ed, nedit, NOUSE, drft, msgnam, 1, mp, anot ? "Resent" : NULL, inplace, cwd); - return done (1); + done (1); + return 1; } diff --git a/uip/dp.c b/uip/dp.c index c20e1ac..6b41bb6 100644 --- a/uip/dp.c +++ b/uip/dp.c @@ -136,7 +136,8 @@ main (int argc, char **argv) status += process (dates[datep], width); context_save (); /* save the context file */ - return done (status); + done (status); + return 1; } diff --git a/uip/flist.c b/uip/flist.c index 97488bb..b5226ce 100644 --- a/uip/flist.c +++ b/uip/flist.c @@ -276,7 +276,8 @@ main(int argc, char **argv) ScanFolders(); qsort(folders, nFolders, sizeof(struct Folder), (qsort_comp) CompareFolders); PrintFolders(); - return done (0); + done (0); + return 1; } /* diff --git a/uip/fmtdump.c b/uip/fmtdump.c index cc9a589..a590a00 100644 --- a/uip/fmtdump.c +++ b/uip/fmtdump.c @@ -106,7 +106,8 @@ main (int argc, char **argv) ncomps = fmt_compile(nfs, &fmt); fmt_dump(fmt); - return done(0); + done(0); + return 1; } static void diff --git a/uip/folder.c b/uip/folder.c index f04ae2f..f50d3f5 100644 --- a/uip/folder.c +++ b/uip/folder.c @@ -405,7 +405,8 @@ main (int argc, char **argv) print_folders(); context_save (); /* save the context file */ - return done (0); + done (0); + return 1; } /* diff --git a/uip/forw.c b/uip/forw.c index 17e78e9..2d4f2d5 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -444,7 +444,8 @@ try_it_again: done (0); what_now (ed, nedit, NOUSE, drft, NULL, 0, mp, anot ? "Forwarded" : NULL, inplace, cwd); - return done (1); + done (1); + return 1; } diff --git a/uip/inc.c b/uip/inc.c index f2d2e77..ef1b08f 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -223,7 +223,7 @@ static FILE *in; */ char *map_name(char *); -static int inc_done(int); +static void inc_done(int); #ifdef POP static int pop_action(char *); static int pop_pack(char *); @@ -952,7 +952,8 @@ go_to_it: seq_setunseen (mp, 0); /* set the Unseen-Sequence */ seq_save (mp); /* synchronize sequences */ context_save (); /* save the context file */ - return done (0); + done (0); + return 1; } @@ -989,7 +990,7 @@ cpymsg (FILE *in, FILE *out) #endif /* if 0 */ -static int +static void inc_done (int status) { #ifdef POP @@ -1003,7 +1004,6 @@ inc_done (int status) DROPGROUPPRIVS(); } exit (status); - return 1; /* dead code to satisfy the compiler */ } #ifdef POP diff --git a/uip/install-mh.c b/uip/install-mh.c index ec847fb..d389093 100644 --- a/uip/install-mh.c +++ b/uip/install-mh.c @@ -213,7 +213,8 @@ query: fprintf (out, "%s: %s\n", np->n_name, np->n_field); } fclose (out); - return done (0); + done (0); + return 1; } diff --git a/uip/mark.c b/uip/mark.c index 4799b23..372568a 100644 --- a/uip/mark.c +++ b/uip/mark.c @@ -228,7 +228,8 @@ main (int argc, char **argv) context_replace (pfolder, folder); /* update current folder */ context_save (); /* save the context file */ folder_free (mp); /* free folder/message structure */ - return done (0); + done (0); + return 1; } diff --git a/uip/mhbuild.c b/uip/mhbuild.c index 15132ee..2776f7c 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -100,7 +100,7 @@ static int unlink_infile = 0; static char outfile[BUFSIZ]; static int unlink_outfile = 0; -static int unlink_done (int); +static void unlink_done (int); /* mhbuildsbr.c */ CT build_mime (char *); @@ -381,11 +381,12 @@ main (int argc, char **argv) unlink_outfile = 0; free_content (ct); - return done (0); + done (0); + return 1; } -static int +static void unlink_done (int status) { /* @@ -398,5 +399,4 @@ unlink_done (int status) unlink (outfile); exit (status); - return 1; /* dead code to satisfy the compiler */ } diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 2c101b9..041a142 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -244,7 +244,8 @@ pidcheck (int status) fflush (stdout); fflush (stderr); - return done (1); + done (1); + return 1; } diff --git a/uip/mhfree.c b/uip/mhfree.c index 418e5c9..df0ee46 100644 --- a/uip/mhfree.c +++ b/uip/mhfree.c @@ -25,7 +25,7 @@ void free_content (CT); void free_header (CT); void free_ctinfo (CT); void free_encoding (CT, int); -int freects_done (int); +void freects_done (int); /* * static prototypes @@ -287,7 +287,7 @@ free_encoding (CT ct, int toplevel) } -int +void freects_done (int status) { CT *ctp; @@ -297,5 +297,4 @@ freects_done (int status) free_content (*ctp); exit (status); - return 1; /* dead code to satisfy the compiler */ } diff --git a/uip/mhl.c b/uip/mhl.c index 03eb49e..e37c3ba 100644 --- a/uip/mhl.c +++ b/uip/mhl.c @@ -21,7 +21,8 @@ main (int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - return done (mhl (argc, argv)); + done (mhl (argc, argv)); + return 1; } diff --git a/uip/mhlist.c b/uip/mhlist.c index 112c098..e8f8163 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -110,7 +110,7 @@ void list_all_messages (CT *, int, int, int, int); /* mhfree.c */ void free_content (CT); extern CT *cts; -int freects_done (int); +void freects_done (int); /* * static prototypes @@ -373,7 +373,8 @@ do_cache: context_save (); /* save the context file */ } - return done (0); + done (0); + return 1; } diff --git a/uip/mhn.c b/uip/mhn.c index 41eb33a..6955476 100644 --- a/uip/mhn.c +++ b/uip/mhn.c @@ -198,7 +198,7 @@ void cache_all_messages (CT *); /* mhfree.c */ void free_content (CT); extern CT *cts; -int freects_done (int); +void freects_done (int); /* * static prototypes @@ -686,7 +686,8 @@ do_cache: context_save (); /* save the context file */ } - return done (0); + done (0); + return 1; } diff --git a/uip/mhparam.c b/uip/mhparam.c index 0b60b03..f9f78c3 100644 --- a/uip/mhparam.c +++ b/uip/mhparam.c @@ -181,7 +181,8 @@ main(int argc, char **argv) } } - return done (missed); + done (missed); + return 1; } diff --git a/uip/mhparse.c b/uip/mhparse.c index 733048d..a348144 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -209,7 +209,8 @@ pidcheck (int status) fflush (stdout); fflush (stderr); - return done (1); + done (1); + return 1; } diff --git a/uip/mhpath.c b/uip/mhpath.c index 3974515..c4fd935 100644 --- a/uip/mhpath.c +++ b/uip/mhpath.c @@ -123,5 +123,6 @@ main(int argc, char **argv) seq_save (mp); /* synchronize message sequences */ context_save (); /* save the context file */ folder_free (mp); /* free folder/message structure */ - return done (0); + done (0); + return 1; } diff --git a/uip/mhshow.c b/uip/mhshow.c index b7a097c..1383388 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -126,7 +126,7 @@ void show_all_messages (CT *); /* mhfree.c */ void free_content (CT); extern CT *cts; -int freects_done (int); +void freects_done (int); /* * static prototypes @@ -453,7 +453,8 @@ do_cache: context_save (); /* save the context file */ } - return done (0); + done (0); + return 1; } diff --git a/uip/mhstore.c b/uip/mhstore.c index 4d1ebe0..bcebb7f 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -104,7 +104,7 @@ void store_all_messages (CT *); /* mhfree.c */ void free_content (CT); extern CT *cts; -int freects_done (int); +void freects_done (int); /* * static prototypes @@ -385,7 +385,8 @@ do_cache: context_save (); /* save the context file */ } - return done (0); + done (0); + return 1; } diff --git a/uip/mhtest.c b/uip/mhtest.c index 6771bdb..fa42cd2 100644 --- a/uip/mhtest.c +++ b/uip/mhtest.c @@ -106,7 +106,7 @@ void flush_errors (void); /* mhfree.c */ void free_content (CT); extern CT *cts; -int freects_done (int); +void freects_done (int); /* * static prototypes @@ -364,7 +364,8 @@ do_cache: context_save (); /* save the context file */ } - return done (0); + done (0); + return 1; } diff --git a/uip/msgchk.c b/uip/msgchk.c index 872dc2e..1a59a3b 100644 --- a/uip/msgchk.c +++ b/uip/msgchk.c @@ -327,7 +327,8 @@ main (int argc, char **argv) } /* host == NULL */ #endif - return done (status); + done (status); + return 1; } diff --git a/uip/msh.c b/uip/msh.c index 3f8a7ab..6d6fbca 100644 --- a/uip/msh.c +++ b/uip/msh.c @@ -413,7 +413,8 @@ main (int argc, char **argv) m_reset (); - return done (0); + done (0); + return 1; } diff --git a/uip/packf.c b/uip/packf.c index 0183da6..fb8871d 100644 --- a/uip/packf.c +++ b/uip/packf.c @@ -33,7 +33,7 @@ static int md = NOTOK; static int mbx_style = MBOX_FORMAT; static int mapping = 0; -static int mbxclose_done(int); +static void mbxclose_done(int); char *file = NULL; @@ -179,13 +179,13 @@ main (int argc, char **argv) seq_save (mp); context_save (); /* save the context file */ folder_free (mp); /* free folder/message structure */ - return done (0); + done (0); + return 1; } -static int +static void mbxclose_done (int status) { mbx_close (file, md); exit (status); - return 1; /* dead code to satisfy the compiler */ } diff --git a/uip/pick.c b/uip/pick.c index afbcf88..ad356e3 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -68,7 +68,7 @@ static struct swit switches[] = { static int listsw = -1; -static int putzero_done (int); +static void putzero_done (int); int main (int argc, char **argv) @@ -286,15 +286,15 @@ main (int argc, char **argv) seq_save (mp); /* synchronize message sequences */ context_save (); /* save the context file */ folder_free (mp); /* free folder/message structure */ - return done (0); + done (0); + return 1; } -static int +static void putzero_done (int status) { if (listsw && status && !isatty (fileno (stdout))) printf ("0\n"); exit (status); - return 1; /* dead code to satisfy the compiler */ } diff --git a/uip/post.c b/uip/post.c index d99da1f..e3b6229 100644 --- a/uip/post.c +++ b/uip/post.c @@ -639,7 +639,8 @@ main (int argc, char **argv) if (verbose) printf (partno ? "Partial Message #%s Processed\n" : "Message Processed\n", partno); - return done (0); + done (0); + return 1; } diff --git a/uip/prompter.c b/uip/prompter.c index fd10aca..35f6860 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -400,7 +400,8 @@ no_body: unlink (tmpfil); context_save (); /* save the context file */ - return done (0); + done (0); + return 1; } diff --git a/uip/rcvdist.c b/uip/rcvdist.c index 1667232..b0a3609 100644 --- a/uip/rcvdist.c +++ b/uip/rcvdist.c @@ -34,7 +34,7 @@ static char tmpfil[BUFSIZ] = ""; * prototypes */ static void rcvdistout (FILE *, char *, char *); -static int unlink_done (int); +static void unlink_done (int); int @@ -270,7 +270,7 @@ finished: ; } -static int +static void unlink_done (int status) { if (backup[0]) @@ -281,5 +281,4 @@ unlink_done (int status) unlink (tmpfil); exit (status ? RCV_MBX : RCV_MOK); - return 1; /* dead code to satisfy the compiler */ } diff --git a/uip/rcvpack.c b/uip/rcvpack.c index 410267b..f03fc99 100644 --- a/uip/rcvpack.c +++ b/uip/rcvpack.c @@ -103,5 +103,6 @@ main (int argc, char **argv) if (mbx_close (file, md) == NOTOK) done (RCV_MBX); - return done (RCV_MOK); + done (RCV_MOK); + return 1; } diff --git a/uip/rcvstore.c b/uip/rcvstore.c index 3e0961e..493bade 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -48,7 +48,7 @@ static struct swit switches[] = { */ static char *tmpfilenam = NULL; -static int unlink_done(int); +static void unlink_done(int); int main (int argc, char **argv) @@ -225,17 +225,17 @@ main (int argc, char **argv) unlink (tmpfilenam); /* remove temporary file */ tmpfilenam = NULL; - return done (0); + done (0); + return 1; } /* * Clean up and exit */ -static int +static void unlink_done(int status) { if (tmpfilenam && *tmpfilenam) unlink (tmpfilenam); exit (status); - return 1; /* dead code to satisfy the compiler */ } diff --git a/uip/refile.c b/uip/refile.c index 0b3afe1..7bc6d0b 100644 --- a/uip/refile.c +++ b/uip/refile.c @@ -266,7 +266,8 @@ main (int argc, char **argv) context_replace (pfolder, folder); /* update current folder */ context_save (); /* save the context file */ folder_free (mp); /* free folder structure */ - return done (0); + done (0); + return 1; } diff --git a/uip/repl.c b/uip/repl.c index 7a1aca1..4584b67 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -442,7 +442,8 @@ try_it_again: done (0); what_now (ed, nedit, NOUSE, drft, msg, 0, mp, anot ? "Replied" : NULL, inplace, cwd); - return done (1); + done (1); + return 1; } void diff --git a/uip/rmf.c b/uip/rmf.c index 1cacbc4..c3dcc91 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -122,7 +122,8 @@ main (int argc, char **argv) } } context_save (); /* save the context file */ - return done (0); + done (0); + return 1; } static int diff --git a/uip/rmm.c b/uip/rmm.c index b1e887e..1530289 100644 --- a/uip/rmm.c +++ b/uip/rmm.c @@ -127,5 +127,6 @@ main (int argc, char **argv) context_replace (pfolder, folder); /* update current folder */ context_save (); /* save the context file */ folder_free (mp); /* free folder structure */ - return done (0); + done (0); + return 1; } diff --git a/uip/scan.c b/uip/scan.c index 05f8bf8..31aa245 100644 --- a/uip/scan.c +++ b/uip/scan.c @@ -326,5 +326,6 @@ main (int argc, char **argv) if (clearflag) clear_screen (); - return done (0); + done (0); + return 1; } diff --git a/uip/send.c b/uip/send.c index 7849472..196af62 100644 --- a/uip/send.c +++ b/uip/send.c @@ -473,5 +473,6 @@ go_to_it: } context_save (); /* save the context file */ - return done (status); + done (status); + return 1; } diff --git a/uip/sendsbr.c b/uip/sendsbr.c index cb6bb3f..877538b 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -60,7 +60,7 @@ char *getusername (void); /* * static prototypes */ -static int armed_done (int); +static void armed_done (int); static void alert (char *, int); static int tmp_fd (void); static void anno (int, struct stat *); @@ -153,7 +153,7 @@ sendsbr (char **vec, int vecp, char *drft, struct stat *st, int rename_drft, cha break; } - done=default_done; + done=exit; if (distfile) unlink (distfile); @@ -1074,11 +1074,10 @@ oops: } -static int +static void armed_done (int status) { longjmp (env, status ? status : NOTOK); exit (status); - return 1; /* dead code to satisfy the compiler */ } diff --git a/uip/slocal.c b/uip/slocal.c index 08a3e28..1396cc2 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -412,7 +412,8 @@ main (int argc, char **argv) /* deliver the message */ status = localmail (fd, mdlvr); - return done (status != -1 ? RCV_MOK : RCV_MBX); + done (status != -1 ? RCV_MOK : RCV_MBX); + return 1; } diff --git a/uip/sortm.c b/uip/sortm.c index 65291ce..212b441 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -285,7 +285,8 @@ main (int argc, char **argv) seq_save (mp); /* synchronize message sequences */ context_save (); /* save the context file */ folder_free (mp); /* free folder/message structure */ - return done (0); + done (0); + return 1; } static int diff --git a/uip/viamail.c b/uip/viamail.c index 859dfaf..04a76d2 100644 --- a/uip/viamail.c +++ b/uip/viamail.c @@ -248,5 +248,6 @@ via_mail (char *mailsw, char *subjsw, char *parmsw, char *descsw, fclose (fp); if (unlink (tmpfil) == -1) advise (NULL, "unable to remove temp file %s", tmpfil); - return done (status); + done (status); + return 1; }