[libvirt PATCH 1/4] vz: separate if conditions in vzEatCookie

Ján Tomko jtomko at redhat.com
Sun Oct 4 22:23:56 UTC 2020


Create a separate scope where 'tmp' variable can be used.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/vz/vz_driver.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 40b1828eb2..5b40f9a835 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -2806,26 +2806,28 @@ vzEatCookie(const char *cookiein, int cookieinlen, unsigned int flags)
                                       _("(_migration_cookie)"), &ctx)))
         goto error;
 
-    if ((flags & VZ_MIGRATION_COOKIE_SESSION_UUID)
-        && (!(tmp = virXPathString("string(./session-uuid[1])", ctx))
+    if (flags & VZ_MIGRATION_COOKIE_SESSION_UUID) {
+        if ((!(tmp = virXPathString("string(./session-uuid[1])", ctx))
             || (VIR_ALLOC_N(mig->session_uuid, VIR_UUID_BUFLEN) < 0)
             || (virUUIDParse(tmp, mig->session_uuid) < 0))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("missing or malformed session-uuid element "
-                         "in migration data"));
-        VIR_FREE(tmp);
-        goto error;
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("missing or malformed session-uuid element "
+                             "in migration data"));
+            VIR_FREE(tmp);
+            goto error;
+        }
     }
     VIR_FREE(tmp);
 
-    if ((flags & VZ_MIGRATION_COOKIE_DOMAIN_UUID)
-        && (!(tmp = virXPathString("string(./uuid[1])", ctx))
+    if (flags & VZ_MIGRATION_COOKIE_DOMAIN_UUID) {
+        if ((!(tmp = virXPathString("string(./uuid[1])", ctx))
             || (VIR_ALLOC_N(mig->uuid, VIR_UUID_BUFLEN) < 0)
             || (virUUIDParse(tmp, mig->uuid) < 0))) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("missing or malformed uuid element in migration data"));
-        VIR_FREE(tmp);
-        goto error;
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("missing or malformed uuid element in migration data"));
+            VIR_FREE(tmp);
+            goto error;
+        }
     }
     VIR_FREE(tmp);
 
-- 
2.26.2




More information about the libvir-list mailing list