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/iucv | |
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/iucv')
-rw-r--r-- | net/iucv/af_iucv.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index cd6f7a991d80..a7d11ffe4284 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c | |||
@@ -156,14 +156,13 @@ static int afiucv_pm_freeze(struct device *dev) | |||
156 | { | 156 | { |
157 | struct iucv_sock *iucv; | 157 | struct iucv_sock *iucv; |
158 | struct sock *sk; | 158 | struct sock *sk; |
159 | struct hlist_node *node; | ||
160 | int err = 0; | 159 | int err = 0; |
161 | 160 | ||
162 | #ifdef CONFIG_PM_DEBUG | 161 | #ifdef CONFIG_PM_DEBUG |
163 | printk(KERN_WARNING "afiucv_pm_freeze\n"); | 162 | printk(KERN_WARNING "afiucv_pm_freeze\n"); |
164 | #endif | 163 | #endif |
165 | read_lock(&iucv_sk_list.lock); | 164 | read_lock(&iucv_sk_list.lock); |
166 | sk_for_each(sk, node, &iucv_sk_list.head) { | 165 | sk_for_each(sk, &iucv_sk_list.head) { |
167 | iucv = iucv_sk(sk); | 166 | iucv = iucv_sk(sk); |
168 | switch (sk->sk_state) { | 167 | switch (sk->sk_state) { |
169 | case IUCV_DISCONN: | 168 | case IUCV_DISCONN: |
@@ -194,13 +193,12 @@ static int afiucv_pm_freeze(struct device *dev) | |||
194 | static int afiucv_pm_restore_thaw(struct device *dev) | 193 | static int afiucv_pm_restore_thaw(struct device *dev) |
195 | { | 194 | { |
196 | struct sock *sk; | 195 | struct sock *sk; |
197 | struct hlist_node *node; | ||
198 | 196 | ||
199 | #ifdef CONFIG_PM_DEBUG | 197 | #ifdef CONFIG_PM_DEBUG |
200 | printk(KERN_WARNING "afiucv_pm_restore_thaw\n"); | 198 | printk(KERN_WARNING "afiucv_pm_restore_thaw\n"); |
201 | #endif | 199 | #endif |
202 | read_lock(&iucv_sk_list.lock); | 200 | read_lock(&iucv_sk_list.lock); |
203 | sk_for_each(sk, node, &iucv_sk_list.head) { | 201 | sk_for_each(sk, &iucv_sk_list.head) { |
204 | switch (sk->sk_state) { | 202 | switch (sk->sk_state) { |
205 | case IUCV_CONNECTED: | 203 | case IUCV_CONNECTED: |
206 | sk->sk_err = EPIPE; | 204 | sk->sk_err = EPIPE; |
@@ -390,9 +388,8 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock, | |||
390 | static struct sock *__iucv_get_sock_by_name(char *nm) | 388 | static struct sock *__iucv_get_sock_by_name(char *nm) |
391 | { | 389 | { |
392 | struct sock *sk; | 390 | struct sock *sk; |
393 | struct hlist_node *node; | ||
394 | 391 | ||
395 | sk_for_each(sk, node, &iucv_sk_list.head) | 392 | sk_for_each(sk, &iucv_sk_list.head) |
396 | if (!memcmp(&iucv_sk(sk)->src_name, nm, 8)) | 393 | if (!memcmp(&iucv_sk(sk)->src_name, nm, 8)) |
397 | return sk; | 394 | return sk; |
398 | 395 | ||
@@ -1678,7 +1675,6 @@ static int iucv_callback_connreq(struct iucv_path *path, | |||
1678 | unsigned char user_data[16]; | 1675 | unsigned char user_data[16]; |
1679 | unsigned char nuser_data[16]; | 1676 | unsigned char nuser_data[16]; |
1680 | unsigned char src_name[8]; | 1677 | unsigned char src_name[8]; |
1681 | struct hlist_node *node; | ||
1682 | struct sock *sk, *nsk; | 1678 | struct sock *sk, *nsk; |
1683 | struct iucv_sock *iucv, *niucv; | 1679 | struct iucv_sock *iucv, *niucv; |
1684 | int err; | 1680 | int err; |
@@ -1689,7 +1685,7 @@ static int iucv_callback_connreq(struct iucv_path *path, | |||
1689 | read_lock(&iucv_sk_list.lock); | 1685 | read_lock(&iucv_sk_list.lock); |
1690 | iucv = NULL; | 1686 | iucv = NULL; |
1691 | sk = NULL; | 1687 | sk = NULL; |
1692 | sk_for_each(sk, node, &iucv_sk_list.head) | 1688 | sk_for_each(sk, &iucv_sk_list.head) |
1693 | if (sk->sk_state == IUCV_LISTEN && | 1689 | if (sk->sk_state == IUCV_LISTEN && |
1694 | !memcmp(&iucv_sk(sk)->src_name, src_name, 8)) { | 1690 | !memcmp(&iucv_sk(sk)->src_name, src_name, 8)) { |
1695 | /* | 1691 | /* |
@@ -2115,7 +2111,6 @@ static int afiucv_hs_callback_rx(struct sock *sk, struct sk_buff *skb) | |||
2115 | static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev, | 2111 | static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev, |
2116 | struct packet_type *pt, struct net_device *orig_dev) | 2112 | struct packet_type *pt, struct net_device *orig_dev) |
2117 | { | 2113 | { |
2118 | struct hlist_node *node; | ||
2119 | struct sock *sk; | 2114 | struct sock *sk; |
2120 | struct iucv_sock *iucv; | 2115 | struct iucv_sock *iucv; |
2121 | struct af_iucv_trans_hdr *trans_hdr; | 2116 | struct af_iucv_trans_hdr *trans_hdr; |
@@ -2132,7 +2127,7 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev, | |||
2132 | iucv = NULL; | 2127 | iucv = NULL; |
2133 | sk = NULL; | 2128 | sk = NULL; |
2134 | read_lock(&iucv_sk_list.lock); | 2129 | read_lock(&iucv_sk_list.lock); |
2135 | sk_for_each(sk, node, &iucv_sk_list.head) { | 2130 | sk_for_each(sk, &iucv_sk_list.head) { |
2136 | if (trans_hdr->flags == AF_IUCV_FLAG_SYN) { | 2131 | if (trans_hdr->flags == AF_IUCV_FLAG_SYN) { |
2137 | if ((!memcmp(&iucv_sk(sk)->src_name, | 2132 | if ((!memcmp(&iucv_sk(sk)->src_name, |
2138 | trans_hdr->destAppName, 8)) && | 2133 | trans_hdr->destAppName, 8)) && |
@@ -2225,10 +2220,9 @@ static void afiucv_hs_callback_txnotify(struct sk_buff *skb, | |||
2225 | struct sk_buff *list_skb; | 2220 | struct sk_buff *list_skb; |
2226 | struct sk_buff *nskb; | 2221 | struct sk_buff *nskb; |
2227 | unsigned long flags; | 2222 | unsigned long flags; |
2228 | struct hlist_node *node; | ||
2229 | 2223 | ||
2230 | read_lock_irqsave(&iucv_sk_list.lock, flags); | 2224 | read_lock_irqsave(&iucv_sk_list.lock, flags); |
2231 | sk_for_each(sk, node, &iucv_sk_list.head) | 2225 | sk_for_each(sk, &iucv_sk_list.head) |
2232 | if (sk == isk) { | 2226 | if (sk == isk) { |
2233 | iucv = iucv_sk(sk); | 2227 | iucv = iucv_sk(sk); |
2234 | break; | 2228 | break; |
@@ -2299,14 +2293,13 @@ static int afiucv_netdev_event(struct notifier_block *this, | |||
2299 | unsigned long event, void *ptr) | 2293 | unsigned long event, void *ptr) |
2300 | { | 2294 | { |
2301 | struct net_device *event_dev = (struct net_device *)ptr; | 2295 | struct net_device *event_dev = (struct net_device *)ptr; |
2302 | struct hlist_node *node; | ||
2303 | struct sock *sk; | 2296 | struct sock *sk; |
2304 | struct iucv_sock *iucv; | 2297 | struct iucv_sock *iucv; |
2305 | 2298 | ||
2306 | switch (event) { | 2299 | switch (event) { |
2307 | case NETDEV_REBOOT: | 2300 | case NETDEV_REBOOT: |
2308 | case NETDEV_GOING_DOWN: | 2301 | case NETDEV_GOING_DOWN: |
2309 | sk_for_each(sk, node, &iucv_sk_list.head) { | 2302 | sk_for_each(sk, &iucv_sk_list.head) { |
2310 | iucv = iucv_sk(sk); | 2303 | iucv = iucv_sk(sk); |
2311 | if ((iucv->hs_dev == event_dev) && | 2304 | if ((iucv->hs_dev == event_dev) && |
2312 | (sk->sk_state == IUCV_CONNECTED)) { | 2305 | (sk->sk_state == IUCV_CONNECTED)) { |