[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/3] qmp-event: Avoid qobject_from_jsonf("%"PRId

From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 1/3] qmp-event: Avoid qobject_from_jsonf("%"PRId64)
Date: Wed, 23 Nov 2016 07:56:38 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 11/23/2016 07:45 AM, Markus Armbruster wrote:
> Eric Blake <address@hidden> writes:
>> The qobject_from_jsonf() function implements a pseudo-printf
>> language for creating a QObject; however, it is hard-coded to
>> only parse a subset of formats understood by printf().  In
>> particular, any use of a 64-bit integer works only if the
>> system's definition of PRId64 matches what the parser expects;
>> which works on glibc (%lld) and mingw (%I64d), but not on
>> Mac OS (%qd).  Rather than enhance the parser, it is just as
>> easy to open-code the few callers that were relying on this
>> particular conversion.
>> Reported by: G 3 <address@hidden>
>> Signed-off-by: Eric Blake <address@hidden>
>> ---
>>  qapi/qmp-event.c | 12 +++++++-----
>>  1 file changed, 7 insertions(+), 5 deletions(-)

> Commit message claims to change "the few callers", patch changes just
> one.  Which of the two is right?

Rebase churn - there were four callers of qobject_from_jsonf() that I
originally identified, then I split it up into the one caller that used
%PRId64 vs. the other three that can be done differently.

> In my opinion, the code becomes less readable.
> We want to convert struct timeval members tv_sec (of type time_t) and
> tv_usec (of type suseconds_t) here.  Since qobject_from_jsonf() lacks
> conversion specifiers for time_t and suseconds_t, we convert to int64_t
> first, then use PRId64.  The problem is that we don't actually implement
> PRId64 everywhere.  Why not simply long long and %lld?

For 2.8, I can leave %lld support in qobject_from_jsonf(), and just cast
to long long instead of int64_t. I'd still like to propose the series
that kills all dynamic JSON for 2.9, but I don't mind posting a v2 of
this series.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]