render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c1c534
From c5355b3f4b45e1a0a432ba7ee420649ef5c4c4a5 Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <c5355b3f4b45e1a0a432ba7ee420649ef5c4c4a5@dist-git>
c1c534
From: Martin Kletzander <mkletzan@redhat.com>
c1c534
Date: Wed, 31 Jan 2018 16:32:10 +0100
c1c534
Subject: [PATCH] util: Make prefix optional in virBitampString
c1c534
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1289368
c1c534
c1c534
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
c1c534
Reviewed-by: John Ferlan <jferlan@redhat.com>
c1c534
(cherry picked from commit d127aced0a694b8158074e167c8c1db03bbc2df1)
c1c534
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
c1c534
---
c1c534
 src/qemu/qemu_capabilities.c | 4 ++--
c1c534
 src/util/virbitmap.c         | 8 ++++++--
c1c534
 src/util/virbitmap.h         | 2 +-
c1c534
 3 files changed, 9 insertions(+), 5 deletions(-)
c1c534
c1c534
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
c1c534
index bd80edc978..d6bd28d072 100644
c1c534
--- a/src/qemu/qemu_capabilities.c
c1c534
+++ b/src/qemu/qemu_capabilities.c
c1c534
@@ -1525,7 +1525,7 @@ int virQEMUCapsParseHelpStr(const char *qemu,
c1c534
                                    qemuCaps, check_yajl) < 0)
c1c534
         goto cleanup;
c1c534
 
c1c534
-    strflags = virBitmapString(qemuCaps->flags);
c1c534
+    strflags = virBitmapString(qemuCaps->flags, true);
c1c534
     VIR_DEBUG("Version %u.%u.%u, cooked version %u, flags %s",
c1c534
               major, minor, micro, *version, NULLSTR(strflags));
c1c534
     VIR_FREE(strflags);
c1c534
@@ -2407,7 +2407,7 @@ virQEMUCapsClear(virQEMUCapsPtr qemuCaps,
c1c534
 
c1c534
 char *virQEMUCapsFlagsString(virQEMUCapsPtr qemuCaps)
c1c534
 {
c1c534
-    return virBitmapString(qemuCaps->flags);
c1c534
+    return virBitmapString(qemuCaps->flags, true);
c1c534
 }
c1c534
 
c1c534
 
c1c534
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
c1c534
index 57a8fbf82c..f08384ff1c 100644
c1c534
--- a/src/util/virbitmap.c
c1c534
+++ b/src/util/virbitmap.c
c1c534
@@ -312,17 +312,21 @@ int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
c1c534
 /**
c1c534
  * virBitmapString:
c1c534
  * @bitmap: Pointer to bitmap
c1c534
+ * @prefix: Whether to prepend "0x"
c1c534
  *
c1c534
  * Convert @bitmap to printable string.
c1c534
  *
c1c534
  * Returns pointer to the string or NULL on error.
c1c534
  */
c1c534
-char *virBitmapString(virBitmapPtr bitmap)
c1c534
+char *
c1c534
+virBitmapString(virBitmapPtr bitmap,
c1c534
+                bool prefix)
c1c534
 {
c1c534
     virBuffer buf = VIR_BUFFER_INITIALIZER;
c1c534
     size_t sz;
c1c534
 
c1c534
-    virBufferAddLit(&buf, "0x");
c1c534
+    if (prefix)
c1c534
+        virBufferAddLit(&buf, "0x");
c1c534
 
c1c534
     sz = bitmap->map_len;
c1c534
 
c1c534
diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
c1c534
index ffa3c42d79..dc8fb71a07 100644
c1c534
--- a/src/util/virbitmap.h
c1c534
+++ b/src/util/virbitmap.h
c1c534
@@ -80,7 +80,7 @@ bool virBitmapIsBitSet(virBitmapPtr bitmap, size_t b)
c1c534
 int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
c1c534
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK;
c1c534
 
c1c534
-char *virBitmapString(virBitmapPtr bitmap)
c1c534
+char *virBitmapString(virBitmapPtr bitmap, bool prefix)
c1c534
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
c1c534
 
c1c534
 char *virBitmapFormat(virBitmapPtr bitmap);
c1c534
-- 
c1c534
2.16.1
c1c534