From d7d6195953f44e5028341a13ff901fde424f7542 Mon Sep 17 00:00:00 2001 From: AtariDreams <83477269+AtariDreams@users.noreply.github.com> Date: Mon, 8 Jan 2024 22:24:37 -0500 Subject: cocci: merge mfree.cocci and mfree_return.cocci (#30838) It makes sense that these should be one file instead of two, as they both involve mfree() --- coccinelle/mfree.cocci | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'coccinelle/mfree.cocci') diff --git a/coccinelle/mfree.cocci b/coccinelle/mfree.cocci index 191cd626f5..1062d0ca53 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); -- cgit v1.2.3