]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
test: Use g_autofree more
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 1 Nov 2021 09:33:49 +0000 (10:33 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 11 Nov 2021 15:16:28 +0000 (16:16 +0100)
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 <mprivozn@redhat.com>
Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
tests/qemuagenttest.c
tests/qemumonitorjsontest.c
tests/qemumonitortestutils.c

index 28a543ce0564e30d8eae6ad35ac55b6ea72cdcf3..a659feedfb184618273abcb40c1afee2c75cce4a 100644 (file)
@@ -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;
 }
 
index fab413d05e2b3c1bd9ca17d7f82fd91881ce7b73..69c41ad42da7f32ee83b528d4ff7b47b2f5f9f7c 100644 (file)
@@ -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;
 }
 
index 2c63e95bda7bb4fd88d5bbe6fef52ca521a7075b..2ca17f7f48764e071a8aebd479bfc53362e11121 100644 (file)
@@ -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;
 
 }