Joel Reicher wrote: >At the moment done() returns int, but it does this *only* because it is >used at the end of main()s as > >return done (status); > >Every definition of done() I've been able to find (it's overridden in >some compilation units) has the line > >return 1; /* dead code to satisfy the compiler */ > >at the end solely because of this calling context. > >While it makes some sense to provide this dead code in main(), I believe >it is bad programming practice to hide it in a function that would not >otherwise contain it for any other reason. > >I'd like to change done() to return void, and replace all the main() >calls with the two lines > >done(status); >return 1; > >I write "return 1;" there only because it's entirely equivalent to what's >currently in the code. All the done() implementations call exit(), so >the line should never be reached.
Ah, you've run into this too. I was halfway through trying to change this to remove the compiler warnings. I'd also be in favour of putting this in h/prototypes.h: /* If this is GCC, we can specify some attributes to help the compiler * (a) generate better code and (b) avoid spurious warnings. * If this isn't GCC, the attributes are ignored. */ #ifdef __GNUC__ #define NORETURN __attribute__ ((__noreturn__)) #define NOTUSED __attribute__ ((__unused__)) #else #define NORETURN #define NOTUSED #endif and then having the prototype for done() (and adios() too) look like void done (int) NORETURN; I'm tempted to suggest dumping the unreachable 'return 1;' lines too... (Returning void also has the advantage that create_folder()'s second argument can be given the right type.) -- PMM _______________________________________________ Nmh-workers mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/nmh-workers
