]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: monitor: Refactor cleanup in qemuMonitorJSONGetAllBlockStatsInfo
authorPeter Krempa <pkrempa@redhat.com>
Mon, 16 Sep 2019 14:19:33 +0000 (16:19 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 25 Sep 2019 11:02:48 +0000 (13:02 +0200)
Use VIR_AUTOPTR and get rid of the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_monitor_json.c

index 8fb3b5bc086302e4560e8a36bba690fafb3d4b9d..a590bd7d6a47e3d42ac12e371343611509efe8f8 100644 (file)
@@ -2676,11 +2676,10 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
                                     virHashTablePtr hash,
                                     bool backingChain)
 {
-    int ret = -1;
     int nstats = 0;
     int rc;
     size_t i;
-    virJSONValuePtr devices;
+    VIR_AUTOPTR(virJSONValue) devices = NULL;
 
     if (!(devices = qemuMonitorJSONQueryBlockstats(mon)))
         return -1;
@@ -2693,14 +2692,14 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("blockstats device entry was not "
                              "in expected format"));
-            goto cleanup;
+            return -1;
         }
 
         if (!(dev_name = virJSONValueObjectGetString(dev, "device"))) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("blockstats device entry was not "
                              "in expected format"));
-            goto cleanup;
+            return -1;
         }
 
         if (*dev_name == '\0')
@@ -2710,17 +2709,13 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
                                                  backingChain);
 
         if (rc < 0)
-            goto cleanup;
+            return -1;
 
         if (rc > nstats)
             nstats = rc;
     }
 
-    ret = nstats;
-
- cleanup:
-    virJSONValueFree(devices);
-    return ret;
+    return nstats;
 }