staging: lustre: lnet: replace list_for_each with list_for_each_entry
Replace use of the combination of list_for_each() and list_entry() with
list_for_each_entry() to simplify the code and remove variables that are
used only in list_for_each().
Issue found and corrected using Coccinelle script:
@r@
expression head, member, e;
type T1, T2, T3;
iterator name list_for_each, list_for_each_entry;
identifier pos, var;
@@
-T1 *pos;
...when!=pos
-list_for_each(pos, head)
+list_for_each_entry(var, head, member)
{
...when!=pos
when!=T3 *var;
-var = list_entry(pos, T2, member);
...when!=pos
}
...when!=pos
Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7c35d3809b
commit
8e55b6fd06
@@ -176,12 +176,9 @@ struct ksock_peer *
|
||||
ksocknal_find_peer_locked(struct lnet_ni *ni, struct lnet_process_id id)
|
||||
{
|
||||
struct list_head *peer_list = ksocknal_nid2peerlist(id.nid);
|
||||
struct list_head *tmp;
|
||||
struct ksock_peer *peer;
|
||||
|
||||
list_for_each(tmp, peer_list) {
|
||||
peer = list_entry(tmp, struct ksock_peer, ksnp_list);
|
||||
|
||||
list_for_each_entry(peer, peer_list, ksnp_list) {
|
||||
LASSERT(!peer->ksnp_closing);
|
||||
|
||||
if (peer->ksnp_ni != ni)
|
||||
@@ -453,7 +450,6 @@ int
|
||||
ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id, __u32 ipaddr,
|
||||
int port)
|
||||
{
|
||||
struct list_head *tmp;
|
||||
struct ksock_peer *peer;
|
||||
struct ksock_peer *peer2;
|
||||
struct ksock_route *route;
|
||||
@@ -491,9 +487,7 @@ ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id, __u32 ipaddr,
|
||||
}
|
||||
|
||||
route2 = NULL;
|
||||
list_for_each(tmp, &peer->ksnp_routes) {
|
||||
route2 = list_entry(tmp, struct ksock_route, ksnr_list);
|
||||
|
||||
list_for_each_entry(route2, &peer->ksnp_routes, ksnr_list) {
|
||||
if (route2->ksnr_ipaddr == ipaddr)
|
||||
break;
|
||||
|
||||
@@ -1854,12 +1848,10 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
|
||||
|
||||
peer = ksocknal_find_peer_locked(ni, id);
|
||||
if (peer) {
|
||||
struct list_head *tmp;
|
||||
struct ksock_conn *conn;
|
||||
int bufnob;
|
||||
|
||||
list_for_each(tmp, &peer->ksnp_conns) {
|
||||
conn = list_entry(tmp, struct ksock_conn, ksnc_list);
|
||||
list_for_each_entry(conn, &peer->ksnp_conns, ksnc_list) {
|
||||
bufnob = conn->ksnc_sock->sk->sk_wmem_queued;
|
||||
|
||||
if (bufnob < conn->ksnc_tx_bufnob) {
|
||||
|
||||
Reference in New Issue
Block a user