From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v6 04/16] qapi: Drop useless 'data' member of unions
Date: Wed, 23 Dec 2015 13:55:33 -0700 [thread overview]
Message-ID: <1450904145-17721-5-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1450904145-17721-1-git-send-email-eblake@redhat.com>
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-clash-data, 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 <eblake@redhat.com>
---
v6: rebase to earlier changes
---
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-clash-data.err | 0
tests/qapi-schema/union-clash-data.exit | 1 -
tests/qapi-schema/union-clash-data.json | 7 -------
tests/qapi-schema/union-clash-data.out | 11 -----------
8 files changed, 3 insertions(+), 32 deletions(-)
delete mode 100644 tests/qapi-schema/union-clash-data.err
delete mode 100644 tests/qapi-schema/union-clash-data.exit
delete mode 100644 tests/qapi-schema/union-clash-data.json
delete mode 100644 tests/qapi-schema/union-clash-data.out
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 47a6523..8597942 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -99,17 +99,8 @@ static inline %(base)s *qapi_%(c_name)s_base(const %(c_name)s *obj)
def gen_variants(variants):
- # 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(variants.tag_member.name))
diff --git a/tests/Makefile b/tests/Makefile
index b7352f1..84caf98 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -356,7 +356,6 @@ qapi-schema += unicode-str.json
qapi-schema += union-base-no-discriminator.json
qapi-schema += union-branch-case.json
qapi-schema += union-clash-branches.json
-qapi-schema += union-clash-data.json
qapi-schema += union-empty.json
qapi-schema += union-invalid-base.json
qapi-schema += union-optional-branch.json
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index a0fdb88..44c1965 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -112,7 +112,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 a2a3c8b..e6088a5 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -171,9 +171,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-clash-data.err b/tests/qapi-schema/union-clash-data.err
deleted file mode 100644
index e69de29..0000000
diff --git a/tests/qapi-schema/union-clash-data.exit b/tests/qapi-schema/union-clash-data.exit
deleted file mode 100644
index 573541a..0000000
--- a/tests/qapi-schema/union-clash-data.exit
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/tests/qapi-schema/union-clash-data.json b/tests/qapi-schema/union-clash-data.json
deleted file mode 100644
index 7308e69..0000000
--- a/tests/qapi-schema/union-clash-data.json
+++ /dev/null
@@ -1,7 +0,0 @@
-# Union branch 'data'
-# FIXME: this parses, but then fails to compile due to a duplicate 'data'
-# (one from the branch name, another as a filler to avoid an empty union).
-# we should either detect the collision at parse time, or change the
-# generated struct to allow this to compile.
-{ 'union': 'TestUnion',
- 'data': { 'data': 'int' } }
diff --git a/tests/qapi-schema/union-clash-data.out b/tests/qapi-schema/union-clash-data.out
deleted file mode 100644
index 19031a2..0000000
--- a/tests/qapi-schema/union-clash-data.out
+++ /dev/null
@@ -1,11 +0,0 @@
-object :empty
-object :obj-int-wrapper
- base :empty
- member data: int optional=False
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
- prefix QTYPE
-object TestUnion
- base :empty
- member type: TestUnionKind optional=False
- case data: :obj-int-wrapper
-enum TestUnionKind ['data']
--
2.4.3
next prev parent reply other threads:[~2015-12-23 20:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-23 20:55 [Qemu-devel] [PATCH v6 00/16] qapi netdev_add introspection (post-introspection cleanups subset F) Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 01/16] net: use Netdev instead of NetClientOptions in client init Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 02/16] qapi: Avoid use of 'data' member of qapi unions Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 03/16] qapi: Forbid empty unions and useless alternates Eric Blake
2015-12-23 20:55 ` Eric Blake [this message]
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 05/16] qapi: Hide tag_name data member of variants Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 06/16] qapi: Plumb in 'box' to qapi generator lower levels Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 07/16] qapi: Implement boxed types for commands/events Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 08/16] qapi: support implicit structs in OptsVisitor Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 09/16] qapi: Change Netdev into a flat union Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 10/16] net: Use correct type for bool flag Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 11/16] net: Complete qapi-fication of netdev_add Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 12/16] qapi: Allow anonymous base for flat union Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 13/16] qapi: Use anonymous base in SchemaInfo Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 14/16] qapi: Use anonymous base in Netdev Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 15/16] qapi: Use anonymous base in CpuInfo Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 16/16] qapi: Populate info['name'] for each entity Eric Blake
2015-12-23 20:58 ` [Qemu-devel] [PATCH v6 00/16] qapi netdev_add introspection (post-introspection cleanups subset F) Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1450904145-17721-5-git-send-email-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).