Skip to contentSkip to conversation

Staging: lustre: obdclass: Use list_first_entry_or_null

PATCH In review Bhumika Goyal 2 participants 2 messages Mar 6, 2016 – Mar 11, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: lustre: obdclass: Use list_first_entry_or_null

This patch replaces list_empty and list_entry with list_first_entry_or_null as it makes the code cleare to read. Also removed the {} around if-statement.
Done using coccinelle:

@@
expression e1,e2;
statement S;
@@
- if(!list_empty(...)){
e2=
- list_entry(e1.next,
+ list_first_entry_or_null(&e1,
...);
+ if(e2){
...
}

---
 drivers/staging/lustre/lustre/obdclass/genops.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/staging/lustre/lustre/obdclass/genops.c +8 -8
index cf97b8f0..08b17d1 100644
@@ -1123,18 +1123,18 @@ static void obd_zombie_impexp_cull(void)
 		spin_lock(&obd_zombie_impexp_lock);
 
 		import = NULL;
-		if (!list_empty(&obd_zombie_imports)) {
-			import = list_entry(obd_zombie_imports.next,
-					    struct obd_import,
-					    imp_zombie_chain);
+		import = list_first_entry_or_null(&obd_zombie_imports,
+						  struct obd_import,
+						  imp_zombie_chain);
+		if (import)
 			list_del_init(&import->imp_zombie_chain);
 		
 
 		export = NULL;
-		if (!list_empty(&obd_zombie_exports)) {
-			export = list_entry(obd_zombie_exports.next,
-					    struct obd_export,
-					    exp_obd_chain);
+		export = list_first_entry_or_null(&obd_zombie_exports,
+						  struct obd_export,
+						  exp_obd_chain);
+		if (export)
 			list_del_init(&export->exp_obd_chain);
 		
 
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 18 lines · Bhumika Goyal

This patch replaces list_empty and list_entry with list_first_entry_or_null as it makes the code cleare to read. Also removed the {} around if-statement.
Done using coccinelle:

@@
expression e1,e2;
statement S;
@@
- if(!list_empty(...)){
e2=
- list_entry(e1.next,
+ list_first_entry_or_null(&e1,
...);
+ if(e2){
...
}

Quoted 4 lines
---
 drivers/staging/lustre/lustre/obdclass/genops.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Does not apply to my tree :(