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

Re: [RFC PATCH 1/1] json-writer: incorrect format specifier

From
JHJeff Hostetler <git@jeffhostetler.com>
Date
Mar 24, 2018, 11:11 UTC
Message-ID
<d6af477d-6865-9580-0389-182a5c19d935@jeffhostetler.com>
In-Reply-To
<140b7646e7efa4175f9d82e6eb2909f2f94771fe.1521868951.git.wink@saville.com>
On 3/24/2018 1:37 AM, Wink Saville wrote:
Show 7 quoted lines
> In routines jw_object_uint64 and jw_object_double strbuf_addf is
> invoked with strbuf_addf(&jw->json, ":%"PRIuMAX, value) where value
> is a uint64_t. This causes a compile error on OSX.
> 
> The correct format specifier is PRIu64 instead of PRIuMax.
> 
> Signed-off-by: Wink Saville <wink@saville.com>
That's odd.

A grep on the Git source tree did not find a "PRIu64" symbol. Searching public-inbox only found one message [1] talking about it (other than the ones associated with your messages here).

I have to wonder if that is defined in a OSX header file and you're getting it from there [2]. (I don't have a MAC in front of me, so I can't verify what's in that header.) But [2] defines PRIuMAX as PRIu64, so we shouldn't need to make that change in json-writer -- unless something is getting lost in the #ifdefs.

Could you double check this in the header files on your system? Any chance you are doing a 32-bit build?

Thanks Jeff

[1] https://public-inbox.org/git/MWHPR21MB0478181AE0B64901DA2C07CDF4600@MWHPR21MB0478.namprd21.prod.outlook.com/raw

[2] https://opensource.apple.com/source/gcc/gcc-926/inttypes.h.auto.html
Show 27 quoted lines
> ---
>   json-writer.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/json-writer.c b/json-writer.c
> index 89a6abb57..04045448a 100644
> --- a/json-writer.c
> +++ b/json-writer.c
> @@ -120,7 +120,7 @@ void jw_object_uint64(struct json_writer *jw, const char *key, uint64_t value)
>   	maybe_add_comma(jw);
>   
>   	append_quoted_string(&jw->json, key);
> -	strbuf_addf(&jw->json, ":%"PRIuMAX, value);
> +	strbuf_addf(&jw->json, ":%"PRIu64, value);
>   }
>   
>   void jw_object_double(struct json_writer *jw, const char *fmt,
> @@ -225,7 +225,7 @@ void jw_array_uint64(struct json_writer *jw, uint64_t value)
>   	assert_in_array(jw);
>   	maybe_add_comma(jw);
>   
> -	strbuf_addf(&jw->json, "%"PRIuMAX, value);
> +	strbuf_addf(&jw->json, "%"PRIu64, value);
>   }
>   
>   void jw_array_double(struct json_writer *jw, const char *fmt, double value)
> 
Previous: Wink SavilleNext: Ramsay Jones
Message 3 of 12 in “json-writer: incorrect format specifier”
  1. 0/1 json-writer: incorrect format specifierWink Saville, Mar 24, 2018
  2. 1/1 json-writer: incorrect format specifierWink Saville, Mar 24, 2018
  3. Jeff HostetlerMar 24, 2018
  4. Ramsay JonesMar 24, 2018
  5. Ramsay JonesMar 24, 2018
  6. Junio C HamanoMar 26, 2018
  7. Jeff HostetlerMar 26, 2018
  8. Ramsay JonesMar 27, 2018
  9. Jeff HostetlerMar 27, 2018
  10. 0/1 json-writer: add cast to uintmax_tWink Saville, Mar 24, 2018
  11. 1/1 json-writer: add cast to uintmax_tWink Saville, Mar 24, 2018
  12. Jeff HostetlerMar 26, 2018

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.