diff options
author | Sasha Levin <sasha.levin@oracle.com> | 2013-02-27 20:06:00 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:24 -0500 |
commit | b67bfe0d42cac56c512dd5da4b1b347a23f4b70a (patch) | |
tree | 3d465aea12b97683f26ffa38eba8744469de9997 /net/batman-adv/gateway_client.c | |
parent | 1e142b29e210b5dfb2deeb6ce2210b60af16d2a6 (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/batman-adv/gateway_client.c')
-rw-r--r-- | net/batman-adv/gateway_client.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index 074107f2cfaa..34f99a46ec1d 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c | |||
@@ -114,7 +114,6 @@ static struct batadv_gw_node * | |||
114 | batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv) | 114 | batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv) |
115 | { | 115 | { |
116 | struct batadv_neigh_node *router; | 116 | struct batadv_neigh_node *router; |
117 | struct hlist_node *node; | ||
118 | struct batadv_gw_node *gw_node, *curr_gw = NULL; | 117 | struct batadv_gw_node *gw_node, *curr_gw = NULL; |
119 | uint32_t max_gw_factor = 0, tmp_gw_factor = 0; | 118 | uint32_t max_gw_factor = 0, tmp_gw_factor = 0; |
120 | uint32_t gw_divisor; | 119 | uint32_t gw_divisor; |
@@ -127,7 +126,7 @@ batadv_gw_get_best_gw_node(struct batadv_priv *bat_priv) | |||
127 | gw_divisor *= 64; | 126 | gw_divisor *= 64; |
128 | 127 | ||
129 | rcu_read_lock(); | 128 | rcu_read_lock(); |
130 | hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw.list, list) { | 129 | hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.list, list) { |
131 | if (gw_node->deleted) | 130 | if (gw_node->deleted) |
132 | continue; | 131 | continue; |
133 | 132 | ||
@@ -344,7 +343,6 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv, | |||
344 | struct batadv_orig_node *orig_node, | 343 | struct batadv_orig_node *orig_node, |
345 | uint8_t new_gwflags) | 344 | uint8_t new_gwflags) |
346 | { | 345 | { |
347 | struct hlist_node *node; | ||
348 | struct batadv_gw_node *gw_node, *curr_gw; | 346 | struct batadv_gw_node *gw_node, *curr_gw; |
349 | 347 | ||
350 | /* Note: We don't need a NULL check here, since curr_gw never gets | 348 | /* Note: We don't need a NULL check here, since curr_gw never gets |
@@ -355,7 +353,7 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv, | |||
355 | curr_gw = batadv_gw_get_selected_gw_node(bat_priv); | 353 | curr_gw = batadv_gw_get_selected_gw_node(bat_priv); |
356 | 354 | ||
357 | rcu_read_lock(); | 355 | rcu_read_lock(); |
358 | hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw.list, list) { | 356 | hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.list, list) { |
359 | if (gw_node->orig_node != orig_node) | 357 | if (gw_node->orig_node != orig_node) |
360 | continue; | 358 | continue; |
361 | 359 | ||
@@ -403,7 +401,7 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv, | |||
403 | void batadv_gw_node_purge(struct batadv_priv *bat_priv) | 401 | void batadv_gw_node_purge(struct batadv_priv *bat_priv) |
404 | { | 402 | { |
405 | struct batadv_gw_node *gw_node, *curr_gw; | 403 | struct batadv_gw_node *gw_node, *curr_gw; |
406 | struct hlist_node *node, *node_tmp; | 404 | struct hlist_node *node_tmp; |
407 | unsigned long timeout = msecs_to_jiffies(2 * BATADV_PURGE_TIMEOUT); | 405 | unsigned long timeout = msecs_to_jiffies(2 * BATADV_PURGE_TIMEOUT); |
408 | int do_deselect = 0; | 406 | int do_deselect = 0; |
409 | 407 | ||
@@ -411,7 +409,7 @@ void batadv_gw_node_purge(struct batadv_priv *bat_priv) | |||
411 | 409 | ||
412 | spin_lock_bh(&bat_priv->gw.list_lock); | 410 | spin_lock_bh(&bat_priv->gw.list_lock); |
413 | 411 | ||
414 | hlist_for_each_entry_safe(gw_node, node, node_tmp, | 412 | hlist_for_each_entry_safe(gw_node, node_tmp, |
415 | &bat_priv->gw.list, list) { | 413 | &bat_priv->gw.list, list) { |
416 | if (((!gw_node->deleted) || | 414 | if (((!gw_node->deleted) || |
417 | (time_before(jiffies, gw_node->deleted + timeout))) && | 415 | (time_before(jiffies, gw_node->deleted + timeout))) && |
@@ -476,7 +474,6 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) | |||
476 | struct batadv_priv *bat_priv = netdev_priv(net_dev); | 474 | struct batadv_priv *bat_priv = netdev_priv(net_dev); |
477 | struct batadv_hard_iface *primary_if; | 475 | struct batadv_hard_iface *primary_if; |
478 | struct batadv_gw_node *gw_node; | 476 | struct batadv_gw_node *gw_node; |
479 | struct hlist_node *node; | ||
480 | int gw_count = 0; | 477 | int gw_count = 0; |
481 | 478 | ||
482 | primary_if = batadv_seq_print_text_primary_if_get(seq); | 479 | primary_if = batadv_seq_print_text_primary_if_get(seq); |
@@ -490,7 +487,7 @@ int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) | |||
490 | primary_if->net_dev->dev_addr, net_dev->name); | 487 | primary_if->net_dev->dev_addr, net_dev->name); |
491 | 488 | ||
492 | rcu_read_lock(); | 489 | rcu_read_lock(); |
493 | hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw.list, list) { | 490 | hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.list, list) { |
494 | if (gw_node->deleted) | 491 | if (gw_node->deleted) |
495 | continue; | 492 | continue; |
496 | 493 | ||