[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 08:04:20 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 |
On 11/23/2016 07:56 AM, Eric Blake wrote:
>>
>> 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,
Note that printf likewise lacks such conversions, so...
>> we convert to int64_t
>> first, then use PRId64.
...some conversion is necessary no matter what, even if it is to 'long
long' instead of 'int64_t'. Also, our choice of using -1 as the
sentinel for failures is difficult to portably code if we don't know if
time_t is signed or unsigned (if it is a 32-bit unsigned value, widening
it to long long won't give us our desired value), so it is not as simple
as doing tv.tv_sec = -1; we still need a conditional or temporary.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
[Qemu-devel] [PATCH 1/3] qmp-event: Avoid qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/22
[Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/22
- Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Paolo Bonzini, 2016/11/23
- Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/23
- Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Markus Armbruster, 2016/11/23
- Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/23
- Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Markus Armbruster, 2016/11/23
- Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/23