aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2018-07-03 10:53:48 +0200
committerMarkus Armbruster <armbru@redhat.com>2018-07-03 23:18:56 +0200
commitcee32796cadc9510ee00f029a933009df7a28ae2 (patch)
tree1fb09ff3405d4ca4b75afc6304047f7376dd1ece /monitor.c
parenta193352ff9c7cd2cd07846118bc49921d0f53af8 (diff)
qmp: De-duplicate error response building
All callers of qmp_build_error_object() duplicate the code to wrap it in a response object. Replace it by qmp_error_response() that captures the duplicated code, including error_free(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180703085358.13941-23-armbru@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/monitor.c b/monitor.c
index 26de90e4d2..6284efe33e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4107,14 +4107,9 @@ static int monitor_can_read(void *opaque)
static void monitor_qmp_respond(Monitor *mon, QObject *rsp,
Error *err, QObject *id)
{
- QDict *qdict = NULL;
-
if (err) {
assert(!rsp);
- qdict = qdict_new();
- qdict_put_obj(qdict, "error", qmp_build_error_object(err));
- error_free(err);
- rsp = QOBJECT(qdict);
+ rsp = QOBJECT(qmp_error_response(err));
}
if (rsp) {