[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 1/4] qmp-event: Avoid qobject_from_jsonf("%"P
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2 1/4] qmp-event: Avoid qobject_from_jsonf("%"PRId64) |
Date: |
Thu, 24 Nov 2016 10:34:04 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 |
On 11/24/2016 05:00 AM, Markus Armbruster wrote:
> Eric Blake <address@hidden> writes:
>
>> + /* Put -1 to indicate failure of getting host time */
>> + obj = qobject_from_jsonf("{ 'seconds': %lld, 'microseconds': %lld }",
>> + err < 0 ? -1LL : tv.tv_sec,
>> + err < 0 ? -1LL : tv.tv_usec);
>> qdict_put_obj(qdict, "timestamp", obj);
>> }
>
> The ternaries must both yield long long for this to work. They will,
> unless their last operand's rank is greater than long long's, or their
> last operand is unsigned long long. The latter case should be harmless
> in practice. The former case would be weird. Hmm.
>
> I think it's best to be a bit more explicit here. Let's cast the last
> operands to long long, or use long long variables. Your choice.
I think I favor the cast, as in:
err < 0 ? -1LL : (long long) tv.tv_sec
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v2 for-2.8 0/4] Fix MacOS runtime failure of qobject_from_jsonf(), Eric Blake, 2016/11/23
- [Qemu-devel] [PATCH v2 2/4] test-qga: Avoid qobject_from_jsonv("%"PRId64), Eric Blake, 2016/11/23
- [Qemu-devel] [PATCH v2 1/4] qmp-event: Avoid qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/23
- [Qemu-devel] [PATCH v2 4/4] RFC: qapi: Drop support for qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/23
- [Qemu-devel] [PATCH v2 3/4] tests: Avoid qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/23
- Re: [Qemu-devel] [PATCH v2 for-2.8 0/4] Fix MacOS runtime failure of qobject_from_jsonf(), Markus Armbruster, 2016/11/24
- Re: [Qemu-devel] [PATCH v2 for-2.8 0/4] Fix MacOS runtime failure of qobject_from_jsonf(), no-reply, 2016/11/29