qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 12/12] qapi: Drop useless 'data' member of unions
Date: Fri,  4 Mar 2016 17:45:28 +0100	[thread overview]
Message-ID: <1457109928-4881-13-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1457109928-4881-1-git-send-email-armbru@redhat.com>

From: Eric Blake <eblake@redhat.com>

We started moving away from the use of the 'void *data' member
in the C union corresponding to a QAPI union back in commit
544a373; 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: Eric Blake <eblake@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>

Message-Id: <1457021813-10704-11-git-send-email-eblake@redhat.com>
---
 scripts/qapi-types.py                   | 9 ---------
 tests/Makefile                          | 1 -
 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  | 9 ---------
 6 files changed, 27 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 19d1fff..0306a88 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -116,17 +116,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 04e34b5..cd4bbd4 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -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
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 f5752f4..0000000
--- a/tests/qapi-schema/union-clash-data.out
+++ /dev/null
@@ -1,9 +0,0 @@
-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']
-- 
2.4.3

  parent reply	other threads:[~2016-03-04 16:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-04 16:45 [Qemu-devel] [PULL 00/12] QAPI patches for 2016-03-04 Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 01/12] qmp-shell: fix pretty printing of JSON responses Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 02/12] qapi-dealloc: Reduce use outside of generated code Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 03/12] qapi: Rename 'fields' to 'members' in generator Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 04/12] qapi: Rename 'fields' to 'members' in generated C code Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 05/12] qapi-visit: Expose visit_type_FOO_members() Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 06/12] qapi: Update docs to match recent generator changes Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 07/12] chardev: Shorten references into ChardevBackend Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 08/12] util: Shorten references into SocketAddress Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 09/12] ui: Shorten references into InputEvent Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 10/12] qapi: Avoid use of 'data' member of QAPI unions Markus Armbruster
2016-03-04 16:45 ` [Qemu-devel] [PULL 11/12] chardev: Drop useless ChardevDummy type Markus Armbruster
2016-03-04 16:45 ` Markus Armbruster [this message]
2016-03-04 17:43 ` [Qemu-devel] [PULL 00/12] QAPI patches for 2016-03-04 Peter Maydell

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=1457109928-4881-13-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.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).