summaryrefslogtreecommitdiffstats
path: root/tools/coccinelle/xcalloc-xmalloc.cocci
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tools/coccinelle/xcalloc-xmalloc.cocci17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/coccinelle/xcalloc-xmalloc.cocci b/tools/coccinelle/xcalloc-xmalloc.cocci
new file mode 100644
index 0000000..2a091d4
--- /dev/null
+++ b/tools/coccinelle/xcalloc-xmalloc.cocci
@@ -0,0 +1,17 @@
+// No need checking against NULL for XMALLOC/XCALLOC.
+// If that happens, we have more problems with memory.
+
+@@
+type T;
+T *ptr;
+@@
+
+ptr =
+(
+XCALLOC(...)
+|
+XMALLOC(...)
+)
+...
+- if (ptr == NULL)
+- return ...;