git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] promisor-remote: fix xcalloc() argument order
Date: Mon, 22 Aug 2022 15:14:58 -0700	[thread overview]
Message-ID: <xmqqh7249b8d.fsf@gitster.g> (raw)
In-Reply-To: 20220822213408.662482-1-szeder.dev@gmail.com

SZEDER Gábor <szeder.dev@gmail.com> writes:

> 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.

> 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);

  reply	other threads:[~2022-08-22 22:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-22 21:34 [PATCH] promisor-remote: fix xcalloc() argument order SZEDER Gábor
2022-08-22 22:14 ` Junio C Hamano [this message]
2022-08-23  1:09   ` Junio C Hamano
2022-08-23  7:04     ` SZEDER Gábor
2022-08-23  9:21       ` SZEDER Gábor
2022-08-23  9:56         ` SZEDER Gábor
2022-08-23  9:57 ` [PATCH v2] " SZEDER Gábor
2022-08-24  8:32   ` Jeff King
2022-08-24 11:39     ` SZEDER Gábor
2022-08-25 10:40       ` Jeff King
2022-08-25 13:51     ` Ævar Arnfjörð Bjarmason
2022-08-24 15:58   ` Junio C Hamano
2022-08-24 17:33     ` SZEDER Gábor
2022-08-24 21:13       ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqh7249b8d.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=szeder.dev@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).