[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 12.6/47] qapi: Document shortcoming with union '
From: |
Eric Blake |
Subject: |
[Qemu-devel] [RFC PATCH 12.6/47] qapi: Document shortcoming with union 'data' branch |
Date: |
Thu, 30 Jul 2015 17:07:17 -0600 |
Add a FIXME to remind us to fully audit whether removing the
'void *data' branch of each qapi union type can be done safely.
Signed-off-by: Eric Blake <address@hidden>
---
Another potential doc FIXME patch, this time based on 7/47
(https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg06101.html)
scripts/qapi-types.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index c6c2786..b3434b9 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -217,6 +217,14 @@ struct %(name)s
''',
discriminator_type_name=c_name(discriminator_type_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 {
void *data;
--
2.4.3
- [Qemu-devel] [PATCH RFC v2 00/47] qapi: QMP introspection, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 03/47] qapi: Simplify guardname(), Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 12/47] tests/qapi-schema: Document events with with base don't work, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 04/47] qapi-event: Clean up how name of enum QAPIEvent is made, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 02/47] qapi: Clean up cgen() and mcgen(), Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 09/47] qapi-visit: Replace list implicit_structs by set, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions, Markus Armbruster, 2015/07/01