Re: [PATCH] Use NULL for pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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.

"6.3.2.3 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>
 ...
  NULL
 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
anyone...

peter


On Fri, 13 Jul 2007, Atsushi Nemoto wrote:

> Date: Fri, 13 Jul 2007 01:49:49 +0900 (JST)
> From: Atsushi Nemoto <anemo@xxxxxxxxxxxxx>
> To: linux-mips@xxxxxxxxxxxxxx
> Cc: ralf@xxxxxxxxxxxxxx
> 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 <anemo@xxxxxxxxxxxxx>
> ---
> 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:
> 
> 
> 



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux