From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] promisor-remote: fix xcalloc() argument order
Date: Tue, 23 Aug 2022 11:21:56 +0200 [thread overview]
Message-ID: <20220823092156.GB1735@szeder.dev> (raw)
In-Reply-To: <20220823070417.GA1735@szeder.dev>
On Tue, Aug 23, 2022 at 09:04:17AM +0200, SZEDER Gábor wrote:
> On Mon, Aug 22, 2022 at 06:09:41PM -0700, Junio C Hamano wrote:
> > Junio C Hamano <gitster@pobox.com> writes:
> >
> > > ... FWIW, "make coccicheck" with what I happen to have
> > > notices it.
> >
> > Oops, that was a serious typo. "notices" -> "fails to notice".
>
> Hm, that's strange. 1.1.1 did notice this transformation for me,
Hang on, it's not quite that simple.
Watch this, it will get weird:
# Batched spatch for faster processing, see 960154b9c1 (coccicheck:
# optionally batch spatch invocations, 2019-05-06)
$ grep SPATCH_BATCH_SIZE config.mak
SPATCH_BATCH_SIZE = 32
$ time make contrib/coccinelle/xcalloc.cocci.patch
SPATCH contrib/coccinelle/xcalloc.cocci
SPATCH result: contrib/coccinelle/xcalloc.cocci.patch
real 0m35.902s
user 0m34.840s
sys 0m1.030s
# Found it, good.
$ make -s cocciclean
# Turn off batched processing (this is the default)
$ sed -i -e '/SPATCH_BATCH_SIZE/ s/= .*/= 1/' config.mak
$ time make contrib/coccinelle/xcalloc.cocci.patch
SPATCH contrib/coccinelle/xcalloc.cocci
real 0m24.553s
user 0m21.468s
sys 0m3.099s
# Not only missed the transformation, but it's faster than batched
# processing?!
# Let's invoke spatch directly.
$ spatch --all-includes --sp-file contrib/coccinelle/xcalloc.cocci --patch . promisor-remote.c
warning: Can't find macro file: /usr/local/bin/lib/coccinelle/standard.h
warning: Can't find default iso file: /usr/local/bin/lib/coccinelle/standard.iso
HANDLING: promisor-remote.c
# Nope.
$ spatch --all-includes --sp-file contrib/coccinelle/xcalloc.cocci --patch . promisor-remote.c lockfile.c
warning: Can't find macro file: /usr/local/bin/lib/coccinelle/standard.h
warning: Can't find default iso file: /usr/local/bin/lib/coccinelle/standard.iso
HANDLING: promisor-remote.c lockfile.c
$ spatch --all-includes --sp-file contrib/coccinelle/xcalloc.cocci --patch . promisor-remote.c git.c
warning: Can't find macro file: /usr/local/bin/lib/coccinelle/standard.h
warning: Can't find default iso file: /usr/local/bin/lib/coccinelle/standard.iso
HANDLING: promisor-remote.c git.c
$ spatch --all-includes --sp-file contrib/coccinelle/xcalloc.cocci --patch . promisor-remote.c usage.c
warning: Can't find macro file: /usr/local/bin/lib/coccinelle/standard.h
warning: Can't find default iso file: /usr/local/bin/lib/coccinelle/standard.iso
HANDLING: promisor-remote.c usage.c
# Nope, nope, nope.
$ spatch --all-includes --sp-file contrib/coccinelle/xcalloc.cocci --patch . promisor-remote.c builtin/*.c
[...]
# Nope!
# But watch this!
$ spatch --all-includes --sp-file contrib/coccinelle/xcalloc.cocci --patch . promisor-remote.c config.c
warning: Can't find macro file: /usr/local/bin/lib/coccinelle/standard.h
warning: Can't find default iso file: /usr/local/bin/lib/coccinelle/standard.iso
HANDLING: promisor-remote.c config.c
diff =
diff -u -p a/promisor-remote.c b/promisor-remote.c
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -146,7 +146,7 @@ static void promisor_remote_init(struct
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);
# Huh?! (;
FWIW, I see this with Coccinelle 1.1.1, 1.0.8 and 1.0.6 as well.
next prev parent reply other threads:[~2022-08-23 11:20 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
2022-08-23 1:09 ` Junio C Hamano
2022-08-23 7:04 ` SZEDER Gábor
2022-08-23 9:21 ` SZEDER Gábor [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220823092156.GB1735@szeder.dev \
--to=szeder.dev@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.