Received: from eggs.gnu.org ([2001:4830:134:3::10]:50905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDy0E-0001Vy-CH for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:15:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDy08-00038P-HG for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:15:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58435) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDy08-00038F-Ac for qemu-devel@nongnu.org; Thu, 13 Feb 2014 10:14:56 -0500 From: Markus Armbruster References: <1392068921-3327-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1392068921-3327-3-git-send-email-xiawenc@linux.vnet.ibm.com> Date: Thu, 13 Feb 2014 16:14:50 +0100 In-Reply-To: <1392068921-3327-3-git-send-email-xiawenc@linux.vnet.ibm.com> (Wenchao Xia's message of "Tue, 11 Feb 2014 05:48:33 +0800") Message-ID: <87y51fujrp.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH V6 02/10] qapi script: add check for duplicated key List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: kwolf@redhat.com, lcapitulino@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com Wenchao Xia writes: > It is bad that same key was specified twice, especially when a union have > two branches with same condition. This patch can prevent it. > > Signed-off-by: Wenchao Xia > Reviewed-by: Eric Blake > --- > scripts/qapi.py | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/scripts/qapi.py b/scripts/qapi.py > index aec6bbb..cf34768 100644 > --- a/scripts/qapi.py > +++ b/scripts/qapi.py > @@ -116,6 +116,8 @@ class QAPISchema: > if self.tok != ':': > raise QAPISchemaError(self, 'Expected ":"') > self.accept() > + if key in expr: > + raise QAPISchemaError(self, 'Duplicated key "%s"' % key) > expr[key] = self.get_expr(True) > if self.tok == '}': > self.accept() All errors should have a test in tests/qapi-schema/. I can try to add tests for you when I rebase your 09/10.