tests: use g_auto instead of virDomainFree

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Ján Tomko 2021-09-04 21:50:02 +02:00
parent 9e1893ebd0
commit 6150910cf7
11 changed files with 13 additions and 26 deletions

View 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;
}

View 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);

View 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;
}

View 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;
}

View 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;
}

View 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);

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}