From: John Ferlan Date: Thu, 27 Sep 2018 23:09:44 +0000 (-0400) Subject: tests: Alter logic in testCompareXMLToDomConfig X-Git-Tag: v4.9.0-rc1~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f3c00c6e8fdd43648600111ee9eccca921ffcc8;p=thirdparty%2Flibvirt.git tests: Alter logic in testCompareXMLToDomConfig 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 ACKed-by: Michal Privoznik --- diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c index cf2132563e..f380941d63 100644 --- a/tests/libxlxml2domconfigtest.c +++ b/tests/libxlxml2domconfigtest.c @@ -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; }