[PATCH 01/13] qemu_monitor_json: Don't check for qemuMonitorNextCommandID() retval

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_monitor_json.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index a7a980fccd..dcf9186191 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -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;
-- 
2.32.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux