git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] promisor-remote: fix xcalloc() argument order

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 22, 2022, 22:14 UTC
Message-ID
<xmqqh7249b8d.fsf@gitster.g>
In-Reply-To
<20220822213408.662482-1-szeder.dev@gmail.com>
SZEDER Gábor <szeder.dev@gmail.com> writes:
Show 5 quoted lines
> Pass the number of elements first and their size second, as expected
> by xcalloc().
>
> Patch generated with 'contrib/coccinelle/xcalloc.cocci' and Coccinelle
> v1.0.7 or later (previous Coccinelle versions don't notice this).

One thing is that Coccinelle is way too slow on our codebase, compared to the usual compilation, to run every time we make changes. Combined with the fact that our codebase is mostly clean, the cycles feel huge waste of time only to find something small like what this patch fixes.

That sadly discourages us from doing "make coccicheck" more often as we should.

I _think_ Googlers have 1.1.1 on their linux boxes, so even if our GitHub Actions CI is fixed to Ubuntu 18.04 and does not run more recent Coccinelle, we theoretically should have been able to catch it before it hit the public list, if "1.0.7 or later" was the condition. FWIW, "make coccicheck" with what I happen to have notices it.

$ spatch version spatch version 1.1.1 compiled with OCaml version 4.13.1 Flags passed to the configure script: --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --enable-ocaml --enable-python --enable-opt OCaml scripting support: yes Python scripting support: yes Syntax of regular expressions: PCRE

Anyway, the patch is correct.
Thanks, will queue.
Show 18 quoted lines
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
>  promisor-remote.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/promisor-remote.c b/promisor-remote.c
> index 5b33f88bca..68f46f5ec7 100644
> --- a/promisor-remote.c
> +++ b/promisor-remote.c
> @@ -146,7 +146,7 @@ static void promisor_remote_init(struct repository *r)
>  	if (r->promisor_remote_config)
>  		return;
>  	config = r->promisor_remote_config =
> -		xcalloc(sizeof(*r->promisor_remote_config), 1);
> +		xcalloc(1, sizeof(*r->promisor_remote_config));
>  	config->promisors_tail = &config->promisors;
>  
>  	repo_config(r, promisor_remote_config, config);
Previous: SZEDER GáborNext: Junio C Hamano
Message 2 of 14 in “promisor-remote: fix xcalloc() argument order”
  1. promisor-remote: fix xcalloc() argument orderSZEDER Gábor, Aug 22, 2022
  2. Junio C HamanoAug 22, 2022
  3. Junio C HamanoAug 23, 2022
  4. SZEDER GáborAug 23, 2022
  5. SZEDER GáborAug 23, 2022
  6. SZEDER GáborAug 23, 2022
  7. promisor-remote: fix xcalloc() argument orderSZEDER Gábor, Aug 23, 2022
  8. Jeff KingAug 24, 2022
  9. SZEDER GáborAug 24, 2022
  10. Jeff KingAug 25, 2022
  11. Ævar Arnfjörð BjarmasonAug 25, 2022
  12. Junio C HamanoAug 24, 2022
  13. SZEDER GáborAug 24, 2022
  14. Junio C HamanoAug 24, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.