Skip to contentSkip to conversation

0 -> NULL, for arch/blackfin

PATCH Applied Yoann Padioleau 3 participants 3 messages Jul 27, 2007 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 4/68 0 -> NULL, for arch/blackfin

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch:

@@
expression *E;
@@

E =
- 0
+ NULL

@@
expression *E;
@@

E !- 0
+ NULL

---

 traps.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/blackfin/kernel/traps.c +1 -1
index 3909f5b..691c66d 100644
@@ -546,7 +546,7 @@ void dump_bfin_regs(struct pt_regs *fp, 
 	}
 
 	printk(KERN_EMERG "return address: [0x%p]; contents of:", retaddr);
-	if (retaddr != 0 && retaddr <= (void *)physical_mem_end
+	if (retaddr != NULL && retaddr <= (void *)physical_mem_end
 #if L1_CODE_LENGTH != 0
 	    /* FIXME: Copy the code out of L1 Instruction SRAM through dma
 	       memcpy.  */
#1 lore raw
Quoted 34 lines · Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch:

@@
expression *E;
@@

E ==
- 0
+ NULL

@@
expression *E;
@@

E !=
- 0
+ NULL

---

 traps.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/blackfin/kernel/traps.c +0 -0
index 3909f5b..691c66d 100644

arch/blackfin/kernel/traps.c void dump_bfin_regs(struct pt_regs *fp, · line 552

Quoted 8 lines
arch/blackfin/kernel/traps.c +1 -1
@@ -546,7 +546,7 @@ void dump_bfin_regs(struct pt_regs *fp, 
 	}
 
 	printk(KERN_EMERG "return address: [0x%p]; contents of:", retaddr);
-	if (retaddr != 0 && retaddr <= (void *)physical_mem_end
+	if (retaddr != NULL && retaddr <= (void *)physical_mem_end
 #if L1_CODE_LENGTH != 0
 	    /* FIXME: Copy the code out of L1 Instruction SRAM through dma
 	       memcpy.  */

Why not just use " if (!E)" instead of " if (E != NULL)"? more readable?

Thanks
- Bryan Wu

#2 lore raw
Quoted 36 lines · Bryan Wu
Quoted 35 lines · Yoann Padioleau

When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch:

@@
expression *E;
@@

E =
- 0
+ NULL

@@
expression *E;
@@

E !> > - 0
+ NULL

---

 traps.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/blackfin/kernel/traps.c +0 -0
index 3909f5b..691c66d 100644
@@ -546,7 +546,7 @@ void dump_bfin_regs(struct pt_regs *fp,
 	}
 
Quoted 10 lines

arch/blackfin/kernel/traps.c void dump_bfin_regs(struct pt_regs *fp, · line 552

Quoted 6 lines
arch/blackfin/kernel/traps.c +1 -1
 	printk(KERN_EMERG "return address: [0x%p]; contents of:", retaddr);
-	if (retaddr != 0 && retaddr <= (void *)physical_mem_end
+	if (retaddr != NULL && retaddr <= (void *)physical_mem_end
 #if L1_CODE_LENGTH != 0
 	    /* FIXME: Copy the code out of L1 Instruction SRAM through dma
 	       memcpy.  */

Why not just use " if (!E)" instead of " if (E != NULL)"? more readable?

Or even "if (E)"

Uli

Signature · 12 lines
------- ROAD ...the handyPC Company - - -  ) ) )

Uli Luckas
Software Development

ROAD GmbH
Bennigsenstr. 14 | 12159 Berlin | Germany
fon: +49 (30) 230069 - 64 | fax: +49 (30) 230069 - 69
url: www.road.de

Amtsgericht Charlottenburg: HRB 96688 B
Managing directors: Hans-Peter Constien, Hubertus von Streit