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

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

From
Patrick Steinhardt <ps@pks.im>
Date
May 13, 2024, 10:00 UTC
Message-ID
<ZkHkiBa2hSbjcmZd@tanuki>
In-Reply-To
<xmqqbk5bim2n.fsf@gitster.g>
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.

Show 13 quoted lines
> 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 <gitster@pobox.com>
> ---
> 
>  * 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!
Previous: Junio C Hamano
Message 2 of 2 in “compat/regex: fix argument order to calloc(3)”
  1. compat/regex: fix argument order to calloc(3)Junio C Hamano, May 12, 2024
  2. Patrick SteinhardtMay 13, 2024

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.