From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXhPz-00089e-RP for qemu-devel@nongnu.org; Thu, 03 Sep 2015 23:12:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXhPw-0007fU-LC for qemu-devel@nongnu.org; Thu, 03 Sep 2015 23:11:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60937) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXhPw-0007ej-Di for qemu-devel@nongnu.org; Thu, 03 Sep 2015 23:11:56 -0400 References: <1441290623-13631-1-git-send-email-armbru@redhat.com> <1441290623-13631-11-git-send-email-armbru@redhat.com> From: Eric Blake Message-ID: <55E90BFA.3040502@redhat.com> Date: Thu, 3 Sep 2015 21:11:54 -0600 MIME-Version: 1.0 In-Reply-To: <1441290623-13631-11-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="1fLOciuxk3iOmcpLQSmE1csCOvoWV8Ok8" Subject: Re: [Qemu-devel] [PATCH RFC v4 10/32] qapi-types: Convert to QAPISchemaVisitor, fixing flat unions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: mdroth@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --1fLOciuxk3iOmcpLQSmE1csCOvoWV8Ok8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/03/2015 08:30 AM, Markus Armbruster wrote: > Fixes flat unions to get the base's base members. Test case is from > commit 2fc0043, in qapi-schema-test.json: >=20 >=20 > Signed-off-by: Markus Armbruster > Reviewed-by: Eric Blake > --- > docs/qapi-code-gen.txt | 51 +++--- > scripts/qapi-types.py | 273 ++++++++++++++----------= -------- > tests/qapi-schema/qapi-schema-test.json | 4 +- > 3 files changed, 144 insertions(+), 184 deletions(-) > @@ -231,39 +200,36 @@ struct %(name)s { > union { /* union tag is @%(c_name)s */ > void *data; > ''', > - c_name=3Dc_name(discriminator or 'kind')) > + c_name=3Dc_name(variants.tag_member.name)) See my review on 30/32. If we change tag_member to match the wire spelling of 'type' in patch 2, then this patch needs a slight alteration. (Of course, I've already posted a potential followup patch, currently for use after your series lands, that fixes the C spelling to quit the pointless rename to 'kind'; maybe we should instead fold that in to the early part of this series? If not, it will be one of our earlier followups). Here's the diff that got the bug in 30/32 fixed, along with changes to the two other files. diff --git i/scripts/qapi-types.py w/scripts/qapi-types.py index 70a57c0..83fc421 100644 --- i/scripts/qapi-types.py +++ w/scripts/qapi-types.py @@ -139,11 +139,12 @@ struct %(c_name)s { # should not be any data leaks even without a data pointer. Or, if # 'data' is merely added to guarantee we don't have an empty union, # shouldn't we enforce that at .json parse time? + # FIXME: Use same tag name in C as on the wire ret +=3D mcgen(''' union { /* union tag is @%(c_name)s */ void *data; ''', - c_name=3Dc_name(variants.tag_member.name)) + c_name=3Dc_name(variants.tag_name or 'kind')) for var in variants.variants: # TODO ugly special case for simple union --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --1fLOciuxk3iOmcpLQSmE1csCOvoWV8Ok8 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/ iQEcBAEBCAAGBQJV6Qv6AAoJEKeha0olJ0Nq+F8H/01fOv23AtpDYkj8cPNjnqmS KwjpS38cuRJS1MFDtJk5ZjL0uJBaIzC3pyXxhw/sIbME7RMJ9wo7KnDJA5sJAOcL jHqlYVccyaX+3QTZMeRTkzN/W522JxiKyhAgIxkMfiq4YKmxZfWcUvJGe0vRLNRO IvJQ9d6qoAA3I3qA0ECSpsTWqh8wjAjTrE3YUCNwZPRZZDnkPCoQd3zrh91NKTuT s3SYfwwVO3BJsTtXH0btfXJwV0kWDubGIp/Dor4ip97+6FI+Pj1YZ1m3fGuOeVy1 upow0Vdzalg0/RyImLNauJLqw47bos9RF6ZnEWOVRyXDU4xx5zuIc7aBnbpIWc4= =mmj7 -----END PGP SIGNATURE----- --1fLOciuxk3iOmcpLQSmE1csCOvoWV8Ok8--