]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
test_virCapabilitiesGetCpusForNodemask: 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>
tests/vircapstest.c

index d1b50338441535a689e3fea3d0cbfb15029e9e65..697803fdc948ec82854fdb98389c316fca7f2d18 100644 (file)
@@ -33,28 +33,21 @@ static int
 test_virCapabilitiesGetCpusForNodemask(const void *data G_GNUC_UNUSED)
 {
     const char *nodestr = "3,4,5,6";
-    virBitmap *nodemask = NULL;
-    virBitmap *cpumap = NULL;
+    g_autoptr(virBitmap) nodemask = NULL;
+    g_autoptr(virBitmap) cpumap = NULL;
     g_autoptr(virCapsHostNUMA) caps = NULL;
     int mask_size = 8;
-    int ret = -1;
 
     if (!(caps = virTestCapsBuildNUMATopology(3)))
-        goto error;
+        return -1;
 
     if (virBitmapParse(nodestr, &nodemask, mask_size) < 0)
-        goto error;
+        return -1;
 
     if (!(cpumap = virCapabilitiesHostNUMAGetCpus(caps, nodemask)))
-        goto error;
-
-    ret = 0;
-
- error:
-    virBitmapFree(nodemask);
-    virBitmapFree(cpumap);
-    return ret;
+        return -1;
 
+    return 0;
 }