[PATCH 03/13] qemuMonitorJSONHumanCommand: Require @reply_str

Michal Privoznik mprivozn at redhat.com
Mon Oct 25 10:57:27 UTC 2021


All callers of qemuMonitorJSONHumanCommand() pass a non-NULL pointer
as @reply_str therefore there's no need to check whether it is NULL.
NB, the sister function (qemuMonitorJSONArbitraryCommand()) doesn't
check for NULL either.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_monitor_json.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 6d8ccd91e8..7833038a06 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1470,6 +1470,7 @@ qemuMonitorJSONHumanCommand(qemuMonitor *mon,
     virJSONValue *cmd = NULL;
     virJSONValue *reply = NULL;
     virJSONValue *obj;
+    const char *data;
     int ret = -1;
 
     cmd = qemuMonitorJSONMakeCommand("human-monitor-command",
@@ -1490,13 +1491,8 @@ qemuMonitorJSONHumanCommand(qemuMonitor *mon,
         goto cleanup;
 
     obj = virJSONValueObjectGet(reply, "return");
-
-    if (reply_str) {
-        const char *data;
-
-        data = virJSONValueGetString(obj);
-        *reply_str = g_strdup(NULLSTR_EMPTY(data));
-    }
+    data = virJSONValueGetString(obj);
+    *reply_str = g_strdup(NULLSTR_EMPTY(data));
 
     ret = 0;
 
-- 
2.32.0




More information about the libvir-list mailing list