Re: [RFC PATCH v5 0/8] rebase-interactive
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 26, 2018, 15:56 UTC
- Message-ID
- <xmqqzi2ude4w.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <CAKk8ispSgNgZxS7KfuOyxfU53tzesvNyLRaNXFZa3K7SCbaRkQ@mail.gmail.com>
Wink Saville <wink@saville.com> writes:
Show 15 quoted lines
> json-writer.c:123:38: error: format specifies type 'uintmax_t' (aka > 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned > long long') [-Werror,-Wformat] > > strbuf_addf(&jw->json, ":%"PRIuMAX, value); > ~~ ^~~~~ > json-writer.c:228:37: error: format specifies type 'uintmax_t' (aka > 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned > long long') [-Werror,-Wformat] [0m > > strbuf_addf(&jw->json, "%"PRIuMAX, value); > ~~ ^~~~~ > 2 errors generated. > make: *** [json-writer.o] Error 1 > make: *** Waiting for unfinished jobs....
For whatever reason, our codebase seems to shy away from PRIu64, even though there are liberal uses of PRIu32. Showing the value casted to uintmax_t with PRIuMAX seems to be our preferred way to say "We cannot say how wide this type is on different platforms, and are playing safe by using widest-possible int type" (e.g. showing a pid_t value from daemon.c).
In this codepath, the actual values are specified to be uint64_t, so the use of PRIu64 may be OK, but I have to wonder why the codepath is not dealing with uintmax_t in the first place. When even larger than present archs are prevalent in N years and 64-bit starts to feel a tad small (like we feel for 16-bit ints these days), it will feel a bit silly to have a subsystem that is limited to such a "fixed and a tad small these days" types and pretend it to be be a generic seriealizer, I suspect.