aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorSasha Levin <sasha.levin@oracle.com>2013-02-27 20:06:00 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:24 -0500
commitb67bfe0d42cac56c512dd5da4b1b347a23f4b70a (patch)
tree3d465aea12b97683f26ffa38eba8744469de9997 /include/net
parent1e142b29e210b5dfb2deeb6ce2210b60af16d2a6 (diff)
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived list_for_each_entry(pos, head, member) The hlist ones were greedy and wanted an extra parameter: hlist_for_each_entry(tpos, pos, head, member) Why did they need an extra pos parameter? I'm not quite sure. Not only they don't really need it, it also prevents the iterator from looking exactly like the list iterator, which is unfortunate. Besides the semantic patch, there was some manual work required: - Fix up the actual hlist iterators in linux/list.h - Fix up the declaration of other iterators based on the hlist ones. - A very small amount of places were using the 'node' parameter, this was modified to use 'obj->member' instead. - Coccinelle didn't handle the hlist_for_each_entry_safe iterator properly, so those had to be fixed up manually. The semantic patch which is mostly the work of Peter Senna Tschudin is here: @@ iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host; type T; expression a,c,d,e; identifier b; statement S; @@ -T b; <+... when != b ( hlist_for_each_entry(a, - b, c, d) S | hlist_for_each_entry_continue(a, - b, c) S | hlist_for_each_entry_from(a, - b, c) S | hlist_for_each_entry_rcu(a, - b, c, d) S | hlist_for_each_entry_rcu_bh(a, - b, c, d) S | hlist_for_each_entry_continue_rcu_bh(a, - b, c) S | for_each_busy_worker(a, c, - b, d) S | ax25_uid_for_each(a, - b, c) S | ax25_for_each(a, - b, c) S | inet_bind_bucket_for_each(a, - b, c) S | sctp_for_each_hentry(a, - b, c) S | sk_for_each(a, - b, c) S | sk_for_each_rcu(a, - b, c) S | sk_for_each_from -(a, b) +(a) S + sk_for_each_from(a) S | sk_for_each_safe(a, - b, c, d) S | sk_for_each_bound(a, - b, c) S | hlist_for_each_entry_safe(a, - b, c, d, e) S | hlist_for_each_entry_continue_rcu(a, - b, c) S | nr_neigh_for_each(a, - b, c) S | nr_neigh_for_each_safe(a, - b, c, d) S | nr_node_for_each(a, - b, c) S | nr_node_for_each_safe(a, - b, c, d) S | - for_each_gfn_sp(a, c, d, b) S + for_each_gfn_sp(a, c, d) S | - for_each_gfn_indirect_valid_sp(a, c, d, b) S + for_each_gfn_indirect_valid_sp(a, c, d) S | for_each_host(a, - b, c) S | for_each_host_safe(a, - b, c, d) S | for_each_mesh_entry(a, - b, c, d) S ) ...+> [akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c] [akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c] [akpm@linux-foundation.org: checkpatch fixes] [akpm@linux-foundation.org: fix warnings] [akpm@linux-foudnation.org: redo intrusive kvm changes] Tested-by: Peter Senna Tschudin <peter.senna@gmail.com> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Signed-off-by: Sasha Levin <sasha.levin@oracle.com> Cc: Wu Fengguang <fengguang.wu@intel.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Gleb Natapov <gleb@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/ax25.h8
-rw-r--r--include/net/inet_hashtables.h4
-rw-r--r--include/net/inet_timewait_sock.h8
-rw-r--r--include/net/netrom.h16
-rw-r--r--include/net/sch_generic.h3
-rw-r--r--include/net/sctp/sctp.h4
-rw-r--r--include/net/sock.h21
7 files changed, 31 insertions, 33 deletions
diff --git a/include/net/ax25.h b/include/net/ax25.h
index 53539acbd81a..89ed9ac5701f 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -161,8 +161,8 @@ typedef struct ax25_uid_assoc {
161 ax25_address call; 161 ax25_address call;
162} ax25_uid_assoc; 162} ax25_uid_assoc;
163 163
164#define ax25_uid_for_each(__ax25, node, list) \ 164#define ax25_uid_for_each(__ax25, list) \
165 hlist_for_each_entry(__ax25, node, list, uid_node) 165 hlist_for_each_entry(__ax25, list, uid_node)
166 166
167#define ax25_uid_hold(ax25) \ 167#define ax25_uid_hold(ax25) \
168 atomic_inc(&((ax25)->refcount)) 168 atomic_inc(&((ax25)->refcount))
@@ -247,8 +247,8 @@ typedef struct ax25_cb {
247 247
248#define ax25_sk(__sk) ((ax25_cb *)(__sk)->sk_protinfo) 248#define ax25_sk(__sk) ((ax25_cb *)(__sk)->sk_protinfo)
249 249
250#define ax25_for_each(__ax25, node, list) \ 250#define ax25_for_each(__ax25, list) \
251 hlist_for_each_entry(__ax25, node, list, ax25_node) 251 hlist_for_each_entry(__ax25, list, ax25_node)
252 252
253#define ax25_cb_hold(__ax25) \ 253#define ax25_cb_hold(__ax25) \
254 atomic_inc(&((__ax25)->refcount)) 254 atomic_inc(&((__ax25)->refcount))
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 7b2ae9d37076..ef83d9e844b5 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -94,8 +94,8 @@ static inline struct net *ib_net(struct inet_bind_bucket *ib)
94 return read_pnet(&ib->ib_net); 94 return read_pnet(&ib->ib_net);
95} 95}
96 96
97#define inet_bind_bucket_for_each(tb, pos, head) \ 97#define inet_bind_bucket_for_each(tb, head) \
98 hlist_for_each_entry(tb, pos, head, node) 98 hlist_for_each_entry(tb, head, node)
99 99
100struct inet_bind_hashbucket { 100struct inet_bind_hashbucket {
101 spinlock_t lock; 101 spinlock_t lock;
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index 7d658d577368..f908dfc06505 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -178,11 +178,11 @@ static inline int inet_twsk_del_dead_node(struct inet_timewait_sock *tw)
178#define inet_twsk_for_each(tw, node, head) \ 178#define inet_twsk_for_each(tw, node, head) \
179 hlist_nulls_for_each_entry(tw, node, head, tw_node) 179 hlist_nulls_for_each_entry(tw, node, head, tw_node)
180 180
181#define inet_twsk_for_each_inmate(tw, node, jail) \ 181#define inet_twsk_for_each_inmate(tw, jail) \
182 hlist_for_each_entry(tw, node, jail, tw_death_node) 182 hlist_for_each_entry(tw, jail, tw_death_node)
183 183
184#define inet_twsk_for_each_inmate_safe(tw, node, safe, jail) \ 184#define inet_twsk_for_each_inmate_safe(tw, safe, jail) \
185 hlist_for_each_entry_safe(tw, node, safe, jail, tw_death_node) 185 hlist_for_each_entry_safe(tw, safe, jail, tw_death_node)
186 186
187static inline struct inet_timewait_sock *inet_twsk(const struct sock *sk) 187static inline struct inet_timewait_sock *inet_twsk(const struct sock *sk)
188{ 188{
diff --git a/include/net/netrom.h b/include/net/netrom.h
index f0793c1cb5f8..121dcf854db5 100644
--- a/include/net/netrom.h
+++ b/include/net/netrom.h
@@ -154,17 +154,17 @@ static __inline__ void nr_node_unlock(struct nr_node *nr_node)
154 nr_node_put(nr_node); 154 nr_node_put(nr_node);
155} 155}
156 156
157#define nr_neigh_for_each(__nr_neigh, node, list) \ 157#define nr_neigh_for_each(__nr_neigh, list) \
158 hlist_for_each_entry(__nr_neigh, node, list, neigh_node) 158 hlist_for_each_entry(__nr_neigh, list, neigh_node)
159 159
160#define nr_neigh_for_each_safe(__nr_neigh, node, node2, list) \ 160#define nr_neigh_for_each_safe(__nr_neigh, node2, list) \
161 hlist_for_each_entry_safe(__nr_neigh, node, node2, list, neigh_node) 161 hlist_for_each_entry_safe(__nr_neigh, node2, list, neigh_node)
162 162
163#define nr_node_for_each(__nr_node, node, list) \ 163#define nr_node_for_each(__nr_node, list) \
164 hlist_for_each_entry(__nr_node, node, list, node_node) 164 hlist_for_each_entry(__nr_node, list, node_node)
165 165
166#define nr_node_for_each_safe(__nr_node, node, node2, list) \ 166#define nr_node_for_each_safe(__nr_node, node2, list) \
167 hlist_for_each_entry_safe(__nr_node, node, node2, list, node_node) 167 hlist_for_each_entry_safe(__nr_node, node2, list, node_node)
168 168
169 169
170/*********************************************************************/ 170/*********************************************************************/
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 2761c905504e..f10818fc8804 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -339,11 +339,10 @@ static inline struct Qdisc_class_common *
339qdisc_class_find(const struct Qdisc_class_hash *hash, u32 id) 339qdisc_class_find(const struct Qdisc_class_hash *hash, u32 id)
340{ 340{
341 struct Qdisc_class_common *cl; 341 struct Qdisc_class_common *cl;
342 struct hlist_node *n;
343 unsigned int h; 342 unsigned int h;
344 343
345 h = qdisc_class_hash(id, hash->hashmask); 344 h = qdisc_class_hash(id, hash->hashmask);
346 hlist_for_each_entry(cl, n, &hash->hash[h], hnode) { 345 hlist_for_each_entry(cl, &hash->hash[h], hnode) {
347 if (cl->classid == id) 346 if (cl->classid == id)
348 return cl; 347 return cl;
349 } 348 }
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 7fdf298a47ef..df85a0c0f2d5 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -675,8 +675,8 @@ static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 vtag)
675 return h & (sctp_assoc_hashsize - 1); 675 return h & (sctp_assoc_hashsize - 1);
676} 676}
677 677
678#define sctp_for_each_hentry(epb, node, head) \ 678#define sctp_for_each_hentry(epb, head) \
679 hlist_for_each_entry(epb, node, head, node) 679 hlist_for_each_entry(epb, head, node)
680 680
681/* Is a socket of this style? */ 681/* Is a socket of this style? */
682#define sctp_style(sk, style) __sctp_style((sk), (SCTP_SOCKET_##style)) 682#define sctp_style(sk, style) __sctp_style((sk), (SCTP_SOCKET_##style))
diff --git a/include/net/sock.h b/include/net/sock.h
index a66caa223d18..14f6e9d19dc7 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -606,24 +606,23 @@ static inline void sk_add_bind_node(struct sock *sk,
606 hlist_add_head(&sk->sk_bind_node, list); 606 hlist_add_head(&sk->sk_bind_node, list);
607} 607}
608 608
609#define sk_for_each(__sk, node, list) \ 609#define sk_for_each(__sk, list) \
610 hlist_for_each_entry(__sk, node, list, sk_node) 610 hlist_for_each_entry(__sk, list, sk_node)
611#define sk_for_each_rcu(__sk, node, list) \ 611#define sk_for_each_rcu(__sk, list) \
612 hlist_for_each_entry_rcu(__sk, node, list, sk_node) 612 hlist_for_each_entry_rcu(__sk, list, sk_node)
613#define sk_nulls_for_each(__sk, node, list) \ 613#define sk_nulls_for_each(__sk, node, list) \
614 hlist_nulls_for_each_entry(__sk, node, list, sk_nulls_node) 614 hlist_nulls_for_each_entry(__sk, node, list, sk_nulls_node)
615#define sk_nulls_for_each_rcu(__sk, node, list) \ 615#define sk_nulls_for_each_rcu(__sk, node, list) \
616 hlist_nulls_for_each_entry_rcu(__sk, node, list, sk_nulls_node) 616 hlist_nulls_for_each_entry_rcu(__sk, node, list, sk_nulls_node)
617#define sk_for_each_from(__sk, node) \ 617#define sk_for_each_from(__sk) \
618 if (__sk && ({ node = &(__sk)->sk_node; 1; })) \ 618 hlist_for_each_entry_from(__sk, sk_node)
619 hlist_for_each_entry_from(__sk, node, sk_node)
620#define sk_nulls_for_each_from(__sk, node) \ 619#define sk_nulls_for_each_from(__sk, node) \
621 if (__sk && ({ node = &(__sk)->sk_nulls_node; 1; })) \ 620 if (__sk && ({ node = &(__sk)->sk_nulls_node; 1; })) \
622 hlist_nulls_for_each_entry_from(__sk, node, sk_nulls_node) 621 hlist_nulls_for_each_entry_from(__sk, node, sk_nulls_node)
623#define sk_for_each_safe(__sk, node, tmp, list) \ 622#define sk_for_each_safe(__sk, tmp, list) \
624 hlist_for_each_entry_safe(__sk, node, tmp, list, sk_node) 623 hlist_for_each_entry_safe(__sk, tmp, list, sk_node)
625#define sk_for_each_bound(__sk, node, list) \ 624#define sk_for_each_bound(__sk, list) \
626 hlist_for_each_entry(__sk, node, list, sk_bind_node) 625 hlist_for_each_entry(__sk, list, sk_bind_node)
627 626
628static inline struct user_namespace *sk_user_ns(struct sock *sk) 627static inline struct user_namespace *sk_user_ns(struct sock *sk)
629{ 628{