]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainSelectHotplugVcpuEntities: 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 'ret' bitmap and remove the
pointless 'cleanup' section.

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

index 2e1d18c633cbd7b5d9966f24c41b745ded611878..f307420ac1caa8448d841bfb5ad410df2dc7e56e 100644 (file)
@@ -6473,7 +6473,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def,
                                     unsigned int nvcpus,
                                     bool *enable)
 {
-    virBitmap *ret = NULL;
+    g_autoptr(virBitmap) ret = NULL;
     virDomainVcpuDef *vcpu;
     qemuDomainVcpuPrivate *vcpupriv;
     unsigned int maxvcpus = virDomainDefGetVcpusMax(def);
@@ -6501,7 +6501,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def,
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("target vm vcpu granularity does not allow the "
                                  "desired vcpu count"));
-                goto error;
+                return NULL;
             }
 
             ignore_value(virBitmapSetBit(ret, i));
@@ -6528,7 +6528,7 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def,
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                                _("target vm vcpu granularity does not allow the "
                                  "desired vcpu count"));
-                goto error;
+                return NULL;
             }
 
             ignore_value(virBitmapSetBit(ret, i));
@@ -6539,14 +6539,10 @@ qemuDomainSelectHotplugVcpuEntities(virDomainDef *def,
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                        _("failed to find appropriate hotpluggable vcpus to "
                          "reach the desired target vcpu count"));
-        goto error;
+        return NULL;
     }
 
-    return ret;
-
- error:
-    virBitmapFree(ret);
-    return NULL;
+    return g_steal_pointer(&ret);
 }