From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zz66B-0000Xq-FG for qemu-devel@nongnu.org; Wed, 18 Nov 2015 12:00:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zz66A-0004aT-7x for qemu-devel@nongnu.org; Wed, 18 Nov 2015 12:00:47 -0500 References: <1447836791-369-1-git-send-email-eblake@redhat.com> <1447836791-369-23-git-send-email-eblake@redhat.com> <87610zpi2b.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <564CAEB4.1040309@redhat.com> Date: Wed, 18 Nov 2015 10:00:36 -0700 MIME-Version: 1.0 In-Reply-To: <87610zpi2b.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6xw758Sw22tupnLFT6w8cGwdv2I0gTHGQ" Subject: Re: [Qemu-devel] [PATCH v12 22/36] qapi: Don't let implicit enum MAX member collide List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Kevin Wolf , Peter Maydell , Alberto Garcia , Eduardo Habkost , "open list:blkdebug" , "Michael S. Tsirkin" , Jason Wang , Juan Quintela , qemu-devel@nongnu.org, Michael Roth , =?UTF-8?Q?Andreas_F=c3=a4rber?= , Gerd Hoffmann , Stefan Hajnoczi , "Denis V. Lunev" , Amit Shah , Paolo Bonzini , Luiz Capitulino , Richard Henderson This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --6xw758Sw22tupnLFT6w8cGwdv2I0gTHGQ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/18/2015 06:12 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> Now that we guarantee the user doesn't have any enum values >> beginning with a single underscore, we can use that for our >> own purposes. Renaming ENUM_MAX to ENUM__MAX makes it obvious >> that the sentinel is generated. >=20 > The ENUM__MAX are mildly ugly. If we cared, we could get rid of most o= r > all uses. Right now, I don't. >=20 > Hmm, perhaps these ENUM__MAX are your motivation for rejecting adjacent= > [-_] in the previous patch, to catch clashes like (foolishly named) typ= e > 'FOO--MAX' with enumeration type 'Foo'. I acknowledge the clash. Yes, and that was part of my reasoning on 21/36 - but you've convinced me to relax that one, so it no longer applies as an argument here. > However, there are many more clashes we don't attempt to catch, > e.g. type 'Foo-lookup' with enumeration type 'Foo'. Perhaps we want to= > build a real fence later, but right now I don't want us to ram in more > scattered fence laths. >=20 > Might want to say something like "Rejecting enum members named 'MAX' is= > now useless, and will be dropped in the next patch". Yes, that helps the commit message. Can you handle it, or do I need to send a fixup? >=20 >> This patch was mostly generated by applying a temporary patch: >> >> |diff --git a/scripts/qapi.py b/scripts/qapi.py >> |index e6d014b..b862ec9 100644 >> |--- a/scripts/qapi.py >> |+++ b/scripts/qapi.py >> |@@ -1570,6 +1570,7 @@ const char *const %(c_name)s_lookup[] =3D { >> | max_index =3D c_enum_const(name, 'MAX', prefix) >> | ret +=3D mcgen(''' >> | [%(max_index)s] =3D NULL, >> |+// %(max_index)s >> | }; >> | ''', >> | max_index=3Dmax_index) >> >> then running: >> >> $ cat qapi-{types,event}.c tests/test-qapi-types.c | >> sed -n 's,^// \(.*\)MAX,s|\1MAX|\1_MAX|g,p' > list >> $ git grep -l _MAX | xargs sed -i -f list >> >> The only things not generated are the changes in scripts/qapi.py. >> >> Signed-off-by: Eric Blake >=20 > Patch looks good. The fun part was coming up with the automation, and then making sure it was reproducible. :) --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --6xw758Sw22tupnLFT6w8cGwdv2I0gTHGQ 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/ iQEcBAEBCAAGBQJWTK60AAoJEKeha0olJ0Nqm/cH/2DQ2k3Q9twtp2RIsP3Fiio5 P1reUPyTRFaD9rhWtmpKnR08e9kffYI/PfIrkRKPKkG8i/LJhuQmnb2q6mtH/joj bzqNiHyxwNsV1BLXdnC+YQZBjlDvsnHwGTZsAcm5AVos3BBLwrGjzh4UOGbFPieb C3WKrF4KhRof5mdv4/SK2epE+fXOayQ6ckGBxjIc2Y9bBgjxnt5cMqlCTw74v7UC OLth9Xp3LJYshx5UHzVKNdI85HSQzONGzcYWjM6l4+slgg5AkEakQPJCZu7YEg5S Ikel7PmM87jtno0FanRt9wIGqxPx0yBoUKN6U8WVomuswWtrpb3w9btta+GgAJ8= =J+we -----END PGP SIGNATURE----- --6xw758Sw22tupnLFT6w8cGwdv2I0gTHGQ--