summaryrefslogtreecommitdiffstats
path: root/coccinelle/mfree.cocci
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 03:50:42 +0000
commit78e9bb837c258ac0ec7712b3d612cc2f407e731e (patch)
treef515d16b6efd858a9aeb5b0ef5d6f90bf288283d /coccinelle/mfree.cocci
parentAdding debian version 255.5-1. (diff)
downloadsystemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.tar.xz
systemd-78e9bb837c258ac0ec7712b3d612cc2f407e731e.zip
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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);