Re: [PATCH] a more efficient BUG() macro

From: Keith Owens (
Date: Sat Feb 17 2001 - 19:48:13 EST

On Sun, 18 Feb 2001 01:33:53 +0100,
"J . A . Magallon" <> wrote:
>Try this:
>#define hello printf("%d at %s\n",__LINE__,__FILE__)
>#include <stdio.h>
>#include "a.h"
>int main()
> hello;
> hello;
> return 0;
>werewolf:~/ko> gcc a.c -o a
>werewolf:~/ko> a
>6 at a.c
>7 at a.c

But ....

static inline void hello(void) { printf("%d at %s\n",__LINE__,__FILE__); }

#include <stdio.h>
#include "a.h"

int main()
    return 0;

# ./a
1 at a.h
1 at a.h

Most uses of BUG() in headers use inline functions instead of #define.
48 occurrences of BUG() in include/{linux,asm-i386}, only 2 are in

>As I said before, my choose would be the __func__ + __LINE__ predefined macros.
>I would prefer to see 'bug in my_buggy_device_init(), line 42'. And you can
>even drop the __LINE__ part.

Function names are not unique, especially when you get into modules.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Fri Feb 23 2001 - 21:00:16 EST