Skip to contentSkip to conversation

0 -> NULL, for arch/parisc

PATCH Applied Yoann Padioleau 2 participants 2 messages Jul 27, 2007 – Jul 30, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 11/68 0 -> NULL, for arch/parisc

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

---

 smp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/kernel/smp.c +1 -1
index 04c7e1d..16fccbe 100644
@@ -333,7 +333,7 @@ smp_call_function (void (*func) (void *i
 
 	if (retry) {
 		spin_lock (&lock);
-		while (smp_call_function_data != 0)
+		while (smp_call_function_data != NULL)
 			barrier();
 	}
 	else {
#1 lore raw
Quoted 2 lines · Yoann Padioleau

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

...

arch/parisc/kernel/smp.c smp_call_function (void (*func) (void *i · line 339

Quoted 13 lines
arch/parisc/kernel/smp.c +1 -1
index 04c7e1d..16fccbe 100644
@@ -333,7 +333,7 @@ smp_call_function (void (*func) (void *i
 
 	if (retry) {
 		spin_lock (&lock);
-		while (smp_call_function_data != 0)
+		while (smp_call_function_data != NULL)
 			barrier();
 	}
 	else {

Yoann,
Thanks!
I like comparing pointers to NULL since it makes it explicit we are dealing with a pointer and is consistent with the assignment to NULL later in the code.

But I'd like the later comparisons of smp_call_function_data to be consistent with your suggestion above.
Patch below adds another "!= NULL".

thanks
grant

arch/parisc/kernel/smp.c +2 -2
index 04c7e1d..c9ce659 100644
@@ -333,12 +333,12 @@ smp_call_function (void (*func) (void *info), void *info, int retry, int wait)
 
 	if (retry) {
 		spin_lock (&lock);
-		while (smp_call_function_data != 0)
+		while (smp_call_function_data != NULL)
 			barrier();
 	}
 	else {
 		spin_lock (&lock);
-		if (smp_call_function_data) {
+		if (smp_call_function_data != NULL) {
 			spin_unlock (&lock);
 			return -EBUSY;
 		}