[PATCH 29/36] lxcSetCpusetTune: Refactor memory clearing

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

 



Use automatic memory clearing for virBitmap and remove a reuse of a
temporary string.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/lxc/lxc_native.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index 972e9cdc15..e9b58cbd1a 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -926,32 +926,28 @@ lxcSetCpuTune(virDomainDef *def, virConf *properties)
 static int
 lxcSetCpusetTune(virDomainDef *def, virConf *properties)
 {
-    g_autofree char *value = NULL;
-    virBitmap *nodeset = NULL;
+    g_autofree char *cpus = NULL;
+    g_autofree char *mems = NULL;
+    g_autoptr(virBitmap) nodeset = NULL;

     if (virConfGetValueString(properties, "lxc.cgroup.cpuset.cpus",
-                              &value) > 0) {
-        if (virBitmapParse(value, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
+                              &cpus) > 0) {
+        if (virBitmapParse(cpus, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0)
             return -1;
         def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC;
-        g_free(value);
-        value = NULL;
     }

     if (virConfGetValueString(properties, "lxc.cgroup.cpuset.mems",
-                              &value) > 0) {
-        if (virBitmapParse(value, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0)
+                              &mems) > 0) {
+        if (virBitmapParse(mems, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0)
             return -1;
         if (virDomainNumatuneSet(def->numa,
                                  def->placement_mode ==
                                  VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
                                  VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC,
                                  VIR_DOMAIN_NUMATUNE_MEM_STRICT,
-                                 nodeset) < 0) {
-            virBitmapFree(nodeset);
+                                 nodeset) < 0)
             return -1;
-        }
-        virBitmapFree(nodeset);
     }

     return 0;
-- 
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