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

[libvirt] [PATCH 39/55] qemu: driver: Don't copy disk alias in qemuDomainBlocksStatsGather



The string is not modified so it does not make sense to have a copy.

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

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7541beb718..c941e502e5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11085,7 +11085,7 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
     virHashTablePtr blockstats = NULL;
     qemuBlockStatsPtr stats;
     int nstats;
-    char *diskAlias = NULL;
+    const char *entryname = NULL;
     int ret = -1;

     if (*path) {
@@ -11100,8 +11100,7 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
             goto cleanup;
         }

-        if (VIR_STRDUP(diskAlias, disk->info.alias) < 0)
-            goto cleanup;
+        entryname = disk->info.alias;
     }

     qemuDomainObjEnterMonitor(driver, vm);
@@ -11117,10 +11116,10 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
     if (VIR_ALLOC(*retstats) < 0)
         goto cleanup;

-    if (diskAlias) {
-        if (!(stats = virHashLookup(blockstats, diskAlias))) {
+    if (entryname) {
+        if (!(stats = virHashLookup(blockstats, entryname))) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("cannot find statistics for device '%s'"), diskAlias);
+                           _("cannot find statistics for device '%s'"), entryname);
             goto cleanup;
         }

@@ -11132,7 +11131,6 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
     ret = nstats;

  cleanup:
-    VIR_FREE(diskAlias);
     virHashFree(blockstats);
     return ret;
 }
-- 
2.16.2


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