From: Karthik Nayak Date: Fri, 11 Sep 2026 21:58:15 GMT Subject: Re: [PATCH v10 4/4] hook: introduce the receive-report hook Message-ID: In-Reply-To: Junio C Hamano writes: > Karthik Nayak writes: > >> +static void override_cmds_error(struct command *commands, const char *err) >> +{ >> + for (struct command *cmd = commands; cmd; cmd = cmd->next) { >> + if (cmd->error_string_owned) >> + FREE_AND_NULL(cmd->error_string_owned); >> + cmd->error_string = err; >> + } >> +} > > This is my fault, but like free(), FREE_AND_NULL() can safely be > called on a variable that already is NULL so we may want to fix up > after the dust settles, perhaps? > I didn't really think too much about the change. I'll avoid a re-roll for this. > builtin/receive-pack.c | 3 +-- > tools/coccinelle/free.cocci | 6 ++++++ > 2 files changed, 7 insertions(+), 2 deletions(-) > > diff --git c/builtin/receive-pack.c w/builtin/receive-pack.c > index 9ac7717096..1d5b050beb 100644 > --- c/builtin/receive-pack.c > +++ w/builtin/receive-pack.c > @@ -2452,8 +2452,7 @@ static void update_shallow_info(struct command *commands, > static void override_cmds_error(struct command *commands, const char *err) > { > for (struct command *cmd = commands; cmd; cmd = cmd->next) { > - if (cmd->error_string_owned) > - FREE_AND_NULL(cmd->error_string_owned); > + FREE_AND_NULL(cmd->error_string_owned); > cmd->error_string = err; > } > } > diff --git c/tools/coccinelle/free.cocci w/tools/coccinelle/free.cocci > index 03799e1908..c95ffa2a07 100644 > --- c/tools/coccinelle/free.cocci > +++ w/tools/coccinelle/free.cocci > @@ -43,3 +43,9 @@ statement S; > S > commit_list_free(E); > - } > +@@ > +expression E; > +@@ > +- if (E) > +- FREE_AND_NULL(E); > ++ FREE_AND_NULL(E); I could send in this patch for coccinelle with the fixup if that's okay with you.