[PATCH 05/36] virDomainDriverGetIOThreadsConfig: Automatically free virBitmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use g_autoptr for the temp bitmap. To achieve this the variable must be
moved down to the appropriate scope.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/hypervisor/domain_driver.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c
index 31737b0f4a..2083f06287 100644
--- a/src/hypervisor/domain_driver.c
+++ b/src/hypervisor/domain_driver.c
@@ -592,8 +592,6 @@ virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef,
                                   unsigned int bitmap_size)
 {
     virDomainIOThreadInfoPtr *info_ret = NULL;
-    virBitmap *bitmap = NULL;
-    virBitmap *cpumask = NULL;
     size_t i;
     int ret = -1;

@@ -603,6 +601,8 @@ virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef,
     info_ret = g_new0(virDomainIOThreadInfoPtr, targetDef->niothreadids);

     for (i = 0; i < targetDef->niothreadids; i++) {
+        g_autoptr(virBitmap) bitmap = NULL;
+        virBitmap *cpumask = NULL;
         info_ret[i] = g_new0(virDomainIOThreadInfo, 1);

         /* IOThread ID's are taken from the iothreadids list */
@@ -627,8 +627,6 @@ virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef,
         if (virBitmapToData(cpumask, &info_ret[i]->cpumap,
                             &info_ret[i]->cpumaplen) < 0)
             goto cleanup;
-        virBitmapFree(bitmap);
-        bitmap = NULL;
     }

     *info = g_steal_pointer(&info_ret);
@@ -640,7 +638,6 @@ virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef,
             virDomainIOThreadInfoFree(info_ret[i]);
         VIR_FREE(info_ret);
     }
-    virBitmapFree(bitmap);

     return ret;
 }
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux