diff --git a/tool/misc/fix_null_pointer_checks.cocci b/tool/misc/fix_null_pointer_checks.cocci new file mode 100644 index 000000000..058f9e166 --- /dev/null +++ b/tool/misc/fix_null_pointer_checks.cocci @@ -0,0 +1,40 @@ +// Replace pointer null checks with boolen operations +// inverse version of https://github.com/neomutt/coccinelle/blob/master/null-check.cocci +// License: GPLv2 + +@@ +type T; +identifier I; +statement S1, S2; +expression E; +@@ + +T *I; + +( +- if (!I) ++ if (I == NULL) +S1 +| +- if (I) ++ if (I != NULL) +S1 +| +- if (!I) ++ if (I == NULL) +S1 else S2 +| +- if (I) ++ if (I != NULL) +S1 else S2 +| +if (E) S1 else +- if (!I) ++ if (I == NULL) +S1 else S2 +| +if (E) S1 else +- if (I) ++ if (I != NULL) +S1 else S2 +) diff --git a/tool/misc/ignore_return_mempcy.cocci b/tool/misc/ignore_return_mempcy.cocci new file mode 100644 index 000000000..2a75a5de7 --- /dev/null +++ b/tool/misc/ignore_return_mempcy.cocci @@ -0,0 +1,6 @@ +// Ignore memcpy return +@@ +expression E1, E2, E3; +@@ +- memcpy(E1, E2, E3) ++ (void) memcpy(E1, E2, E3)