[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] Changing the return type of done()

From: Joel Reicher
Subject: Re: [Nmh-workers] Changing the return type of done()
Date: Wed, 18 Apr 2007 17:25:51 +1000

> >> 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);


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?


        - Joel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]