Skip to contentSkip to conversation

staging: lustre: ptlrpc: Use list_for_each_entry_safe()

PATCH In review Janani Ravichandran 2 participants 3 messages Feb 28, 2016 – Mar 2, 2016 Staging

lore
Share & tools
lore
#0 lore raw

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

Use list_for_each_entry_safe() instead of a combination of list_for_each_safe() and list_entry(). Also remove variable pos which 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/ptlrpc/ptlrpcd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +3 -4
index 0c36663..7c1dddd 100644
@@ -199,15 +199,14 @@ ptlrpcd_select_pc(struct ptlrpc_request *req)
 static int ptlrpcd_steal_rqset(struct ptlrpc_request_set *des,
 			       struct ptlrpc_request_set *src)
 {
-	struct list_head *tmp, *pos;
+	struct list_head *tmp;
 	struct ptlrpc_request *req;
 	int rc = 0;
 
 	spin_lock(&src->set_new_req_lock);
 	if (likely(!list_empty(&src->set_new_requests))) {
-		list_for_each_safe(pos, tmp, &src->set_new_requests) {
-			req = list_entry(pos, struct ptlrpc_request,
-					     rq_set_chain);
+		list_for_each_entry_safe(req, tmp, &src->set_new_requests,
+					 rq_set_chain) {
 			req->rq_set = des;
 		}
 		list_splice_init(&src->set_new_requests,
Signature · 1 line
2.5.0
maintainer
#1 lore raw
Quoted 19 lines · Janani Ravichandran

Use list_for_each_entry_safe() instead of a combination of list_for_each_safe() and list_entry(). Also remove variable pos which 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
Quoted 6 lines

}

---
 drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Does not apply to the tree properly :(

maintainer
#2 lore raw
In reply to Janani Ravichandran
Quoted 19 lines · Janani Ravichandran

Use list_for_each_entry_safe() instead of a combination of list_for_each_safe() and list_entry(). Also remove variable pos which 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
Quoted 6 lines

}

---
 drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Does not apply to the tree properly :(