From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9wyQ-0001Mt-SE for qemu-devel@nongnu.org; Thu, 24 Nov 2016 11:34:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9wyM-0004eg-Ub for qemu-devel@nongnu.org; Thu, 24 Nov 2016 11:34:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42464) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9wyM-0004eL-MS for qemu-devel@nongnu.org; Thu, 24 Nov 2016 11:34:06 -0500 References: <1479922617-4400-1-git-send-email-eblake@redhat.com> <1479922617-4400-2-git-send-email-eblake@redhat.com> <871sy1jg7e.fsf@dusky.pond.sub.org> From: Eric Blake Message-ID: Date: Thu, 24 Nov 2016 10:34:04 -0600 MIME-Version: 1.0 In-Reply-To: <871sy1jg7e.fsf@dusky.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uhnFWM59J4fvdMeLHLxDhl9tuLaj8mXsi" Subject: Re: [Qemu-devel] [PATCH v2 1/4] qmp-event: Avoid qobject_from_jsonf("%"PRId64) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth , programmingkidx@gmail.com, pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --uhnFWM59J4fvdMeLHLxDhl9tuLaj8mXsi From: Eric Blake To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth , programmingkidx@gmail.com, pbonzini@redhat.com Message-ID: Subject: Re: [Qemu-devel] [PATCH v2 1/4] qmp-event: Avoid qobject_from_jsonf("%"PRId64) References: <1479922617-4400-1-git-send-email-eblake@redhat.com> <1479922617-4400-2-git-send-email-eblake@redhat.com> <871sy1jg7e.fsf@dusky.pond.sub.org> In-Reply-To: <871sy1jg7e.fsf@dusky.pond.sub.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/24/2016 05:00 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> + /* Put -1 to indicate failure of getting host time */ >> + obj =3D qobject_from_jsonf("{ 'seconds': %lld, 'microseconds': %l= ld }", >> + err < 0 ? -1LL : tv.tv_sec, >> + err < 0 ? -1LL : tv.tv_usec); >> qdict_put_obj(qdict, "timestamp", obj); >> } >=20 > 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. >=20 > 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 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --uhnFWM59J4fvdMeLHLxDhl9tuLaj8mXsi Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJYNxZ8AAoJEKeha0olJ0Nq3V8IAKjob5jUULqNrbne0IOLUnXw YQik3GdpeG4X7CWCcRLkYKMjP1A88UaKMf/7QQmv2Yxv1Kt+y7st4I/8d6QEmmUZ Ezr6VdTkiwrP8qdp6yJy+Th+twWEW5k/4+CEmHHywSxh4i83mxNf13PlApm8ZaVS vLyLwHPpCeIckwarHnwSJusCqdFG2Q1Uc6D1TpkJYFeQ+MFF0g6Os/0t7NS82ykv fE5yG3LUNJkw5HZ8hKyLbS9yviZAED8/XYhBWjaH4db4iaWkvzf/egdWwCnjY4lu pMw4lJWLyQqGClHJRD23vczApXcQc1wit8bCV5v0JHuQsfKMZDyG0fmptmeGDE8= =g4ew -----END PGP SIGNATURE----- --uhnFWM59J4fvdMeLHLxDhl9tuLaj8mXsi--