Use g_autoptr for the virCPUDef variables.

Signed-off-by: Ján Tomko <jto...@redhat.com>
---
 tests/qemumonitorjsontest.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 168d6cd172..d3bee2043e 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -3018,8 +3018,8 @@ 
testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseline(const void *opaque)
 {
     const testGenericData *data = opaque;
     g_autoptr(qemuMonitorTest) test = NULL;
-    virCPUDefPtr cpu_a;
-    virCPUDefPtr cpu_b = NULL;
+    g_autoptr(virCPUDef) cpu_a = virCPUDefNew();
+    g_autoptr(virCPUDef) cpu_b = virCPUDefNew();
     qemuMonitorCPUModelInfoPtr baseline = NULL;
     int ret = -1;
 
@@ -3040,9 +3040,6 @@ 
testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseline(const void *opaque)
                                "}") < 0)
         return -1;
 
-    cpu_a = virCPUDefNew();
-    cpu_b = virCPUDefNew();
-
     cpu_a->model = g_strdup("cpu_a");
     cpu_b->model = g_strdup("cpu_b");
 
@@ -3082,8 +3079,6 @@ 
testQemuMonitorJSONqemuMonitorJSONGetCPUModelBaseline(const void *opaque)
     ret = 0;
 
  cleanup:
-    virCPUDefFree(cpu_a);
-    virCPUDefFree(cpu_b);
     qemuMonitorCPUModelInfoFree(baseline);
     return ret;
 }
-- 
2.24.1

Reply via email to