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

Re: [PATCH 1/1] git-compat-util.h: drop the `PRIuMAX` definition

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 25, 2019, 02:24 UTC
Message-ID
<xmqq1rtwzoal.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20191124170643.GA16907@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 13 quoted lines
> On Sun, Nov 24, 2019 at 01:09:23PM +0000, Hariom Verma via GitGitGadget wrote:
>
>> From: Hariom Verma <hariom18599@gmail.com>
>> 
>> Git's code base already seems to be using `PRIdMAX` without any such
>> fallback definition for quite a while (75459410edd (json_writer: new
>> routines to create JSON data, 2018-07-13), to be precise, and the
>> first Git version to include that commit was v2.19.0).
>> 
>> Therefore it should be safe to drop the fallback definition for
>> `PRIuMAX` in `git-compat-util.h`.
>
> I noticed this recently, too, and wondered if it was time for a cleanup.

While I agree with the conclusion, I do not think I agree with the above "Therefore (implying that the lack of need for fallback PRIdMAX means the same for PRIuMAX) it should be safe" as a good justification. That reasoning assumes that the outside world is much saner than us. We thought PRIuMAX fallback necessary while a counterpart for PRIdMAX unneeded---the outside world could have made a similar mistake and in the opposite way (i.e. only defined PRIdMAX while leaving PRIuMAX undefined).

But I do agree with the alternative justification in the following two paragraphs you have given, which are ...

Show 10 quoted lines
> We do sometimes get portability reports more than a year after the
> problem was introduced. But I think this one is pretty safe. PRIuMAX is
> in C99, and we've been picking up other C99-isms without complaint.
>
> I was curious what system originally spurred this. The PRIuMAX
> definition was originally added in 3efb1f343a (Check for PRIuMAX rather
> than NO_C99_FORMAT in fast-import.c., 2007-02-20). But it was replacing
> a construct that was introduced in 579d1fbfaf (Add NO_C99_FORMAT to
> support older compilers., 2006-07-30), which talks about gcc 2.95.
> That's pretty ancient at this point.
... these.
Show 8 quoted lines
> This part of the patch looks obviously correct. :) But...
>
>>  #ifndef SCNuMAX
>>  #define SCNuMAX PRIuMAX
>>  #endif
>
> Can we likewise ditch the fallback definition for SCNuMAX? And PRIu32,
> etc? It seems likely any platform would either have all of them or none.
I guess that's also a C99-ism that we can use?
Thanks, both.
Previous: Carlo ArenasNext: Junio C Hamano
Message 6 of 8 in “git-compat-util.h: drop the PRIuMAX definition”
  1. 0/1 git-compat-util.h: drop the PRIuMAX definitionHariom Verma via GitGitGadget, Nov 24, 2019
  2. 1/1 git-compat-util.h: drop the `PRIuMAX` definitionHariom Verma via GitGitGadget, Nov 24, 2019
  3. Jeff KingNov 24, 2019
  4. Carlo ArenasNov 24, 2019
  5. Carlo ArenasNov 24, 2019
  6. Junio C HamanoNov 25, 2019
  7. Junio C HamanoNov 25, 2019
  8. Jeff KingNov 25, 2019

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.