qapi: Separate type QNull from QObject

Backports commit 006ca09f3027d86346fce707e9295975c6558f42 from qemu
This commit is contained in:
Markus Armbruster 2018-03-07 16:43:41 -05:00 committed by Lioncash
parent 566b097b85
commit 3fd0ff8aa7
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 13 additions and 7 deletions

View file

@ -99,11 +99,15 @@ static inline QType qobject_type(const QObject *obj)
return obj->type; 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_; return &qnull_;
} }

View file

@ -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) static void qobject_output_type_null(Visitor *v, const char *name, Error **errp)
{ {
QObjectOutputVisitor *qov = to_qov(v); 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. /* Finish building, and return the root object.

View file

@ -13,7 +13,9 @@
#include "qemu-common.h" #include "qemu-common.h"
#include "qapi/qmp/qobject.h" #include "qapi/qmp/qobject.h"
QObject qnull_ = { QNull qnull_ = {
{
QTYPE_QNULL, QTYPE_QNULL,
1, 1,
}
}; };