summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2015-07-30 17:07:17 -0600
committerMarkus Armbruster <armbru@redhat.com>2015-09-04 15:47:14 +0200
commitca56a822dd538017715345cbbe1f8829e0cc2742 (patch)
treeddbde6c3a1ebddf1930f57a309fdc9a64bfdf55e
parent2f52e20597ebd55ede668b2b7d162a84f419b03e (diff)
downloadhqemu-ca56a822dd538017715345cbbe1f8829e0cc2742.zip
hqemu-ca56a822dd538017715345cbbe1f8829e0cc2742.tar.gz
qapi: Document shortcoming with union 'data' branch
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 <eblake@redhat.com> Message-Id: <1438297637-26789-1-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
-rw-r--r--scripts/qapi-types.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 82141cd..8444f98 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -219,6 +219,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 { /* union tag is @%(c_name)s */
void *data;
OpenPOWER on IntegriCloud