staging: lustre: lustre: obdclass: Use list_for_each_entry()
PATCH 1/1 staging: lustre: lustre: obdclass: Use list_for_each_entry()
Use list_for_each_entry() rather than a combination of list_for_each() and list_entry(). Also remove declaration ofvariable 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/obdclass/genops.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/lustre/lustre/obdclass/genops.c +1 -3
@@ -90,12 +90,10 @@ static void obd_device_free(struct obd_device *obd)static struct obd_type *class_search_type (const char *name) { -struct list_head *tmp;struct obd_type *type;spin_lock (&obd_types_lock); -list_for_each (tmp, &obd_types) { - type = list_entry(tmp, struct obd_type, typ_chain); +list_for_each_entry (type, &obd_types, typ_chain) {if (strcmp (type->typ_name, name) ==0 ) {spin_unlock (&obd_types_lock);return type;
Signature · 1 line
2.5.0