From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw1Yz-0006U8-Sq for qemu-devel@nongnu.org; Tue, 10 Nov 2015 00:33:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zw1Yv-0000q7-S5 for qemu-devel@nongnu.org; Tue, 10 Nov 2015 00:33:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw1Yv-0000q3-L0 for qemu-devel@nongnu.org; Tue, 10 Nov 2015 00:33:45 -0500 References: <1446791754-23823-1-git-send-email-eblake@redhat.com> <1446791754-23823-26-git-send-email-eblake@redhat.com> <87mvungw3i.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <564181B8.8060707@redhat.com> Date: Mon, 9 Nov 2015 22:33:44 -0700 MIME-Version: 1.0 In-Reply-To: <87mvungw3i.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LIh18nWH35djVo7lLD8POJtWUDlHRwXJ3" Subject: Re: [Qemu-devel] [PATCH v10 25/30] qapi: Hoist tag collision check to Variants.check() 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) --LIh18nWH35djVo7lLD8POJtWUDlHRwXJ3 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/09/2015 06:07 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> Checking that a given QAPISchemaObjectTypeVariant.name is a >> member of the corresponding QAPISchemaEnumType of the owning >> QAPISchemaObjectTypeVariants.tag_member ensures that there are >> no collisions in the generated C union for those tag values >> (since the enum itself should have no collisions). >> >> However, this check was the only thing that Variant.check() was >> doing beyond the work of the superclass ObjectTypeMember.check(), >> and resulted in a difference of the .check() signatures just to >> pass the enum type down. >> >> Simplify things by instead doing the tag name check as part of >> Variants.check(), at which point we can rely on inheritance >> instead of overriding Variant.check(). >> >> Signed-off-by: Eric Blake >> >> --- >> - assert isinstance(self.tag_member.type, QAPISchemaEnumType) >> + tag_type =3D self.tag_member.type >> + assert isinstance(tag_type, QAPISchemaEnumType) >> for v in self.variants: >> - v.check(schema, self.tag_member.type) >> + v.check(schema) >> + assert v.name in tag_type.values >=20 > Two changes squashed together: >=20 > * Move the assertion from QAPISchemaObjectTypeVariant.check(), >=20 > * Capture self.tag_member.type in tag_type >=20 > The second part makes the patch slightly less obvious. Matter of taste= =2E I'm dropping the tag_type temporary member. Once I played more with making qtype_code a qapi builtin type, it became much more elegant to revisit this code (the use of tag_type here was for when my later patches were trying to key off of tag_type=3D=3DNone as a witness of alternates). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --LIh18nWH35djVo7lLD8POJtWUDlHRwXJ3 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/ iQEcBAEBCAAGBQJWQYG4AAoJEKeha0olJ0NqSz8H/07ESfw4Sanu1Q1t5w+RixA0 jLeGWEvGHdwz5Q9W3Nhb6U6qxwID+b81M1R/142OUnz/V2TCcL++slSktecpTilu A3SGH7428/byL3xDXG5Ivs++SLkz8PjNpHORiqW4+u/j4vdrsQ5SGyXG0eUlGpRT dlSq3/kakYd8JhzBZgLNokZS4ewX8Kn4AzEPIWUqc2ItoEC71ThM4WeYL7SboA/T CmdHfQc+6mEf4m31x8OsG3bQjWnXY2bOpNk8wIS41Y+b5GxUHyhv9HJ0n/N4ORPm a6OtLxFLsNLLzqmkcXjcK85AX3trODbbHRC6khQ4/2EOxw9vmCqLfU95yAHZU5k= =S3Zf -----END PGP SIGNATURE----- --LIh18nWH35djVo7lLD8POJtWUDlHRwXJ3--