From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9YA0-0000cB-Ic for qemu-devel@nongnu.org; Wed, 23 Nov 2016 09:04:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9Y9u-0004v2-UC for qemu-devel@nongnu.org; Wed, 23 Nov 2016 09:04:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46652) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9Y9u-0004uA-LV for qemu-devel@nongnu.org; Wed, 23 Nov 2016 09:04:22 -0500 References: <1479874588-1969-1-git-send-email-eblake@redhat.com> <1479874588-1969-2-git-send-email-eblake@redhat.com> <87wpfupaww.fsf@dusky.pond.sub.org> <1fb53e28-ccb0-c83b-e4a2-d92d819e1b43@redhat.com> From: Eric Blake Message-ID: <25d8c174-0015-9ed1-5dc4-ac480a1c36f0@redhat.com> Date: Wed, 23 Nov 2016 08:04:20 -0600 MIME-Version: 1.0 In-Reply-To: <1fb53e28-ccb0-c83b-e4a2-d92d819e1b43@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="NIFMkHsDfu5qMp8eUmv4lQ04IccoV47pL" Subject: Re: [Qemu-devel] [PATCH 1/3] 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) --NIFMkHsDfu5qMp8eUmv4lQ04IccoV47pL From: Eric Blake To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth , programmingkidx@gmail.com, pbonzini@redhat.com Message-ID: <25d8c174-0015-9ed1-5dc4-ac480a1c36f0@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/3] qmp-event: Avoid qobject_from_jsonf("%"PRId64) References: <1479874588-1969-1-git-send-email-eblake@redhat.com> <1479874588-1969-2-git-send-email-eblake@redhat.com> <87wpfupaww.fsf@dusky.pond.sub.org> <1fb53e28-ccb0-c83b-e4a2-d92d819e1b43@redhat.com> In-Reply-To: <1fb53e28-ccb0-c83b-e4a2-d92d819e1b43@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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. =2E..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 =3D -1; we still need a conditional or temporary. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --NIFMkHsDfu5qMp8eUmv4lQ04IccoV47pL 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/ iQEcBAEBCAAGBQJYNaHkAAoJEKeha0olJ0NqDBwH/1fU3RCGtgChg1WNsoNIIEcw kd7hSzHFFKbUj481GRHe3Tuku5TUgUE6fymjJcVeqZlgxwXLQdcV7gdtlA9amVG2 Q75v022F3BUtd6VKFpi8wHis2wHEIQRK1KDX77MKClV3NKUrEuIIUV25MZNFdkME fVsocvyITbvrGGECFG7cQNRtJt6qYa9n3shj2ECAXADVZa79QVyFd07IoC5I2Rgl MPIKl/BgmxEjfocRVDfP6xGn46D4bpYW6uXNRRPZKR25H+lEjxqeddRwzffNZ7U8 s7f12Bk3AGWthfXwwwmBuy1V59xmLKPltY6Os3BjDC+cA9hKPZo1f0RSFDxTuX8= =nqsn -----END PGP SIGNATURE----- --NIFMkHsDfu5qMp8eUmv4lQ04IccoV47pL--