[PATCH] cocci: FREE_AND_NULL(E) is safe to call on NULL
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 11, 2026, 22:21 UTC
- Message-ID
- <xmqqh5jv8m4w.fsf@gitster.g>
- In-Reply-To
- <xmqqld978mok.fsf@gitster.g>
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