From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnZO2-0008Lf-No for qemu-devel@nongnu.org; Mon, 02 Dec 2013 14:42:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VnZNy-00023d-09 for qemu-devel@nongnu.org; Mon, 02 Dec 2013 14:42:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:23594) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnZNx-000224-NX for qemu-devel@nongnu.org; Mon, 02 Dec 2013 14:42:25 -0500 Message-ID: <529CE29D.6020004@redhat.com> Date: Mon, 02 Dec 2013 12:42:21 -0700 From: Eric Blake MIME-Version: 1.0 References: <1384295108-10913-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1384295108-10913-3-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1384295108-10913-3-git-send-email-xiawenc@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="q1duQ08kmnOH6vVvQMwn7hlTJF2Vo2JfN" Subject: Re: [Qemu-devel] [PATCH V2 2/8] qapi script: add check for duplicated key List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia , qemu-devel@nongnu.org Cc: mdroth@linux.vnet.ibm.com, kwolf@redhat.com, armbru@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --q1duQ08kmnOH6vVvQMwn7hlTJF2Vo2JfN Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 11/12/2013 03:25 PM, Wenchao Xia wrote: > It is bad that same key was specified twice, especially when a union ha= ve > two branches with same condition. This patch can prevent it. >=20 > Signed-off-by: Wenchao Xia > --- > scripts/qapi.py | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) Reviewed-by: Eric Blake >=20 > diff --git a/scripts/qapi.py b/scripts/qapi.py > index 82f586e..aa91edc 100644 > --- a/scripts/qapi.py > +++ b/scripts/qapi.py > @@ -116,6 +116,8 @@ class QAPISchema: > if self.tok !=3D ':': > raise QAPISchemaError(self, 'Expected ":"') > self.accept() > + if key in expr: > + raise QAPISchemaError(self, 'Duplicated key "%s"' % ke= y) > expr[key] =3D self.get_expr(True) > if self.tok =3D=3D '}': > self.accept() >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --q1duQ08kmnOH6vVvQMwn7hlTJF2Vo2JfN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSnOKdAAoJEKeha0olJ0NqDrMH/i0GhM4oBtWOWLGNunnQzBIP Lx5M0wQX1B4wQadFwdJR8h9cWO9HAWrfa9dNmp6ZFhQ+/nGIElbdU8Wp/lCnAc0g KMHsvYEUkGF/Yh6M6gJWr2dzDjZQrvm/of5Mr7fZOVV1YFMHNCcDCact4cnrLtQN CQhmLlm4+fkzcnZGxuBsYSoJZepMwvlI/Kfr+UeuhrLOm4XnrJVkDAyLZEyqRnt2 9wrIdk+e1XaShFtnpk7rK41dk3UBm5In+MjQic36+2PiwPW1dBX3hJdvAfs1P3xy yB/fXx/FDCGmgrt1cpnCybIU5RNZZJzztMfAzDJcvLu2pcXBHqytbdImtmTMxOQ= =LR0p -----END PGP SIGNATURE----- --q1duQ08kmnOH6vVvQMwn7hlTJF2Vo2JfN--