Calculate req_json only if trace_handle_qmp_command enabled.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>
---
 monitor.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index 6d040e620f..3606a7928b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3823,7 +3823,7 @@ static void handle_qmp_command(JSONMessageParser *parser, 
GQueue *tokens)
     QDict *qdict = NULL;
     Monitor *mon = cur_mon;
     Error *err = NULL;
-    QString *req_json;
+    QString *req_json = NULL;
 
     req = json_parser_parse_err(tokens, NULL, &err);
     if (!req && !err) {
@@ -3841,8 +3841,8 @@ static void handle_qmp_command(JSONMessageParser *parser, 
GQueue *tokens)
         qdict_del(qdict, "id");
     } /* else will fail qmp_dispatch() */
 
-    req_json = qobject_to_json(req);
-    trace_handle_qmp_command(mon, qstring_get_str(req_json));
+    trace_handle_qmp_command(mon,
+                             qstring_get_str(req_json = qobject_to_json(req)));
     QDECREF(req_json);
 
     rsp = qmp_dispatch(cur_mon->qmp.commands, req);
-- 
2.11.1


Reply via email to