aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipx/af_ipx.c
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 /net/ipx/af_ipx.c
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 'net/ipx/af_ipx.c')
-rw-r--r--net/ipx/af_ipx.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c
index dfd6faaf0ea7..f547a47d381c 100644
--- a/net/ipx/af_ipx.c
+++ b/net/ipx/af_ipx.c
@@ -228,9 +228,8 @@ static struct sock *__ipxitf_find_socket(struct ipx_interface *intrfc,
228 __be16 port) 228 __be16 port)
229{ 229{
230 struct sock *s; 230 struct sock *s;
231 struct hlist_node *node;
232 231
233 sk_for_each(s, node, &intrfc->if_sklist) 232 sk_for_each(s, &intrfc->if_sklist)
234 if (ipx_sk(s)->port == port) 233 if (ipx_sk(s)->port == port)
235 goto found; 234 goto found;
236 s = NULL; 235 s = NULL;
@@ -259,12 +258,11 @@ static struct sock *ipxitf_find_internal_socket(struct ipx_interface *intrfc,
259 __be16 port) 258 __be16 port)
260{ 259{
261 struct sock *s; 260 struct sock *s;
262 struct hlist_node *node;
263 261
264 ipxitf_hold(intrfc); 262 ipxitf_hold(intrfc);
265 spin_lock_bh(&intrfc->if_sklist_lock); 263 spin_lock_bh(&intrfc->if_sklist_lock);
266 264
267 sk_for_each(s, node, &intrfc->if_sklist) { 265 sk_for_each(s, &intrfc->if_sklist) {
268 struct ipx_sock *ipxs = ipx_sk(s); 266 struct ipx_sock *ipxs = ipx_sk(s);
269 267
270 if (ipxs->port == port && 268 if (ipxs->port == port &&
@@ -282,14 +280,14 @@ found:
282static void __ipxitf_down(struct ipx_interface *intrfc) 280static void __ipxitf_down(struct ipx_interface *intrfc)
283{ 281{
284 struct sock *s; 282 struct sock *s;
285 struct hlist_node *node, *t; 283 struct hlist_node *t;
286 284
287 /* Delete all routes associated with this interface */ 285 /* Delete all routes associated with this interface */
288 ipxrtr_del_routes(intrfc); 286 ipxrtr_del_routes(intrfc);
289 287
290 spin_lock_bh(&intrfc->if_sklist_lock); 288 spin_lock_bh(&intrfc->if_sklist_lock);
291 /* error sockets */ 289 /* error sockets */
292 sk_for_each_safe(s, node, t, &intrfc->if_sklist) { 290 sk_for_each_safe(s, t, &intrfc->if_sklist) {
293 struct ipx_sock *ipxs = ipx_sk(s); 291 struct ipx_sock *ipxs = ipx_sk(s);
294 292
295 s->sk_err = ENOLINK; 293 s->sk_err = ENOLINK;
@@ -385,12 +383,11 @@ static int ipxitf_demux_socket(struct ipx_interface *intrfc,
385 int is_broadcast = !memcmp(ipx->ipx_dest.node, ipx_broadcast_node, 383 int is_broadcast = !memcmp(ipx->ipx_dest.node, ipx_broadcast_node,
386 IPX_NODE_LEN); 384 IPX_NODE_LEN);
387 struct sock *s; 385 struct sock *s;
388 struct hlist_node *node;
389 int rc; 386 int rc;
390 387
391 spin_lock_bh(&intrfc->if_sklist_lock); 388 spin_lock_bh(&intrfc->if_sklist_lock);
392 389
393 sk_for_each(s, node, &intrfc->if_sklist) { 390 sk_for_each(s, &intrfc->if_sklist) {
394 struct ipx_sock *ipxs = ipx_sk(s); 391 struct ipx_sock *ipxs = ipx_sk(s);
395 392
396 if (ipxs->port == ipx->ipx_dest.sock && 393 if (ipxs->port == ipx->ipx_dest.sock &&
@@ -446,12 +443,11 @@ static struct sock *ncp_connection_hack(struct ipx_interface *intrfc,
446 connection = (((int) *(ncphdr + 9)) << 8) | (int) *(ncphdr + 8); 443 connection = (((int) *(ncphdr + 9)) << 8) | (int) *(ncphdr + 8);
447 444
448 if (connection) { 445 if (connection) {
449 struct hlist_node *node;
450 /* Now we have to look for a special NCP connection handling 446 /* Now we have to look for a special NCP connection handling
451 * socket. Only these sockets have ipx_ncp_conn != 0, set by 447 * socket. Only these sockets have ipx_ncp_conn != 0, set by
452 * SIOCIPXNCPCONN. */ 448 * SIOCIPXNCPCONN. */
453 spin_lock_bh(&intrfc->if_sklist_lock); 449 spin_lock_bh(&intrfc->if_sklist_lock);
454 sk_for_each(sk, node, &intrfc->if_sklist) 450 sk_for_each(sk, &intrfc->if_sklist)
455 if (ipx_sk(sk)->ipx_ncp_conn == connection) { 451 if (ipx_sk(sk)->ipx_ncp_conn == connection) {
456 sock_hold(sk); 452 sock_hold(sk);
457 goto found; 453 goto found;