diff options
| author | Thomas Graf <tgraf@suug.ch> | 2014-08-13 10:38:31 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2014-08-14 18:13:39 -0400 |
| commit | 93f560811e80216e98f3fcec220aa0f8836b09af (patch) | |
| tree | c04384f2ba1a9d07431c1705bc0f3462066c1f25 | |
| parent | c91eee56dc4f8c3d9ae834bacb835596d47a709e (diff) | |
rhashtable: fix annotations for rht_for_each_entry_rcu()
Call rcu_deference_raw() directly from within rht_for_each_entry_rcu()
as list_for_each_entry_rcu() does.
Fixes the following sparse warnings:
net/netlink/af_netlink.c:2906:25: expected struct rhash_head const *__mptr
net/netlink/af_netlink.c:2906:25: got struct rhash_head [noderef] <asn:4>*<noident>
Fixes: e341694e3eb57fc ("netlink: Convert netlink_lookup() to use RCU protected hash table")
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | include/linux/rhashtable.h | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h index af967c4c7591..36826c0166c5 100644 --- a/include/linux/rhashtable.h +++ b/include/linux/rhashtable.h | |||
| @@ -123,11 +123,6 @@ void rhashtable_destroy(const struct rhashtable *ht); | |||
| 123 | typeof(ptr) __ptr = (ptr); \ | 123 | typeof(ptr) __ptr = (ptr); \ |
| 124 | __ptr ? rht_entry(__ptr, type, member) : NULL; \ | 124 | __ptr ? rht_entry(__ptr, type, member) : NULL; \ |
| 125 | }) | 125 | }) |
| 126 | #define rht_entry_safe_rcu(ptr, type, member) \ | ||
| 127 | ({ \ | ||
| 128 | typeof(*ptr) __rcu *__ptr = (typeof(*ptr) __rcu __force *)ptr; \ | ||
| 129 | __ptr ? container_of((typeof(ptr))rcu_dereference_raw(__ptr), type, member) : NULL; \ | ||
| 130 | }) | ||
| 131 | 126 | ||
| 132 | #define rht_next_entry_safe(pos, ht, member) \ | 127 | #define rht_next_entry_safe(pos, ht, member) \ |
| 133 | ({ \ | 128 | ({ \ |
| @@ -204,9 +199,10 @@ void rhashtable_destroy(const struct rhashtable *ht); | |||
| 204 | * traversal is guarded by rcu_read_lock(). | 199 | * traversal is guarded by rcu_read_lock(). |
| 205 | */ | 200 | */ |
| 206 | #define rht_for_each_entry_rcu(pos, head, member) \ | 201 | #define rht_for_each_entry_rcu(pos, head, member) \ |
| 207 | for (pos = rht_entry_safe_rcu(head, typeof(*(pos)), member); \ | 202 | for (pos = rht_entry_safe(rcu_dereference_raw(head), \ |
| 203 | typeof(*(pos)), member); \ | ||
| 208 | pos; \ | 204 | pos; \ |
| 209 | pos = rht_entry_safe_rcu((pos)->member.next, \ | 205 | pos = rht_entry_safe(rcu_dereference_raw((pos)->member.next), \ |
| 210 | typeof(*(pos)), member)) | 206 | typeof(*(pos)), member)) |
| 211 | 207 | ||
| 212 | #endif /* _LINUX_RHASHTABLE_H */ | 208 | #endif /* _LINUX_RHASHTABLE_H */ |
