aboutsummaryrefslogtreecommitdiff
path: root/include/qapi
diff options
context:
space:
mode:
Diffstat (limited to 'include/qapi')
-rw-r--r--include/qapi/qmp/qnull.h3
-rw-r--r--include/qapi/qmp/qobject.h9
2 files changed, 9 insertions, 3 deletions
diff --git a/include/qapi/qmp/qnull.h b/include/qapi/qmp/qnull.h
index 75b29c6a39..c1426882c5 100644
--- a/include/qapi/qmp/qnull.h
+++ b/include/qapi/qmp/qnull.h
@@ -23,8 +23,7 @@ extern QNull qnull_;
static inline QNull *qnull(void)
{
- qobject_ref(&qnull_);
- return &qnull_;
+ return qobject_ref(&qnull_);
}
bool qnull_is_equal(const QObject *x, const QObject *y);
diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h
index e20006faf5..fcfd549220 100644
--- a/include/qapi/qmp/qobject.h
+++ b/include/qapi/qmp/qobject.h
@@ -103,8 +103,15 @@ static inline void qobject_unref_impl(QObject *obj)
/**
* qobject_ref(): Increment QObject's reference count
+ *
+ * Returns: the same @obj. The type of @obj will be propagated to the
+ * return type.
*/
-#define qobject_ref(obj) qobject_ref_impl(QOBJECT(obj))
+#define qobject_ref(obj) ({ \
+ typeof(obj) _o = (obj); \
+ qobject_ref_impl(QOBJECT(_o)); \
+ _o; \
+})
/**
* qobject_unref(): Decrement QObject's reference count, deallocate