From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH] cocci: FREE_AND_NULL(E) is safe to call on NULL
Date: Fri, 11 Sep 2026 15:21:35 -0700 [thread overview]
Message-ID: <xmqqh5jv8m4w.fsf@gitster.g> (raw)
In-Reply-To: <xmqqld978mok.fsf@gitster.g> (Junio C. Hamano's message of "Fri, 11 Sep 2026 15:09:47 -0700")
Just like we allow calling free(E) without checking if E is not
NULL, it is safe to call FREE_AND_NULL(E) unconditionally.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
tools/coccinelle/free.cocci | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/coccinelle/free.cocci b/tools/coccinelle/free.cocci
index 3dfaae9dd8..f2af140cfb 100644
--- a/tools/coccinelle/free.cocci
+++ b/tools/coccinelle/free.cocci
@@ -6,6 +6,8 @@ expression E;
free(E);
|
commit_list_free(E);
+|
+ FREE_AND_NULL(E);
)
@@
--
2.56.0-rc0-143-g1fea62d0ca
next prev parent reply other threads:[~2026-09-11 22:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 22:09 [PATCH] cocci: remove risky "if (!E) free(E)" conversion Junio C Hamano
2026-09-11 22:21 ` Junio C Hamano [this message]
2026-09-12 7:13 ` René Scharfe
2026-09-12 19:07 ` Junio C Hamano
2026-09-13 10:45 ` René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqh5jv8m4w.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.