From: Marc-André Lureau Date: Fri, 10 Jan 2020 15:30:31 +0000 (+0400) Subject: object: return self in object_ref() X-Git-Tag: v5.0.0-rc0~125^2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b77ade9bb37b2e9813a42008cb21d0c743aa50a1;p=thirdparty%2Fqemu.git object: return self in object_ref() This allow for simpler assignment with ref: foo = object_ref(bar) Signed-off-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200110153039.1379601-19-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- diff --git a/include/qom/object.h b/include/qom/object.h index 5e2f60d4b07..18660fde1c7 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1005,8 +1005,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 66c4a5f1cb4..555c8b9d07e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1107,12 +1107,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)