mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
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>
This commit is contained in:
parent
3d3eacaecc
commit
cb3e7f08ae
94 changed files with 609 additions and 613 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue