[PATCH 3/6] Format NULL bitmap as an empty string

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

 



This simplifies the usage in {libxl,qemu}DomainGetNumaParameters
and it's needed for consistent error reporting in virBitmapFormat.

Also remove the forgotten ATTRIBUTE_NONNULL marker.
---
 src/libxl/libxl_driver.c | 3 +--
 src/qemu/qemu_driver.c   | 2 +-
 src/util/virbitmap.c     | 6 +-----
 src/util/virbitmap.h     | 3 +--
 4 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 9feacb1..c62c55e 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -4002,8 +4002,7 @@ libxlDomainGetNumaParameters(virDomainPtr dom,
                 }
             }
 
-            nodeset = virBitmapFormat(nodes);
-            if (!nodeset && VIR_STRDUP(nodeset, "") < 0)
+            if (!(nodeset = virBitmapFormat(nodes)))
                 goto cleanup;
 
             if (virTypedParameterAssign(param, VIR_DOMAIN_NUMA_NODESET,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3a7622a..578c223 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8914,7 +8914,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
         case 1: /* fill numa nodeset here */
             if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
                 nodeset = virBitmapFormat(persistentDef->numatune.memory.nodemask);
-                if (!nodeset && VIR_STRDUP(nodeset, "") < 0)
+                if (!nodeset)
                     goto cleanup;
             } else {
                 if (virCgroupGetCpusetMems(priv->cgroup, &nodeset) < 0)
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index e44dce6..1dc74cb 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -227,11 +227,7 @@ char *virBitmapFormat(virBitmapPtr bitmap)
     bool first = true;
     int start, cur, prev;
 
-    if (!bitmap)
-        return NULL;
-
-    cur = virBitmapNextSetBit(bitmap, -1);
-    if (cur < 0) {
+    if (!bitmap || (cur = virBitmapNextSetBit(bitmap, -1)) < 0) {
         char *ret;
         ignore_value(VIR_STRDUP(ret, ""));
         return ret;
diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
index b682523..6573aa2 100644
--- a/src/util/virbitmap.h
+++ b/src/util/virbitmap.h
@@ -69,8 +69,7 @@ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
 char *virBitmapString(virBitmapPtr bitmap)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
 
-char *virBitmapFormat(virBitmapPtr bitmap)
-    ATTRIBUTE_NONNULL(1);
+char *virBitmapFormat(virBitmapPtr bitmap);
 
 int virBitmapParse(const char *str,
                    char sep,
-- 
1.8.3.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]