Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
tests/qemuagenttest.c | 9 +++-----
tests/qemucapabilitiestest.c | 18 +++++----------
tests/qemucaps2xmltest.c | 20 +++++------------
tests/qemudomainsnapshotxml2xmltest.c | 9 +++-----
tests/qemuhotplugtest.c | 32 +++++++++------------------
tests/qemumemlocktest.c | 10 +++------
tests/qemumigparamstest.c | 24 +++++++-------------
tests/qemumonitortestutils.c | 15 +++++--------
tests/qemusecuritymock.c | 12 ++++------
tests/qemuxml2argvtest.c | 15 +++++--------
tests/qemuxml2xmltest.c | 6 ++---
tests/testutilsqemu.c | 7 ++----
12 files changed, 57 insertions(+), 120 deletions(-)
diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c
index 2c3a1efb09..347438c14a 100644
--- a/tests/qemuagenttest.c
+++ b/tests/qemuagenttest.c
@@ -173,7 +173,7 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOptionPtr xmlopt,
virDomainDefPtr *def)
{
int ret = -1;
- char *domain_filename = NULL;
+ g_autofree char *domain_filename = NULL;
qemuMonitorTestPtr ret_test = NULL;
virDomainDefPtr ret_def = NULL;
@@ -233,7 +233,6 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOptionPtr xmlopt,
ret = 0;
cleanup:
- VIR_FREE(domain_filename);
if (ret_test)
qemuMonitorTestFree(ret_test);
virDomainDefFree(ret_def);
@@ -664,7 +663,7 @@ testQemuAgentArbitraryCommand(const void *data)
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewAgent(xmlopt);
int ret = -1;
- char *reply = NULL;
+ g_autofree char *reply = NULL;
if (!test)
return -1;
@@ -693,7 +692,6 @@ testQemuAgentArbitraryCommand(const void *data)
ret = 0;
cleanup:
- VIR_FREE(reply);
qemuMonitorTestFree(test);
return ret;
}
@@ -713,7 +711,7 @@ testQemuAgentTimeout(const void *data)
{
virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewAgent(xmlopt);
- char *reply = NULL;
+ g_autofree char *reply = NULL;
int ret = -1;
if (!test)
@@ -757,7 +755,6 @@ testQemuAgentTimeout(const void *data)
ret = 0;
cleanup:
- VIR_FREE(reply);
qemuMonitorTestFree(test);
return ret;
}
diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
index 5b32ac1451..be8741dd5f 100644
--- a/tests/qemucapabilitiestest.c
+++ b/tests/qemucapabilitiestest.c
@@ -71,12 +71,12 @@ testQemuCaps(const void *opaque)
{
int ret = -1;
testQemuData *data = (void *) opaque;
- char *repliesFile = NULL;
- char *capsFile = NULL;
+ g_autofree char *repliesFile = NULL;
+ g_autofree char *capsFile = NULL;
qemuMonitorTestPtr mon = NULL;
virQEMUCapsPtr capsActual = NULL;
- char *binary = NULL;
- char *actual = NULL;
+ g_autofree char *binary = NULL;
+ g_autofree char *actual = NULL;
unsigned int fakeMicrocodeVersion = 0;
const char *p;
@@ -133,10 +133,6 @@ testQemuCaps(const void *opaque)
ret = 0;
cleanup:
- VIR_FREE(repliesFile);
- VIR_FREE(capsFile);
- VIR_FREE(actual);
- VIR_FREE(binary);
qemuMonitorTestFree(mon);
virObjectUnref(capsActual);
return ret;
@@ -148,10 +144,10 @@ testQemuCapsCopy(const void *opaque)
{
int ret = -1;
const testQemuData *data = opaque;
- char *capsFile = NULL;
+ g_autofree char *capsFile = NULL;
virQEMUCapsPtr orig = NULL;
virQEMUCapsPtr copy = NULL;
- char *actual = NULL;
+ g_autofree char *actual = NULL;
capsFile = g_strdup_printf("%s/%s_%s.%s.xml",
data->outputDir, data->prefix, data->version,
@@ -173,10 +169,8 @@ testQemuCapsCopy(const void *opaque)
ret = 0;
cleanup:
- VIR_FREE(capsFile);
virObjectUnref(orig);
virObjectUnref(copy);
- VIR_FREE(actual);
return ret;
}
diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c
index f087b037ce..5ff4374935 100644
--- a/tests/qemucaps2xmltest.c
+++ b/tests/qemucaps2xmltest.c
@@ -55,7 +55,7 @@ testQemuGetCaps(char *caps)
xmlDocPtr xml;
xmlXPathContextPtr ctxt = NULL;
ssize_t i, n;
- xmlNodePtr *nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
if (!(xml = virXMLParseStringCtxt(caps, "(test caps)", &ctxt)))
goto error;
@@ -69,26 +69,22 @@ testQemuGetCaps(char *caps)
goto error;
for (i = 0; i < n; i++) {
- char *str = virXMLPropString(nodes[i], "name");
+ g_autofree char *str = virXMLPropString(nodes[i], "name");
if (str) {
int flag = virQEMUCapsTypeFromString(str);
if (flag < 0) {
fprintf(stderr, "Unknown qemu capabilities flag %s", str);
- VIR_FREE(str);
goto error;
}
- VIR_FREE(str);
virQEMUCapsSet(qemuCaps, flag);
}
}
- VIR_FREE(nodes);
xmlFreeDoc(xml);
xmlXPathFreeContext(ctxt);
return qemuCaps;
error:
- VIR_FREE(nodes);
virObjectUnref(qemuCaps);
xmlFreeDoc(xml);
xmlXPathFreeContext(ctxt);
@@ -137,10 +133,10 @@ testQemuCapsXML(const void *opaque)
{
int ret = -1;
const testQemuData *data = opaque;
- char *capsFile = NULL
- char *xmlFile = NULL;
- char *capsData = NULL;
- char *capsXml = NULL;
+ g_autofree char *capsFile = NULL;
+ g_autofree char *xmlFile = NULL;
+ g_autofree char *capsData = NULL;
+ g_autofree char *capsXml = NULL;
virCapsPtr capsProvided = NULL;
xmlFile = g_strdup_printf("%s/caps.%s.xml", data->outputDir,
data->archName);
@@ -164,10 +160,6 @@ testQemuCapsXML(const void *opaque)
ret = 0;
cleanup:
- VIR_FREE(xmlFile);
- VIR_FREE(capsFile);
- VIR_FREE(capsXml);
- VIR_FREE(capsData);
virObjectUnref(capsProvided);
return ret;
}
diff --git a/tests/qemudomainsnapshotxml2xmltest.c
b/tests/qemudomainsnapshotxml2xmltest.c
index 220dae33b9..6c10f3e953 100644
--- a/tests/qemudomainsnapshotxml2xmltest.c
+++ b/tests/qemudomainsnapshotxml2xmltest.c
@@ -31,9 +31,9 @@ testCompareXMLToXMLFiles(const char *inxml,
const char *uuid,
unsigned int flags)
{
- char *inXmlData = NULL;
- char *outXmlData = NULL;
- char *actual = NULL;
+ g_autofree char *inXmlData = NULL;
+ g_autofree char *outXmlData = NULL;
+ g_autofree char *actual = NULL;
int ret = -1;
unsigned int parseflags = VIR_DOMAIN_SNAPSHOT_PARSE_DISKS;
unsigned int formatflags = VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE;
@@ -82,9 +82,6 @@ testCompareXMLToXMLFiles(const char *inxml,
ret = 0;
cleanup:
- VIR_FREE(inXmlData);
- VIR_FREE(outXmlData);
- VIR_FREE(actual);
return ret;
}
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index ba30cf5aa6..9d7d2e44e8 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -203,7 +203,7 @@ testQemuHotplugCheckResult(virDomainObjPtr vm,
const char *expectedFile,
bool fail)
{
- char *actual;
+ g_autofree char *actual = NULL;
int ret;
actual = virDomainDefFormat(vm->def, driver.xmlopt,
@@ -224,7 +224,6 @@ testQemuHotplugCheckResult(virDomainObjPtr vm,
ret = -1;
}
- VIR_FREE(actual);
return ret;
}
@@ -233,12 +232,12 @@ testQemuHotplug(const void *data)
{
int ret = -1;
struct qemuHotplugTestData *test = (struct qemuHotplugTestData *) data;
- char *domain_filename = NULL;
- char *device_filename = NULL;
- char *result_filename = NULL;
- char *domain_xml = NULL;
- char *device_xml = NULL;
- char *result_xml = NULL;
+ g_autofree char *domain_filename = NULL;
+ g_autofree char *device_filename = NULL;
+ g_autofree char *result_filename = NULL;
+ g_autofree char *domain_xml = NULL;
+ g_autofree char *device_xml = NULL;
+ g_autofree char *result_xml = NULL;
const char *const *tmp;
bool fail = test->fail;
bool keep = test->keep;
@@ -340,12 +339,6 @@ testQemuHotplug(const void *data)
virObjectLock(priv->mon);
cleanup:
- VIR_FREE(domain_filename);
- VIR_FREE(device_filename);
- VIR_FREE(result_filename);
- VIR_FREE(domain_xml);
- VIR_FREE(device_xml);
- VIR_FREE(result_xml);
/* don't dispose test monitor with VM */
if (priv)
priv->mon = NULL;
@@ -416,7 +409,7 @@ testQemuHotplugCpuPrepare(const char *test,
{
qemuDomainObjPrivatePtr priv = NULL;
virCapsPtr caps = NULL;
- char *prefix = NULL;
+ g_autofree char *prefix = NULL;
struct testQemuHotplugCpuData *data = NULL;
prefix = g_strdup_printf("%s/qemuhotplugtestcpus/%s", abs_srcdir, test);
@@ -468,14 +461,11 @@ testQemuHotplugCpuPrepare(const char *test,
if (qemuDomainRefreshVcpuInfo(&driver, data->vm, 0, false) < 0)
goto error;
- VIR_FREE(prefix);
-
return data;
error:
virObjectUnref(caps);
testQemuHotplugCpuDataFree(data);
- VIR_FREE(prefix);
return NULL;
}
@@ -484,8 +474,8 @@ static int
testQemuHotplugCpuFinalize(struct testQemuHotplugCpuData *data)
{
int ret = -1;
- char *activeXML = NULL;
- char *configXML = NULL;
+ g_autofree char *activeXML = NULL;
+ g_autofree char *configXML = NULL;
if (data->file_xml_res_live) {
if (!(activeXML = virDomainDefFormat(data->vm->def, driver.xmlopt,
@@ -509,8 +499,6 @@ testQemuHotplugCpuFinalize(struct testQemuHotplugCpuData *data)
ret = 0;
cleanup:
- VIR_FREE(activeXML);
- VIR_FREE(configXML);
return ret;
}
diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c
index 3f18fed1c3..0867e3a255 100644
--- a/tests/qemumemlocktest.c
+++ b/tests/qemumemlocktest.c
@@ -31,7 +31,7 @@ testCompareMemLock(const void *data)
{
const struct testInfo *info = data;
virDomainDefPtr def = NULL;
- char *xml = NULL;
+ g_autofree char *xml = NULL;
int ret = -1;
xml = g_strdup_printf("%s/qemumemlockdata/qemumemlock-%s.xml", abs_srcdir,
@@ -46,7 +46,6 @@ testCompareMemLock(const void *data)
cleanup:
virDomainDefFree(def);
- VIR_FREE(xml);
return ret;
}
@@ -57,7 +56,7 @@ static int
mymain(void)
{
int ret = 0;
- char *fakerootdir;
+ g_autofree char *fakerootdir = NULL;
virQEMUCapsPtr qemuCaps = NULL;
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
@@ -69,10 +68,8 @@ mymain(void)
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
- if (qemuTestDriverInit(&driver) < 0) {
- VIR_FREE(fakerootdir);
+ if (qemuTestDriverInit(&driver) < 0)
return EXIT_FAILURE;
- }
driver.privileged = true;
@@ -154,7 +151,6 @@ mymain(void)
virFileDeleteTree(fakerootdir);
qemuTestDriverFree(&driver);
- VIR_FREE(fakerootdir);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/qemumigparamstest.c b/tests/qemumigparamstest.c
index 057cde5e72..f4357e0f53 100644
--- a/tests/qemumigparamstest.c
+++ b/tests/qemumigparamstest.c
@@ -59,11 +59,11 @@ qemuMigParamsTestXML2XML(const void *opaque)
{
const qemuMigParamsData *data = opaque;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- char *xmlFile = NULL;
+ g_autofree char *xmlFile = NULL;
xmlDocPtr doc = NULL;
xmlXPathContextPtr ctxt = NULL;
qemuMigrationParamsPtr migParams = NULL;
- char *actualXML = NULL;
+ g_autofree char *actualXML = NULL;
int ret = -1;
xmlFile = g_strdup_printf("%s/qemumigparamsdata/%s.xml", abs_srcdir,
@@ -86,8 +86,6 @@ qemuMigParamsTestXML2XML(const void *opaque)
ret = 0;
cleanup:
- VIR_FREE(xmlFile);
- VIR_FREE(actualXML);
qemuMigrationParamsFree(migParams);
xmlXPathFreeContext(ctxt);
xmlFreeDoc(doc);
@@ -100,12 +98,12 @@ qemuMigParamsTestXML(const void *opaque)
{
const qemuMigParamsData *data = opaque;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- char *replyFile = NULL;
- char *xmlFile = NULL;
+ g_autofree char *replyFile = NULL;
+ g_autofree char *xmlFile = NULL;
qemuMonitorTestPtr mon = NULL;
virJSONValuePtr params = NULL;
qemuMigrationParamsPtr migParams = NULL;
- char *actualXML = NULL;
+ g_autofree char *actualXML = NULL;
int ret = -1;
replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
@@ -134,9 +132,6 @@ qemuMigParamsTestXML(const void *opaque)
ret = 0;
cleanup:
- VIR_FREE(replyFile);
- VIR_FREE(xmlFile);
- VIR_FREE(actualXML);
virJSONValueFree(params);
qemuMigrationParamsFree(migParams);
qemuMonitorTestFree(mon);
@@ -148,13 +143,13 @@ static int
qemuMigParamsTestJSON(const void *opaque)
{
const qemuMigParamsData *data = opaque;
- char *replyFile = NULL;
- char *jsonFile = NULL;
+ g_autofree char *replyFile = NULL;
+ g_autofree char *jsonFile = NULL;
qemuMonitorTestPtr mon = NULL;
virJSONValuePtr paramsIn = NULL;
virJSONValuePtr paramsOut = NULL;
qemuMigrationParamsPtr migParams = NULL;
- char *actualJSON = NULL;
+ g_autofree char *actualJSON = NULL;
int ret = -1;
replyFile = g_strdup_printf("%s/qemumigparamsdata/%s.reply",
@@ -182,9 +177,6 @@ qemuMigParamsTestJSON(const void *opaque)
ret = 0;
cleanup:
- VIR_FREE(replyFile);
- VIR_FREE(jsonFile);
- VIR_FREE(actualJSON);
virJSONValueFree(paramsIn);
virJSONValueFree(paramsOut);
qemuMigrationParamsFree(migParams);
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index c7396e4361..08e90757b1 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -724,7 +724,7 @@ qemuMonitorTestProcessGuestAgentSync(qemuMonitorTestPtr test,
virJSONValuePtr args;
unsigned long long id;
const char *cmdname;
- char *retmsg = NULL;
+ g_autofree char *retmsg = NULL;
int ret = -1;
if (!(val = virJSONValueFromString(cmdstr)))
@@ -757,7 +757,6 @@ qemuMonitorTestProcessGuestAgentSync(qemuMonitorTestPtr test,
cleanup:
virJSONValueFree(val);
- VIR_FREE(retmsg);
return ret;
}
@@ -908,7 +907,7 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTestPtr test,
struct qemuMonitorTestHandlerData *data = item->opaque;
virJSONValuePtr val = NULL;
virJSONValuePtr args;
- char *argstr = NULL;
+ g_autofree char *argstr = NULL;
const char *cmdname;
int ret = -1;
@@ -947,7 +946,6 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTestPtr test,
ret = qemuMonitorTestAddResponse(test, data->response);
cleanup:
- VIR_FREE(argstr);
virJSONValueFree(val);
return ret;
}
@@ -1228,7 +1226,7 @@ qemuMonitorTestNewFromFile(const char *fileName,
bool simple)
{
qemuMonitorTestPtr test = NULL;
- char *json = NULL;
+ g_autofree char *json = NULL;
char *tmp;
char *singleReply;
@@ -1277,7 +1275,6 @@ qemuMonitorTestNewFromFile(const char *fileName,
goto error;
cleanup:
- VIR_FREE(json);
return test;
error:
@@ -1334,14 +1331,13 @@ qemuMonitorTestFullAddItem(qemuMonitorTestPtr test,
const char *response,
size_t line)
{
- char *cmderr;
+ g_autofree char *cmderr = NULL;
int ret;
cmderr = g_strdup_printf("wrong expected command in %s:%zu: ", filename,
line);
ret = qemuMonitorTestAddItemVerbatim(test, command, cmderr, response);
- VIR_FREE(cmderr);
return ret;
}
@@ -1369,7 +1365,7 @@ qemuMonitorTestNewFromFileFull(const char *fileName,
virHashTablePtr qmpschema)
{
qemuMonitorTestPtr ret = NULL;
- char *jsonstr = NULL;
+ g_autofree char *jsonstr = NULL;
char *tmp;
size_t line = 0;
@@ -1435,7 +1431,6 @@ qemuMonitorTestNewFromFileFull(const char *fileName,
}
cleanup:
- VIR_FREE(jsonstr);
return ret;
error:
diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c
index ad182c7bf7..6da8a91a9e 100644
--- a/tests/qemusecuritymock.c
+++ b/tests/qemusecuritymock.c
@@ -129,7 +129,7 @@ virFileGetXAttrQuiet(const char *path,
char **value)
{
int ret = -1;
- char *key;
+ g_autofree char *key = NULL;
char *val;
key = get_key(path, name);
@@ -148,7 +148,6 @@ virFileGetXAttrQuiet(const char *path,
ret = 0;
cleanup:
virMutexUnlock(&m);
- VIR_FREE(key);
return ret;
}
@@ -186,8 +185,8 @@ int virFileSetXAttr(const char *path,
const char *value)
{
int ret = -1;
- char *key;
- char *val;
+ g_autofree char *key = NULL;
+ g_autofree char *val = NULL;
key = get_key(path, name);
val = g_strdup(value);
@@ -203,8 +202,6 @@ int virFileSetXAttr(const char *path,
ret = 0;
cleanup:
virMutexUnlock(&m);
- VIR_FREE(val);
- VIR_FREE(key);
return ret;
}
@@ -213,7 +210,7 @@ int virFileRemoveXAttr(const char *path,
const char *name)
{
int ret = -1;
- char *key;
+ g_autofree char *key = NULL;
key = get_key(path, name);
@@ -225,7 +222,6 @@ int virFileRemoveXAttr(const char *path,
errno = ENODATA;
virMutexUnlock(&m);
- VIR_FREE(key);
return ret;
}
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index ebc4cd6240..9388f7bf39 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -105,7 +105,7 @@ static virStoragePoolPtr
fakeStoragePoolLookupByName(virConnectPtr conn,
const char *name)
{
- char *xmlpath = NULL;
+ g_autofree char *xmlpath = NULL;
virStoragePoolPtr ret = NULL;
if (STRNEQ(name, "inactive")) {
@@ -122,7 +122,6 @@ fakeStoragePoolLookupByName(virConnectPtr conn,
ret = virGetStoragePool(conn, name, fakeUUID, NULL, NULL);
cleanup:
- VIR_FREE(xmlpath);
return ret;
}
@@ -196,7 +195,7 @@ static char *
fakeStoragePoolGetXMLDesc(virStoragePoolPtr pool,
unsigned int flags_unused G_GNUC_UNUSED)
{
- char *xmlpath = NULL;
+ g_autofree char *xmlpath = NULL;
char *xmlbuf = NULL;
if (STREQ(pool->name, "inactive")) {
@@ -215,7 +214,6 @@ fakeStoragePoolGetXMLDesc(virStoragePoolPtr pool,
}
cleanup:
- VIR_FREE(xmlpath);
return xmlbuf;
}
@@ -560,8 +558,8 @@ static int
testCompareXMLToArgv(const void *data)
{
struct testQemuInfo *info = (void *) data;
- char *migrateURI = NULL;
- char *actualargv = NULL;
+ g_autofree char *migrateURI = NULL;
+ g_autofree char *actualargv = NULL;
unsigned int flags = info->flags;
unsigned int parseFlags = info->parseFlags;
int ret = -1;
@@ -689,14 +687,12 @@ testCompareXMLToArgv(const void *data)
cleanup:
VIR_FREE(log);
- VIR_FREE(actualargv);
virDomainChrSourceDefClear(&monitor_chr);
virCommandFree(cmd);
virObjectUnref(vm);
virSetConnectSecret(NULL);
virSetConnectStorage(NULL);
virObjectUnref(conn);
- VIR_FREE(migrateURI);
if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
qemuTestSetHostArch(&driver, VIR_ARCH_NONE);
@@ -719,7 +715,7 @@ static int
mymain(void)
{
int ret = 0;
- char *fakerootdir;
+ g_autofree char *fakerootdir = NULL;
virHashTablePtr capslatest = NULL;
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
@@ -3366,7 +3362,6 @@ mymain(void)
VIR_FREE(driver.config->nbdTLSx509certdir);
qemuTestDriverFree(&driver);
- VIR_FREE(fakerootdir);
virHashFree(capslatest);
virFileWrapperClearPrefixes();
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index c17e3303b0..ccb810ee08 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -55,7 +55,7 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
{
const struct testQemuInfo *data = opaque;
virDomainObjPtr obj = NULL;
- char *actual = NULL;
+ g_autofree char *actual = NULL;
int ret = -1;
if (!(obj = virDomainObjParseFile(data->infile, driver.xmlopt,
@@ -85,7 +85,6 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
cleanup:
virDomainObjEndAPI(&obj);
- VIR_FREE(actual);
return ret;
}
@@ -132,7 +131,7 @@ static int
mymain(void)
{
int ret = 0;
- char *fakerootdir;
+ g_autofree char *fakerootdir = NULL;
virQEMUDriverConfigPtr cfg = NULL;
virHashTablePtr capslatest = NULL;
g_autoptr(virConnect) conn = NULL;
@@ -1501,7 +1500,6 @@ mymain(void)
virHashFree(capslatest);
qemuTestDriverFree(&driver);
- VIR_FREE(fakerootdir);
virFileWrapperClearPrefixes();
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 855e51460b..51ac59bade 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -220,15 +220,13 @@ virCapsPtr testQemuCapsInit(void)
}
if (virTestGetDebug()) {
- char *caps_str;
+ g_autofree char *caps_str = NULL;
caps_str = virCapabilitiesFormatXML(caps);
if (!caps_str)
goto cleanup;
VIR_TEST_DEBUG("QEMU driver capabilities:\n%s", caps_str);
-
- VIR_FREE(caps_str);
}
return caps;
@@ -496,7 +494,7 @@ testQemuGetLatestCapsForArch(const char *arch,
struct dirent *ent;
DIR *dir = NULL;
int rc;
- char *fullsuffix = NULL;
+ g_autofree char *fullsuffix = NULL;
unsigned long maxver = 0;
unsigned long ver;
g_autofree char *maxname = NULL;
@@ -542,7 +540,6 @@ testQemuGetLatestCapsForArch(const char *arch,
ret = g_strdup_printf("%s/%s", TEST_QEMU_CAPS_PATH, maxname);
cleanup:
- VIR_FREE(fullsuffix);
virDirClose(&dir);
return ret;
}
--
2.26.2