[PATCH 11/36] qemuProcessValidateHotpluggableVcpus: Refactor cleanup

Peter Krempa posted 36 patches 4 years, 2 months ago
[PATCH 11/36] qemuProcessValidateHotpluggableVcpus: Refactor cleanup
Posted by Peter Krempa 4 years, 2 months ago
Use automatic memory freeing for the temporary bitmap and remove the
pointless 'cleanup' section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_process.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 6b83a571b9..804205131a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5954,8 +5954,7 @@ qemuProcessValidateHotpluggableVcpus(virDomainDef *def)
     unsigned int maxvcpus = virDomainDefGetVcpusMax(def);
     size_t i = 0;
     size_t j;
-    virBitmap *ordermap = virBitmapNew(maxvcpus + 1);
-    int ret = -1;
+    g_autoptr(virBitmap) ordermap = virBitmapNew(maxvcpus + 1);

     /* validate:
      * - all hotpluggable entities to be hotplugged have the correct data
@@ -5974,14 +5973,14 @@ qemuProcessValidateHotpluggableVcpus(virDomainDef *def)
             if (virBitmapIsBitSet(ordermap, vcpu->order)) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                _("duplicate vcpu order '%u'"), vcpu->order);
-                goto cleanup;
+                return -1;
             }

             if (virBitmapSetBit(ordermap, vcpu->order)) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                _("vcpu order '%u' exceeds vcpu count"),
                                vcpu->order);
-                goto cleanup;
+                return -1;
             }
         }

@@ -5993,7 +5992,7 @@ qemuProcessValidateHotpluggableVcpus(virDomainDef *def)
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                _("vcpus '%zu' and '%zu' are in the same hotplug "
                                  "group but differ in configuration"), i, j);
-                goto cleanup;
+                return -1;
             }
         }

@@ -6003,15 +6002,12 @@ qemuProcessValidateHotpluggableVcpus(virDomainDef *def)
                 !vcpupriv->type) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                _("vcpu '%zu' is missing hotplug data"), i);
-                goto cleanup;
+                return -1;
             }
         }
     }

-    ret = 0;
- cleanup:
-    virBitmapFree(ordermap);
-    return ret;
+    return 0;
 }


-- 
2.31.1

Re: [PATCH 11/36] qemuProcessValidateHotpluggableVcpus: Refactor cleanup
Posted by Ján Tomko 4 years, 2 months ago
On a Thursday in 2021, Peter Krempa wrote:
>Use automatic memory freeing for the temporary bitmap and remove the
>pointless 'cleanup' section.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_process.c | 16 ++++++----------
> 1 file changed, 6 insertions(+), 10 deletions(-)
>

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

Jano