From 3fd0ff8aa76f7af2ecc1c461b73d131c5854f6d9 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 7 Mar 2018 16:43:41 -0500 Subject: [PATCH] qapi: Separate type QNull from QObject Backports commit 006ca09f3027d86346fce707e9295975c6558f42 from qemu --- qemu/include/qapi/qmp/qobject.h | 10 +++++++--- qemu/qapi/qobject-output-visitor.c | 2 +- qemu/qobject/qnull.c | 8 +++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/qemu/include/qapi/qmp/qobject.h b/qemu/include/qapi/qmp/qobject.h index 2b0bd995..d8f91c3c 100644 --- a/qemu/include/qapi/qmp/qobject.h +++ b/qemu/include/qapi/qmp/qobject.h @@ -99,11 +99,15 @@ static inline QType qobject_type(const QObject *obj) return obj->type; } -extern QObject qnull_; +typedef struct QNull { + QObject base; +} QNull; -static inline QObject *qnull(void) +extern QNull qnull_; + +static inline QNull *qnull(void) { - qobject_incref(&qnull_); + QINCREF(&qnull_); return &qnull_; } diff --git a/qemu/qapi/qobject-output-visitor.c b/qemu/qapi/qobject-output-visitor.c index 5f81146e..cc8c85b5 100644 --- a/qemu/qapi/qobject-output-visitor.c +++ b/qemu/qapi/qobject-output-visitor.c @@ -196,7 +196,7 @@ static void qobject_output_type_any(Visitor *v, const char *name, QObject **obj, static void qobject_output_type_null(Visitor *v, const char *name, Error **errp) { QObjectOutputVisitor *qov = to_qov(v); - qobject_output_add_obj(qov, name, qnull()); + qobject_output_add(qov, name, qnull()); } /* Finish building, and return the root object. diff --git a/qemu/qobject/qnull.c b/qemu/qobject/qnull.c index 69cd1b34..cb3eeec5 100644 --- a/qemu/qobject/qnull.c +++ b/qemu/qobject/qnull.c @@ -13,7 +13,9 @@ #include "qemu-common.h" #include "qapi/qmp/qobject.h" -QObject qnull_ = { - QTYPE_QNULL, - 1, +QNull qnull_ = { + { + QTYPE_QNULL, + 1, + } };