Skip to contentSkip to conversation

staging: lustre: lustre: osc: Use list_for_each_entry_safe()

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lustre: lustre: osc: Use list_for_each_entry_safe()

Use list_for_each_entry_safe() rather than a combination of list_for_each() and list_entry(). Also remove the variable l which becomes useless after the transformation.

Semantic patch used:

@a@
expression pos, n, head;
expression mem;
type t;
identifier var;
iterator name list_for_each_entry_safe, list_for_each_safe; @@

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

---
 drivers/staging/lustre/lustre/osc/osc_cache.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/osc/osc_cache.c +2 -3
index c6623c1..6c3fc6f 100644
@@ -1624,11 +1624,10 @@ out:
 /* caller must hold loi_list_lock */
 void osc_wake_cache_waiters(struct client_obd *cli)
 {
-	struct list_head *l, *tmp;
+	struct list_head *tmp;
 	struct osc_cache_waiter *ocw;
 
-	list_for_each_safe(l, tmp, &cli->cl_cache_waiters) {
-		ocw = list_entry(l, struct osc_cache_waiter, ocw_entry);
+	list_for_each_entry_safe(ocw, tmp, &cli->cl_cache_waiters, ocw_entry) {
 		list_del_init(&ocw->ocw_entry);
 
 		ocw->ocw_rc = -EDQUOT;
Signature · 1 line
2.5.0