]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: driver: Don't copy disk alias in qemuDomainBlocksStatsGather
authorPeter Krempa <pkrempa@redhat.com>
Fri, 3 Aug 2018 12:50:06 +0000 (14:50 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 21 Aug 2018 13:46:06 +0000 (15:46 +0200)
The string is not modified so it does not make sense to have a copy.

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

index c7b58923ef138f8fb70dc0aeac9d549833f9046f..ad66f6ae7249b6117db6043d6a768b8c04e08505 100644 (file)
@@ -11069,7 +11069,7 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
     virHashTablePtr blockstats = NULL;
     qemuBlockStatsPtr stats;
     int nstats;
-    char *diskAlias = NULL;
+    const char *entryname = NULL;
     int ret = -1;
 
     if (*path) {
@@ -11084,8 +11084,7 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
             goto cleanup;
         }
 
-        if (VIR_STRDUP(diskAlias, disk->info.alias) < 0)
-            goto cleanup;
+        entryname = disk->info.alias;
     }
 
     qemuDomainObjEnterMonitor(driver, vm);
@@ -11101,10 +11100,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;
         }
 
@@ -11116,7 +11115,6 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
     ret = nstats;
 
  cleanup:
-    VIR_FREE(diskAlias);
     virHashFree(blockstats);
     return ret;
 }