[PATCH 1/6] util: bitmap: Make bitmaps const in virBitmapNewData and virBitmapDataToString

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

 



The functions just read the passed pointer so it can be marked as const.
---
 src/util/virbitmap.c | 6 +++---
 src/util/virbitmap.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 3b85c16..0c04f1a 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -689,12 +689,12 @@ virBitmapPtr virBitmapNewCopy(virBitmapPtr src)
  * Returns a pointer to the allocated bitmap or NULL if
  * memory cannot be allocated.
  */
-virBitmapPtr virBitmapNewData(void *data, int len)
+virBitmapPtr virBitmapNewData(const void *data, int len)
 {
     virBitmapPtr bitmap;
     size_t i, j;
     unsigned long *p;
-    unsigned char *bytes = data;
+    const unsigned char *bytes = data;

     bitmap = virBitmapNew(len * CHAR_BIT);
     if (!bitmap)
@@ -1058,7 +1058,7 @@ virBitmapCountBits(virBitmapPtr bitmap)
  * Returns: a string representation of the data, or NULL on error
  */
 char *
-virBitmapDataToString(void *data,
+virBitmapDataToString(const void *data,
                       int len)
 {
     virBitmapPtr map = NULL;
diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
index 5984b80..58e0ee6 100644
--- a/src/util/virbitmap.h
+++ b/src/util/virbitmap.h
@@ -101,7 +101,7 @@ virBitmapParseUnlimited(const char *str,

 virBitmapPtr virBitmapNewCopy(virBitmapPtr src) ATTRIBUTE_NONNULL(1);

-virBitmapPtr virBitmapNewData(void *data, int len) ATTRIBUTE_NONNULL(1);
+virBitmapPtr virBitmapNewData(const void *data, int len) ATTRIBUTE_NONNULL(1);

 int virBitmapToData(virBitmapPtr bitmap, unsigned char **data, int *dataLen)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
@@ -138,7 +138,7 @@ ssize_t virBitmapNextClearBit(virBitmapPtr bitmap, ssize_t pos)
 size_t virBitmapCountBits(virBitmapPtr bitmap)
     ATTRIBUTE_NONNULL(1);

-char *virBitmapDataToString(void *data,
+char *virBitmapDataToString(const void *data,
                             int len)
     ATTRIBUTE_NONNULL(1);
 bool virBitmapOverlaps(virBitmapPtr b1,
-- 
2.10.0

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