All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] Use NULL for pointer
  2007-07-12 16:49 [PATCH] Use NULL for pointer Atsushi Nemoto
@ 2007-07-12 16:42 ` Ralf Baechle
  2007-07-12 23:50 ` post
  1 sibling, 0 replies; 4+ messages in thread
From: Ralf Baechle @ 2007-07-12 16:42 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-mips

On Fri, Jul 13, 2007 at 01:49:49AM +0900, Atsushi Nemoto wrote:

> This fixes a sparse warning:
> 
> arch/mips/kernel/traps.c:376:44: warning: Using plain integer as NULL pointer

Also applied.

  Ralf

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

* [PATCH] Use NULL for pointer
@ 2007-07-12 16:49 Atsushi Nemoto
  2007-07-12 16:42 ` Ralf Baechle
  2007-07-12 23:50 ` post
  0 siblings, 2 replies; 4+ messages in thread
From: Atsushi Nemoto @ 2007-07-12 16:49 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf

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@mba.ocn.ne.jp>
---
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:

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

* Re: [PATCH] Use NULL for pointer
  2007-07-12 16:49 [PATCH] Use NULL for pointer Atsushi Nemoto
  2007-07-12 16:42 ` Ralf Baechle
@ 2007-07-12 23:50 ` post
  2007-07-13 13:07   ` Atsushi Nemoto
  1 sibling, 1 reply; 4+ messages in thread
From: post @ 2007-07-12 23:50 UTC (permalink / raw)
  To: linux-mips



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@mba.ocn.ne.jp>
> To: linux-mips@linux-mips.org
> Cc: ralf@linux-mips.org
> 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@mba.ocn.ne.jp>
> ---
> 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:
> 
> 
> 

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

* Re: [PATCH] Use NULL for pointer
  2007-07-12 23:50 ` post
@ 2007-07-13 13:07   ` Atsushi Nemoto
  0 siblings, 0 replies; 4+ messages in thread
From: Atsushi Nemoto @ 2007-07-13 13:07 UTC (permalink / raw)
  To: post; +Cc: linux-mips

On Fri, 13 Jul 2007 01:50:07 +0200 (CEST), post@pfrst.de wrote:
> 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.

The warning is produced by sparse, not gcc.

http://www.kernel.org/pub/software/devel/sparse/

I know C++ dislike NULL, but it seems kernel developpers like NULL for
a null pointer.  There is another way to convert a pointer to a bool:

		action = board_be_handler(regs, !!fixup);

It might satisfy both people, but might surprise other people a bit :)

---
Atsushi Nemoto

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

end of thread, other threads:[~2007-07-13 13:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-12 16:49 [PATCH] Use NULL for pointer Atsushi Nemoto
2007-07-12 16:42 ` Ralf Baechle
2007-07-12 23:50 ` post
2007-07-13 13:07   ` Atsushi Nemoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.