From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WE7vH-0004ty-Qo for qemu-devel@nongnu.org; Thu, 13 Feb 2014 20:50:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WE7v9-0005aM-Ca for qemu-devel@nongnu.org; Thu, 13 Feb 2014 20:50:35 -0500 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:50044) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WE7v8-0005Xw-N0 for qemu-devel@nongnu.org; Thu, 13 Feb 2014 20:50:27 -0500 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 14 Feb 2014 07:20:20 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 4A66A3940023 for ; Fri, 14 Feb 2014 07:20:17 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s1E1oJo76095294 for ; Fri, 14 Feb 2014 07:20:19 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s1E1oGaG018244 for ; Fri, 14 Feb 2014 07:20:16 +0530 Message-ID: <52FD7667.3070309@linux.vnet.ibm.com> Date: Fri, 14 Feb 2014 09:50:31 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1392068921-3327-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1392068921-3327-3-git-send-email-xiawenc@linux.vnet.ibm.com> <87y51fujrp.fsf@blackfin.pond.sub.org> In-Reply-To: <87y51fujrp.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 8bit 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: Markus Armbruster Cc: kwolf@redhat.com, lcapitulino@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com ÓÚ 2014/2/13 23:14, Markus Armbruster дµÀ: > 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. > I considered error path test before but didn't find a good place to go. It would be great if you can add one.