From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>,
programmingkidx@gmail.com, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/3] qmp-event: Avoid qobject_from_jsonf("%"PRId64)
Date: Wed, 23 Nov 2016 08:04:20 -0600 [thread overview]
Message-ID: <25d8c174-0015-9ed1-5dc4-ac480a1c36f0@redhat.com> (raw)
In-Reply-To: <1fb53e28-ccb0-c83b-e4a2-d92d819e1b43@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 959 bytes --]
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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-11-23 14:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-23 4:16 [Qemu-devel] [PATCH for-2.8 0/3] Fix MacOS runtime failure of qobject_from_jsonf() Eric Blake
2016-11-23 4:16 ` [Qemu-devel] [PATCH 1/3] qmp-event: Avoid qobject_from_jsonf("%"PRId64) Eric Blake
2016-11-23 13:45 ` Markus Armbruster
2016-11-23 13:56 ` Eric Blake
2016-11-23 14:04 ` Eric Blake [this message]
2016-11-23 4:16 ` [Qemu-devel] [PATCH 2/3] test-qga: " Eric Blake
2016-11-23 9:23 ` Paolo Bonzini
2016-11-23 10:36 ` Eric Blake
2016-11-23 11:08 ` Eric Blake
2016-11-23 12:06 ` Paolo Bonzini
2016-11-23 14:05 ` Markus Armbruster
2016-11-23 14:14 ` Eric Blake
2016-11-23 16:55 ` Markus Armbruster
2016-11-23 4:16 ` [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64) Eric Blake
2016-11-23 9:25 ` Paolo Bonzini
2016-11-23 10:54 ` Eric Blake
2016-11-23 14:17 ` Markus Armbruster
2016-11-23 14:24 ` Eric Blake
2016-11-23 16:56 ` Markus Armbruster
2016-11-23 16:59 ` Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25d8c174-0015-9ed1-5dc4-ac480a1c36f0@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=programmingkidx@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).