Skip to contentSkip to conversation

staging: lustre: lnet: Use list_for_each_entry()

PATCH New Janani Ravichandran 1 participant 1 message Feb 28, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lustre: lnet: Use list_for_each_entry()

Use list_for_each_entry() rather than a combination of list_for_each() and list_entry(). Also, remove variable pacer which becomes useless as a result of the transformation.
Semantic patch used:

@a@
expression pos, head;
expression mem;
type t;
identifier var;
iterator name list_for_each_entry, list_for_each;
@@

- list_for_each(pos, head)
+ list_for_each_entry(var, head, mem)
{
... when != var
- var = \(list_entry \| container_of\)(pos, t, mem); ... when != pos
}

---
 drivers/staging/lustre/lnet/selftest/conrpc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/lustre/lnet/selftest/conrpc.c +2 -5
index b02a140..7e607f8 100644
@@ -1332,7 +1332,6 @@ lstcon_rpc_cleanup_wait(void)
 {
 	lstcon_rpc_trans_t *trans;
 	lstcon_rpc_t *crpc;
-	struct list_head *pacer;
 	struct list_head zlist;
 
 	/* Called with hold of global mutex */
@@ -1340,10 +1339,8 @@ lstcon_rpc_cleanup_wait(void)
 	LASSERT(console_session.ses_shutdown);
 
 	while (!list_empty(&console_session.ses_trans_list)) {
-		list_for_each(pacer, &console_session.ses_trans_list) {
-			trans = list_entry(pacer, lstcon_rpc_trans_t,
-					   tas_link);
-
+		list_for_each_entry(trans, &console_session.ses_trans_list,
+				    tas_link) {
 			CDEBUG(D_NET, "Session closed, wakeup transaction %s\n",
 			       lstcon_rpc_trans_name(trans->tas_opc));
 
Signature · 1 line
2.5.0