]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: use g_auto instead of virDomainFree
authorJán Tomko <jtomko@redhat.com>
Sat, 4 Sep 2021 19:50:02 +0000 (21:50 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 9 Sep 2021 16:06:13 +0000 (18:06 +0200)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
tests/domainconftest.c
tests/libxlxml2domconfigtest.c
tests/lxcconf2xmltest.c
tests/openvzutilstest.c
tests/qemuagenttest.c
tests/securityselinuxlabeltest.c
tests/testutils.c
tests/vmx2xmltest.c
tests/xlconfigtest.c
tests/xmconfigtest.c
tests/xml2vmxtest.c

index 8b77952860cbe2b3f4ef3113235870d936e1a683..aaf58bcf9388e6e7e873406169a3817367f1e89d 100644 (file)
@@ -41,7 +41,7 @@ struct testGetFilesystemData {
 static int testGetFilesystem(const void *opaque)
 {
     int ret = -1;
-    virDomainDef *def = NULL;
+    g_autoptr(virDomainDef) def = NULL;
     g_autofree char *filename = NULL;
     const struct testGetFilesystemData *data = opaque;
     virDomainFSDef *fsdef;
@@ -71,7 +71,6 @@ static int testGetFilesystem(const void *opaque)
     ret = 0;
 
  cleanup:
-    virDomainDefFree(def);
     return ret;
 }
 
index 2bc5c262236fc21f860c261e12818b039b4c1f2f..015597eb440e60c2b3e116a7f1fe8f6fe2e16d0f 100644 (file)
@@ -52,7 +52,7 @@ testCompareXMLToDomConfig(const char *xmlfile,
     libxl_domain_config expectconfig;
     xentoollog_logger *log = NULL;
     virPortAllocatorRange *gports = NULL;
-    virDomainDef *vmdef = NULL;
+    g_autoptr(virDomainDef) vmdef = NULL;
     g_autofree char *actualjson = NULL;
     g_autofree char *tempjson = NULL;
     g_autofree char *expectjson = NULL;
@@ -128,7 +128,6 @@ testCompareXMLToDomConfig(const char *xmlfile,
         vmdef->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC)
         virPortAllocatorRelease(vmdef->graphics[0]->data.vnc.port);
 
-    virDomainDefFree(vmdef);
     virPortAllocatorRangeFree(gports);
     libxl_domain_config_dispose(&actualconfig);
     libxl_domain_config_dispose(&expectconfig);
index 99473a0b89c95965b9456096801794db9285d70a..be70671d6847148b76d440c219ff36b5ee3bc189 100644 (file)
@@ -28,7 +28,7 @@ testCompareXMLToConfigFiles(const char *xmlfile,
     int ret = -1;
     g_autofree char *config = NULL;
     g_autofree char *actualxml = NULL;
-    virDomainDef *vmdef = NULL;
+    g_autoptr(virDomainDef) vmdef = NULL;
 
     if (virTestLoadFile(configfile, &config) < 0)
         goto fail;
@@ -51,7 +51,6 @@ testCompareXMLToConfigFiles(const char *xmlfile,
     ret = 0;
 
  fail:
-    virDomainDefFree(vmdef);
     return ret;
 }
 
index 10cf307d6133b14935c49cf85ade90266a72aeee..3ebf38f104d61d90b507356a7cd07a72d120c087 100644 (file)
@@ -69,7 +69,7 @@ static int
 testReadNetworkConf(const void *data G_GNUC_UNUSED)
 {
     int result = -1;
-    virDomainDef *def = NULL;
+    g_autoptr(virDomainDef) def = NULL;
     g_autofree char *actual = NULL;
     const char *expected =
         "<domain type='openvz'>\n"
@@ -131,7 +131,6 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED)
  cleanup:
     virObjectUnref(driver.xmlopt);
     virObjectUnref(driver.caps);
-    virDomainDefFree(def);
 
     return result;
 }
index a447c934940722b0a9c8ccd69da7b8c5c99c0959..10d02bd1b491a9f42a1a3e5479301c5abbf25128 100644 (file)
@@ -313,7 +313,7 @@ testQemuAgentGetFSInfo(const void *data)
 {
     virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
     qemuMonitorTest *test = NULL;
-    virDomainDef *def = NULL;
+    g_autoptr(virDomainDef) def = NULL;
     qemuAgentFSInfo **info = NULL;
     int ret = -1, ninfo = 0, i;
 
@@ -405,7 +405,6 @@ testQemuAgentGetFSInfo(const void *data)
     for (i = 0; i < ninfo; i++)
         qemuAgentFSInfoFree(info[i]);
     VIR_FREE(info);
-    virDomainDefFree(def);
     qemuMonitorTestFree(test);
     return ret;
 }
index a192e86464dddfe1745c638253e4ca8094231547..2da9cb7bb91b145305c4920847a55d1ceb175401 100644 (file)
@@ -275,7 +275,7 @@ testSELinuxLabeling(const void *opaque)
     testSELinuxFile *files = NULL;
     size_t nfiles = 0;
     size_t i;
-    virDomainDef *def = NULL;
+    g_autoptr(virDomainDef) def = NULL;
 
     if (testSELinuxLoadFileList(testname, &files, &nfiles) < 0)
         goto cleanup;
@@ -298,7 +298,6 @@ testSELinuxLabeling(const void *opaque)
     if (testSELinuxDeleteDisks(files, nfiles) < 0)
         VIR_WARN("unable to fully clean up");
 
-    virDomainDefFree(def);
     for (i = 0; i < nfiles; i++) {
         VIR_FREE(files[i].file);
         VIR_FREE(files[i].context);
index 1bec5fa8496568e00e40703b9b3696148f4aa081..d071abd6d7f54a75b77771b4ec5e877bd4ea83f5 100644 (file)
@@ -1009,7 +1009,7 @@ testCompareDomXML2XMLFiles(virCaps *caps G_GNUC_UNUSED,
     g_autofree char *actual = NULL;
     int ret = -1;
     testCompareDomXML2XMLResult result;
-    virDomainDef *def = NULL;
+    g_autoptr(virDomainDef) def = NULL;
     unsigned int parse_flags = live ? 0 : VIR_DOMAIN_DEF_PARSE_INACTIVE;
     unsigned int format_flags = VIR_DOMAIN_DEF_FORMAT_SECURE;
 
@@ -1059,7 +1059,6 @@ testCompareDomXML2XMLFiles(virCaps *caps G_GNUC_UNUSED,
                        expectResult, result);
     }
 
-    virDomainDefFree(def);
     return ret;
 }
 
index cd44a84a07a46628d473f67bd6f202940d06e51c..b7f232eb7738dac1eef653c6dfb003cf2ba42f91 100644 (file)
@@ -71,7 +71,7 @@ testCompareFiles(const char *vmx, const char *xml, bool should_fail_parse)
     int ret = -1;
     g_autofree char *vmxData = NULL;
     g_autofree char *formatted = NULL;
-    virDomainDef *def = NULL;
+    g_autoptr(virDomainDef) def = NULL;
 
     if (virTestLoadFile(vmx, &vmxData) < 0)
         return -1;
@@ -102,7 +102,6 @@ testCompareFiles(const char *vmx, const char *xml, bool should_fail_parse)
     ret = 0;
 
  cleanup:
-    virDomainDefFree(def);
 
     return ret;
 }
index 95ee670b002fc962394ba26705a627913677cf59..671737798272df01b8eabe2cf7f55fb081c91005 100644 (file)
@@ -69,7 +69,7 @@ testCompareParseXML(const char *xlcfg, const char *xml, bool replaceVars)
     g_autoptr(virConnect) conn = NULL;
     int wrote = 4096;
     int ret = -1;
-    virDomainDef *def = NULL;
+    g_autoptr(virDomainDef) def = NULL;
     g_autofree char *replacedXML = NULL;
 
     gotxlcfgData = g_new0(char, wrote);
@@ -107,7 +107,6 @@ testCompareParseXML(const char *xlcfg, const char *xml, bool replaceVars)
     ret = 0;
 
  fail:
-    virDomainDefFree(def);
 
     return ret;
 }
@@ -124,7 +123,7 @@ testCompareFormatXML(const char *xlcfg, const char *xml, bool replaceVars)
     g_autoptr(virConf) conf = NULL;
     int ret = -1;
     g_autoptr(virConnect) conn = NULL;
-    virDomainDef *def = NULL;
+    g_autoptr(virDomainDef) def = NULL;
     g_autofree char *replacedXML = NULL;
     g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
 
@@ -158,7 +157,6 @@ testCompareFormatXML(const char *xlcfg, const char *xml, bool replaceVars)
     ret = 0;
 
  fail:
-    virDomainDefFree(def);
 
     return ret;
 }
index a756f752f8f1f8ac828c0d03d4f0bf4c56bca5ec..bd23e5fd5d2a228173c6dee8311af85eda1bccc9 100644 (file)
@@ -44,7 +44,7 @@ testCompareParseXML(const char *xmcfg, const char *xml)
     int ret = -1;
     g_autoptr(virConnect) conn = NULL;
     int wrote = 4096;
-    virDomainDef *def = NULL;
+    g_autoptr(virDomainDef) def = NULL;
 
     gotxmcfgData = g_new0(char, wrote);
 
@@ -73,7 +73,6 @@ testCompareParseXML(const char *xmcfg, const char *xml)
     ret = 0;
 
  fail:
-    virDomainDefFree(def);
 
     return ret;
 }
@@ -85,7 +84,7 @@ testCompareFormatXML(const char *xmcfg, const char *xml)
     g_autofree char *gotxml = NULL;
     g_autoptr(virConf) conf = NULL;
     int ret = -1;
-    virDomainDef *def = NULL;
+    g_autoptr(virDomainDef) def = NULL;
     g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
 
     if (virTestLoadFile(xmcfg, &xmcfgData) < 0)
@@ -106,7 +105,6 @@ testCompareFormatXML(const char *xmcfg, const char *xml)
     ret = 0;
 
  fail:
-    virDomainDefFree(def);
 
     return ret;
 }
index cb70f70f4f2238d70f9349f125cd575fd206a0a3..8a03237b1695dcccc8a891b668b11fe2164085a6 100644 (file)
@@ -72,7 +72,7 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
 {
     int result = -1;
     g_autofree char *formatted = NULL;
-    virDomainDef *def = NULL;
+    g_autoptr(virDomainDef) def = NULL;
 
     def = virDomainDefParseFile(xml, xmlopt, NULL,
                                 VIR_DOMAIN_DEF_PARSE_INACTIVE);
@@ -95,7 +95,6 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
     result = 0;
 
  failure:
-    virDomainDefFree(def);
 
     return result;
 }