[PATCH 3/3] qemuMigrationDstStartNBDServer: Refactor cleanup

Peter Krempa posted 3 patches 12 months ago
[PATCH 3/3] qemuMigrationDstStartNBDServer: Refactor cleanup
Posted by Peter Krempa 12 months ago
There's nothing under the 'cleanup:' label thus the whole code can be
simplified.

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

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 182e51f0f0..832cbd1c17 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -541,7 +541,6 @@ qemuMigrationDstStartNBDServer(virQEMUDriver *driver,
                                const char *nbdURI,
                                const char *tls_alias)
 {
-    int ret = -1;
     qemuDomainObjPrivate *priv = vm->privateData;
     size_t i;
     virStorageNetHostDef server = {
@@ -610,22 +609,22 @@ qemuMigrationDstStartNBDServer(virQEMUDriver *driver,
             virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
                            _("Cannot migrate empty or read-only disk %1$s"),
                            disk->dst);
-            goto cleanup;
+            return -1;
         }

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

         if (!server_started &&
             server.transport == VIR_STORAGE_NET_HOST_TRANS_TCP) {
             if (server.port) {
                 if (virPortAllocatorSetUsed(server.port) < 0)
-                    goto cleanup;
+                    return -1;
             } else {
                 unsigned short port = 0;

                 if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0)
-                    goto cleanup;
+                    return -1;

                 server.port = port;
             }
@@ -635,7 +634,7 @@ qemuMigrationDstStartNBDServer(virQEMUDriver *driver,
         }

         if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_MIGRATION_IN) < 0)
-            goto cleanup;
+            return -1;

         if (!server_started) {
             if (qemuMonitorNBDServerStart(priv->mon, &server, tls_alias) < 0)
@@ -648,14 +647,11 @@ qemuMigrationDstStartNBDServer(virQEMUDriver *driver,
         qemuDomainObjExitMonitor(vm);
     }

-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;

  exit_monitor:
     qemuDomainObjExitMonitor(vm);
-    goto cleanup;
+    return -1;
 }


-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH 3/3] qemuMigrationDstStartNBDServer: Refactor cleanup
Posted by Andrea Bolognani 11 months, 3 weeks ago
On Tue, Jan 16, 2024 at 04:25:04PM +0100, Peter Krempa wrote:
> There's nothing under the 'cleanup:' label thus the whole code can be
> simplified.
>
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/qemu/qemu_migration.c | 18 +++++++-----------
>  1 file changed, 7 insertions(+), 11 deletions(-)

Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org