[libvirt PATCH 03/10] qemuMonitorGetAllBlockStatsInfo: Assign hash table only on success

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

 



`virHashNew` cannot return NULL, the check is not needed.

Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/qemu/qemu_monitor.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 19fcc5658b..86aabc98c3 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2155,23 +2155,23 @@ qemuMonitorGetAllBlockStatsInfo(qemuMonitor *mon,
                                 bool backingChain)
 {
     int ret;
+    GHashTable *stats = virHashNew(g_free);
+
     VIR_DEBUG("ret_stats=%p, backing=%d", ret_stats, backingChain);
 
     QEMU_CHECK_MONITOR(mon);
 
-    if (!(*ret_stats = virHashNew(g_free)))
-        goto error;
-
-    ret = qemuMonitorJSONGetAllBlockStatsInfo(mon, *ret_stats, backingChain);
+    *ret_stats = NULL;
+    ret = qemuMonitorJSONGetAllBlockStatsInfo(mon, stats, backingChain);
 
     if (ret < 0)
         goto error;
 
+    *ret_stats = stats;
     return ret;
 
  error:
-    virHashFree(*ret_stats);
-    *ret_stats = NULL;
+    virHashFree(stats);
     return -1;
 }
 
-- 
2.31.1




[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