: Remove warning in node_set_parent.
Subsystems (4)
PATCH 1/1 : Remove warning in node_set_parent.
net/ipv4/fib_trie.c: In function 'node_set_parent':net/ipv4/fib_trie.c:184: warning: assignment makes integer from pointer without a cast
--- net/ipv4/fib_trie.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
net/ipv4/fib_trie.c +4 -3
@@ -177,10 +177,11 @@ static inline struct tnode *node_parent_rcu(struct node *node)return rcu_dereference (ret); } -static inline void node_set_parent (struct node *node,struct tnode *ptr) +static inline void node_set_parent (struct node *node,struct tnode *__ptr) { -rcu_assign_pointer (node->parent, - (unsigned long )ptr |NODE_TYPE (node)); +struct node *ptr; + ptr = (struct node *)((unsigned long )__ptr |NODE_TYPE (node)); +rcu_assign_pointer (node->parent, ptr); }static inline struct node *tnode_get_child (struct tnode *tn,unsigned int i)
Signature · 1 line
1.5.3.rc5
Quoted 18 lines · On Mon, 11 Feb 2008 11:47:17 +0300 "Denis V. Lunev" <[email protected]> wrote:
net/ipv4/fib_trie.c: In function 'node_set_parent':net/ipv4/fib_trie.c:184: warning: assignment makes integer from pointer without a castSigned-off-by Denis V. Lunev <[email protected]>--- net/ipv4/fib_trie.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)net/ipv4/fib_trie.c +0
-1@@ -177,10 +177,11 @@ static inline struct tnode *node_parent_rcu(struct node *node)return rcu_dereference (ret); } -static inline void node_set_parent (struct node *node,struct tnode *ptr)
net/ipv4/fib_trie.c static inline struct tnode *node_parent_rcu(struct node *node) · line 187
Quoted 10 lines
net/ipv4/fib_trie.c +4
-2+static inline void node_set_parent (struct node *node,struct tnode *__ptr) { -rcu_assign_pointer (node->parent, - (unsigned long )ptr |NODE_TYPE (node)); +struct node *ptr; + ptr = (struct node *)((unsigned long )__ptr |NODE_TYPE (node)); +rcu_assign_pointer (node->parent, ptr); }static inline struct node *tnode_get_child (struct tnode *tn,unsigned int i)
No, this causes new warning from assigning pointer (ptr) to integer node->parent.
Why not just change rcupdate.h to do the right thing.
Quoted 1 line
From
a00f7cbf1c2f2282eced236e1e8b99b0fecd213aMon Sep 17 00:00:00 2001
From: Stephen Hemminger <[email protected]>
Date: Mon, 11 Feb 2008 11:28:13 -0800
Subject: [PATCH] eliminate warnings when rcu_assign_pointer is used with unsigned long
It is reasonable to use RCU with non-pointer values, and describe the optimization.
--- include/linux/rcupdate.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
include/linux/rcupdate.h +7 -6
@@ -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 · 7 lines
1.5.3.8 -- Stephen Hemminger <[email protected]>
Denis V. Lunev
Acked-byugly :), but
Quoted 81 lines · Stephen Hemminger
Quoted 18 lines · On Mon, 11 Feb 2008 11:47:17 +0300 "Denis V. Lunev" <[email protected]> wrote:
net/ipv4/fib_trie.c: In function 'node_set_parent':net/ipv4/fib_trie.c:184: warning: assignment makes integer from pointer without a castSigned-off-by Denis V. Lunev <[email protected]>--- net/ipv4/fib_trie.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)net/ipv4/fib_trie.c +0
-1@@ -177,10 +177,11 @@ static inline struct tnode *node_parent_rcu(struct node *node)return rcu_dereference (ret); } -static inline void node_set_parent (struct node *node,struct tnode *ptr)net/ipv4/fib_trie.c static inline struct tnode *node_parent_rcu(struct node *node) · line 187
Quoted 10 lines
net/ipv4/fib_trie.c +4
-2+static inline void node_set_parent (struct node *node,struct tnode *__ptr) { -rcu_assign_pointer (node->parent, - (unsigned long )ptr |NODE_TYPE (node)); +struct node *ptr; + ptr = (struct node *)((unsigned long )__ptr |NODE_TYPE (node)); +rcu_assign_pointer (node->parent, ptr); }static inline struct node *tnode_get_child (struct tnode *tn,unsigned int i)No, this causes new warning from assigning pointer (ptr) to integer
node->parent.Why not just change
rcupdate.hto do the right thing.Quoted 1 line
From
a00f7cbf1c2f2282eced236e1e8b99b0fecd213aMon Sep 17 00:00:00 2001From: Stephen Hemminger <[email protected]>
Date: Mon, 11 Feb 2008 11:28:13 -0800
Subject: [PATCH] eliminate warnings whenrcu_assign_pointeris used with unsigned longIt is reasonable to use RCU with non-pointer values, and describe the optimization.
Signed-off-by Stephen Hemminger <[email protected]>--- include/linux/rcupdate.h | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)include/linux/rcupdate.h +7
-6@@ -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