[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 38/46] qapi: Drop useless 'data' member of unions
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v5 38/46] qapi: Drop useless 'data' member of unions |
Date: |
Mon, 21 Sep 2015 15:57:54 -0600 |
Now that we no longer have any clients of the 'void *data'
member injected into unions, we can drop it. Update the
testsuite to drop the negative test union-clash2, and
replace it with a positive test in qapi-schema-test that
proves that we no longer have a name collision.
Signed-off-by: Eric Blake <address@hidden>
---
scripts/qapi-types.py | 9 ---------
tests/Makefile | 1 -
tests/qapi-schema/qapi-schema-test.json | 2 +-
tests/qapi-schema/qapi-schema-test.out | 4 ++--
tests/qapi-schema/union-clash2.err | 0
tests/qapi-schema/union-clash2.exit | 1 -
tests/qapi-schema/union-clash2.json | 3 ---
tests/qapi-schema/union-clash2.out | 7 -------
8 files changed, 3 insertions(+), 24 deletions(-)
delete mode 100644 tests/qapi-schema/union-clash2.err
delete mode 100644 tests/qapi-schema/union-clash2.exit
delete mode 100644 tests/qapi-schema/union-clash2.json
delete mode 100644 tests/qapi-schema/union-clash2.out
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 5b9cb69..e7f7c36 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -116,17 +116,8 @@ struct %(c_name)s {
c_type=c_name(variants.tag_member.type.name))
tag_name = variants.tag_member.name
- # FIXME: What purpose does data serve, besides preventing a union that
- # has a branch named 'data'? We use it in qapi-visit.py to decide
- # whether to bypass the switch statement if visiting the discriminator
- # failed; but since we 0-initialize structs, and cannot tell what
- # branch of the union is in use if the discriminator is invalid, there
- # should not be any data leaks even without a data pointer. Or, if
- # 'data' is merely added to guarantee we don't have an empty union,
- # shouldn't we enforce that at .json parse time?
ret += mcgen('''
union { /* union tag is @%(c_name)s */
- void *data;
''',
c_name=c_name(tag_name))
diff --git a/tests/Makefile b/tests/Makefile
index f351833..638bf50 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -335,7 +335,6 @@ qapi-schema += unicode-str.json
qapi-schema += union-bad-branch.json
qapi-schema += union-base-no-discriminator.json
qapi-schema += union-clash.json
-qapi-schema += union-clash2.json
qapi-schema += union-empty.json
qapi-schema += union-invalid-base.json
qapi-schema += union-max.json
diff --git a/tests/qapi-schema/qapi-schema-test.json
b/tests/qapi-schema/qapi-schema-test.json
index b1292c5..97830a3 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -90,7 +90,7 @@
'number': ['number'],
'boolean': ['bool'],
'string': ['str'],
- 'sizes': ['size'],
+ 'data': ['size'],
'any': ['any'] } }
# testing commands
diff --git a/tests/qapi-schema/qapi-schema-test.out
b/tests/qapi-schema/qapi-schema-test.out
index d9e8595..c1a5a02 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -126,9 +126,9 @@ object UserDefNativeListUnion
case number: :obj-numberList-wrapper
case boolean: :obj-boolList-wrapper
case string: :obj-strList-wrapper
- case sizes: :obj-sizeList-wrapper
+ case data: :obj-sizeList-wrapper
case any: :obj-anyList-wrapper
-enum UserDefNativeListUnionKind ['integer', 's8', 's16', 's32', 's64', 'u8',
'u16', 'u32', 'u64', 'number', 'boolean', 'string', 'sizes', 'any']
+enum UserDefNativeListUnionKind ['integer', 's8', 's16', 's32', 's64', 'u8',
'u16', 'u32', 'u64', 'number', 'boolean', 'string', 'data', 'any']
object UserDefOne
base UserDefZero
member string: str optional=False
diff --git a/tests/qapi-schema/union-clash2.err
b/tests/qapi-schema/union-clash2.err
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/qapi-schema/union-clash2.exit
b/tests/qapi-schema/union-clash2.exit
deleted file mode 100644
index 573541a..0000000
--- a/tests/qapi-schema/union-clash2.exit
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/tests/qapi-schema/union-clash2.json
b/tests/qapi-schema/union-clash2.json
deleted file mode 100644
index b2d45fb..0000000
--- a/tests/qapi-schema/union-clash2.json
+++ /dev/null
@@ -1,3 +0,0 @@
-# FIXME - a union branch named 'data' collides with generated C code
-{ 'union': 'TestUnion',
- 'data': { 'data': 'int' } }
diff --git a/tests/qapi-schema/union-clash2.out
b/tests/qapi-schema/union-clash2.out
deleted file mode 100644
index 689ee74..0000000
--- a/tests/qapi-schema/union-clash2.out
+++ /dev/null
@@ -1,7 +0,0 @@
-object :empty
-object :obj-int-wrapper
- member data: int optional=False
-object TestUnion
- tag type
- case data: :obj-int-wrapper
-enum TestUnionKind ['data']
--
2.4.3
- [Qemu-devel] [PATCH v5 24/46] qapi: Document visitor interfaces, (continued)
- [Qemu-devel] [PATCH v5 24/46] qapi: Document visitor interfaces, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 28/46] qapi: Rework deallocation of partial struct, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 29/46] qapi: Change visit_type_FOO() to no longer return partial objects, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 30/46] net: use Netdev instead of NetClientOptions in client init, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 33/46] vnc: hoist allocation of VncBasicInfo to callers, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 32/46] qapi: Hide tag_name data member of variants, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 35/46] qapi-visit: Remove redundant functions for flat union base, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 34/46] qapi: Unbox base members, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 36/46] qapi: Avoid use of 'data' member of qapi unions, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 38/46] qapi: Drop useless 'data' member of unions,
Eric Blake <=
- [Qemu-devel] [PATCH v5 37/46] qapi: Forbid empty unions and useless alternates, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 39/46] qapi: Plumb in 'box' to qapi generator lower levels, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 41/46] qapi: Support boxed unions, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 40/46] qapi: Implement boxed structs for commands/events, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 42/46] qapi: support implicit structs in OptsVisitor, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 31/46] qapi: use 'type' in generated C code to match QMP union wire form, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 44/46] net: Use correct type for bool flag, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 46/46] qapi: Allow anonymous base for flat union, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 43/46] qapi: Change Netdev into a flat union, Eric Blake, 2015/09/21