[PATCH 19/20] qemuMigrationCookieXMLParse: Avoid VIR_FREE when parsing lockstate

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

 



Restructure the control-flow a bit using an temporary variable to avoid
the need to use VIR_FREE.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_migration_cookie.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 93d91b8a1c..84274301dc 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -1218,15 +1218,18 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,

     if ((flags & QEMU_MIGRATION_COOKIE_LOCKSTATE) &&
         virXPathBoolean("count(./lockstate) > 0", ctxt)) {
+        g_autofree char *lockState = NULL;
+
         mig->lockDriver = virXPathString("string(./lockstate[1]/@driver)", ctxt);
         if (!mig->lockDriver) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("Missing lock driver name in migration cookie"));
             return -1;
         }
-        mig->lockState = virXPathString("string(./lockstate[1]/leases[1])", ctxt);
-        if (mig->lockState && STREQ(mig->lockState, ""))
-            VIR_FREE(mig->lockState);
+
+        lockState = virXPathString("string(./lockstate[1]/leases[1])", ctxt);
+        if (STRNEQ_NULLABLE(lockState, ""))
+            mig->lockState = g_steal_pointer(&lockState);
     }

     if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
-- 
2.26.2




[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