]> git.karo-electronics.de Git - linux-beck.git/commitdiff
coccinelle: ifnullfree: various cleanups
authorJulia Lawall <Julia.Lawall@lip6.fr>
Mon, 26 Oct 2015 21:28:25 +0000 (22:28 +0100)
committerMichal Marek <mmarek@suse.cz>
Mon, 26 Oct 2015 21:41:13 +0000 (22:41 +0100)
Adjust tests to compare against NULL, to match cases that explicitly make
that comparison.

Remove removal and re-addition of freeing functions.

Add position variable on usb_free_urb in the non-patch case.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.cz>
scripts/coccinelle/free/ifnullfree.cocci

index a42d70bf88b3b5f834eb5654d5e52519982568d4..d4a072d5b505fd5a8655cc4c389a34367745bbf5 100644 (file)
@@ -16,19 +16,15 @@ virtual context
 @r2 depends on patch@
 expression E;
 @@
-- if (E)
+- if (E != NULL)
 (
--      kfree(E);
-+ kfree(E);
+  kfree(E);
 |
--      debugfs_remove(E);
-+ debugfs_remove(E);
+  debugfs_remove(E);
 |
--      debugfs_remove_recursive(E);
-+ debugfs_remove_recursive(E);
+  debugfs_remove_recursive(E);
 |
--      usb_free_urb(E);
-+ usb_free_urb(E);
+  usb_free_urb(E);
 )
 
 @r depends on context || report || org @
@@ -36,8 +32,8 @@ expression E;
 position p;
 @@
 
-* if (E)
-*      \(kfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|usb_free_urb\)(E);
+* if (E != NULL)
+*      \(kfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|usb_free_urb@p\)(E);
 
 @script:python depends on org@
 p << r.p;