diff options
author | Yury Norov <yury.norov@gmail.com> | 2022-07-01 05:54:25 -0700 |
---|---|---|
committer | Yury Norov <yury.norov@gmail.com> | 2022-07-15 06:35:54 -0700 |
commit | 4dea97f8636d0514befc9fc5cf342b351b7d0e20 (patch) | |
tree | 229c6eb22cd7c99bbe8d942a8f1b84465199a2fa /lib/bitmap.c | |
parent | e2863a78593d638d3924a6f67900c4820034f349 (diff) |
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 'lib/bitmap.c')
-rw-r--r-- | lib/bitmap.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index 9bc80f5bf149..2b67cd657692 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -333,10 +333,9 @@ bool __bitmap_subset(const unsigned long *bitmap1, } EXPORT_SYMBOL(__bitmap_subset); -int __bitmap_weight(const unsigned long *bitmap, unsigned int bits) +unsigned long __bitmap_weight(const unsigned long *bitmap, unsigned int bits) { - unsigned int k, lim = bits/BITS_PER_LONG; - int w = 0; + unsigned long k, w = 0, lim = bits/BITS_PER_LONG; for (k = 0; k < lim; k++) w += hweight_long(bitmap[k]); |