qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 18/26] object: return self in object_ref()


From: Marc-André Lureau
Subject: [PATCH 18/26] object: return self in object_ref()
Date: Sun, 1 Dec 2019 15:15:23 +0400

This allow for simpler assignment with ref: foo = object_ref(bar)

Signed-off-by: Marc-André Lureau <address@hidden>
---
 include/qom/object.h | 3 ++-
 qom/object.c         | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/qom/object.h b/include/qom/object.h
index 6cafc5f368..aa2cf1ca75 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -994,8 +994,9 @@ GSList *object_class_get_list_sorted(const char 
*implements_type,
  *
  * Increase the reference count of a object.  A object cannot be freed as long
  * as its reference count is greater than zero.
+ * Returns: @obj
  */
-void object_ref(Object *obj);
+Object *object_ref(Object *obj);
 
 /**
  * object_unref:
diff --git a/qom/object.c b/qom/object.c
index 10acf9bff9..c01cd54243 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1074,12 +1074,13 @@ GSList *object_class_get_list_sorted(const char 
*implements_type,
                         object_class_cmp);
 }
 
-void object_ref(Object *obj)
+Object *object_ref(Object *obj)
 {
     if (!obj) {
-        return;
+        return NULL;
     }
     atomic_inc(&obj->ref);
+    return obj;
 }
 
 void object_unref(Object *obj)
-- 
2.24.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]