Re: [PATCH v10 4/4] hook: introduce the receive-report hook
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 11, 2026, 21:39 UTC
- Message-ID
- <xmqq33vfa2ny.fsf@gitster.g>
- In-Reply-To
- <20260910-758-introduce-hook-v10-4-06f9c506631c@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 8 quoted lines
> +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?
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);