Skip to contentSkip to conversation

staging: lustre: obdecho: 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: obdecho: Use list_for_each_entry()

Use list_for_each_entry() rather than a combination of list_for_each() and list_entry(). Also remove variable el which becomes useless as a result.
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/lustre/obdecho/echo_client.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/lustre/lustre/obdecho/echo_client.c +1 -3
index 3be28c5..2b13aa2 100644
@@ -1060,12 +1060,10 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed,
 {
 	struct echo_client_obd *ec = ed->ed_ec;
 	struct echo_lock       *ecl = NULL;
-	struct list_head	     *el;
 	int found = 0, still_used = 0;
 
 	spin_lock(&ec->ec_lock);
-	list_for_each(el, &ec->ec_locks) {
-		ecl = list_entry(el, struct echo_lock, el_chain);
+	list_for_each_entry(ecl, &ec->ec_locks, el_chain) {
 		CDEBUG(D_INFO, "ecl: %p, cookie: %#llx\n", ecl, ecl->el_cookie);
 		found = (ecl->el_cookie == cookie);
 		if (found) {
Signature · 1 line
2.5.0