The virBitmapIsBitSet API is a permissive one which returns false when
the bit is not set or is out of range. We can do the same if the bitmap
is NULL to aid certain situations when this can happen, but we don't
want to add extra checks.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/util/virbitmap.c | 4 ++--
src/util/virbitmap.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 5b9204cbd7..bdcbd0aece 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -216,7 +216,7 @@ virBitmapIsSet(virBitmap *bitmap, size_t b)
/**
* virBitmapIsBitSet:
- * @bitmap: Pointer to bitmap
+ * @bitmap: Pointer to bitmap (May be NULL)
* @b: bit position to get
*
* Get setting of bit position @b in @bitmap.
@@ -228,7 +228,7 @@ bool
virBitmapIsBitSet(virBitmap *bitmap,
size_t b)
{
- if (bitmap->nbits <= b)
+ if (!bitmap || bitmap->nbits <= b)
return false;
return virBitmapIsSet(bitmap, b);
diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
index e2314904b0..dbd88c9bb5 100644
--- a/src/util/virbitmap.h
+++ b/src/util/virbitmap.h
@@ -61,7 +61,7 @@ void virBitmapClearBitExpand(virBitmap *bitmap, size_t b)
* Get bit @b in @bitmap. Returns false if b is out of range.
*/
bool virBitmapIsBitSet(virBitmap *bitmap, size_t b)
- ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT;
+ G_GNUC_WARN_UNUSED_RESULT;
/*
* Get setting of bit position @b in @bitmap and store in @result
*/
--
2.39.1