]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_monitor_json: Don't check for qemuMonitorNextCommandID() retval
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 21 Oct 2021 10:52:14 +0000 (12:52 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 25 Oct 2021 11:41:25 +0000 (13:41 +0200)
The qemuMonitorNextCommandID() function can never fail. There's
no need to check for its retval then. Moreover, the temporary
variable used to hold the retval can be declared in the inner
most block.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
src/qemu/qemu_monitor_json.c

index a7a980fccd33be4f53257b4585691dfd662bceef..dcf9186191a05047d8fd7dcca358b87cc982f47c 100644 (file)
@@ -302,15 +302,14 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon,
     int ret = -1;
     qemuMonitorMessage msg;
     g_auto(virBuffer) cmdbuf = VIR_BUFFER_INITIALIZER;
-    char *id = NULL;
 
     *reply = NULL;
 
     memset(&msg, 0, sizeof(msg));
 
     if (virJSONValueObjectHasKey(cmd, "execute") == 1) {
-        if (!(id = qemuMonitorNextCommandID(mon)))
-            goto cleanup;
+        g_autofree char *id = qemuMonitorNextCommandID(mon);
+
         if (virJSONValueObjectAppendString(cmd, "id", id) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("Unable to append command 'id' string"));
@@ -339,7 +338,6 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon,
     }
 
  cleanup:
-    VIR_FREE(id);
     VIR_FREE(msg.txBuffer);
 
     return ret;