]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
xen_xl.c: Use g_autoptr() for virCPUDef
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 14 Jan 2022 08:37:29 +0000 (09:37 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 17 Jan 2022 08:53:45 +0000 (09:53 +0100)
In xenParseXLVnuma() the @cpu variable is freed explicitly.
However, when switched to g_autoptr(virCPUDef) the explicit call
can be removed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/libxl/xen_xl.c

index 6e5f7488a0154a4e852689811f0160e9322c74f8..2f50d885e1dfa0b6b23fab099c159f6ba4fa8bf3 100644 (file)
@@ -396,7 +396,7 @@ xenParseXLVnuma(virConf *conf,
     size_t vcpus = 0;
     size_t nr_nodes = 0;
     size_t vnodeCnt = 0;
-    virCPUDef *cpu = NULL;
+    g_autoptr(virCPUDef) cpu = NULL;
     virConfValue *list;
     virConfValue *vnode;
     virDomainNuma *numa;
@@ -529,14 +529,11 @@ xenParseXLVnuma(virConf *conf,
     }
 
     cpu->type = VIR_CPU_TYPE_GUEST;
-    def->cpu = cpu;
+    def->cpu = g_steal_pointer(&cpu);
 
     ret = 0;
 
  cleanup:
-    if (ret)
-        VIR_FREE(cpu);
-
     return ret;
 }