summaryrefslogtreecommitdiffstats
path: root/qapi
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-09-16 13:06:23 +0200
committerMarkus Armbruster <armbru@redhat.com>2015-09-21 09:56:49 +0200
commit6c2f9a15dfc8c18ba94defb0f819109902a817cb (patch)
tree527804812340b02a82461013289ea0c86b78f15a /qapi
parentf133f2db1eedd409d3c1b0892f65b99f83c74754 (diff)
downloadhqemu-6c2f9a15dfc8c18ba94defb0f819109902a817cb.zip
hqemu-6c2f9a15dfc8c18ba94defb0f819109902a817cb.tar.gz
qapi: Make output visitor return qnull() instead of NULL
Before commit 1d10b44, it crashed. Since then, it returns NULL, with a FIXME comment. The FIXME is valid: code that assumes QObject * can't be null exists. I'm not aware of a way to feed this problematic return value to code that actually chokes on null in the current code, but the next few commits will create one, failing "make check". Commit 481b002 solved a very similar problem by introducing a special null QObject. Using this special null QObject is clearly the right way to resolve this FIXME, so do that, and update the test accordingly. However, the patch isn't quite right: it messes up the reference counting. After about SIZE_MAX visits, the reference counter overflows, failing the assertion in qnull_destroy_obj(). Because that's many orders of magnitude more visits of nulls than we expect, we take this patch despite its flaws, to get the QMP introspection stuff in without further delay. We'll want to fix it for real before the release. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Message-Id: <1442401589-24189-21-git-send-email-armbru@redhat.com>
Diffstat (limited to 'qapi')
-rw-r--r--qapi/qmp-output-visitor.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c
index efc19d5..8dce087 100644
--- a/qapi/qmp-output-visitor.c
+++ b/qapi/qmp-output-visitor.c
@@ -66,9 +66,13 @@ static QObject *qmp_output_first(QmpOutputVisitor *qov)
{
QStackEntry *e = QTAILQ_LAST(&qov->stack, QStack);
- /* FIXME - find a better way to deal with NULL values */
+ /*
+ * FIXME Wrong, because qmp_output_get_qobject() will increment
+ * the refcnt *again*. We need to think through how visitors
+ * handle null.
+ */
if (!e) {
- return NULL;
+ return qnull();
}
return e->value;
OpenPOWER on IntegriCloud