[PATCH 04/20] qemuMigrationCookieXMLParse: Decrease scope of 'nodes' and use automatic freeing

Peter Krempa pkrempa at redhat.com
Fri Oct 2 08:57:38 UTC 2020


Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_migration_cookie.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 9b1268833a..a9dd2b9323 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -1214,7 +1214,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
     g_autofree char *uuid = NULL;
     g_autofree char *hostuuid = NULL;
     char localdomuuid[VIR_UUID_STRING_BUFLEN];
-    xmlNodePtr *nodes = NULL;

     /* We don't store the uuid, name, hostname, or hostuuid
      * values. We just compare them to local data to do some
@@ -1299,6 +1298,8 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,

     if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
         virXPathBoolean("count(./domain) > 0", ctxt)) {
+        g_autofree xmlNodePtr *nodes = NULL;
+
         if ((virXPathNodeSet("./domain", ctxt, &nodes)) != 1) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("Too many domain elements in migration cookie"));
@@ -1314,7 +1315,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
              * an error for us */
             goto error;
         }
-        VIR_FREE(nodes);
     }

     if ((flags & QEMU_MIGRATION_COOKIE_NETWORK) &&
@@ -1347,7 +1347,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
     return 0;

  error:
-    VIR_FREE(nodes);
     return -1;
 }

-- 
2.26.2




More information about the libvir-list mailing list