hlist: drop the node parameter from iterators
commitb67bfe0d42cac56c512dd5da4b1b347a23f4b70a
authorSasha Levin <sasha.levin@oracle.com>
Thu, 28 Feb 2013 01:06:00 +0000 (27 17:06 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Feb 2013 03:10:24 +0000 (27 19:10 -0800)
tree3d465aea12b97683f26ffa38eba8744469de9997
parent1e142b29e210b5dfb2deeb6ce2210b60af16d2a6
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>
218 files changed:
arch/arm/kernel/kprobes.c
arch/ia64/kernel/kprobes.c
arch/mips/kernel/kprobes.c
arch/powerpc/kernel/kprobes.c
arch/powerpc/kvm/book3s_mmu_hpte.c
arch/s390/kernel/kprobes.c
arch/s390/pci/pci_msi.c
arch/sh/kernel/kprobes.c
arch/sparc/kernel/kprobes.c
arch/sparc/kernel/ldc.c
arch/x86/kernel/kprobes/core.c
arch/x86/kvm/mmu.c
block/blk-cgroup.c
block/blk-ioc.c
block/bsg.c
block/cfq-iosched.c
block/elevator.c
crypto/algapi.c
drivers/atm/atmtcp.c
drivers/atm/eni.c
drivers/atm/he.c
drivers/atm/solos-pci.c
drivers/clk/clk.c
drivers/gpu/drm/drm_hashtab.c
drivers/infiniband/core/cma.c
drivers/infiniband/core/fmr_pool.c
drivers/isdn/mISDN/socket.c
drivers/isdn/mISDN/stack.c
drivers/md/dm-bio-prison.c
drivers/md/dm-bufio.c
drivers/md/dm-snap.c
drivers/md/persistent-data/dm-transaction-manager.c
drivers/md/raid5.c
drivers/misc/sgi-gru/grutlbpurge.c
drivers/misc/vmw_vmci/vmci_doorbell.c
drivers/misc/vmw_vmci/vmci_resource.c
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
drivers/net/ethernet/mellanox/mlx4/en_rx.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
drivers/net/ethernet/sun/sunvnet.c
drivers/net/macvlan.c
drivers/net/tun.c
drivers/net/vxlan.c
drivers/net/wireless/zd1201.c
drivers/pci/pci.c
drivers/staging/android/binder.c
drivers/target/tcm_fc/tfc_sess.c
fs/affs/amigaffs.c
fs/aio.c
fs/cifs/inode.c
fs/dcache.c
fs/dlm/lowcomms.c
fs/ecryptfs/messaging.c
fs/exportfs/expfs.c
fs/fat/inode.c
fs/fat/nfs.c
fs/fscache/cookie.c
fs/inode.c
fs/lockd/host.c
fs/lockd/svcsubs.c
fs/nfs/pnfs_dev.c
fs/nfsd/nfscache.c
fs/notify/fsnotify.c
fs/notify/inode_mark.c
fs/notify/vfsmount_mark.c
fs/ocfs2/dcache.c
fs/ocfs2/dlm/dlmrecovery.c
fs/super.c
fs/sysfs/bin.c
fs/xfs/xfs_log_recover.c
include/linux/hashtable.h
include/linux/if_team.h
include/linux/list.h
include/linux/pid.h
include/linux/rculist.h
include/net/ax25.h
include/net/inet_hashtables.h
include/net/inet_timewait_sock.h
include/net/netrom.h
include/net/sch_generic.h
include/net/sctp/sctp.h
include/net/sock.h
kernel/cgroup.c
kernel/events/core.c
kernel/kprobes.c
kernel/pid.c
kernel/sched/core.c
kernel/smpboot.c
kernel/trace/ftrace.c
kernel/trace/trace_output.c
kernel/tracepoint.c
kernel/user-return-notifier.c
kernel/user.c
kernel/workqueue.c
lib/debugobjects.c
lib/lru_cache.c
mm/huge_memory.c
mm/kmemleak.c
mm/ksm.c
mm/mmu_notifier.c
net/9p/error.c
net/9p/trans_virtio.c
net/appletalk/ddp.c
net/atm/common.c
net/atm/lec.c
net/atm/signaling.c
net/ax25/af_ax25.c
net/ax25/ax25_ds_subr.c
net/ax25/ax25_ds_timer.c
net/ax25/ax25_iface.c
net/ax25/ax25_uid.c
net/batman-adv/bat_iv_ogm.c
net/batman-adv/bridge_loop_avoidance.c
net/batman-adv/distributed-arp-table.c
net/batman-adv/gateway_client.c
net/batman-adv/main.c
net/batman-adv/originator.c
net/batman-adv/originator.h
net/batman-adv/routing.c
net/batman-adv/send.c
net/batman-adv/translation-table.c
net/batman-adv/vis.c
net/bluetooth/hci_sock.c
net/bluetooth/rfcomm/sock.c
net/bluetooth/sco.c
net/bridge/br_fdb.c
net/bridge/br_mdb.c
net/bridge/br_multicast.c
net/can/af_can.c
net/can/gw.c
net/can/proc.c
net/core/dev.c
net/core/flow.c
net/core/net-procfs.c
net/core/rtnetlink.c
net/decnet/af_decnet.c
net/decnet/dn_table.c
net/ieee802154/dgram.c
net/ieee802154/raw.c
net/ipv4/devinet.c
net/ipv4/fib_frontend.c
net/ipv4/fib_semantics.c
net/ipv4/fib_trie.c
net/ipv4/inet_connection_sock.c
net/ipv4/inet_fragment.c
net/ipv4/inet_hashtables.c
net/ipv4/inet_timewait_sock.c
net/ipv4/raw.c
net/ipv4/tcp_ipv4.c
net/ipv6/addrconf.c
net/ipv6/addrlabel.c
net/ipv6/inet6_connection_sock.c
net/ipv6/ip6_fib.c
net/ipv6/raw.c
net/ipv6/xfrm6_tunnel.c
net/ipx/af_ipx.c
net/ipx/ipx_proc.c
net/iucv/af_iucv.c
net/key/af_key.c
net/l2tp/l2tp_core.c
net/l2tp/l2tp_ip.c
net/l2tp/l2tp_ip6.c
net/llc/llc_sap.c
net/mac80211/mesh_pathtbl.c
net/netfilter/ipvs/ip_vs_conn.c
net/netfilter/nf_conntrack_expect.c
net/netfilter/nf_conntrack_helper.c
net/netfilter/nf_conntrack_netlink.c
net/netfilter/nf_conntrack_sip.c
net/netfilter/nf_nat_core.c
net/netfilter/nfnetlink_cthelper.c
net/netfilter/nfnetlink_log.c
net/netfilter/nfnetlink_queue_core.c
net/netfilter/xt_RATEEST.c
net/netfilter/xt_connlimit.c
net/netfilter/xt_hashlimit.c
net/netlink/af_netlink.c
net/netrom/af_netrom.c
net/netrom/nr_route.c
net/nfc/llcp/llcp.c
net/openvswitch/datapath.c
net/openvswitch/flow.c
net/openvswitch/vport.c
net/packet/af_packet.c
net/packet/diag.c
net/phonet/pep.c
net/phonet/socket.c
net/rds/bind.c
net/rds/connection.c
net/rose/af_rose.c
net/sched/sch_api.c
net/sched/sch_cbq.c
net/sched/sch_drr.c
net/sched/sch_hfsc.c
net/sched/sch_htb.c
net/sched/sch_qfq.c
net/sctp/endpointola.c
net/sctp/input.c
net/sctp/proc.c
net/sctp/socket.c
net/sunrpc/auth.c
net/sunrpc/cache.c
net/sunrpc/svcauth.c
net/tipc/name_table.c
net/tipc/node.c
net/unix/af_unix.c
net/unix/diag.c
net/x25/af_x25.c
net/xfrm/xfrm_policy.c
net/xfrm/xfrm_state.c
security/integrity/ima/ima_queue.c
security/selinux/avc.c
tools/perf/util/evlist.c
virt/kvm/eventfd.c
virt/kvm/irq_comm.c