> >> I'm tempted to suggest dumping the unreachable 'return 1;' lines too...
> >
> >I don't want to do this. The "return 1;" lines serve as a reminder that
> >the code is awkward, and should be rewritten.
> 
> They're there because they're in a function returning int (ie main())
> and the compiler doesn't know that done() never returns. If we gave
> done() the noreturn attribute that would work. (Going to exit/atexit
> would work too since exit is declared noreturn already.)

Well, that's an explanation strictly from the compiler's point of view,
but since return in main() is the same as exit() the problem is really
that done() is doing exit() precisely when it doesn't need to be done,
because it'll be followed by a return from main().

I've thought a bit more about this, and am now thinking of changing

return done(status);

to

done(status);
assert(0); /* done() shouldn't have returned */
return 1;

to emphasise that the return should not be reached. What do you think?
Is this overkill?

Cheers,

        - Joel


_______________________________________________
Nmh-workers mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/nmh-workers

Reply via email to