From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtNnj-0002xc-PX for qemu-devel@nongnu.org; Mon, 02 Nov 2015 17:42:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtNng-0003ee-GN for qemu-devel@nongnu.org; Mon, 02 Nov 2015 17:42:07 -0500 Received: from resqmta-po-08v.sys.comcast.net ([96.114.154.167]:58884) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtNng-0003ea-BX for qemu-devel@nongnu.org; Mon, 02 Nov 2015 17:42:04 -0500 From: Eric Blake Date: Mon, 2 Nov 2015 15:41:31 -0700 Message-Id: <1446504092-29008-4-git-send-email-eblake@redhat.com> In-Reply-To: <871tc8tnsl.fsf@blackfin.pond.sub.org> References: <871tc8tnsl.fsf@blackfin.pond.sub.org> Subject: [Qemu-devel] [PATCH v8.5 3/4] qapi: Fix check for variant tag values collision List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com, Michael Roth Now that commit e4ba22b3 has separated the C representation of qapi unions so that tag values no longer collide with non-variant members, we must adjust QAPISchemaObjectTypeVariant.check() to match. The fix is conceptually simple - track a separate dictionary of tag names we have seen so far, different from the dictionary of non-variant names. And while the non-variant seen array gets reset for each new variant (because the JSON object does not have collisions between separate branches), the map of tag names is not reset. Signed-off-by: Eric Blake --- v9: new patch, split off from v8 7/17 --- scripts/qapi.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 3cf051f..10bf16f 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -1055,10 +1055,11 @@ class QAPISchemaObjectTypeVariants(object): else: # simple union or alternate assert self.tag_member in seen.itervalues() assert isinstance(self.tag_member.type, QAPISchemaEnumType) + cases = {} for v in self.variants: # Reset seen array for each variant, since QMP names from one # branch do not affect another branch - v.check(schema, self.tag_member.type, dict(seen), union) + v.check(schema, self.tag_member.type, dict(seen), cases, union) class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember): @@ -1066,8 +1067,8 @@ class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember): QAPISchemaObjectTypeMember.__init__(self, name, typ, False) # TODO drop 'union' param once tag_type is sufficient to spot alternates - def check(self, schema, tag_type, seen, union): - QAPISchemaObjectTypeMember.check(self, schema, dict(seen)) + def check(self, schema, tag_type, seen, cases, union): + QAPISchemaObjectTypeMember.check(self, schema, cases) assert self.name in tag_type.values if union: # If this variant is used within a union, then each member -- 2.4.3