Subject: Re: [PATCH] compat/regex: fix argument order to calloc(3)

From: Patrick Steinhardt <[email-masked]>
Date: Mon, 13 May 2024 12:00:10 +0200

On Sat, May 11, 2024 at 11:25:04PM -0700, Junio C Hamano wrote:
> Windows compiler suddenly started complaining that calloc(3) takes
> its arguments in <nmemb, size> order.  Indeed, there are many calls
> that has their arguments in a _wrong_ order.

I think this is actually new to GCC 14. The release notes include this
bit:

    -Walloc-size and -Wcalloc-transposed-args warnings are enabled for C++ as well

It's a bit puzzling that this seemingly only changed for C++, but oh,
well.

> Fix them all.
> 
> A sample breakage can be seen at
> 
>   https://github.com/git/git/actions/runs/9046793153/job/24857988702#step:4:272
> 
> Signed-off-by: Junio C Hamano <[email-masked]>
> ---
> 
>  * I wonder if there is an easier way to deal with toolchain and/or
>    platform changes (I am assuming that is what caused this
>    breakage) than just seeing and then reacting to a breakage after
>    it happens.

I think the best thing we can do is to be proactive and be faster than
our toolchain to enable (sensible) warnings. Over time all the compilers
tend to become stricter, and if we are already as strict as possible
then chances are less likely that we'll have to do anything about
upstream changes.

But other than that I don't really have much of an idea.

The patch itself looks obviously good to me, thanks!