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 v2 1/4] qmp-event: Avoid qobject_from_jsonf("%"PRId64)
Date: Thu, 24 Nov 2016 10:34:04 -0600 [thread overview]
Message-ID: <a242f473-aa13-f628-c0c4-387cc9263ed3@redhat.com> (raw)
In-Reply-To: <871sy1jg7e.fsf@dusky.pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 1038 bytes --]
On 11/24/2016 05:00 AM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> 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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-11-24 16:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-23 17:36 [Qemu-devel] [PATCH v2 for-2.8 0/4] Fix MacOS runtime failure of qobject_from_jsonf() Eric Blake
2016-11-23 17:36 ` [Qemu-devel] [PATCH v2 1/4] qmp-event: Avoid qobject_from_jsonf("%"PRId64) Eric Blake
2016-11-24 11:00 ` Markus Armbruster
2016-11-24 16:34 ` Eric Blake [this message]
2016-11-23 17:36 ` [Qemu-devel] [PATCH v2 2/4] test-qga: Avoid qobject_from_jsonv("%"PRId64) Eric Blake
2016-11-23 17:36 ` [Qemu-devel] [PATCH v2 3/4] tests: Avoid qobject_from_jsonf("%"PRId64) Eric Blake
2016-11-24 11:03 ` Markus Armbruster
2016-11-23 17:36 ` [Qemu-devel] [PATCH v2 4/4] RFC: qapi: Drop support for qobject_from_jsonf("%"PRId64) Eric Blake
2016-11-24 11:07 ` [Qemu-devel] [PATCH v2 for-2.8 0/4] Fix MacOS runtime failure of qobject_from_jsonf() Markus Armbruster
2016-11-24 16:32 ` Eric Blake
2016-11-25 8:59 ` Markus Armbruster
2016-11-25 11:56 ` Stefan Hajnoczi
2016-11-29 8:20 ` no-reply
2016-11-29 9:33 ` Markus Armbruster
2016-12-05 16:55 ` Markus Armbruster
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=a242f473-aa13-f628-c0c4-387cc9263ed3@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).