From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWUvQ-0001qw-Gk for qemu-devel@nongnu.org; Thu, 18 Feb 2016 15:11:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWUvK-0002XP-HX for qemu-devel@nongnu.org; Thu, 18 Feb 2016 15:11:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53355) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWUvK-0002XB-9y for qemu-devel@nongnu.org; Thu, 18 Feb 2016 15:11:38 -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> <56C5D7C8.1020701@redhat.com> <87povu7xyu.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <56C62579.40809@redhat.com> Date: Thu, 18 Feb 2016 13:11:37 -0700 MIME-Version: 1.0 In-Reply-To: <87povu7xyu.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Mo7g3TU3RmHHkHD1UdJgoLHfcC8bFJHPT" 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) --Mo7g3TU3RmHHkHD1UdJgoLHfcC8bFJHPT Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/18/2016 10:03 AM, Markus Armbruster wrote: >>> 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. >=20 > Then find_alternate_member_qtype()'s final return None is unreachable, > correct? Indeed, the testsuite still passes with: diff --git i/scripts/qapi.py w/scripts/qapi.py index 8497777..81d435f 100644 --- i/scripts/qapi.py +++ w/scripts/qapi.py @@ -345,7 +345,7 @@ def find_alternate_member_qtype(qapi_type): return "QTYPE_QSTRING" elif find_union(qapi_type): return "QTYPE_QDICT" - return None + assert False # Return the discriminator enum define if discriminator is specified as = an That said, even though we currently filter out unknown types before deciding to call find_alternate_member_qtype, it's not out of the question that future work to move ad hoc front-end tests into formal QAPISchema .check() methods may cause us to call find_alternate_member_qtype('unknown'). Leaving it as return None instead of asserting would make the error message added in this patch nicer. Then again, refactoring would move the error message of this patch to the .check() methods. So I won't worry about it for now. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Mo7g3TU3RmHHkHD1UdJgoLHfcC8bFJHPT 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/ iQEcBAEBCAAGBQJWxiV5AAoJEKeha0olJ0NqPRkH/1+07XP/sWcIkIP/QqG04LS6 +ARG5LJ+98jAAKyPUJu3227G+mkZULGK3LY9kHhW465dhveShUrzI3FOKAP22tGd QrYrkm2+aqmN4a6hlBNUFGGTS6Qrp52WuesvdrdC1flZDeSciLQuMXJB4xctuT4r wvGO+i0L6MXoeWag1Sb/mxLe+r+NXtZCAd1Sax2fK6gKyrw2qHIX11z6dYP5MUk7 vBr3SMqIzpUXm860D+Slc1187NiXjVwu6LMkq3YRDoWc1tVvX3gBqVAAaVBgkCuY cW4f8CphzFV0njMHBVXqD68hgqmYbiCrmBESKdPErJtdycbslmoUHA5V7yQ00kA= =R+Ek -----END PGP SIGNATURE----- --Mo7g3TU3RmHHkHD1UdJgoLHfcC8bFJHPT--