qemu-devel
[Top][All Lists]
Advanced

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

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


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 18/26] object: return self in object_ref()
Date: Fri, 10 Jan 2020 20:22:54 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2

On 1/10/20 4:30 PM, Marc-André Lureau wrote:
This allow for simpler assignment with ref: foo = object_ref(bar)

Signed-off-by: Marc-André Lureau <address@hidden>

Reviewed-by: Philippe Mathieu-Daudé <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 ead9129ac8..933e5c6cb9 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -1013,8 +1013,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 3924678ec3..9f76a330ff 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1098,12 +1098,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)





reply via email to

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