diff options
author | Yury Norov <yury.norov@gmail.com> | 2022-07-01 15:54:25 +0300 |
---|---|---|
committer | Yury Norov <yury.norov@gmail.com> | 2022-07-15 16:35:54 +0300 |
commit | 4dea97f8636d0514befc9fc5cf342b351b7d0e20 (patch) | |
tree | 229c6eb22cd7c99bbe8d942a8f1b84465199a2fa /include/linux | |
parent | e2863a78593d638d3924a6f67900c4820034f349 (diff) | |
download | linux-4dea97f8636d0514befc9fc5cf342b351b7d0e20.tar.xz |
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 'include/linux')
-rw-r--r-- | include/linux/bitmap.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index e1a438bdda52..035d4ac66641 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -163,7 +163,7 @@ bool __bitmap_intersects(const unsigned long *bitmap1, const unsigned long *bitmap2, unsigned int nbits); bool __bitmap_subset(const unsigned long *bitmap1, const unsigned long *bitmap2, unsigned int nbits); -int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits); +unsigned long __bitmap_weight(const unsigned long *bitmap, unsigned int nbits); void __bitmap_set(unsigned long *map, unsigned int start, int len); void __bitmap_clear(unsigned long *map, unsigned int start, int len); @@ -431,7 +431,8 @@ static inline bool bitmap_full(const unsigned long *src, unsigned int nbits) return find_first_zero_bit(src, nbits) == nbits; } -static __always_inline int bitmap_weight(const unsigned long *src, unsigned int nbits) +static __always_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)); |