Re: IA32 (2.6.2 - 2004-02-05.22.30) - 3 New warnings (gcc 3.2.2)

From: Petr Vandrovec
Date: Fri Feb 06 2004 - 13:37:36 EST


On Fri, Feb 06, 2004 at 06:22:08PM +0000, viro@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx wrote:
>
> Umm... How about
>
> static inline void BUG() __attribute__((noreturn));
>
> static inline void BUG(void)
> {
> __asm__ ....
> }

Unfortunately gcc thinks that it knows better than you whether function
can return or not. I attempted to use noreturn attribute in couple of
my projects, but it is useless - unless you terminate your function
with for(;;) or with call to _exit(), it won't work.

vana:~# more m.c
static inline void BUG() __attribute__((noreturn));

static inline void BUG(void) {
__asm__ ("1: jmp 1b");
}

void main(void) {
BUG();
}

vana:~# gcc -W -Wall m.c
m.c:7: warning: return type of `main' is not `int'
m.c: In function `BUG':
m.c:3: warning: `noreturn' function does return
vana:~#

(gcc version 3.3.3 20040125 (prerelease) (Debian))

> > Better to just initialize the variable to a default value and avoid the
> > warning for now.
>
> Alternatively, we can just turn the damn thing into
> if (dev->mode == IMM_NIBBLE || dev->mode = IMM_PS2)
> ports = 3;
> else
> ports = 8;
> and be done with that...

Yes.
Petr Vandrovec

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/