From: Peter Krempa Date: Tue, 7 Dec 2021 16:20:46 +0000 (+0100) Subject: qemuDomainAssignMemorySlots: Refactor cleanup X-Git-Tag: v8.0.0-rc1~323 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b18972630590e13fd963a02e39a1048194f39ab;p=thirdparty%2Flibvirt.git qemuDomainAssignMemorySlots: Refactor cleanup Automatically free the 'slotmap' bitmap and get rid of the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index f4cddc6176..18fc34d049 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -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; }