Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
tests/domaincapstest.c | 15 +++++----------
tests/domainconftest.c | 3 +--
tests/eventtest.c | 3 +--
tests/fchosttest.c | 30 ++++++++++--------------------
tests/fdstreamtest.c | 18 ++++++------------
tests/genericxml2xmltest.c | 6 ++----
tests/interfacexml2xmltest.c | 9 +++------
tests/lxcconf2xmltest.c | 18 ++++++------------
tests/lxcxml2xmltest.c | 6 ++----
tests/metadatatest.c | 9 +++------
tests/nodedevxml2xmltest.c | 9 +++------
tests/nsstest.c | 4 +---
tests/openvzutilstest.c | 9 +++------
tests/scsihosttest.c | 12 ++++--------
tests/secretxml2xmltest.c | 7 ++-----
tests/securityselinuxlabeltest.c | 9 +++------
tests/sockettest.c | 4 +---
tests/testutilslxc.c | 4 +---
tests/vboxsnapshotxmltest.c | 12 ++++--------
tests/vmwarevertest.c | 6 ++----
tests/vshtabletest.c | 24 ++++++++----------------
21 files changed, 71 insertions(+), 146 deletions(-)
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index 6ab14a0179..463ff83890 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -74,7 +74,7 @@ fillQemuCaps(virDomainCaps *domCaps,
virQEMUDriverConfig *cfg)
{
int ret = -1;
- char *path = NULL;
+ g_autofree char *path = NULL;
g_autoptr(virQEMUCaps) qemuCaps = NULL;
virDomainCapsLoader *loader = &domCaps->os.loader;
virDomainVirtType virtType;
@@ -127,7 +127,6 @@ fillQemuCaps(virDomainCaps *domCaps,
ret = 0;
cleanup:
- VIR_FREE(path);
return ret;
}
#endif /* WITH_QEMU */
@@ -167,7 +166,7 @@ fillXenCaps(virDomainCaps *domCaps)
static int
fillBhyveCaps(virDomainCaps *domCaps, unsigned int *bhyve_caps)
{
- virDomainCapsStringValues *firmwares = NULL;
+ g_autofree virDomainCapsStringValues *firmwares = NULL;
int ret = -1;
firmwares = g_new0(virDomainCapsStringValues, 1);
@@ -180,7 +179,6 @@ fillBhyveCaps(virDomainCaps *domCaps, unsigned int *bhyve_caps)
ret = 0;
cleanup:
- VIR_FREE(firmwares);
return ret;
}
#endif /* WITH_BHYVE */
@@ -208,8 +206,8 @@ test_virDomainCapsFormat(const void *opaque)
{
const struct testData *data = opaque;
g_autoptr(virDomainCaps) domCaps = NULL;
- char *path = NULL;
- char *domCapsXML = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *domCapsXML = NULL;
int ret = -1;
path = g_strdup_printf("%s/domaincapsdata/%s.xml", abs_srcdir,
data->name);
@@ -253,8 +251,6 @@ test_virDomainCapsFormat(const void *opaque)
ret = 0;
cleanup:
- VIR_FREE(domCapsXML);
- VIR_FREE(path);
return ret;
}
@@ -400,7 +396,7 @@ mymain(void)
#define DO_TEST_BHYVE(Name, Emulator, BhyveCaps, Type) \
do { \
- char *name = NULL; \
+ g_autofree char *name = NULL; \
name = g_strdup_printf("bhyve_%s.x86_64", Name); \
struct testData data = { \
.name = name, \
@@ -412,7 +408,6 @@ mymain(void)
}; \
if (virTestRun(name, test_virDomainCapsFormat, &data) < 0) \
ret = -1; \
- VIR_FREE(name); \
} while (0)
DO_TEST("empty", "/bin/emulatorbin",
"my-machine-type",
diff --git a/tests/domainconftest.c b/tests/domainconftest.c
index 66a133c13e..8b77952860 100644
--- a/tests/domainconftest.c
+++ b/tests/domainconftest.c
@@ -42,7 +42,7 @@ static int testGetFilesystem(const void *opaque)
{
int ret = -1;
virDomainDef *def = NULL;
- char *filename = NULL;
+ g_autofree char *filename = NULL;
const struct testGetFilesystemData *data = opaque;
virDomainFSDef *fsdef;
@@ -72,7 +72,6 @@ static int testGetFilesystem(const void *opaque)
cleanup:
virDomainDefFree(def);
- VIR_FREE(filename);
return ret;
}
diff --git a/tests/eventtest.c b/tests/eventtest.c
index 7a9c87b8cf..1e93c70e74 100644
--- a/tests/eventtest.c
+++ b/tests/eventtest.c
@@ -89,7 +89,7 @@ G_GNUC_PRINTF(3, 4)
testEventReport(const char *name, bool failed, const char *msg, ...)
{
va_list vargs;
- char *str = NULL;
+ g_autofree char *str = NULL;
struct testEventResultData data;
va_start(vargs, msg);
@@ -102,7 +102,6 @@ testEventReport(const char *name, bool failed, const char *msg, ...)
ignore_value(virTestRun(name, testEventResultCallback, &data));
va_end(vargs);
- VIR_FREE(str);
}
static void
diff --git a/tests/fchosttest.c b/tests/fchosttest.c
index 53d02241ca..707dd7e410 100644
--- a/tests/fchosttest.c
+++ b/tests/fchosttest.c
@@ -118,11 +118,11 @@ test3(const void *data G_GNUC_UNUSED)
const char *expect_fabric_wwn = "2001000dec9877c1";
const char *expect_max_vports = "127";
const char *expect_vports = "0";
- char *wwnn = NULL;
- char *wwpn = NULL;
- char *fabric_wwn = NULL;
- char *max_vports = NULL;
- char *vports = NULL;
+ g_autofree char *wwnn = NULL;
+ g_autofree char *wwpn = NULL;
+ g_autofree char *fabric_wwn = NULL;
+ g_autofree char *max_vports = NULL;
+ g_autofree char *vports = NULL;
int ret = -1;
if (!(wwnn = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM,
@@ -155,11 +155,6 @@ test3(const void *data G_GNUC_UNUSED)
ret = 0;
cleanup:
- VIR_FREE(wwnn);
- VIR_FREE(wwpn);
- VIR_FREE(fabric_wwn);
- VIR_FREE(max_vports);
- VIR_FREE(vports);
return ret;
}
@@ -168,7 +163,7 @@ static int
test4(const void *data G_GNUC_UNUSED)
{
const char *expect_hostname = "host5";
- char *hostname = NULL;
+ g_autofree char *hostname = NULL;
int ret = -1;
if (!(hostname = virVHBAGetHostByWWN(TEST_FC_HOST_PREFIX,
@@ -181,7 +176,6 @@ test4(const void *data G_GNUC_UNUSED)
ret = 0;
cleanup:
- VIR_FREE(hostname);
return ret;
}
@@ -193,7 +187,7 @@ static int
test5(const void *data G_GNUC_UNUSED)
{
const char *expect_hostname = "host5";
- char *hostname = NULL;
+ g_autofree char *hostname = NULL;
int ret = -1;
if (!(hostname = virVHBAFindVportHost(TEST_FC_HOST_PREFIX)))
@@ -204,7 +198,6 @@ test5(const void *data G_GNUC_UNUSED)
ret = 0;
cleanup:
- VIR_FREE(hostname);
return ret;
}
@@ -214,9 +207,9 @@ test6(const void *data G_GNUC_UNUSED)
{
const char *expect_wwnn = "2002001b32a9da4e";
const char *expect_wwpn = "2102001b32a9da4e";
- char *wwnn = NULL;
- char *wwpn = NULL;
- char *fabric_wwn = NULL;
+ g_autofree char *wwnn = NULL;
+ g_autofree char *wwpn = NULL;
+ g_autofree char *fabric_wwn = NULL;
int ret = -1;
if (!(wwnn = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_NO_FAB,
@@ -238,9 +231,6 @@ test6(const void *data G_GNUC_UNUSED)
ret = 0;
cleanup:
- VIR_FREE(wwnn);
- VIR_FREE(wwpn);
- VIR_FREE(fabric_wwn);
return ret;
}
diff --git a/tests/fdstreamtest.c b/tests/fdstreamtest.c
index 7a2fe27477..182c853b33 100644
--- a/tests/fdstreamtest.c
+++ b/tests/fdstreamtest.c
@@ -39,10 +39,10 @@ VIR_LOG_INIT("tests.fdstreamtest");
static int testFDStreamReadCommon(const char *scratchdir, bool blocking)
{
int fd = -1;
- char *file = NULL;
+ g_autofree char *file = NULL;
int ret = -1;
- char *pattern = NULL;
- char *buf = NULL;
+ g_autofree char *pattern = NULL;
+ g_autofree char *buf = NULL;
virStreamPtr st = NULL;
size_t i;
virConnectPtr conn = NULL;
@@ -149,9 +149,6 @@ static int testFDStreamReadCommon(const char *scratchdir, bool
blocking)
unlink(file);
if (conn)
virConnectClose(conn);
- VIR_FREE(file);
- VIR_FREE(pattern);
- VIR_FREE(buf);
return ret;
}
@@ -169,10 +166,10 @@ static int testFDStreamReadNonblock(const void *data)
static int testFDStreamWriteCommon(const char *scratchdir, bool blocking)
{
int fd = -1;
- char *file = NULL;
+ g_autofree char *file = NULL;
int ret = -1;
- char *pattern = NULL;
- char *buf = NULL;
+ g_autofree char *pattern = NULL;
+ g_autofree char *buf = NULL;
virStreamPtr st = NULL;
size_t i;
virConnectPtr conn = NULL;
@@ -292,9 +289,6 @@ static int testFDStreamWriteCommon(const char *scratchdir, bool
blocking)
unlink(file);
if (conn)
virConnectClose(conn);
- VIR_FREE(file);
- VIR_FREE(pattern);
- VIR_FREE(buf);
return ret;
}
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
index 39fd6d403a..a6f974e758 100644
--- a/tests/genericxml2xmltest.c
+++ b/tests/genericxml2xmltest.c
@@ -26,8 +26,8 @@ static int
testCompareXMLToXMLHelper(const void *data)
{
const struct testInfo *info = data;
- char *xml_in = NULL;
- char *xml_out = NULL;
+ g_autofree char *xml_in = NULL;
+ g_autofree char *xml_out = NULL;
int ret = -1;
xml_in = g_strdup_printf("%s/genericxml2xmlindata/%s.xml",
@@ -39,8 +39,6 @@ testCompareXMLToXMLHelper(const void *data)
info->different ? xml_out : xml_in,
info->active_only, 0,
info->expectResult);
- VIR_FREE(xml_in);
- VIR_FREE(xml_out);
return ret;
}
diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c
index 3785467f84..8235e701a9 100644
--- a/tests/interfacexml2xmltest.c
+++ b/tests/interfacexml2xmltest.c
@@ -16,8 +16,8 @@
static int
testCompareXMLToXMLFiles(const char *xml)
{
- char *xmlData = NULL;
- char *actual = NULL;
+ g_autofree char *xmlData = NULL;
+ g_autofree char *actual = NULL;
int ret = -1;
virInterfaceDef *dev = NULL;
@@ -38,8 +38,6 @@ testCompareXMLToXMLFiles(const char *xml)
ret = 0;
fail:
- VIR_FREE(xmlData);
- VIR_FREE(actual);
virInterfaceDefFree(dev);
return ret;
}
@@ -48,14 +46,13 @@ static int
testCompareXMLToXMLHelper(const void *data)
{
int result = -1;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
xml = g_strdup_printf("%s/interfaceschemadata/%s.xml", abs_srcdir,
(const char *)data);
result = testCompareXMLToXMLFiles(xml);
- VIR_FREE(xml);
return result;
}
diff --git a/tests/lxcconf2xmltest.c b/tests/lxcconf2xmltest.c
index df7756c931..99473a0b89 100644
--- a/tests/lxcconf2xmltest.c
+++ b/tests/lxcconf2xmltest.c
@@ -26,8 +26,8 @@ testCompareXMLToConfigFiles(const char *xmlfile,
bool expectError)
{
int ret = -1;
- char *config = NULL;
- char *actualxml = NULL;
+ g_autofree char *config = NULL;
+ g_autofree char *actualxml = NULL;
virDomainDef *vmdef = NULL;
if (virTestLoadFile(configfile, &config) < 0)
@@ -51,8 +51,6 @@ testCompareXMLToConfigFiles(const char *xmlfile,
ret = 0;
fail:
- VIR_FREE(actualxml);
- VIR_FREE(config);
virDomainDefFree(vmdef);
return ret;
}
@@ -67,8 +65,8 @@ testCompareXMLToConfigHelperLegacy(const void *data)
{
int result = -1;
const struct testInfo *info = data;
- char *xml = NULL;
- char *config = NULL;
+ g_autofree char *xml = NULL;
+ g_autofree char *config = NULL;
xml = g_strdup_printf("%s/lxcconf2xmldata/lxcconf2xml-%s.xml",
abs_srcdir, info->name);
@@ -77,8 +75,6 @@ testCompareXMLToConfigHelperLegacy(const void *data)
result = testCompareXMLToConfigFiles(xml, config, info->expectError);
- VIR_FREE(xml);
- VIR_FREE(config);
return result;
}
@@ -87,8 +83,8 @@ testCompareXMLToConfigHelperV3(const void *data)
{
int result = -1;
const struct testInfo *info = data;
- char *xml = NULL;
- char *config = NULL;
+ g_autofree char *xml = NULL;
+ g_autofree char *config = NULL;
xml = g_strdup_printf("%s/lxcconf2xmldata/lxcconf2xml-%s.xml",
abs_srcdir, info->name);
@@ -97,8 +93,6 @@ testCompareXMLToConfigHelperV3(const void *data)
result = testCompareXMLToConfigFiles(xml, config, info->expectError);
- VIR_FREE(xml);
- VIR_FREE(config);
return result;
}
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
index 69c333b9b5..8ab32acf42 100644
--- a/tests/lxcxml2xmltest.c
+++ b/tests/lxcxml2xmltest.c
@@ -29,8 +29,8 @@ static int
testCompareXMLToXMLHelper(const void *data)
{
const struct testInfo *info = data;
- char *xml_in = NULL;
- char *xml_out = NULL;
+ g_autofree char *xml_in = NULL;
+ g_autofree char *xml_out = NULL;
int ret = -1;
xml_in = g_strdup_printf("%s/lxcxml2xmldata/lxc-%s.xml",
@@ -43,8 +43,6 @@ testCompareXMLToXMLHelper(const void *data)
info->active_only,
info->parse_flags,
TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS);
- VIR_FREE(xml_in);
- VIR_FREE(xml_out);
return ret;
}
diff --git a/tests/metadatatest.c b/tests/metadatatest.c
index e565383ce2..5112912161 100644
--- a/tests/metadatatest.c
+++ b/tests/metadatatest.c
@@ -92,8 +92,8 @@ verifyMetadata(virDomainPtr dom,
const char *uri)
{
bool ret = false;
- char *metadataXML = NULL;
- char *metadataAPI = NULL;
+ g_autofree char *metadataXML = NULL;
+ g_autofree char *metadataAPI = NULL;
if (!expectAPI) {
if ((metadataAPI = virDomainGetMetadata(dom,
@@ -147,8 +147,6 @@ verifyMetadata(virDomainPtr dom,
ret = true;
cleanup:
- VIR_FREE(metadataXML);
- VIR_FREE(metadataAPI);
return ret;
}
@@ -214,7 +212,7 @@ static int
testTextMetadata(const void *data)
{
const struct metadataTest *test = data;
- char *actual = NULL;
+ g_autofree char *actual = NULL;
int ret = -1;
if (virDomainSetMetadata(test->dom, test->type, test->data, NULL, NULL, 0)
< 0) {
@@ -236,7 +234,6 @@ testTextMetadata(const void *data)
ret = 0;
cleanup:
- VIR_FREE(actual);
return ret;
}
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
index d8f81456ee..9e32e7d553 100644
--- a/tests/nodedevxml2xmltest.c
+++ b/tests/nodedevxml2xmltest.c
@@ -16,8 +16,8 @@
static int
testCompareXMLToXMLFiles(const char *xml, const char *outfile)
{
- char *xmlData = NULL;
- char *actual = NULL;
+ g_autofree char *xmlData = NULL;
+ g_autofree char *actual = NULL;
int ret = -1;
virNodeDeviceDef *dev = NULL;
virNodeDevCapsDef *caps;
@@ -59,8 +59,6 @@ testCompareXMLToXMLFiles(const char *xml, const char *outfile)
ret = 0;
fail:
- VIR_FREE(xmlData);
- VIR_FREE(actual);
virNodeDeviceDefFree(dev);
return ret;
}
@@ -69,7 +67,7 @@ static int
testCompareXMLToXMLHelper(const void *data)
{
int result = -1;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
g_autofree char *outfile = NULL;
xml = g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir,
@@ -80,7 +78,6 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(xml, outfile);
- VIR_FREE(xml);
return result;
}
diff --git a/tests/nsstest.c b/tests/nsstest.c
index a4e8a4a37f..2c2e57769b 100644
--- a/tests/nsstest.c
+++ b/tests/nsstest.c
@@ -118,7 +118,7 @@ testGetHostByName(const void *opaque)
i = 0;
while (*addrList) {
virSocketAddr sa;
- char *ipAddr;
+ g_autofree char *ipAddr = NULL;
void *address = *addrList;
memset(&sa, 0, sizeof(sa));
@@ -138,10 +138,8 @@ testGetHostByName(const void *opaque)
virReportError(VIR_ERR_INTERNAL_ERROR,
"Unexpected address %s, expecting %s",
ipAddr, NULLSTR(data->ipAddr[i]));
- VIR_FREE(ipAddr);
return -1;
}
- VIR_FREE(ipAddr);
addrList++;
i++;
diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c
index ddb2fcbe6c..10cf307d61 100644
--- a/tests/openvzutilstest.c
+++ b/tests/openvzutilstest.c
@@ -38,8 +38,8 @@ testReadConfigParam(const void *data G_GNUC_UNUSED)
{
int result = -1;
size_t i;
- char *conf = NULL;
- char *value = NULL;
+ g_autofree char *conf = NULL;
+ g_autofree char *value = NULL;
conf = g_strdup_printf("%s/openvzutilstest.conf", abs_srcdir);
@@ -61,8 +61,6 @@ testReadConfigParam(const void *data G_GNUC_UNUSED)
result = 0;
cleanup:
- VIR_FREE(conf);
- VIR_FREE(value);
return result;
}
@@ -72,7 +70,7 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED)
{
int result = -1;
virDomainDef *def = NULL;
- char *actual = NULL;
+ g_autofree char *actual = NULL;
const char *expected =
"<domain type='openvz'>\n"
" <uuid>00000000-0000-0000-0000-000000000000</uuid>\n"
@@ -133,7 +131,6 @@ testReadNetworkConf(const void *data G_GNUC_UNUSED)
cleanup:
virObjectUnref(driver.xmlopt);
virObjectUnref(driver.caps);
- VIR_FREE(actual);
virDomainDefFree(def);
return result;
diff --git a/tests/scsihosttest.c b/tests/scsihosttest.c
index 7508ac37a3..336b3cc496 100644
--- a/tests/scsihosttest.c
+++ b/tests/scsihosttest.c
@@ -67,8 +67,8 @@ static int
create_scsihost(const char *fakesysfsdir, const char *devicepath,
const char *unique_id, const char *hostname)
{
- char *unique_id_path = NULL;
- char *link_path = NULL;
+ g_autofree char *unique_id_path = NULL;
+ g_autofree char *link_path = NULL;
char *spot;
int ret = -1;
int fd = -1;
@@ -137,8 +137,6 @@ create_scsihost(const char *fakesysfsdir, const char *devicepath,
cleanup:
VIR_FORCE_CLOSE(fd);
- VIR_FREE(unique_id_path);
- VIR_FREE(link_path);
return ret;
}
@@ -242,8 +240,8 @@ static int
mymain(void)
{
int ret = -1;
- char *fakerootdir = NULL;
- char *fakesysfsdir = NULL;
+ g_autofree char *fakerootdir = NULL;
+ g_autofree char *fakesysfsdir = NULL;
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
@@ -279,8 +277,6 @@ mymain(void)
cleanup:
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
virFileDeleteTree(fakerootdir);
- VIR_FREE(fakerootdir);
- VIR_FREE(fakesysfsdir);
VIR_FREE(scsihost_class_path);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/secretxml2xmltest.c b/tests/secretxml2xmltest.c
index 48f48416b5..62b82b4a24 100644
--- a/tests/secretxml2xmltest.c
+++ b/tests/secretxml2xmltest.c
@@ -40,8 +40,8 @@ static int
testCompareXMLToXMLHelper(const void *data)
{
int result = -1;
- char *inxml = NULL;
- char *outxml = NULL;
+ g_autofree char *inxml = NULL;
+ g_autofree char *outxml = NULL;
const struct testInfo *info = data;
inxml = g_strdup_printf("%s/secretxml2xmlin/%s.xml", abs_srcdir,
info->name);
@@ -52,9 +52,6 @@ testCompareXMLToXMLHelper(const void *data)
result = testCompareXMLToXMLFiles(inxml, outxml);
- VIR_FREE(inxml);
- VIR_FREE(outxml);
-
return result;
}
diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index f7dd3c866a..cd604eda31 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -59,7 +59,7 @@ testUserXattrEnabled(void)
int ret = -1;
ssize_t len;
const char *con_value = "system_u:object_r:svirt_image_t:s0:c41,c264";
- char *path = NULL;
+ g_autofree char *path = NULL;
path = g_strdup_printf("%s/securityselinuxlabeldata/testxattr",
abs_builddir);
if (g_mkdir_with_parents(abs_builddir "/securityselinuxlabeldata", 0777)
< 0 ||
@@ -79,7 +79,6 @@ testUserXattrEnabled(void)
cleanup:
unlink(path);
rmdir(abs_builddir "/securityselinuxlabeldata");
- VIR_FREE(path);
return ret;
}
@@ -101,9 +100,9 @@ testSELinuxLoadFileList(const char *testname,
size_t *nfiles)
{
int ret = -1;
- char *path = NULL;
+ g_autofree char *path = NULL;
FILE *fp = NULL;
- char *line = NULL;
+ g_autofree char *line = NULL;
*files = NULL;
*nfiles = 0;
@@ -153,8 +152,6 @@ testSELinuxLoadFileList(const char *testname,
cleanup:
VIR_FORCE_FCLOSE(fp);
- VIR_FREE(path);
- VIR_FREE(line);
return ret;
}
diff --git a/tests/sockettest.c b/tests/sockettest.c
index e9654fcebb..332def2c93 100644
--- a/tests/sockettest.c
+++ b/tests/sockettest.c
@@ -43,7 +43,7 @@ static int testParse(virSocketAddr *addr, const char *addrstr, int
family, bool
static int testFormat(virSocketAddr *addr, const char *addrstr, bool pass)
{
- char *newaddrstr;
+ g_autofree char *newaddrstr = NULL;
newaddrstr = virSocketAddrFormat(addr);
if (!newaddrstr)
@@ -51,10 +51,8 @@ static int testFormat(virSocketAddr *addr, const char *addrstr, bool
pass)
if (STRNEQ(newaddrstr, addrstr)) {
virTestDifference(stderr, addrstr, newaddrstr);
- VIR_FREE(newaddrstr);
return pass ? -1 : 0;
} else {
- VIR_FREE(newaddrstr);
return pass ? 0 : -1;
}
}
diff --git a/tests/testutilslxc.c b/tests/testutilslxc.c
index 9ab57f7ccb..0139de7437 100644
--- a/tests/testutilslxc.c
+++ b/tests/testutilslxc.c
@@ -39,15 +39,13 @@ testLXCCapsInit(void)
if (virTestGetDebug()) {
- char *caps_str;
+ g_autofree char *caps_str = NULL;
caps_str = virCapabilitiesFormatXML(caps);
if (!caps_str)
goto error;
VIR_TEST_DEBUG("LXC driver capabilities:\n%s", caps_str);
-
- VIR_FREE(caps_str);
}
return caps;
diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c
index f5f8fe36b9..da39561456 100644
--- a/tests/vboxsnapshotxmltest.c
+++ b/tests/vboxsnapshotxmltest.c
@@ -46,9 +46,9 @@ testFilterXML(char *xml)
static int
testCompareXMLtoXMLFiles(const char *xml)
{
- char *xmlData = NULL;
- char *actual = NULL;
- char *pathResult = NULL;
+ g_autofree char *xmlData = NULL;
+ g_autofree char *actual = NULL;
+ g_autofree char *pathResult = NULL;
int ret = -1;
virVBoxSnapshotConfMachine *machine = NULL;
@@ -84,10 +84,7 @@ testCompareXMLtoXMLFiles(const char *xml)
cleanup:
unlink(pathResult);
rmdir(abs_builddir "/vboxsnapshotxmldata");
- VIR_FREE(xmlData);
- VIR_FREE(actual);
virVBoxSnapshotConfMachineFree(machine);
- VIR_FREE(pathResult);
return ret;
}
@@ -96,14 +93,13 @@ static int
testCompareXMLToXMLHelper(const void *data)
{
int result = -1;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
xml = g_strdup_printf("%s/vboxsnapshotxmldata/%s.vbox", abs_srcdir,
(const char *)data);
result = testCompareXMLtoXMLFiles(xml);
- VIR_FREE(xml);
return result;
}
diff --git a/tests/vmwarevertest.c b/tests/vmwarevertest.c
index fa909ad022..7cb358795f 100644
--- a/tests/vmwarevertest.c
+++ b/tests/vmwarevertest.c
@@ -38,8 +38,8 @@ testVerStrParse(const void *data)
{
const struct testInfo *info = data;
int ret = -1;
- char *path = NULL;
- char *databuf = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *databuf = NULL;
unsigned long version;
int vmware_type;
@@ -63,8 +63,6 @@ testVerStrParse(const void *data)
ret = 0;
cleanup:
- VIR_FREE(path);
- VIR_FREE(databuf);
return ret;
}
diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c
index 41c33b1701..804aaf4d9c 100644
--- a/tests/vshtabletest.c
+++ b/tests/vshtabletest.c
@@ -119,7 +119,7 @@ static int
testUnicode(const void *opaque G_GNUC_UNUSED)
{
int ret = 0;
- char *act = NULL;
+ g_autofree char *act = NULL;
const char *exp =
" Id 名稱 государство\n"
@@ -141,7 +141,6 @@ testUnicode(const void *opaque G_GNUC_UNUSED)
ret = -1;
cleanup:
- VIR_FREE(act);
vshTableFree(table);
return ret;
}
@@ -151,7 +150,7 @@ static int
testUnicodeArabic(const void *opaque G_GNUC_UNUSED)
{
int ret = 0;
- char *act = NULL;
+ g_autofree char *act = NULL;
const char *exp =
" ﻡﺍ ﻢﻣﺍ ﻕﺎﺌﻣﺓ ﺓ ﺎﻠﺼﻋ
ﺍﻸﺜﻧﺎﻧ\n"
@@ -184,7 +183,6 @@ testUnicodeArabic(const void *opaque G_GNUC_UNUSED)
ret = -1;
cleanup:
- VIR_FREE(act);
vshTableFree(table);
return ret;
}
@@ -200,7 +198,7 @@ testUnicodeZeroWidthChar(const void *opaque G_GNUC_UNUSED)
"--------------------------\n"
" 1\u200B fedora28 run\u200Bning\n"
" 2 rhel7.5 running\n";
- char *act = NULL;
+ g_autofree char *act = NULL;
wchar_t wc;
/* If this char is not classed as printable, the actual
@@ -222,7 +220,6 @@ testUnicodeZeroWidthChar(const void *opaque G_GNUC_UNUSED)
ret = -1;
cleanup:
- VIR_FREE(act);
vshTableFree(table);
return ret;
}
@@ -237,7 +234,7 @@ testUnicodeCombiningChar(const void *opaque G_GNUC_UNUSED)
"--------------------------\n"
" 1 fědora28 running\n"
" 2 rhel running\n";
- char *act = NULL;
+ g_autofree char *act = NULL;
table = vshTableNew("Id", "Náme", "Ⓢtatus", NULL);
if (!table)
@@ -250,7 +247,6 @@ testUnicodeCombiningChar(const void *opaque G_GNUC_UNUSED)
ret = -1;
cleanup:
- VIR_FREE(act);
vshTableFree(table);
return ret;
}
@@ -266,7 +262,7 @@ testUnicodeNonPrintableChar(const void *opaque G_GNUC_UNUSED)
"----------------------------------\n"
" 1 f\\x07edora28 running\n"
" 2 rhel7.5 running\n";
- char *act = NULL;
+ g_autofree char *act = NULL;
table = vshTableNew("I\td", "Name", "Status", NULL);
if (!table)
@@ -279,7 +275,6 @@ testUnicodeNonPrintableChar(const void *opaque G_GNUC_UNUSED)
ret = -1;
cleanup:
- VIR_FREE(act);
vshTableFree(table);
return ret;
}
@@ -307,9 +302,9 @@ testNTables(const void *opaque G_GNUC_UNUSED)
" 2\n"
" 3\n"
" 4\n";
- char *act1 = NULL;
- char *act2 = NULL;
- char *act3 = NULL;
+ g_autofree char *act1 = NULL;
+ g_autofree char *act2 = NULL;
+ g_autofree char *act3 = NULL;
table1 = vshTableNew("Id", "Name", "Status", NULL);
if (!table1)
@@ -341,9 +336,6 @@ testNTables(const void *opaque G_GNUC_UNUSED)
ret = -1;
cleanup:
- VIR_FREE(act1);
- VIR_FREE(act2);
- VIR_FREE(act3);
vshTableFree(table1);
vshTableFree(table2);
vshTableFree(table3);
--
2.31.1