]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Alter logic in testCompareXMLToDomConfig
authorJohn Ferlan <jferlan@redhat.com>
Thu, 27 Sep 2018 23:09:44 +0000 (19:09 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 1 Oct 2018 18:27:37 +0000 (14:27 -0400)
Rather than initialize actualconfig and expectconfig before
having the possibility that libxlDriverConfigNew could fail
and thus land in cleanup, let's just move them and return
immediately upon failure.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
tests/libxlxml2domconfigtest.c

index cf2132563e9c527e8a2d84c7321f30df0e048b4a..f380941d63e0f15b23a9a82f45ef4c93ae9bdf44 100644 (file)
@@ -62,14 +62,14 @@ testCompareXMLToDomConfig(const char *xmlfile,
     char *tempjson = NULL;
     char *expectjson = NULL;
 
-    libxl_domain_config_init(&actualconfig);
-    libxl_domain_config_init(&expectconfig);
-
     if (!(cfg = libxlDriverConfigNew()))
-        goto cleanup;
+        return -1;
 
     cfg->caps = caps;
 
+    libxl_domain_config_init(&actualconfig);
+    libxl_domain_config_init(&expectconfig);
+
     if (!(log = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr, XTL_DEBUG, 0)))
         goto cleanup;
 
@@ -135,8 +135,7 @@ testCompareXMLToDomConfig(const char *xmlfile,
     libxl_domain_config_dispose(&actualconfig);
     libxl_domain_config_dispose(&expectconfig);
     xtl_logger_destroy(log);
-    if (cfg)
-        cfg->caps = NULL;
+    cfg->caps = NULL;
     virObjectUnref(cfg);
     return ret;
 }