Received: from eggs.gnu.org ([2001:4830:134:3::10]:43685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGSO9-0006er-2K for qemu-devel@nongnu.org; Thu, 20 Feb 2014 07:06:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGSO3-0004MK-LH for qemu-devel@nongnu.org; Thu, 20 Feb 2014 07:06:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11787) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGSO3-0004M5-DG for qemu-devel@nongnu.org; Thu, 20 Feb 2014 07:05:55 -0500 From: Markus Armbruster References: <1392875695-15627-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1392875695-15627-3-git-send-email-xiawenc@linux.vnet.ibm.com> Date: Thu, 20 Feb 2014 13:05:46 +0100 In-Reply-To: <1392875695-15627-3-git-send-email-xiawenc@linux.vnet.ibm.com> (Wenchao Xia's message of "Thu, 20 Feb 2014 00:54:46 -0500") Message-ID: <87mwhm0z1h.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH V7 02/11] 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 > --- > scripts/qapi.py | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/scripts/qapi.py b/scripts/qapi.py > index bd81f06..3732fe1 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, 'Duplicate key "%s"' % key) > expr[key] = self.get_expr(True) > if self.tok == '}': > self.accept() The test for this error is in 11/11. If you need to respin anyway, consider adding error tests in the same patch as the error they test.