Skip to contentSkip to conversation

warning in 2.4.1pre10

DISCUSSION J . A . Magallon 2 participants 4 messages Jan 24, 2001 – Jan 25, 2001 MD RAID

lore
Share & tools
lore
#0 lore raw

In file included from /usr/src/linux/include/linux/raid/md.h:51,

                 from init/main.c:25:

/usr/src/linux/include/linux/raid/md_k.h: In function `pers_to_level':
/usr/src/linux/include/linux/raid/md_k.h:39: warning: control reaches end of non-void function

It is harmless, 'cause the last sentence in the funtion is a panic, but it is good to add the 'return 0', just to shut up the compiler.

The same happens in the aic7xxx drivers v 6.0.9b, file aic7xxx_linux.h, line 824.

Signature · 9 lines
J.A. Magallon                                                      $> cd pub
mailto:[email protected]                                          $> more beer

Linux werewolf 2.4.1-pre10 #4 SMP Wed Jan 24 00:20:15 CET 2001 i686

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#1 lore raw

[J. A. Magallon]

Quoted 2 lines

It is harmless, 'cause the last sentence in the funtion is a panic, but it is good to add the 'return 0', just to shut up the compiler.

The correct fix is __attribute__((noreturn)) in the panic() prototype. As it happens, this has already been done....

Peter

include/linux/raid/md_k.h renamed from include/linux/raid/md_k.h~ +2 -0
@@ -15,6 +15,8 @@
 #ifndef _MD_K_H
 #define _MD_K_H
 
+#include <linux/kernel.h>	// for panic()
+
 #define MD_RESERVED       0UL
 #define LINEAR            1UL
 #define STRIPED           2UL

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
In reply to J . A . Magallon
Quoted 8 lines · On 01.25 Peter Samuelson wrote:

[J. A. Magallon]

Quoted 2 lines

It is harmless, 'cause the last sentence in the funtion is a panic, but it is good to add the 'return 0', just to shut up the compiler.

The correct fix is __attribute__((noreturn)) in the panic() prototype. As it happens, this has already been done....

I know Linux will never be compiled with any other thing than gcc. But what I do not understand is why if there is a standard C way of doing something you have to use an strange extension of gcc.
Same happens with 'return' and 'break'. You type the same to add a '/* DO NOT REMEMBER THE PRECISE COMMENT */' to shut up the compiler instead of just writing
case X:

	...
	return xxx;
	break;

???
Size optimization for the couple of bytes of the jump in return or break ?

Signature · 9 lines
J.A. Magallon                                                      $> cd pub
mailto:[email protected]                                          $> more beer

Linux werewolf 2.4.1-pre10 #4 SMP Wed Jan 24 00:20:15 CET 2001 i686

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#3 lore raw
In reply to J . A . Magallon

[J. A. Magallon]

Quoted 3 lines

I know Linux will never be compiled with any other thing than gcc. But what I do not understand is why if there is a standard C way of doing something you have to use an strange extension of gcc.

__attribute__((noreturn)) may do other things besides suppress the "no return from non-void function" warning. The gcc manual gives two additional reasons for it:

void fatal () __attribute__ ((noreturn));

The noreturn' keyword tells the compiler to assume that fatal' cannot return. It can then optimize without regard to what would happen if `fatal' ever did return. This makes slightly better code. More importantly, it helps avoid spurious warnings of uninitialized variables.

Thus it is not a workaround, it is a way to give the optimizer extra information. Standard C cannot express this assertion, to my knowledge, so if you stick with ISO you get suboptimal code.

Quoted 1 line

From another viewpoint: the 'return 0', though syntactically correct,

would be misleading -- it will never be executed and we know it. Using __attribute__((noreturn)) reflects reality, which is usually a good thing for coding style. (Whoops, I said "coding style".(: )

Quoted 10 lines

Same happens with 'return' and 'break'. You type the same to add a '/* DO NOT REMEMBER THE PRECISE COMMENT */' to shut up the compiler instead of just writing
case X:

	...
	return xxx;
	break;

???
Size optimization for the couple of bytes of the jump in return or break ?

Sorry, I don't follow your point here..

Peter
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/