lib: bitmap: make the start index of bitmap_set unsigned
[deliverable/linux.git] / lib / bitmap.c
index 06f7e4fe8d2de4046a3139106058b9c831c9b789..2a3a92fc33557c5be8d717a429de63cb86ea852c 100644 (file)
@@ -40,9 +40,9 @@
  * for the best explanations of this ordering.
  */
 
-int __bitmap_empty(const unsigned long *bitmap, int bits)
+int __bitmap_empty(const unsigned long *bitmap, unsigned int bits)
 {
-       int k, lim = bits/BITS_PER_LONG;
+       unsigned int k, lim = bits/BITS_PER_LONG;
        for (k = 0; k < lim; ++k)
                if (bitmap[k])
                        return 0;
@@ -55,9 +55,9 @@ int __bitmap_empty(const unsigned long *bitmap, int bits)
 }
 EXPORT_SYMBOL(__bitmap_empty);
 
-int __bitmap_full(const unsigned long *bitmap, int bits)
+int __bitmap_full(const unsigned long *bitmap, unsigned int bits)
 {
-       int k, lim = bits/BITS_PER_LONG;
+       unsigned int k, lim = bits/BITS_PER_LONG;
        for (k = 0; k < lim; ++k)
                if (~bitmap[k])
                        return 0;
@@ -71,9 +71,9 @@ int __bitmap_full(const unsigned long *bitmap, int bits)
 EXPORT_SYMBOL(__bitmap_full);
 
 int __bitmap_equal(const unsigned long *bitmap1,
-               const unsigned long *bitmap2, int bits)
+               const unsigned long *bitmap2, unsigned int bits)
 {
-       int k, lim = bits/BITS_PER_LONG;
+       unsigned int k, lim = bits/BITS_PER_LONG;
        for (k = 0; k < lim; ++k)
                if (bitmap1[k] != bitmap2[k])
                        return 0;
@@ -86,14 +86,14 @@ int __bitmap_equal(const unsigned long *bitmap1,
 }
 EXPORT_SYMBOL(__bitmap_equal);
 
-void __bitmap_complement(unsigned long *dst, const unsigned long *src, int bits)
+void __bitmap_complement(unsigned long *dst, const unsigned long *src, unsigned int bits)
 {
-       int k, lim = bits/BITS_PER_LONG;
+       unsigned int k, lim = bits/BITS_PER_LONG;
        for (k = 0; k < lim; ++k)
                dst[k] = ~src[k];
 
        if (bits % BITS_PER_LONG)
-               dst[k] = ~src[k] & BITMAP_LAST_WORD_MASK(bits);
+               dst[k] = ~src[k];
 }
 EXPORT_SYMBOL(__bitmap_complement);
 
@@ -182,10 +182,10 @@ void __bitmap_shift_left(unsigned long *dst,
 EXPORT_SYMBOL(__bitmap_shift_left);
 
 int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
-                               const unsigned long *bitmap2, int bits)
+                               const unsigned long *bitmap2, unsigned int bits)
 {
-       int k;
-       int nr = BITS_TO_LONGS(bits);
+       unsigned int k;
+       unsigned int nr = BITS_TO_LONGS(bits);
        unsigned long result = 0;
 
        for (k = 0; k < nr; k++)
@@ -195,10 +195,10 @@ int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
 EXPORT_SYMBOL(__bitmap_and);
 
 void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
-                               const unsigned long *bitmap2, int bits)
+                               const unsigned long *bitmap2, unsigned int bits)
 {
-       int k;
-       int nr = BITS_TO_LONGS(bits);
+       unsigned int k;
+       unsigned int nr = BITS_TO_LONGS(bits);
 
        for (k = 0; k < nr; k++)
                dst[k] = bitmap1[k] | bitmap2[k];
@@ -206,10 +206,10 @@ void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
 EXPORT_SYMBOL(__bitmap_or);
 
 void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
-                               const unsigned long *bitmap2, int bits)
+                               const unsigned long *bitmap2, unsigned int bits)
 {
-       int k;
-       int nr = BITS_TO_LONGS(bits);
+       unsigned int k;
+       unsigned int nr = BITS_TO_LONGS(bits);
 
        for (k = 0; k < nr; k++)
                dst[k] = bitmap1[k] ^ bitmap2[k];
@@ -217,10 +217,10 @@ void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
 EXPORT_SYMBOL(__bitmap_xor);
 
 int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
-                               const unsigned long *bitmap2, int bits)
+                               const unsigned long *bitmap2, unsigned int bits)
 {
-       int k;
-       int nr = BITS_TO_LONGS(bits);
+       unsigned int k;
+       unsigned int nr = BITS_TO_LONGS(bits);
        unsigned long result = 0;
 
        for (k = 0; k < nr; k++)
@@ -230,9 +230,9 @@ int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
 EXPORT_SYMBOL(__bitmap_andnot);
 
 int __bitmap_intersects(const unsigned long *bitmap1,
-                               const unsigned long *bitmap2, int bits)
+                       const unsigned long *bitmap2, unsigned int bits)
 {
-       int k, lim = bits/BITS_PER_LONG;
+       unsigned int k, lim = bits/BITS_PER_LONG;
        for (k = 0; k < lim; ++k)
                if (bitmap1[k] & bitmap2[k])
                        return 1;
@@ -245,9 +245,9 @@ int __bitmap_intersects(const unsigned long *bitmap1,
 EXPORT_SYMBOL(__bitmap_intersects);
 
 int __bitmap_subset(const unsigned long *bitmap1,
-                               const unsigned long *bitmap2, int bits)
+                   const unsigned long *bitmap2, unsigned int bits)
 {
-       int k, lim = bits/BITS_PER_LONG;
+       unsigned int k, lim = bits/BITS_PER_LONG;
        for (k = 0; k < lim; ++k)
                if (bitmap1[k] & ~bitmap2[k])
                        return 0;
@@ -259,9 +259,10 @@ int __bitmap_subset(const unsigned long *bitmap1,
 }
 EXPORT_SYMBOL(__bitmap_subset);
 
-int __bitmap_weight(const unsigned long *bitmap, int bits)
+int __bitmap_weight(const unsigned long *bitmap, unsigned int bits)
 {
-       int k, w = 0, lim = bits/BITS_PER_LONG;
+       unsigned int k, lim = bits/BITS_PER_LONG;
+       int w = 0;
 
        for (k = 0; k < lim; k++)
                w += hweight_long(bitmap[k]);
@@ -273,21 +274,21 @@ int __bitmap_weight(const unsigned long *bitmap, int bits)
 }
 EXPORT_SYMBOL(__bitmap_weight);
 
-void bitmap_set(unsigned long *map, int start, int nr)
+void bitmap_set(unsigned long *map, unsigned int start, int len)
 {
        unsigned long *p = map + BIT_WORD(start);
-       const int size = start + nr;
+       const unsigned int size = start + len;
        int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
        unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
 
-       while (nr - bits_to_set >= 0) {
+       while (len - bits_to_set >= 0) {
                *p |= mask_to_set;
-               nr -= bits_to_set;
+               len -= bits_to_set;
                bits_to_set = BITS_PER_LONG;
                mask_to_set = ~0UL;
                p++;
        }
-       if (nr) {
+       if (len) {
                mask_to_set &= BITMAP_LAST_WORD_MASK(size);
                *p |= mask_to_set;
        }
This page took 0.031319 seconds and 5 git commands to generate.