staging: lustre: lustre: ldlm: Use list_for_each_entry()
PATCH 1/1 staging: lustre: lustre: ldlm: Use list_for_each_entry()
Use list_for_each_entry() rather than a combination of list_for_each() and list_entry(). Also remove the variable tmp which becomes useless as a result.
Semantic patch used:
@a@
expression pos, head;
expression mem;
type t;
identifier var;
iterator name list_for_each_entry, list_for_each;
@@
- list_for_each(pos, head)
+ list_for_each_entry(var, head, mem)
{
... when != var
- var = \(list_entry \| container_of\)(pos, t, mem); ... when != pos
}
Signed-off-by Janani Ravichandran <[email protected]>
--- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +1 -4
@@ -743,7 +743,6 @@ extern struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock);static void cleanup_resource (struct ldlm_resource *res,struct list_head *q,__u64 flags) { -struct list_head *tmp;int rc =0 ;bool local_only = !!(flags &LDLM_FL_LOCAL_ONLY );
@@ -755,9 +754,7 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,* all cleaned locks are marked by CLEANED flag. */ lock_res (res); -list_for_each (tmp, q) { - lock = list_entry(tmp, struct ldlm_lock, - l_res_link); +list_for_each_entry (lock, q, l_res_link) {if (lock->l_flags &LDLM_FL_CLEANED ) { lock =NULL ;continue ;
Signature · 1 line
2.5.0