From patchwork Mon Feb 10 21:48:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 319119 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 810612C0097 for ; Tue, 11 Feb 2014 16:49:52 +1100 (EST) Received: from localhost ([::1]:59565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WD6E9-0003Bx-1W for incoming@patchwork.ozlabs.org; Tue, 11 Feb 2014 00:49:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WD6Dc-0003BW-9A for qemu-devel@nongnu.org; Tue, 11 Feb 2014 00:49:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WD6DT-0003q0-VW for qemu-devel@nongnu.org; Tue, 11 Feb 2014 00:49:16 -0500 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:38660) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WD6DT-0003od-An for qemu-devel@nongnu.org; Tue, 11 Feb 2014 00:49:07 -0500 Received: from /spool/local by e28smtp06.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 11 Feb 2014 11:19:04 +0530 Received: from d28dlp03.in.ibm.com (9.184.220.128) by e28smtp06.in.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 11 Feb 2014 11:19:02 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id EE0F01258053 for ; Tue, 11 Feb 2014 11:20:55 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s1B5mwji3146090 for ; Tue, 11 Feb 2014 11:18:58 +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 s1B5n1gr030325 for ; Tue, 11 Feb 2014 11:19:02 +0530 Received: from RH64wenchao ([9.181.129.59]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s1B5mvVn030084; Tue, 11 Feb 2014 11:19:00 +0530 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Tue, 11 Feb 2014 05:48:33 +0800 Message-Id: <1392068921-3327-3-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1392068921-3327-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1392068921-3327-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14021105-9574-0000-0000-00000BE43102 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.6 Cc: kwolf@redhat.com, mdroth@linux.vnet.ibm.com, armbru@redhat.com, lcapitulino@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V6 02/10] qapi script: add check for duplicated key X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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()