From cb3e7f08aeaab0ab13e629ce8496dca150a449ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 19 Apr 2018 17:01:43 +0200 Subject: qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that we can safely call QOBJECT() on QObject * as well as its subtypes, we can have macros qobject_ref() / qobject_unref() that work everywhere instead of having to use QINCREF() / QDECREF() for QObject and qobject_incref() / qobject_decref() for its subtypes. The replacement is mechanical, except I broke a long line, and added a cast in monitor_qmp_cleanup_req_queue_locked(). Unlike qobject_decref(), qobject_unref() doesn't accept void *. Note that the new macros evaluate their argument exactly once, thus no need to shout them. Signed-off-by: Marc-André Lureau Reviewed-by: Eric Blake Message-Id: <20180419150145.24795-4-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster [Rebased, semantic conflict resolved, commit message improved] Signed-off-by: Markus Armbruster --- tests/device-introspect-test.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tests/device-introspect-test.c') diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c index a01321aced..0b4f221c29 100644 --- a/tests/device-introspect-test.c +++ b/tests/device-introspect-test.c @@ -40,8 +40,8 @@ static QList *qom_list_types(const char *implements, bool abstract) " 'arguments': %p }", args); g_assert(qdict_haskey(resp, "return")); ret = qdict_get_qlist(resp, "return"); - QINCREF(ret); - QDECREF(resp); + qobject_ref(ret); + qobject_unref(resp); return ret; } @@ -54,7 +54,7 @@ static QDict *qom_type_index(QList *types) QLIST_FOREACH_ENTRY(types, e) { QDict *d = qobject_to(QDict, qlist_entry_obj(e)); const char *name = qdict_get_str(d, "name"); - QINCREF(d); + qobject_ref(d); qdict_put(index, name, d); } return index; @@ -108,7 +108,7 @@ static void test_one_device(const char *type) resp = qmp("{'execute': 'device-list-properties'," " 'arguments': {'typename': %s}}", type); - QDECREF(resp); + qobject_unref(resp); help = hmp("device_add \"%s,help\"", type); g_free(help); @@ -129,7 +129,7 @@ static void test_device_intro_list(void) qtest_start(common_args); types = device_type_list(true); - QDECREF(types); + qobject_unref(types); help = hmp("device_add help"); g_free(help); @@ -157,8 +157,8 @@ static void test_qom_list_parents(const char *parent) g_assert(qom_has_parent(index, name, parent)); } - QDECREF(types); - QDECREF(index); + qobject_unref(types); + qobject_unref(index); } static void test_qom_list_fields(void) @@ -187,8 +187,8 @@ static void test_qom_list_fields(void) test_qom_list_parents("device"); test_qom_list_parents("sys-bus-device"); - QDECREF(all_types); - QDECREF(non_abstract); + qobject_unref(all_types); + qobject_unref(non_abstract); qtest_end(); } @@ -222,7 +222,7 @@ static void test_device_intro_concrete(void) test_one_device(type); } - QDECREF(types); + qobject_unref(types); qtest_end(); } @@ -255,8 +255,8 @@ static void test_abstract_interfaces(void) g_assert(qdict_haskey(d, "abstract") && qdict_get_bool(d, "abstract")); } - QDECREF(all_types); - QDECREF(index); + qobject_unref(all_types); + qobject_unref(index); qtest_end(); } -- cgit v1.2.1