Add a coccinelle patch to find 0 (instead of NULL) used with pointers.
authorSascha Wildner <saw@online.de>
Tue, 6 Mar 2012 19:13:55 +0000 (20:13 +0100)
committerSascha Wildner <saw@online.de>
Tue, 6 Mar 2012 19:13:55 +0000 (20:13 +0100)
test/cocci/bad_zero.cocci [new file with mode: 0644]

diff --git a/test/cocci/bad_zero.cocci b/test/cocci/bad_zero.cocci
new file mode 100644 (file)
index 0000000..9965375
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright: (C) 2009 Gilles Muller, Julia Lawall, INRIA, DIKU.  GPLv2.
+//
+// -no_includes -include_headers
+//
+
+@ disable is_zero @
+expression *E;
+@@
+
+  E ==
+- 0
++ NULL
+
+@ disable is_zero @
+expression *E;
+@@
+
+- 0
++ NULL
+  == E
+
+@ disable isnt_zero @
+expression *E;
+@@
+
+  E !=
+- 0
++ NULL
+
+@ disable isnt_zero @
+expression *E;
+@@
+
+- 0
++ NULL
+  != E
+
+@ disable is_zero @
+expression *E;
+@@
+
+  E =
+- 0
++ NULL