mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
qmp: Use QDict * instead of QObject * for response objects
By using the more specific type, we get fewer downcasts. The downcasts are safe, but not obviously so, at least not locally. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180703085358.13941-24-armbru@redhat.com>
This commit is contained in:
parent
cee32796ca
commit
d43b16945a
5 changed files with 32 additions and 34 deletions
|
@ -98,13 +98,13 @@ __org_qemu_x_Union1 *qmp___org_qemu_x_command(__org_qemu_x_EnumList *a,
|
|||
static void test_dispatch_cmd(void)
|
||||
{
|
||||
QDict *req = qdict_new();
|
||||
QObject *resp;
|
||||
QDict *resp;
|
||||
|
||||
qdict_put_str(req, "execute", "user_def_cmd");
|
||||
|
||||
resp = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
|
||||
assert(resp != NULL);
|
||||
assert(!qdict_haskey(qobject_to(QDict, resp), "error"));
|
||||
assert(!qdict_haskey(resp, "error"));
|
||||
|
||||
qobject_unref(resp);
|
||||
qobject_unref(req);
|
||||
|
@ -115,13 +115,13 @@ static void test_dispatch_cmd_failure(void)
|
|||
{
|
||||
QDict *req = qdict_new();
|
||||
QDict *args = qdict_new();
|
||||
QObject *resp;
|
||||
QDict *resp;
|
||||
|
||||
qdict_put_str(req, "execute", "user_def_cmd2");
|
||||
|
||||
resp = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
|
||||
assert(resp != NULL);
|
||||
assert(qdict_haskey(qobject_to(QDict, resp), "error"));
|
||||
assert(qdict_haskey(resp, "error"));
|
||||
|
||||
qobject_unref(resp);
|
||||
qobject_unref(req);
|
||||
|
@ -135,7 +135,7 @@ static void test_dispatch_cmd_failure(void)
|
|||
|
||||
resp = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
|
||||
assert(resp != NULL);
|
||||
assert(qdict_haskey(qobject_to(QDict, resp), "error"));
|
||||
assert(qdict_haskey(resp, "error"));
|
||||
|
||||
qobject_unref(resp);
|
||||
qobject_unref(req);
|
||||
|
@ -143,18 +143,15 @@ static void test_dispatch_cmd_failure(void)
|
|||
|
||||
static QObject *test_qmp_dispatch(QDict *req)
|
||||
{
|
||||
QObject *resp_obj;
|
||||
QDict *resp;
|
||||
QObject *ret;
|
||||
|
||||
resp_obj = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
|
||||
assert(resp_obj);
|
||||
resp = qobject_to(QDict, resp_obj);
|
||||
resp = qmp_dispatch(&qmp_commands, QOBJECT(req), false);
|
||||
assert(resp && !qdict_haskey(resp, "error"));
|
||||
ret = qdict_get(resp, "return");
|
||||
assert(ret);
|
||||
qobject_ref(ret);
|
||||
qobject_unref(resp_obj);
|
||||
qobject_unref(resp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue