[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 09/25] qmp: simplify qmp_return_error()
From: |
Marc-André Lureau |
Subject: |
[PATCH v6 09/25] qmp: simplify qmp_return_error() |
Date: |
Fri, 8 Nov 2019 19:01:07 +0400 |
It's simple, probably more efficient, to hand-craft the dict.
Signed-off-by: Marc-André Lureau <address@hidden>
---
qapi/qmp-dispatch.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index 188b5680b6..fcf6cb0bf8 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -50,10 +50,10 @@ void qmp_return(QmpReturn *qret, QObject *rsp)
void qmp_return_error(QmpReturn *qret, Error *err)
{
- qdict_put_obj(qret->rsp, "error",
- qobject_from_jsonf_nofail("{ 'class': %s, 'desc': %s }",
- QapiErrorClass_str(error_get_class(err)),
- error_get_pretty(err)));
+ QDict *qdict = qdict_new();
+ qdict_put_str(qdict, "class", QapiErrorClass_str(error_get_class(err)));
+ qdict_put_str(qdict, "desc", error_get_pretty(err));
+ qdict_put_obj(qret->rsp, "error", QOBJECT(qdict));
error_free(err);
qret->session->return_cb(qret->session, qret->rsp);
qmp_return_free(qret);
--
2.24.0
- [PATCH v6 01/25] qmp: constify QmpCommand and list, (continued)
- [PATCH v6 01/25] qmp: constify QmpCommand and list, Marc-André Lureau, 2019/11/08
- [PATCH v6 02/25] json-lexer: make it safe to call destroy multiple times, Marc-André Lureau, 2019/11/08
- [PATCH v6 03/25] qmp: add QmpSession, Marc-André Lureau, 2019/11/08
- [PATCH v6 04/25] QmpSession: add a return callback, Marc-André Lureau, 2019/11/08
- [PATCH v6 05/25] QmpSession: add json parser and use it in qga, Marc-André Lureau, 2019/11/08
- [PATCH v6 06/25] monitor: use qmp session to parse json feed, Marc-André Lureau, 2019/11/08
- [PATCH v6 07/25] qga: simplify dispatch_return_cb, Marc-André Lureau, 2019/11/08
- [PATCH v6 08/25] QmpSession: introduce QmpReturn, Marc-André Lureau, 2019/11/08
- [PATCH v6 09/25] qmp: simplify qmp_return_error(),
Marc-André Lureau <=
- [PATCH v6 10/25] QmpSession: keep a queue of pending commands, Marc-André Lureau, 2019/11/08
- [PATCH v6 11/25] QmpSession: return orderly, Marc-André Lureau, 2019/11/08
- [PATCH v6 12/25] qmp: introduce asynchronous command type, Marc-André Lureau, 2019/11/08
- [PATCH v6 14/25] qmp: add qmp_return_is_cancelled(), Marc-André Lureau, 2019/11/08
- [PATCH v6 13/25] scripts: learn 'async' qapi commands, Marc-André Lureau, 2019/11/08
- [PATCH v6 15/25] console: add graphic_hw_update_done(), Marc-André Lureau, 2019/11/08
- [PATCH v6 16/25] ppm-save: pass opened fd, Marc-André Lureau, 2019/11/08
- [PATCH v6 17/25] ui: add pixman image g_autoptr support, Marc-André Lureau, 2019/11/08
- [PATCH v6 18/25] object: add g_autoptr support, Marc-André Lureau, 2019/11/08
- [PATCH v6 19/25] screendump: replace FILE with QIOChannel and fix close()/qemu_close(), Marc-André Lureau, 2019/11/08