From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVjgq-0005nS-Ew for qemu-devel@nongnu.org; Tue, 16 Feb 2016 12:45:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVjgn-0008JT-0X for qemu-devel@nongnu.org; Tue, 16 Feb 2016 12:45:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41658) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVjgm-0008JP-Oj for qemu-devel@nongnu.org; Tue, 16 Feb 2016 12:45:28 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 3FB888E6EF for ; Tue, 16 Feb 2016 17:45:28 +0000 (UTC) References: <20160216173540.GG11370@redhat.com> From: Eric Blake Message-ID: <56C36037.5070702@redhat.com> Date: Tue, 16 Feb 2016 10:45:27 -0700 MIME-Version: 1.0 In-Reply-To: <20160216173540.GG11370@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hUOp9IbMdgqDnNwJOIEpSj4CW3An1gomI" Subject: Re: [Qemu-devel] Problem with discriminated unions with enum prefixes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --hUOp9IbMdgqDnNwJOIEpSj4CW3An1gomI Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/16/2016 10:35 AM, Daniel P. Berrange wrote: > In my LUKS encryption series, I have a discriminated union for > storing options for different encryption formats. See qapi/crypto.json > in this file: >=20 > https://lists.gnu.org/archive/html/qemu-devel/2016-02/msg03187.html >=20 > You'll notice I have the 'prefix' line for the enum commented out. When= > I uncomment this, I discovered that the discriminated union visitor doe= s > not deal with prefixes. >=20 > Apply that and then try to build and it'll fail with: >=20 > qapi-visit.c: In function =E2=80=98visit_type_QDemo=E2=80=99: > qapi-visit.c:7596:10: error: =E2=80=98Q_DEMO_TYPE_FOO=E2=80=99 undeclar= ed (first use in this function) > case Q_DEMO_TYPE_FOO: > ^ > qapi-visit.c:7596:10: note: each undeclared identifier is reported only= once for each function it appears in > qapi-visit.c:7599:10: error: =E2=80=98Q_DEMO_TYPE_BAR=E2=80=99 undeclar= ed (first use in this function) > case Q_DEMO_TYPE_BAR: > ^ >=20 > The issue is that we used the 'QDEMO_TYPE' custom prefix for generating= the > enum, but we didn't use the prefix in the union visitor. Should be a quick fix, if we want to keep prefixes. I'll go ahead and post it, at least for discussion purposes. >=20 > I know we had had previous discussions with Markus strongly wanting to = kill > off the support for enum prefixes. So before I waste time trying to fix= > this union visitor code to handle prefixes, I figure we should decide i= f > we actually want to fix it, or go with Markus' plan to kill custom pref= ixes > on enums. I'm still on the fence which way to go; we've definitely improved the code base so that inadvertent collisions due to odd heuristics are less likely to occur, but every special case we have to carry (custom prefix being one of them) results in more code to maintain and test. >=20 > Per previous discussions, I think the ability to have custom prefixes i= s > quite desirable, to get more natural enum constant names. At the end of= > the day though, the default enum naming is far from the worst bit of > QEMU, so I'm not ultimately too bothered either way. We either make > custom enum prefixes work everything they need to, or remove them. >=20 > Regards, > Daniel >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --hUOp9IbMdgqDnNwJOIEpSj4CW3An1gomI 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/ iQEcBAEBCAAGBQJWw2A3AAoJEKeha0olJ0NqqBkH/R16q9De6FD+zmvbFcjleaWL QVRveoyMyHRW123vP8+S1jP1Sr2ZHMpjdNg/R/LhqB2QCW/uvGWtAtw33s8YSwWK YW4nJMjqvb5RjwDK3Hc0+Y7dgDT8JwcffqcJv1OLVyZc8SAUQiN345HVhFRyHsFX 3lLFIZfmaX4fa7h5N8Xj5//fBuBTFZF+8KXx/W5tt9E2x6j0S/4Oqdhrmtu2BYF9 RQtQ1NPEMx0CXufW/MySMyfOXtA62Aie0f+xWL7I7IeiW5HBVKM0yvy6o+zIL+Sw w2yJFivGG+bg4+Zim1f++szHUiWArq4YpKNz79Zj/5sUPaRhfGCwvdH+QyA28jM= =W+16 -----END PGP SIGNATURE----- --hUOp9IbMdgqDnNwJOIEpSj4CW3An1gomI--