From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3R4Z-0006Oc-6x for qemu-devel@nongnu.org; Fri, 12 Jun 2015 11:40:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z3R4V-0000BJ-V1 for qemu-devel@nongnu.org; Fri, 12 Jun 2015 11:40:47 -0400 Received: from resqmta-po-12v.sys.comcast.net ([2001:558:fe16:19:96:114:154:171]:55468) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3R4V-0000AO-Pp for qemu-devel@nongnu.org; Fri, 12 Jun 2015 11:40:43 -0400 Message-ID: <557AFCE9.5030100@redhat.com> Date: Fri, 12 Jun 2015 09:38:17 -0600 From: Eric Blake MIME-Version: 1.0 References: <1431728700-18055-1-git-send-email-eblake@redhat.com> <1431728700-18055-2-git-send-email-eblake@redhat.com> <87a8w57akk.fsf@blackfin.pond.sub.org> In-Reply-To: <87a8w57akk.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jn0Eosh7L13FuVvcHQp9A5UaSaREwbfJA" Subject: Re: [Qemu-devel] [PATCH 1/2] qobject: Use 'bool' for qbool List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, berto@igalia.com, mst@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com, mreitz@redhat.com, afaerber@suse.de This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jn0Eosh7L13FuVvcHQp9A5UaSaREwbfJA Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/11/2015 11:35 PM, Markus Armbruster wrote: > Patch looks good to me, but it made me wonder about something. Please > find the question inline. >=20 > Eric Blake writes: >=20 >> We require a C99 compiler, so let's use 'bool' instead of 'int' >> when dealing with boolean values. There are few enough clients >> to fix them all in one pass. >> >> @@ -593,7 +593,7 @@ static QObject *parse_escape(JSONParserContext *ct= xt, va_list *ap) >> if (token_is_escape(token, "%p")) { >> obj =3D va_arg(*ap, QObject *); >> } else if (token_is_escape(token, "%i")) { >> - obj =3D QOBJECT(qbool_from_int(va_arg(*ap, int))); >> + obj =3D QOBJECT(qbool_from_bool(va_arg(*ap, int))); >=20 > Funny: JSON_ESCAPE "%i" gets an int, but maps it to bool. See also > patch to check-qjson.c below. >=20 > Is this feature actually used anywhere other than the tests? >=20 When using va_arg(), you have to use the type argument that things promote to when called through var-args (that is, va_arg(*ap, bool) would be a compiler warning). I don't know if anyone besides the testsuite is using %i; but I've already mentioned in another thread [1] that the correlation between... >> >> - obj =3D qobject_from_jsonf("%i", true); >> + /* Test that non-zero values other than 1 get collapsed to true *= / >> + obj =3D qobject_from_jsonf("%i", 2); >> g_assert(obj !=3D NULL); >> g_assert(qobject_type(obj) =3D=3D QTYPE_QBOOL); >=20 > These are test test cases for JSON_ESCAPE "%i". =2E..qobject_from_json in one file to the implementation of %i in another= was very hard to trace when writing this patch, as well as the idea of getting rid of the remaining 2 out of only 3 clients of %p [1]. So it's already on my table of ideas to do a followup patch that adds documentation, and audits all clients to see what can be pruned. [1] https://lists.gnu.org/archive/html/qemu-devel/2015-05/msg04660.html --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --jn0Eosh7L13FuVvcHQp9A5UaSaREwbfJA 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/ iQEcBAEBCAAGBQJVevzpAAoJEKeha0olJ0Nq2q0H/R8gQXCB2+GomAWS9GpYTh0F QTPJkTMZ6AOYuHYbzYIt0AYghCrzN1v7alEMTtbE8NkGxW+sM7oi8znviYuyH9pW RlG8invBs6UmMNpD34Z1s7phOeAkX0wIoXlY2q3pCye3YkycDt+TtDTkZSZz2xbI ehFP6nTocHKjGwQL5+HyhPBjWHWPW/6anTWJl5Kcy0RP7RP5Tbu01fpY3hQVSdfT zLLQaKl4tpVeaE17Buw4kWVF8uABwiriUp+5UoAoZtNiMzLxOhQl4vlaHuPGqV4M xQ9HjnQPDpSy6FKV5ynveR0wCdLUo71EZt/+5CV65Y2xo1/vLocssP8wwGbNBG8= =7zzE -----END PGP SIGNATURE----- --jn0Eosh7L13FuVvcHQp9A5UaSaREwbfJA--