Re: How to fix warning 'control reaches end of non-void function'

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

 



Hi,

Marcin Slusarz <marcin.slusarz@xxxxxxxxx> writes:

> On Tue, Jul 29, 2008 at 11:17:38PM +0400, Alexander Beregalov wrote:
>> Hi
>> 
>> What is it a right way to fix these warnings?
>> 
>> smth function()
>> {
>> 	switch (var) {
>> 	case one:
>> 		return 1;
>> 	default:
>> 		BUG();
>> 	}
>> }
>> 
>> warning: control reaches end of non-void function
>
> If BUG() would be normal function it could be marked as __attribute__((noreturn)).
> But it's a macro defined differently depending on architecture and CONFIG_*.
> Sometimes it calls panic() which is annotated properly and sometimes it calls
> other code....
>
> If you are brave, you could fix all implementations.

And sometimes it calls nothing at all (!CONFIG_BUG).  So even if you
mark the thing that _does_ something as noreturn, it will still emit
warnings then on !CONFIG_BUG.

	Hannes

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux