qemu-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]