Skip to contentSkip to conversation

staging: lustre: ldlm: ldlm_extent.c: Use list_for_each_entry()

PATCH New Janani Ravichandran 1 participant 1 message Feb 28, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lustre: ldlm: ldlm_extent.c: 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
}

---
 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +1 -4
index 222cb62..36b13db 100644
@@ -67,7 +67,6 @@
 __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms)
 {
 	struct ldlm_resource *res = lock->l_resource;
-	struct list_head *tmp;
 	struct ldlm_lock *lck;
 	__u64 kms = 0;
 
@@ -77,9 +76,7 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms)
 	 */
 	lock->l_flags |= LDLM_FL_KMS_IGNORE;
 
-	list_for_each(tmp, &res->lr_granted) {
-		lck = list_entry(tmp, struct ldlm_lock, l_res_link);
-
+	list_for_each_entry(lck, &res->lr_granted, l_res_link) {
 		if (lck->l_flags & LDLM_FL_KMS_IGNORE)
 			continue;
 
Signature · 1 line
2.5.0