[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v8.5 3/4] qapi: Fix check for variant tag values col
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v8.5 3/4] qapi: Fix check for variant tag values collision |
Date: |
Mon, 2 Nov 2015 15:41:31 -0700 |
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 <address@hidden>
---
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
- Re: [Qemu-devel] [PATCH v8.5 1/4] qapi: Drop all_members parameter from check(), (continued)
- [Qemu-devel] [PATCH 1/7] qapi: Drop obsolete tag value collision assertions, Markus Armbruster, 2015/11/03
- [Qemu-devel] [PATCH 2/7] qapi: Simplify QAPISchemaObjectTypeMember.check(), Markus Armbruster, 2015/11/03
- [Qemu-devel] [PATCH 7/7] qapi: QAPISchemaObjectTypeVariants.check(), Markus Armbruster, 2015/11/03
- [Qemu-devel] [PATCH 4/7] qapi: Fix up commit 7618b91's clash sanity checking change, Markus Armbruster, 2015/11/03
- [Qemu-devel] [PATCH 5/7] qapi: Eliminate QAPISchemaObjectType.check() variable members, Markus Armbruster, 2015/11/03
- [Qemu-devel] [PATCH 3/7] qapi: Clean up after previous commit, Markus Armbruster, 2015/11/03
- [Qemu-devel] [PATCH 6/7] qapi: Factor out QAPISchemaObjectTypeMember.check_clash(), Markus Armbruster, 2015/11/03
[Qemu-devel] [PATCH v8.5 2/4] qapi: Check for QMP collisions of flat union branches, Eric Blake, 2015/11/02
[Qemu-devel] [PATCH v8.5 3/4] qapi: Fix check for variant tag values collision,
Eric Blake <=
[Qemu-devel] [PATCH v8.5 4/4] qapi: Consolidate collision detection code, Eric Blake, 2015/11/02