]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virshParseCPUList: Refactor cleanup
authorPeter Krempa <pkrempa@redhat.com>
Tue, 7 Dec 2021 16:22:26 +0000 (17:22 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 10 Dec 2021 15:36:24 +0000 (16:36 +0100)
Use automatic memory freeing for the temporary bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virsh-domain.c

index 8379f9f13582272b32f7a2d11f5814430f052301..2338d6522a0a9638b59b63e46e7cd0af93e21fff 100644 (file)
@@ -6983,7 +6983,7 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen,
                   const char *cpulist, int maxcpu)
 {
     unsigned char *cpumap = NULL;
-    virBitmap *map = NULL;
+    g_autoptr(virBitmap) map = NULL;
 
     if (cpulist[0] == 'r') {
         map = virBitmapNew(maxcpu);
@@ -6994,21 +6994,19 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen,
         if (virBitmapParse(cpulist, &map, 1024) < 0 ||
             virBitmapIsAllClear(map)) {
             vshError(ctl, _("Invalid cpulist '%s'"), cpulist);
-            goto cleanup;
+            return NULL;
         }
         lastcpu = virBitmapLastSetBit(map);
         if (lastcpu >= maxcpu) {
             vshError(ctl, _("CPU %d in cpulist '%s' exceed the maxcpu %d"),
                      lastcpu, cpulist, maxcpu);
-            goto cleanup;
+            return NULL;
         }
     }
 
     if (virBitmapToData(map, &cpumap, cpumaplen) < 0)
-        goto cleanup;
+        return NULL;
 
- cleanup:
-    virBitmapFree(map);
     return cpumap;
 }