[Top] [All Lists]

Re: [PATCH] Use NULL for pointer

Subject: Re: [PATCH] Use NULL for pointer
Date: Fri, 13 Jul 2007 01:50:07 +0200 (CEST)
In-reply-to: <>
Original-recipient: rfc822;

Please excuse me, i couldn't restrain myself from commenting on this.
It's a pity, that a weird warning (which gcc version with what settings
did produce it ?) urges one to (re-)introduce this obsolescent macro.

" Pointers
 3 An integer constant expression with the value 0, or such an
   expression cast to type void*, is called a null pointer constant.
   If a null pointer constant is assigned to or compared for equality
   to a pointer, the constant is converted to a pointer of that type..."

"7.17 Common definitions <stddef.h>
 which expands to an implementation-defined null pointer constant..." 

And pre-ISO-Standard C compilers de-facto behaved the same way.

So, NULL simply isn't a "better" null pointer constant than plain 0. It
is a relic from the (good old ?) times, when no prototypes were available,
and one needed another way to ensure the proper type (width) of function
arguments.  (C++ could do without it from the very beginning)
In other words, the code seems to be more correct than the warning.

In the hope of neither having been too much off-topic nor having offended


On Fri, 13 Jul 2007, Atsushi Nemoto wrote:

> Date: Fri, 13 Jul 2007 01:49:49 +0900 (JST)
> From: Atsushi Nemoto <>
> To:
> Cc:
> Subject: [PATCH] Use NULL for pointer
> This fixes a sparse warning:
> arch/mips/kernel/traps.c:376:44: warning: Using plain integer as NULL pointer
> Signed-off-by: Atsushi Nemoto <>
> ---
> diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
> index 80ea4fa..5e9fa83 100644
> --- a/arch/mips/kernel/traps.c
> +++ b/arch/mips/kernel/traps.c
> @@ -373,7 +373,7 @@ asmlinkage void do_be(struct pt_regs *regs)
>               action = MIPS_BE_FIXUP;
>       if (board_be_handler)
> -             action = board_be_handler(regs, fixup != 0);
> +             action = board_be_handler(regs, fixup != NULL);
>       switch (action) {
>       case MIPS_BE_DISCARD:

<Prev in Thread] Current Thread [Next in Thread>