Re: [RFC PATCH 1/1] json-writer: incorrect format specifier
- From
Ramsay Jones <ramsay@ramsayjones.plus.com>
- Date
- Mar 24, 2018, 15:14 UTC
- Message-ID
- <4f4221d9-2ad9-2282-d26f-412ba0bfd719@ramsayjones.plus.com>
- In-Reply-To
- <140b7646e7efa4175f9d82e6eb2909f2f94771fe.1521868951.git.wink@saville.com>
On 24/03/18 05:37, Wink Saville wrote:
Show 21 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> > --- > 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);
In this code-base, that would normally be written as:
strbuf_addf(&jw->json, ":%"PRIuMAX, (uintmax_t) value);
ATB, Ramsay Jones