All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: ptlrpc: Use list_for_each_entry_safe()
@ 2016-02-28 22:20 Janani Ravichandran
  2016-03-02 16:25 ` [Outreachy kernel] " Greg KH
  2016-03-02 18:48 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Janani Ravichandran @ 2016-02-28 22:20 UTC (permalink / raw)
  To: outreachy-kernel

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
  }

Signed-off-by: Janani Ravichandran <janani.rvchndrn@gmail.com>
---
 drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
index 0c36663..7c1dddd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
@@ -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,
-- 
2.5.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-02 18:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-28 22:20 [PATCH] staging: lustre: ptlrpc: Use list_for_each_entry_safe() Janani Ravichandran
2016-03-02 16:25 ` [Outreachy kernel] " Greg KH
2016-03-02 18:48 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.