[PATCH v1 16/25] qemu_migration_cookie.c: modernize qemuMigrationEatCookie()

Daniel Henrique Barboza danielhb413 at gmail.com
Mon Jul 13 09:49:48 UTC 2020


Use g_autoptr() and remove the obsolete 'error' label.

Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
---
 src/qemu/qemu_migration_cookie.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 2e48d1b524..81b557e0a8 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -1464,14 +1464,14 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
                        int cookieinlen,
                        unsigned int flags)
 {
-    qemuMigrationCookiePtr mig = NULL;
+    g_autoptr(qemuMigrationCookie) mig = NULL;
 
     /* Parse & validate incoming cookie (if any) */
     if (cookiein && cookieinlen &&
         cookiein[cookieinlen-1] != '\0') {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Migration cookie was not NULL terminated"));
-        goto error;
+        return NULL;
     }
 
     VIR_DEBUG("cookielen=%d cookie='%s'", cookieinlen, NULLSTR(cookiein));
@@ -1485,7 +1485,7 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
                                        priv ? priv->qemuCaps : NULL,
                                        cookiein,
                                        flags) < 0)
-        goto error;
+        return NULL;
 
     if (flags & QEMU_MIGRATION_COOKIE_PERSISTENT &&
         mig->persistent &&
@@ -1500,7 +1500,7 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
                 virReportError(VIR_ERR_INTERNAL_ERROR,
                                _("Missing %s lock state for migration cookie"),
                                virLockManagerPluginGetName(driver->lockManager));
-                goto error;
+                return NULL;
             }
         } else if (STRNEQ(mig->lockDriver,
                           virLockManagerPluginGetName(driver->lockManager))) {
@@ -1508,16 +1508,12 @@ qemuMigrationEatCookie(virQEMUDriverPtr driver,
                            _("Source host lock driver %s different from target %s"),
                            mig->lockDriver,
                            virLockManagerPluginGetName(driver->lockManager));
-            goto error;
+            return NULL;
         }
     }
 
     if (flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo)
         mig->jobInfo->operation = priv->job.current->operation;
 
-    return mig;
-
- error:
-    qemuMigrationCookieFree(mig);
-    return NULL;
+    return g_steal_pointer(&mig);
 }
-- 
2.26.2




More information about the libvir-list mailing list