staging: lustre: lustre: lov: Prefer list_for_each_entry_safe()
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
@@ -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
Greg KH
maintainerQuoted 20 lines · Janani Ravichandran
Use
list_for_each_entry_safe()instead of a combination oflist_for_each_safe()andlist_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 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/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
Greg KH
maintainerQuoted 20 lines · Janani Ravichandran
Use
list_for_each_entry_safe()instead of a combination oflist_for_each_safe()andlist_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 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/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