summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorYury Norov <yury.norov@gmail.com>2022-07-01 05:54:25 -0700
committerYury Norov <yury.norov@gmail.com>2022-07-15 06:35:54 -0700
commit4dea97f8636d0514befc9fc5cf342b351b7d0e20 (patch)
tree229c6eb22cd7c99bbe8d942a8f1b84465199a2fa /tools
parente2863a78593d638d3924a6f67900c4820034f349 (diff)
downloadlinux-4dea97f8636d0514befc9fc5cf342b351b7d0e20.tar.gz
linux-4dea97f8636d0514befc9fc5cf342b351b7d0e20.tar.bz2
linux-4dea97f8636d0514befc9fc5cf342b351b7d0e20.zip
lib/bitmap: change type of bitmap_weight to unsigned long
bitmap_weight() doesn't return negative values, so change it's type to unsigned long. It may help compiler to generate better code and catch bugs. Signed-off-by: Yury Norov <yury.norov@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/include/linux/bitmap.h4
-rw-r--r--tools/lib/bitmap.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/tools/include/linux/bitmap.h b/tools/include/linux/bitmap.h
index 2ae7ab8ed7d1..ae1852e39142 100644
--- a/tools/include/linux/bitmap.h
+++ b/tools/include/linux/bitmap.h
@@ -11,7 +11,7 @@
#define DECLARE_BITMAP(name,bits) \
unsigned long name[BITS_TO_LONGS(bits)]
-int __bitmap_weight(const unsigned long *bitmap, int bits);
+unsigned long __bitmap_weight(const unsigned long *bitmap, unsigned int bits);
void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
const unsigned long *bitmap2, int bits);
bool __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
@@ -61,7 +61,7 @@ static inline bool bitmap_full(const unsigned long *src, unsigned int nbits)
return find_first_zero_bit(src, nbits) == nbits;
}
-static inline int bitmap_weight(const unsigned long *src, unsigned int nbits)
+static inline unsigned long bitmap_weight(const unsigned long *src, unsigned int nbits)
{
if (small_const_nbits(nbits))
return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
diff --git a/tools/lib/bitmap.c b/tools/lib/bitmap.c
index 2e351d63fdba..e1fafc131a49 100644
--- a/tools/lib/bitmap.c
+++ b/tools/lib/bitmap.c
@@ -5,9 +5,9 @@
*/
#include <linux/bitmap.h>
-int __bitmap_weight(const unsigned long *bitmap, int bits)
+unsigned long __bitmap_weight(const unsigned long *bitmap, unsigned int bits)
{
- int k, w = 0, lim = bits/BITS_PER_LONG;
+ unsigned long k, w = 0, lim = bits/BITS_PER_LONG;
for (k = 0; k < lim; k++)
w += hweight_long(bitmap[k]);