Skip to content
Snippets Groups Projects
Commit 48eb62a7 authored by Eric Blake's avatar Eric Blake Committed by Markus Armbruster
Browse files

qapi: Drop useless 'data' member of unions


We started moving away from the use of the 'void *data' member
in the C union corresponding to a QAPI union back in commit
544a3731; recent commits have gotten rid of other uses.  Now
that it is completely unused, we can remove the member itself
as well as the FIXME comment.  Update the testsuite to drop the
negative test union-clash-data.

Signed-off-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarDaniel P. Berrange <berrange@redhat.com>
Message-Id: <1457021813-10704-11-git-send-email-eblake@redhat.com>
Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
parent b1918fbb
No related branches found
No related tags found
No related merge requests found
......@@ -116,17 +116,8 @@ def gen_upcast(name, base):
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))
......
......@@ -358,7 +358,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
......
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' } }
object :empty
object :obj-int-wrapper
member data: int optional=False
enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
prefix QTYPE
object TestUnion
member type: TestUnionKind optional=False
case data: :obj-int-wrapper
enum TestUnionKind ['data']
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment