tests: network: 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:35:15 +02:00
parent 2e3b056cdd
commit e062566885
4 changed files with 16 additions and 35 deletions

View File

@ -20,12 +20,12 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf,
char *outhostsfile, dnsmasqCaps *caps)
{
char *confactual = NULL;
char *hostsfileactual = NULL;
g_autofree char *hostsfileactual = NULL;
int ret = -1;
virNetworkDef *def = NULL;
virNetworkObj *obj = NULL;
virCommand *cmd = NULL;
char *pidfile = NULL;
g_autofree char *pidfile = NULL;
dnsmasqContext *dctx = NULL;
g_autoptr(virNetworkXMLOption) xmlopt = NULL;
@ -82,8 +82,6 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf,
fail:
VIR_FREE(confactual);
VIR_FREE(hostsfileactual);
VIR_FREE(pidfile);
virCommandFree(cmd);
virNetworkObjEndAPI(&obj);
dnsmasqContextFree(dctx);
@ -100,9 +98,9 @@ testCompareXMLToConfHelper(const void *data)
{
int result = -1;
const testInfo *info = data;
char *inxml = NULL;
char *outconf = NULL;
char *outhostsfile = NULL;
g_autofree char *inxml = NULL;
g_autofree char *outconf = NULL;
g_autofree char *outhostsfile = NULL;
inxml = g_strdup_printf("%s/networkxml2confdata/%s.xml", abs_srcdir, info->name);
outconf = g_strdup_printf("%s/networkxml2confdata/%s.conf", abs_srcdir, info->name);
@ -110,10 +108,6 @@ testCompareXMLToConfHelper(const void *data)
result = testCompareXMLToConfFiles(inxml, outconf, outhostsfile, info->caps);
VIR_FREE(inxml);
VIR_FREE(outconf);
VIR_FREE(outhostsfile);
return result;
}

View File

@ -91,7 +91,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
const char *cmdline,
const char *baseargs)
{
char *actualargv = NULL;
g_autofree char *actualargv = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virNetworkDef *def = NULL;
int ret = -1;
@ -121,7 +121,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
ret = 0;
cleanup:
VIR_FREE(actualargv);
virNetworkDefFree(def);
return ret;
}
@ -137,8 +136,8 @@ testCompareXMLToIPTablesHelper(const void *data)
{
int result = -1;
const struct testInfo *info = data;
char *xml = NULL;
char *args = NULL;
g_autofree char *xml = NULL;
g_autofree char *args = NULL;
xml = g_strdup_printf("%s/networkxml2firewalldata/%s.xml",
abs_srcdir, info->name);
@ -147,8 +146,6 @@ testCompareXMLToIPTablesHelper(const void *data)
result = testCompareXMLToArgvFiles(xml, args, info->baseargs);
VIR_FREE(xml);
VIR_FREE(args);
return result;
}

View File

@ -26,7 +26,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
unsigned int flags,
testCompareNetXML2XMLResult expectResult)
{
char *actual = NULL;
g_autofree char *actual = NULL;
int ret;
testCompareNetXML2XMLResult result = TEST_COMPARE_NET_XML2XML_RESULT_SUCCESS;
virNetworkDef *dev = NULL;
@ -70,7 +70,6 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml,
}
virResetLastError();
VIR_FREE(actual);
virNetworkDefFree(dev);
return ret;
}
@ -86,8 +85,8 @@ testCompareXMLToXMLHelper(const void *data)
{
const struct testInfo *info = data;
int result = -1;
char *inxml = NULL;
char *outxml = NULL;
g_autofree char *inxml = NULL;
g_autofree char *outxml = NULL;
inxml = g_strdup_printf("%s/networkxml2xmlin/%s.xml", abs_srcdir, info->name);
outxml = g_strdup_printf("%s/networkxml2xmlout/%s.xml", abs_srcdir, info->name);
@ -95,9 +94,6 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(inxml, outxml, info->flags,
info->expectResult);
VIR_FREE(inxml);
VIR_FREE(outxml);
return result;
}

View File

@ -19,8 +19,8 @@ testCompareXMLToXMLFiles(const char *netxml, const char *updatexml,
unsigned int command, unsigned int section,
int parentIndex, bool expectFailure)
{
char *updateXmlData = NULL;
char *actual = NULL;
g_autofree char *updateXmlData = NULL;
g_autofree char *actual = NULL;
int ret = -1;
virNetworkDef *def = NULL;
@ -55,8 +55,6 @@ testCompareXMLToXMLFiles(const char *netxml, const char *updatexml,
}
}
error:
VIR_FREE(updateXmlData);
VIR_FREE(actual);
virNetworkDefFree(def);
return ret;
}
@ -78,9 +76,9 @@ testCompareXMLToXMLHelper(const void *data)
{
const struct testInfo *info = data;
int result = -1;
char *netxml = NULL;
char *updatexml = NULL;
char *outxml = NULL;
g_autofree char *netxml = NULL;
g_autofree char *updatexml = NULL;
g_autofree char *outxml = NULL;
netxml = g_strdup_printf("%s/networkxml2xmlin/%s.xml",
abs_srcdir, info->netxml);
@ -93,10 +91,6 @@ testCompareXMLToXMLHelper(const void *data)
info->command, info->section,
info->parentIndex, info->expectFailure);
VIR_FREE(netxml);
VIR_FREE(updatexml);
VIR_FREE(outxml);
return result;
}