aboutsummaryrefslogtreecommitdiff
path: root/tests/test-qmp-cmds.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2018-07-03 10:53:49 +0200
committerMarkus Armbruster <armbru@redhat.com>2018-07-03 23:18:56 +0200
commitd43b16945afa8457b03aee543a110c4ff0b7f070 (patch)
tree3639afe23f1067412e3eaa6baa2bf345ef2b5fc1 /tests/test-qmp-cmds.c
parentcee32796cadc9510ee00f029a933009df7a28ae2 (diff)
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>
Diffstat (limited to 'tests/test-qmp-cmds.c')
-rw-r--r--tests/test-qmp-cmds.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/tests/test-qmp-cmds.c b/tests/test-qmp-cmds.c
index 10c7ba40c1..afb338a61e 100644
--- a/tests/test-qmp-cmds.c
+++ b/tests/test-qmp-cmds.c
@@ -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;
}