]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainAssignMemorySlots: Refactor cleanup
authorPeter Krempa <pkrempa@redhat.com>
Tue, 7 Dec 2021 16:20:46 +0000 (17:20 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 10 Dec 2021 15:36:24 +0000 (16:36 +0100)
Automatically free the 'slotmap' bitmap and get rid of the cleanup
section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain_address.c

index f4cddc6176b804c6642117aadc1b67c6b1a5ac18..18fc34d0498589afe84e736634311bbae6b6207f 100644 (file)
@@ -3086,8 +3086,7 @@ qemuDomainReleaseMemoryDeviceSlot(virDomainObj *vm,
 static int
 qemuDomainAssignMemorySlots(virDomainDef *def)
 {
-    virBitmap *slotmap = NULL;
-    int ret = -1;
+    g_autoptr(virBitmap) slotmap = NULL;
     size_t i;
 
     if (!virDomainDefHasMemoryHotplug(def))
@@ -3103,7 +3102,7 @@ qemuDomainAssignMemorySlots(virDomainDef *def)
         case VIR_DOMAIN_MEMORY_MODEL_DIMM:
         case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
             if (qemuAssignMemoryDeviceSlot(def->mems[i], slotmap) < 0)
-                goto cleanup;
+                return -1;
             break;
 
         case VIR_DOMAIN_MEMORY_MODEL_VIRTIO_PMEM:
@@ -3116,12 +3115,7 @@ qemuDomainAssignMemorySlots(virDomainDef *def)
         }
     }
 
-    ret = 0;
-
- cleanup:
-    virBitmapFree(slotmap);
-    return ret;
-
+    return 0;
 }