public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* warning in 2.4.1pre10
@ 2001-01-24 23:44 J . A . Magallon
  2001-01-25  0:45 ` Peter Samuelson
  0 siblings, 1 reply; 4+ messages in thread
From: J . A . Magallon @ 2001-01-24 23:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Justin T . Gibbs

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.

-- 
J.A. Magallon                                                      $> cd pub
mailto:jamagallon@able.es                                          $> 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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: warning in 2.4.1pre10
  2001-01-24 23:44 warning in 2.4.1pre10 J . A . Magallon
@ 2001-01-25  0:45 ` Peter Samuelson
  2001-01-25  0:58   ` J . A . Magallon
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Samuelson @ 2001-01-25  0:45 UTC (permalink / raw)
  To: J . A . Magallon; +Cc: linux-kernel, Justin T . Gibbs


[J. A. Magallon]
> 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

--- 2.3.99pre4pre2/include/linux/raid/md_k.h~	Thu Feb 24 22:02:59 2000
+++ 2.3.99pre4pre2/include/linux/raid/md_k.h	Wed Jan 24 18:40:28 2001
@@ -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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: warning in 2.4.1pre10
  2001-01-25  0:45 ` Peter Samuelson
@ 2001-01-25  0:58   ` J . A . Magallon
  2001-01-25  1:33     ` Peter Samuelson
  0 siblings, 1 reply; 4+ messages in thread
From: J . A . Magallon @ 2001-01-25  0:58 UTC (permalink / raw)
  To: Peter Samuelson; +Cc: J . A . Magallon, linux-kernel, Justin T . Gibbs


On 01.25 Peter Samuelson wrote:
> 
> [J. A. Magallon]
> > 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 ?

-- 
J.A. Magallon                                                      $> cd pub
mailto:jamagallon@able.es                                          $> 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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: warning in 2.4.1pre10
  2001-01-25  0:58   ` J . A . Magallon
@ 2001-01-25  1:33     ` Peter Samuelson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Samuelson @ 2001-01-25  1:33 UTC (permalink / raw)
  To: J . A . Magallon; +Cc: linux-kernel


[J. A. Magallon]
> 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.

>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".(: )


> 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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-01-25  1:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-01-24 23:44 warning in 2.4.1pre10 J . A . Magallon
2001-01-25  0:45 ` Peter Samuelson
2001-01-25  0:58   ` J . A . Magallon
2001-01-25  1:33     ` Peter Samuelson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox