Skip to contentSkip to conversation

fib_trie: rcu_assign_pointer warning fix

PATCH New Stephen Hemminger 1 participant 1 message Feb 12, 2008 RCU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fib_trie: rcu_assign_pointer warning fix

Eliminate warnings when rcu_assign_pointer is used with unsigned long. It is reasonable to use RCU with non-pointer values so allow it for general use. Add a comment to explain the if test.

---
 include/linux/rcupdate.h |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
include/linux/rcupdate.h +7 -6
index 37a642c..c44ac87 100644
@@ -172,14 +172,15 @@ struct rcu_head {
  * structure after the pointer assignment.  More importantly, this
  * call documents which pointers will be dereferenced by RCU read-side
  * code.
+ *
+ * If value is the NULL (constant 0), then no barrier is needed.
  */
 
-#define rcu_assign_pointer(p, v) \
-	({ \
-		if (!__builtin_constant_p(v) || \
-		    ((v) != NULL)) \
-			smp_wmb(); \
-		(p) = (v); \
+#define rcu_assign_pointer(p, v)			\
+	({						\
+		if (!(__builtin_constant_p(v) && v))	\
+			smp_wmb();			\
+		(p) = (v);				\
 	})
 
 /**
Signature · 1 line
1.5.3.8