From: Michal Privoznik Date: Mon, 1 Nov 2021 09:33:49 +0000 (+0100) Subject: test: Use g_autofree more X-Git-Tag: v7.10.0-rc1~148 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74da85bcb9b62197bbd0905f416d32964d27e04e;p=thirdparty%2Flibvirt.git test: Use g_autofree more This commit doesn't aim to extinguish every VIR_FREE() call, but only those which were touched by the previous commit. The aim is to drop cleanup/error labels. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index 28a543ce05..a659feedfb 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -624,7 +624,7 @@ testQemuAgentCPU(const void *data) { virDomainXMLOption *xmlopt = (virDomainXMLOption *)data; g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt); - qemuAgentCPUInfo *cpuinfo = NULL; + g_autofree qemuAgentCPUInfo *cpuinfo = NULL; int nvcpus; int ret = -1; @@ -694,7 +694,6 @@ testQemuAgentCPU(const void *data) ret = 0; cleanup: - VIR_FREE(cpuinfo); return ret; } diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index fab413d05e..69c41ad42d 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -247,7 +247,7 @@ testQemuMonitorJSONGetVersion(const void *opaque) int major; int minor; int micro; - char *package = NULL; + g_autofree char *package = NULL; g_autoptr(qemuMonitorTest) test = NULL; if (!(test = qemuMonitorTestNewSchema(xmlopt, data->schema))) @@ -337,7 +337,6 @@ testQemuMonitorJSONGetVersion(const void *opaque) ret = 0; cleanup: - VIR_FREE(package); return ret; } diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 2c63e95bda..2ca17f7f48 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -997,8 +997,8 @@ qemuMonitorCommonTestNew(virDomainXMLOption *xmlopt, virDomainChrSourceDef *src) { g_autoptr(qemuMonitorTest) test = NULL; - char *path = NULL; - char *tmpdir_template = NULL; + g_autofree char *path = NULL; + g_autofree char *tmpdir_template = NULL; test = g_new0(qemuMonitorTest, 1); @@ -1047,8 +1047,6 @@ qemuMonitorCommonTestNew(virDomainXMLOption *xmlopt, return g_steal_pointer(&test); error: - VIR_FREE(path); - VIR_FREE(tmpdir_template); return NULL; }