[libvirt] [PATCH 12/22] qemu: monitor: Refactor cleanup in qemuMonitorJSONGetAllBlockStatsInfo

Peter Krempa posted 22 patches 6 years, 4 months ago
[libvirt] [PATCH 12/22] qemu: monitor: Refactor cleanup in qemuMonitorJSONGetAllBlockStatsInfo
Posted by Peter Krempa 6 years, 4 months ago
Use VIR_AUTOPTR and get rid of the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_monitor_json.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 8d0ef62c8b..9be122a465 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2678,11 +2678,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;
@@ -2695,14 +2694,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')
@@ -2712,17 +2711,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;
 }


-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 12/22] qemu: monitor: Refactor cleanup in qemuMonitorJSONGetAllBlockStatsInfo
Posted by Ján Tomko 6 years, 4 months ago
On Thu, Sep 19, 2019 at 07:13:15PM +0200, Peter Krempa wrote:
>Use VIR_AUTOPTR and get rid of the cleanup label.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_monitor_json.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list