From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9Y2W-0002a4-NE for qemu-devel@nongnu.org; Wed, 23 Nov 2016 08:56:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9Y2S-0004zp-Rc for qemu-devel@nongnu.org; Wed, 23 Nov 2016 08:56:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52558) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9Y2S-0004yW-Jb for qemu-devel@nongnu.org; Wed, 23 Nov 2016 08:56:40 -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> From: Eric Blake Message-ID: <1fb53e28-ccb0-c83b-e4a2-d92d819e1b43@redhat.com> Date: Wed, 23 Nov 2016 07:56:38 -0600 MIME-Version: 1.0 In-Reply-To: <87wpfupaww.fsf@dusky.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="RURAAhNViPwTrP3Ln1XHpgfJUE9IRPaDs" 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) --RURAAhNViPwTrP3Ln1XHpgfJUE9IRPaDs From: Eric Blake To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth , programmingkidx@gmail.com, pbonzini@redhat.com Message-ID: <1fb53e28-ccb0-c83b-e4a2-d92d819e1b43@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> In-Reply-To: <87wpfupaww.fsf@dusky.pond.sub.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/23/2016 07:45 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> The qobject_from_jsonf() function implements a pseudo-printf >> language for creating a QObject; however, it is hard-coded to >> only parse a subset of formats understood by printf(). In >> particular, any use of a 64-bit integer works only if the >> system's definition of PRId64 matches what the parser expects; >> which works on glibc (%lld) and mingw (%I64d), but not on >> Mac OS (%qd). Rather than enhance the parser, it is just as >> easy to open-code the few callers that were relying on this >> particular conversion. >> >> Reported by: G 3 >> Signed-off-by: Eric Blake >> --- >> qapi/qmp-event.c | 12 +++++++----- >> 1 file changed, 7 insertions(+), 5 deletions(-) > Commit message claims to change "the few callers", patch changes just > one. Which of the two is right? Rebase churn - there were four callers of qobject_from_jsonf() that I originally identified, then I split it up into the one caller that used %PRId64 vs. the other three that can be done differently. >=20 > In my opinion, the code becomes less readable. >=20 > 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, we convert to int64_t= > first, then use PRId64. The problem is that we don't actually implemen= t > PRId64 everywhere. Why not simply long long and %lld? For 2.8, I can leave %lld support in qobject_from_jsonf(), and just cast to long long instead of int64_t. I'd still like to propose the series that kills all dynamic JSON for 2.9, but I don't mind posting a v2 of this series. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --RURAAhNViPwTrP3Ln1XHpgfJUE9IRPaDs 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/ iQEcBAEBCAAGBQJYNaAWAAoJEKeha0olJ0NqNmgH/iacraP3HR3B/lqMErhxGmo9 gob0CTlGXo0QJjRMk9jaJlVfOFY1TeA5+AkciPhreWGC7+q1OfrLblCkT2cd9j+e WlvBMkefRcNEG7ZPzKHdojy45rQQOBNJvibXZ/jMBCrxYJb6Y8Gl0/B/QlpYBrH+ /03/xZi6dPoxWBJYfBog7pbDm9Cd3rSniBstDhJdnHFYhsBqhDGMSwsWme1W/Bwe n4SX8WRFfbUxtQ1meMgsvO1SrckXdr1E9vUnMp6zuEoLV4apMxvKM1OLBYNVNft4 ME+1ijs4owT4igowrrVoMHK8vegsbZ2kvnOwLLlHnxoZsuMrydI0eGaPzbgeuq8= =bSnh -----END PGP SIGNATURE----- --RURAAhNViPwTrP3Ln1XHpgfJUE9IRPaDs--