diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2018-04-19 17:01:43 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2018-05-04 08:27:53 +0200 |
commit | cb3e7f08aeaab0ab13e629ce8496dca150a449ba (patch) | |
tree | 189830b93bea625aac19f86f26dc4b04cd99f5a3 /tests/test-qmp-cmds.c | |
parent | 3d3eacaeccaab718ea0e2ddaa578bfae9e311c59 (diff) | |
download | qemu-cb3e7f08aeaab0ab13e629ce8496dca150a449ba.zip qemu-cb3e7f08aeaab0ab13e629ce8496dca150a449ba.tar.gz qemu-cb3e7f08aeaab0ab13e629ce8496dca150a449ba.tar.bz2 |
qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF
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 <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180419150145.24795-4-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, semantic conflict resolved, commit message improved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'tests/test-qmp-cmds.c')
-rw-r--r-- | tests/test-qmp-cmds.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c index db690cc..e0ed461 100644 --- a/tests/test-qmp-cmds.c +++ b/tests/test-qmp-cmds.c @@ -106,8 +106,8 @@ static void test_dispatch_cmd(void) assert(resp != NULL); assert(!qdict_haskey(qobject_to(QDict, resp), "error")); - qobject_decref(resp); - QDECREF(req); + qobject_unref(resp); + qobject_unref(req); } /* test commands that return an error due to invalid parameters */ @@ -123,8 +123,8 @@ static void test_dispatch_cmd_failure(void) assert(resp != NULL); assert(qdict_haskey(qobject_to(QDict, resp), "error")); - qobject_decref(resp); - QDECREF(req); + qobject_unref(resp); + qobject_unref(req); /* check that with extra arguments it throws an error */ req = qdict_new(); @@ -137,8 +137,8 @@ static void test_dispatch_cmd_failure(void) assert(resp != NULL); assert(qdict_haskey(qobject_to(QDict, resp), "error")); - qobject_decref(resp); - QDECREF(req); + qobject_unref(resp); + qobject_unref(req); } static QObject *test_qmp_dispatch(QDict *req) @@ -153,8 +153,8 @@ static QObject *test_qmp_dispatch(QDict *req) assert(resp && !qdict_haskey(resp, "error")); ret = qdict_get(resp, "return"); assert(ret); - qobject_incref(ret); - qobject_decref(resp_obj); + qobject_ref(ret); + qobject_unref(resp_obj); return ret; } @@ -195,7 +195,7 @@ static void test_dispatch_cmd_io(void) assert(qdict_get_int(ret_dict_dict2_userdef, "integer") == 422); assert(!strcmp(qdict_get_str(ret_dict_dict2_userdef, "string"), "hello2")); assert(!strcmp(qdict_get_str(ret_dict_dict2, "string"), "blah4")); - QDECREF(ret); + qobject_unref(ret); qdict_put_int(args3, "a", 66); qdict_put(req, "arguments", args3); @@ -204,9 +204,9 @@ static void test_dispatch_cmd_io(void) ret3 = qobject_to(QNum, test_qmp_dispatch(req)); g_assert(qnum_get_try_int(ret3, &val)); g_assert_cmpint(val, ==, 66); - QDECREF(ret3); + qobject_unref(ret3); - QDECREF(req); + qobject_unref(req); } /* test generated dealloc functions for generated types */ @@ -257,7 +257,7 @@ static void test_dealloc_partial(void) v = qobject_input_visitor_new(QOBJECT(ud2_dict)); visit_type_UserDefTwo(v, NULL, &ud2, &err); visit_free(v); - QDECREF(ud2_dict); + qobject_unref(ud2_dict); } /* verify that visit_type_XXX() cleans up properly on error */ |