Skip to contentSkip to conversation

staging: lustre: lustre: ldlm: ldlm_lock.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: lustre: ldlm: ldlm_lock.c: Use list_for_each_entry()

Use list_for_each_entry() rather than a combination of list_for_each() and list_entry(). Also, remove 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_lock.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +2 -7
index 98975ef..010ae02 100644
@@ -884,11 +884,9 @@ static void search_granted_lock(struct list_head *queue,
 				struct ldlm_lock *req,
 				struct sl_insert_point *prev)
 {
-	struct list_head *tmp;
 	struct ldlm_lock *lock, *mode_end, *policy_end;
 
-	list_for_each(tmp, queue) {
-		lock = list_entry(tmp, struct ldlm_lock, l_res_link);
+	list_for_each_entry(lock, queue, l_res_link) {
 
 		mode_end = list_entry(lock->l_sl_mode.prev,
 					  struct ldlm_lock, l_sl_mode);
@@ -1053,13 +1051,10 @@ static struct ldlm_lock *search_queue(struct list_head *queue,
 				      __u64 flags, int unref)
 {
 	struct ldlm_lock *lock;
-	struct list_head       *tmp;
 
-	list_for_each(tmp, queue) {
+	list_for_each_entry(lock, queue, l_res_link) {
 		enum ldlm_mode match;
 
-		lock = list_entry(tmp, struct ldlm_lock, l_res_link);
-
 		if (lock == old_lock)
 			break;
 
Signature · 1 line
2.5.0