crond and non-void function not returning

Bernhard Fischer rep.nop at aon.at
Sat May 20 13:34:56 UTC 2006


On Fri, May 19, 2006 at 10:03:34PM +0200, Yann E. MORIN wrote:
>Bernhard,
>All,
>
>On Friday 19 May 2006 214, Bernhard Fischer wrote:
>> On Fri, May 19, 2006 at 09:35:07PM +0200, Yann E. MORIN wrote:
>> >The crond_main function is non-void, but is never returning. The compiler,
>> >how smart can he be, can not know that. The warning is trivial, and should
>> >be suppressed.
>> hmz. I'd rather put ATTRIBUTE_NORETURN unto the decl of crond_main..
>
>Nope. See: http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html
>(and other gcc versions too), which states that:
>   It does not make sense for a noreturn function to have a return type other
>   than void.
>
>We could change the prototype of crond_main to be void, but...
>
>crond_main must be prototyped as int crond_main(int,char**) because it is
>called that way by run_applet_by_name which exit(3) with the return code of
>the applet it runs.
>
>And using ATTRIBUTE_NORETURN has no effect on a function that is non-void.

You're right.

So.. that proposed return 0; confuses the optimizers enough to add about
50 (or so) bytes to the defconfig binary.
I suggest that everyone who is concerned about size (also) uses IMA mode
(CONFIG_BUILD_AT_ONCE in the "build options" menu) to check proposed
changes..

AFAICS adding a exit(0) or bb_fflush_stdout_and_exit(0) is size-neutral
for both IMA and legacy compiles, so i will apply the latter instead of
return 0.




More information about the busybox mailing list