summaryrefslogtreecommitdiffstats
path: root/coccinelle/mfree.cocci
diff options
context:
space:
mode:
Diffstat (limited to 'coccinelle/mfree.cocci')
-rw-r--r--coccinelle/mfree.cocci29
1 files changed, 29 insertions, 0 deletions
diff --git a/coccinelle/mfree.cocci b/coccinelle/mfree.cocci
index 191cd62..1062d0c 100644
--- a/coccinelle/mfree.cocci
+++ b/coccinelle/mfree.cocci
@@ -1,7 +1,36 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
@@
+/* Avoid running this transformation on the mfree function itself */
+position p : script:python() { p[0].current_element != "mfree" };
+expression e;
+@@
+- free@p(e);
+- return NULL;
++ return mfree(e);
+
+@@
expression p;
@@
- free(p);
- p = NULL;
+ p = mfree(p);
+
+@@
+expression p;
+@@
+- if (p)
+- free(p);
++ free(p);
+
+@@
+expression p;
+@@
+- if (p)
+- mfree(p);
++ free(p);
+
+@@
+expression p;
+@@
+- mfree(p);
++ free(p);