Skip to contentSkip to conversation

staging: lustre: lustre: mdc: 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: mdc: Use list_for_each_entry_safe()

Use list_for_each_entry_safe() rather than a combination of list_for_each_safe() and list_entry(). Also remove variable l that becomes useless as a result.

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/mdc/mdc_lib.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/mdc/mdc_lib.c +2 -3
index b3bfdcb..a398958 100644
@@ -520,18 +520,17 @@ int mdc_enter_request(struct client_obd *cli)
 
 void mdc_exit_request(struct client_obd *cli)
 {
-	struct list_head *l, *tmp;
+	struct list_head *tmp;
 	struct mdc_cache_waiter *mcw;
 
 	client_obd_list_lock(&cli->cl_loi_list_lock);
 	cli->cl_r_in_flight--;
-	list_for_each_safe(l, tmp, &cli->cl_cache_waiters) {
+	list_for_each_entry_safe(mcw, tmp, &cli->cl_cache_waiters, mcw_entry) {
 		if (cli->cl_r_in_flight >= cli->cl_max_rpcs_in_flight) {
 			/* No free request slots anymore */
 			break;
 		}
 
-		mcw = list_entry(l, struct mdc_cache_waiter, mcw_entry);
 		list_del_init(&mcw->mcw_entry);
 		cli->cl_r_in_flight++;
 		wake_up(&mcw->mcw_waitq);
Signature · 1 line
2.5.0