[PATCH 06/36] qemuDomainAssignMemorySlots: Refactor cleanup

Peter Krempa posted 36 patches 4 years, 2 months ago
[PATCH 06/36] qemuDomainAssignMemorySlots: Refactor cleanup
Posted by Peter Krempa 4 years, 2 months ago
Automatically free the 'slotmap' bitmap and get rid of the cleanup
section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_domain_address.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

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;
 }


-- 
2.31.1

Re: [PATCH 06/36] qemuDomainAssignMemorySlots: Refactor cleanup
Posted by Ján Tomko 4 years, 2 months ago
On a Thursday in 2021, Peter Krempa wrote:
>Automatically free the 'slotmap' bitmap and get rid of the cleanup
>section.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_domain_address.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano