crond and non-void function not returning

Yann E. MORIN yann.morin.1998 at anciens.enib.fr
Fri May 19 20:03:34 UTC 2006


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.

So to get rid of the warning, the only solution I see is a dummy return at
the end of the function, with the two comments: "not reached" and "avoid a
compiler warning".

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |   ^                |
| --==< °_° >==-- °---.----------------:  X  AGAINST      |  /e\  There is no  |
| web: ymorin.free.fr | SETI at home 3808 | / \ HTML MAIL    |  """  conspiracy.  |
°---------------------°----------------°------------------°--------------------°




More information about the busybox mailing list