From 63f7a3b910282b62fcfbae165b9c9cbb2bca567c Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Tue, 29 Jun 2021 15:16:01 +0300 Subject: [PATCH] tools: Add coccinelle script for checking against XMALLOC/XCALLOC NULLs Signed-off-by: Donatas Abraitis --- tools/coccinelle/xcalloc-xmalloc.cocci | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tools/coccinelle/xcalloc-xmalloc.cocci diff --git a/tools/coccinelle/xcalloc-xmalloc.cocci b/tools/coccinelle/xcalloc-xmalloc.cocci new file mode 100644 index 0000000000..2a091d4cd9 --- /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 ...; -- 2.39.5