diff --git a/ds/bitmap.c b/ds/bitmap.c index c1038f9..12d88f8 100644 --- a/ds/bitmap.c +++ b/ds/bitmap.c @@ -88,7 +88,7 @@ unsigned int bitmap_highest_set(unsigned long *map, unsigned long nbits) } if (last_word == 0x00) { - return (unsigned int)-1; + return BITMAP_NPOS; } return bit_index + (BITS_PER_WORD - __builtin_ctzl(last_word) - 1); @@ -108,7 +108,7 @@ unsigned int bitmap_highest_clear(unsigned long *map, unsigned long nbits) } if (last_word == ~(unsigned long)0) { - return (unsigned int)-1; + return BITMAP_NPOS; } if (last_word == 0) { @@ -134,7 +134,7 @@ unsigned int bitmap_lowest_set(unsigned long *map, unsigned long nbits) } if (last_word == 0x00) { - return (unsigned int)-1; + return BITMAP_NPOS; } return bit_index + __builtin_clzl(last_word); @@ -160,7 +160,7 @@ unsigned int bitmap_lowest_clear(unsigned long *map, unsigned long nbits) } if (last_word == (~(unsigned long)0)) { - return (unsigned int)-1; + return BITMAP_NPOS; } return bit_index + __builtin_clzl(~last_word); diff --git a/include/socks/bitmap.h b/include/socks/bitmap.h index 4b393f0..0210eef 100644 --- a/include/socks/bitmap.h +++ b/include/socks/bitmap.h @@ -10,6 +10,7 @@ extern "C" { #define BITS_PER_WORD (8 * sizeof(unsigned long)) #define __DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) #define BITMAP_WORDS(nbits) __DIV_ROUND_UP(nbits, BITS_PER_WORD) +#define BITMAP_NPOS ((unsigned int)-1) #define DECLARE_BITMAP(name, nbits) unsigned long name[BITMAP_WORDS(nbits)]