staging: lustre: ptlrpc: Use list_for_each_entry_safe()
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
@@ -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
Greg KH
maintainerQuoted 19 lines · Janani Ravichandran
Use
list_for_each_entry_safe()instead of a combination oflist_for_each_safe()andlist_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 namelist_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
}
Signed-off-by Janani Ravichandran <[email protected]>--- drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Does not apply to the tree properly :(
Greg KH
maintainerQuoted 19 lines · Janani Ravichandran
Use
list_for_each_entry_safe()instead of a combination oflist_for_each_safe()andlist_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 namelist_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
}
Signed-off-by Janani Ravichandran <[email protected]>--- drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Does not apply to the tree properly :(