tests: vmx: use g_autofree

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 22:37:06 +02:00
parent f657b02ce3
commit 5679b6283b
2 changed files with 8 additions and 19 deletions

View File

@ -69,8 +69,8 @@ static int
testCompareFiles(const char *vmx, const char *xml, bool should_fail_parse)
{
int ret = -1;
char *vmxData = NULL;
char *formatted = NULL;
g_autofree char *vmxData = NULL;
g_autofree char *formatted = NULL;
virDomainDef *def = NULL;
if (virTestLoadFile(vmx, &vmxData) < 0)
@ -102,8 +102,6 @@ testCompareFiles(const char *vmx, const char *xml, bool should_fail_parse)
ret = 0;
cleanup:
VIR_FREE(vmxData);
VIR_FREE(formatted);
virDomainDefFree(def);
return ret;
@ -119,8 +117,8 @@ testCompareHelper(const void *data)
{
int ret = -1;
const struct testInfo *info = data;
char *vmx = NULL;
char *xml = NULL;
g_autofree char *vmx = NULL;
g_autofree char *xml = NULL;
vmx = g_strdup_printf("%s/vmx2xmldata/%s.vmx", abs_srcdir,
info->file);
@ -129,9 +127,6 @@ testCompareHelper(const void *data)
ret = testCompareFiles(vmx, xml, info->should_fail);
VIR_FREE(vmx);
VIR_FREE(xml);
return ret;
}

View File

@ -71,7 +71,7 @@ static int
testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
{
int result = -1;
char *formatted = NULL;
g_autofree char *formatted = NULL;
virDomainDef *def = NULL;
def = virDomainDefParseFile(xml, xmlopt, NULL,
@ -95,7 +95,6 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
result = 0;
failure:
VIR_FREE(formatted);
virDomainDefFree(def);
return result;
@ -112,8 +111,8 @@ testCompareHelper(const void *data)
{
int result = -1;
const struct testInfo *info = data;
char *xml = NULL;
char *vmx = NULL;
g_autofree char *xml = NULL;
g_autofree char *vmx = NULL;
xml = g_strdup_printf("%s/xml2vmxdata/xml2vmx-%s.xml", abs_srcdir,
info->input);
@ -122,9 +121,6 @@ testCompareHelper(const void *data)
result = testCompareFiles(xml, vmx, info->virtualHW_version);
VIR_FREE(xml);
VIR_FREE(vmx);
return result;
}
@ -141,7 +137,7 @@ static char *
testFormatVMXFileName(const char *src, void *opaque G_GNUC_UNUSED)
{
bool success = false;
char *copyOfDatastorePath = NULL;
g_autofree char *copyOfDatastorePath = NULL;
char *tmp = NULL;
char *saveptr = NULL;
char *datastoreName = NULL;
@ -182,8 +178,6 @@ testFormatVMXFileName(const char *src, void *opaque G_GNUC_UNUSED)
if (! success)
VIR_FREE(absolutePath);
VIR_FREE(copyOfDatastorePath);
return absolutePath;
}