summaryrefslogtreecommitdiff
path: root/qapi
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-03-17 12:54:47 +0100
committerMarkus Armbruster <armbru@redhat.com>2020-03-17 21:25:47 +0100
commitd3226035630c6f0805ed26c77011e49565029cb0 (patch)
tree3f7def074764eef8f8c7ac38e633a1013f2bcd43 /qapi
parentcf4a0643c8ab7d503465bd3f725369b630ea5001 (diff)
downloadqemu-d3226035630c6f0805ed26c77011e49565029cb0.zip
qapi: Simplify how qmp_dispatch() deals with QCO_NO_SUCCESS_RESP
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20200317115459.31821-23-armbru@redhat.com>
Diffstat (limited to 'qapi')
-rw-r--r--qapi/qmp-dispatch.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index a588072523..550d1fe8d2 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -106,7 +106,7 @@ QDict *qmp_dispatch(QmpCommandList *cmds, QObject *request,
QDict *dict = qobject_to(QDict, request);
QObject *id = dict ? qdict_get(dict, "id") : NULL;
QObject *ret = NULL;
- QDict *rsp;
+ QDict *rsp = NULL;
dict = qmp_dispatch_check_obj(request, allow_oob, &err);
if (!dict) {
@@ -151,31 +151,32 @@ QDict *qmp_dispatch(QmpCommandList *cmds, QObject *request,
args = qdict_get_qdict(dict, "arguments");
qobject_ref(args);
}
-
cmd->fn(args, &ret, &err);
+ qobject_unref(args);
if (err) {
- ;
- } else if (cmd->options & QCO_NO_SUCCESS_RESP) {
+ goto out;
+ }
+
+ if (cmd->options & QCO_NO_SUCCESS_RESP) {
g_assert(!ret);
+ return NULL;
} else if (!ret) {
/* TODO turn into assertion */
ret = QOBJECT(qdict_new());
}
- qobject_unref(args);
+ rsp = qdict_new();
+ qdict_put_obj(rsp, "return", ret);
out:
if (err) {
+ assert(!rsp);
rsp = qmp_error_response(err);
- } else if (ret) {
- rsp = qdict_new();
- qdict_put_obj(rsp, "return", ret);
- } else {
- /* Can only happen for commands with QCO_NO_SUCCESS_RESP */
- rsp = NULL;
}
- if (rsp && id) {
+ assert(rsp);
+
+ if (id) {
qdict_put_obj(rsp, "id", qobject_ref(id));
}