[PATCH 09/10] qemuMigrationSrcNBDStorageCopyOne: Refactor cleanup

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

 



Autofree the temporary string and shuffle around the success path to
avoid the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_migration.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 3650de3de8..69bcdafdf8 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1035,7 +1035,7 @@ qemuMigrationSrcNBDStorageCopyOne(virQEMUDriver *driver,
     qemuDomainObjPrivate *priv = vm->privateData;
     qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
     qemuBlockJobData *job = NULL;
-    char *diskAlias = NULL;
+    g_autofree char *diskAlias = NULL;
     const char *jobname = NULL;
     const char *sourcename = NULL;
     bool persistjob = false;
@@ -1044,10 +1044,10 @@ qemuMigrationSrcNBDStorageCopyOne(virQEMUDriver *driver,
     int ret = -1;

     if (!(diskAlias = qemuAliasDiskDriveFromDisk(disk)))
-        goto cleanup;
+        return -1;

     if (!(job = qemuBlockJobDiskNew(vm, disk, QEMU_BLOCKJOB_TYPE_COPY, diskAlias)))
-        goto cleanup;
+        return -1;

     if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
         jobname = diskAlias;
@@ -1079,17 +1079,13 @@ qemuMigrationSrcNBDStorageCopyOne(virQEMUDriver *driver,
                                                        mirror_shallow);
     }

-    if (rc < 0)
-        goto cleanup;
-
-    diskPriv->migrating = true;
-    qemuBlockJobStarted(job, vm);
-
-    ret = 0;
+    if (rc == 0) {
+        diskPriv->migrating = true;
+        qemuBlockJobStarted(job, vm);
+        ret = 0;
+    }

- cleanup:
     qemuBlockJobStartupFinalize(vm, job);
-    VIR_FREE(diskAlias);
     return ret;
 }

-- 
2.35.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