Skip to contentSkip to conversation

staging: lustre: lustre: lov: Prefer list_for_each_entry_safe()

PATCH In review Janani Ravichandran 2 participants 3 messages Feb 28, 2016 – Mar 2, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lustre: lustre: lov: Prefer 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 declaration of variable pos, which is no longer used.

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/lov/lov_obd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/lustre/lustre/lov/lov_obd.c +2 -3
index 7ba670a..f62ae45 100644
@@ -857,11 +857,10 @@ static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
 static int lov_cleanup(struct obd_device *obd)
 {
 	struct lov_obd *lov = &obd->u.lov;
-	struct list_head *pos, *tmp;
+	struct list_head *tmp;
 	struct pool_desc *pool;
 
-	list_for_each_safe(pos, tmp, &lov->lov_pool_list) {
-		pool = list_entry(pos, struct pool_desc, pool_list);
+	list_for_each_entry_safe(pool, tmp, &lov->lov_pool_list, pool_list) {
 		/* free pool structs */
 		CDEBUG(D_INFO, "delete pool %p\n", pool);
 		/* In the function below, .hs_keycmp resolves to
Signature · 1 line
2.5.0
maintainer
#1 lore raw
Quoted 20 lines · Janani Ravichandran

Use list_for_each_entry_safe() instead of a combination of list_for_each_safe() and list_entry(). Also, remove declaration of variable pos, which is no longer used.

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
Quoted 6 lines

}

---
 drivers/staging/lustre/lustre/lov/lov_obd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

One, or more, of your patches in this 9 patch series (why didn't you number it), breaks the build :(

Please ALWAYS test build your patches.

greg k-h

maintainer
#2 lore raw
In reply to Janani Ravichandran
Quoted 20 lines · Janani Ravichandran

Use list_for_each_entry_safe() instead of a combination of list_for_each_safe() and list_entry(). Also, remove declaration of variable pos, which is no longer used.

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
Quoted 6 lines

}

---
 drivers/staging/lustre/lustre/lov/lov_obd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

One, or more, of your patches in this 9 patch series (why didn't you number it), breaks the build :(

Please ALWAYS test build your patches.

greg k-h