From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxM26-0005dw-Sy for qemu-devel@nongnu.org; Fri, 13 Nov 2015 16:37:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZxM25-00017O-RE for qemu-devel@nongnu.org; Fri, 13 Nov 2015 16:37:22 -0500 References: <1447224690-9743-1-git-send-email-eblake@redhat.com> <1447224690-9743-20-git-send-email-eblake@redhat.com> <564621E7.9040103@redhat.com> <87wptlu5sg.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <56465806.8030103@redhat.com> Date: Fri, 13 Nov 2015 14:37:10 -0700 MIME-Version: 1.0 In-Reply-To: <87wptlu5sg.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QbN789Xgr0WrLtwCLHc4sQriQe0CA68BH" Subject: Re: [Qemu-devel] [PATCH v11 19/28] qapi: Change munging of CamelCase enum values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Kevin Wolf , Peter Maydell , "open list:Block layer core" , "Michael S. Tsirkin" , Jason Wang , qemu-devel@nongnu.org, Michael Roth , Gerd Hoffmann , Amit Shah , Luiz Capitulino , =?UTF-8?Q?Andreas_F=c3=a4rber?= This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --QbN789Xgr0WrLtwCLHc4sQriQe0CA68BH Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/13/2015 11:13 AM, Markus Armbruster wrote: > We need c_name() to protect ticklish identifiers only when its result i= s > used as identifier. Not when it's *part* of an identifier, > e.g. prefixed with qapi_, or camel_to_upper(type_name) + '_'. >=20 > We can protect even when we don't need to, if that helps keeping things= > simple. As far as I can tell, as soon as we reserve Q_ in addition to q_, and fix the bug in c_name() applying munging backwards, then we are safe to state that any comparison between two names for collisions will be accurate as long as both sides of the comparison picked the same value of c_name(name, protect), whether or not our later use of that name is done with protect=3DTrue or protect=3DFalse. >=20 > The obvious simple way to check for collisions works like this: >=20 > 1. Every QAPI name is mangled in exactly one way, modulo case: always > with c_name(), and always with the same value of protect. That part is easy. Maybe I could even reuse guardname(name) instead of c_name(name).upper(), although I don't know that it buys any clarity. >=20 > 2. We require the mangled name to be case-insensitively unique in its > name space. That part is a bit harder: we unfortunately have the existing clash between the command 'stop' and the event 'STOP'. I didn't find any other clashes in existing clients, though (phew), so we can either whitelist just that one, or more likely, set up separate namespaces for commands vs. events when doing the case collision tests. But it's a bummer that it won't be quite as easy as I had hoped (using a single dictionary for both lookups and case collisions is easier than having two dictionaries to separate namespaces, while still searching both dictionaries for lookups). At any rate, I'm playing with patches along these lines. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --QbN789Xgr0WrLtwCLHc4sQriQe0CA68BH 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/ iQEcBAEBCAAGBQJWRlgGAAoJEKeha0olJ0NqfBgH/i4vzMmwF3ELgAuyVXq/UJbD t24kF9NG4SiJbnTMvfrkT4rY6Wr4FfU12e9ZLk18HBCU+sYjSgwIjQPU/xDb8voF ZMNYgAGoazJXDDvQ+O6UtwW61laf3k/dZWMHqQUpTRmp9ILwWbDkeyh0Zn8mgWK+ 7A4dbVgtYySboYBiwJd0osi2p281H9DjZDQU2qw02R9CNEBp597Qs/dHJmC5RctO dYVH8s4rrNUMYiumGO4jxzekYftrdWFwlV6IrgRFTnJ1BBCXtvG8IeKAlPm62hxi Bkk2ZikM1q62eAKfZBOBRQqOd4tx4xI6PcCcD/4aX7exr5ovvja3NEWPcKvHGg4= =HrxL -----END PGP SIGNATURE----- --QbN789Xgr0WrLtwCLHc4sQriQe0CA68BH--