From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34207) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWPkd-0006QP-4r for qemu-devel@nongnu.org; Thu, 18 Feb 2016 09:40:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWPkZ-0000ut-3k for qemu-devel@nongnu.org; Thu, 18 Feb 2016 09:40:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60826) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWPkY-0000ul-SS for qemu-devel@nongnu.org; Thu, 18 Feb 2016 09:40:11 -0500 References: <1455778109-6278-1-git-send-email-eblake@redhat.com> <1455778109-6278-4-git-send-email-eblake@redhat.com> <87si0qgr5u.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <56C5D7C8.1020701@redhat.com> Date: Thu, 18 Feb 2016 07:40:08 -0700 MIME-Version: 1.0 In-Reply-To: <87si0qgr5u.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4wxmmAjLC7QhcdxI7aol5aAN1ErsJJFb9" Subject: Re: [Qemu-devel] [PATCH v11 03/15] qapi: Forbid 'any' inside an alternate List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --4wxmmAjLC7QhcdxI7aol5aAN1ErsJJFb9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/18/2016 05:05 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> The whole point of an alternate is to allow some type-safety while >> still accepting more than one JSON type. Meanwhile, the 'any' >> type exists to bypass type-safety altogether. The two are >> incompatible: you can't accept every type, and still tell which >> branch of the alternate to use for the parse; fix this to give a >> sane error instead of a Python stack trace. >> >> Signed-off-by: Eric Blake >> >=20 > Interestingly, find_alternate_member_qtype(T) can return None in two > ways: when builtin_types[T] is None (only for T =3D=3D 'any'), and when= T is > neither built-in, struct, enum or union (it must be alternate then). >=20 > This leads to the question whether this patch catches exactly 'any', as= > the commit message claims, or alternate as well. >=20 >>=20 >> @@ -629,7 +629,10 @@ def check_alternate(expr, expr_info): >> value, >> allow_metas=3D['built-in', 'union', 'struct', 'enu= m']) >> qtype =3D find_alternate_member_qtype(value) >=20 >=20 > Could use a test for alternate member of alternate type. One step ahead of you: commit 3d0c4829 added the test alternate-nested.json, and commits 44bd1276 and dd883c6f fixed the parser to reject it (first by a hard-coded check, then via allow_metas[] excluding alternates). 'any' is the only value that could sneak through, because it is a subset of 'built-in' which allow_metas[] whitelisted. If you want to squash any of this information into the commit message, though, I don't mind. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --4wxmmAjLC7QhcdxI7aol5aAN1ErsJJFb9 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/ iQEcBAEBCAAGBQJWxdfIAAoJEKeha0olJ0Nq7yMH/jLaR47Ag0kYDCdD0WGoGYPh BKo2PiaWp9l2qwq0Np/4fP4DC7n2UQfPNCIlVoa7VvE3ji8VDgK+VLVXy49c+kgX wDCmTPhHp6ABQbIJWc0gs6Z9OB96WQJ7dFLlQk+uXPXXM7IgWXDcvza49g7Z639y aDr/FS9TL+tkc4eYk5n1eQvBwZkskUxDRvi9ZbLcuY5Bt3HKHseUE1dPhcUWouYr 4yhzs1I5xIuA1TvfsC9qVx8mSFHyqZW3PlEokR2gU3kg/BixCssKqKd+J9Ko8YDO +IZdVpWOb2gbmbmfYMfVR0RHIQwkI17ObOAoWHkKP7XW3zkR5U/h5aSNNMzAGNM= =RGMO -----END PGP SIGNATURE----- --4wxmmAjLC7QhcdxI7aol5aAN1ErsJJFb9--