Skip to contentSkip to conversation

futex: s/0/NULL/ in pointer context

PATCH In review Alexey Dobriyan 2 participants 2 messages Jan 9, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 futex: s/0/NULL/ in pointer context

kernel/futex.c +3 -3
Index: linux-2.6.10-bk11-warnings/kernel/futex.c
===================================================================
@@ -236,7 +236,7 @@
  */
 static inline void get_key_refs(union futex_key *key)
 {
-	if (key->both.ptr != 0) {
+	if (key->both.ptr != NULL) {
 		if (key->both.offset & 1)
 			atomic_inc(&key->shared.inode->i_count);
 		else
@@ -250,7 +250,7 @@
  */
 static void drop_key_refs(union futex_key *key)
 {
-	if (key->both.ptr != 0) {
+	if (key->both.ptr != NULL) {
 		if (key->both.offset & 1)
 			iput(key->shared.inode);
 		else
@@ -445,7 +445,7 @@
 	/* In the common case we don't take the spinlock, which is nice. */
  retry:
 	lock_ptr = q->lock_ptr;
-	if (lock_ptr != 0) {
+	if (lock_ptr != NULL) {
 		spin_lock(lock_ptr);
 		/*
 		 * q->lock_ptr can change between reading it and
#1 lore raw

kernel/futex.c line 242

Quoted 9 lines · Alexey Dobriyan
kernel/futex.c +1 -1
@@ -236,7 +236,7 @@
  */
 static inline void get_key_refs(union futex_key *key)
 {
-	if (key->both.ptr != 0) {
+	if (key->both.ptr != NULL) {
 		if (key->both.offset & 1)
 			atomic_inc(&key->shared.inode->i_count);
 		else

Actually, many consider the preferred way to write this

	if (key->both.ptr) {

instead, since the condition you want to check is 'is key->both.ptr a valid pointer', not 'is key->both.ptr inequal to the invalid pointer'. The normal use for NULL is only in assignments and initializations, not in comparisons.

	Arnd <><