summaryrefslogtreecommitdiff
path: root/include/qapi/qmp/qobject.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/qapi/qmp/qobject.h')
-rw-r--r--include/qapi/qmp/qobject.h9
1 files changed, 8 insertions, 1 deletions
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