[PATCH 4/4] hlist_for_each_entry_continue simplification

Stephen Hemminger
2008-02-13T00:57:38Z

[-- Attachment #1: rcu-continue.patch --]
[-- Type: text/plain, Size: 2921 bytes --]

All the users of hlist_for_each_entry_continue had to intialize pos
before use; change API so pos is a pure temporary variable which matches
the usage of other xxxx_for_each_entry routines.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/include/linux/list.h 2008-02-12 15:09:17.000000000 -0800
+++ b/include/linux/list.h 2008-02-12 15:09:53.000000000 -0800
@@ -944,7 +944,7 @@ static inline void hlist_add_after_rcu(s
* @member: the name of the hlist_node within the struct.
*/
#define hlist_for_each_entry_continue(tpos, pos, member) \
- for (pos = (pos)->next; \
+ for (pos = (tpos)->member.next; \
pos && ({ prefetch(pos->next); 1;}) && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = pos->next)
@@ -999,7 +999,7 @@ static inline void hlist_add_after_rcu(s
* @member: the name of the hlist_node within the struct.
*/
#define hlist_for_each_entry_continue_rcu(tpos, pos, member) \
- for (pos = (pos)->next; \
+ for (pos = (tpos)->member.next; \
rcu_dereference(pos) && ({ prefetch(pos->next); 1;}) && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = pos->next)
--- a/include/net/sock.h 2008-02-12 15:09:17.000000000 -0800
+++ b/include/net/sock.h 2008-02-12 15:09:53.000000000 -0800
@@ -381,7 +381,7 @@ static __inline__ void sk_add_bind_node(
if (__sk && ({ node = &(__sk)->sk_node; 1; })) \
hlist_for_each_entry_from(__sk, node, sk_node)
#define sk_for_each_continue(__sk, node) \
- if (__sk && ({ node = &(__sk)->sk_node; 1; })) \
+ if (__sk) \
hlist_for_each_entry_continue(__sk, node, sk_node)
#define sk_for_each_safe(__sk, node, tmp, list) \
hlist_for_each_entry_safe(__sk, node, tmp, list, sk_node)
--- a/net/ipv4/fib_hash.c 2008-02-12 15:09:17.000000000 -0800
+++ b/net/ipv4/fib_hash.c 2008-02-12 15:09:53.000000000 -0800
@@ -883,7 +883,7 @@ static struct fib_alias *fib_get_next(st

/* Advance FN. */
if (fn) {
- struct hlist_node *node = &fn->fn_hash;
+ struct hlist_node *node;
hlist_for_each_entry_continue(fn, node, fn_hash) {
iter->fn = fn;

--- a/net/xfrm/xfrm_policy.c 2008-02-12 15:09:17.000000000 -0800
+++ b/net/xfrm/xfrm_policy.c 2008-02-12 15:09:53.000000000 -0800
@@ -577,7 +577,7 @@ int xfrm_policy_insert(int dir, struct x

read_lock_bh(&xfrm_policy_lock);
gc_list = NULL;
- entry = &policy->bydst;
+
hlist_for_each_entry_continue(policy, entry, bydst) {
struct dst_entry *dst;

--- a/net/ipv4/fib_trie.c 2008-02-12 15:09:46.000000000 -0800
+++ b/net/ipv4/fib_trie.c 2008-02-12 15:12:21.000000000 -0800
@@ -2333,7 +2333,6 @@ static void *fib_trie_seq_next(struct se

/* walk rest of this hash chain */
h = tb->tb_id & (FIB_TABLE_HASHSZ - 1);
- tb_node = &tb->tb_hlist;
hlist_for_each_entry_continue_rcu(tb, tb_node, tb_hlist) {
n = trie_get_first(iter, tb);
if (n)