From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGMbW-00057m-8B for qemu-devel@nongnu.org; Thu, 20 Feb 2014 00:55:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGMbL-00016H-CT for qemu-devel@nongnu.org; Thu, 20 Feb 2014 00:55:26 -0500 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:33979) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGMbK-00014g-Mk for qemu-devel@nongnu.org; Thu, 20 Feb 2014 00:55:15 -0500 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 20 Feb 2014 11:25:08 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 218B43940058 for ; Thu, 20 Feb 2014 11:25:07 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s1K5t9mG66584608 for ; Thu, 20 Feb 2014 11:25:10 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s1K5t6kQ001881 for ; Thu, 20 Feb 2014 11:25:06 +0530 From: Wenchao Xia Date: Thu, 20 Feb 2014 00:54:46 -0500 Message-Id: <1392875695-15627-3-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1392875695-15627-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1392875695-15627-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: [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: qemu-devel@nongnu.org Cc: kwolf@redhat.com, mdroth@linux.vnet.ibm.com, armbru@redhat.com, lcapitulino@redhat.com, Wenchao Xia 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() -- 1.7.1