X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fbitmap.c;h=ac568e97be072112dea6c3e4d7e65b9417a09e8d;hb=69fc54f47bbc35e81bfe2e38e57f5dcfd9858df4;hp=d607526d5f55be3234ac0be98fe8b324819c5674;hpb=e0edde6fee279cdbbf3c179f5f50adaf0c7c7f1e;p=sliver-openvswitch.git diff --git a/lib/bitmap.c b/lib/bitmap.c index d607526d5..ac568e97b 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -24,6 +24,7 @@ bitmap_allocate1(size_t n_bits) { size_t n_bytes = bitmap_n_bytes(n_bits); size_t n_longs = bitmap_n_longs(n_bits); + size_t r_bits = n_bits % BITMAP_ULONG_BITS; unsigned long *bitmap; /* Allocate and initialize most of the bitmap. */ @@ -32,7 +33,9 @@ bitmap_allocate1(size_t n_bits) /* Ensure that the last "unsigned long" in the bitmap only has as many * 1-bits as there actually should be. */ - bitmap[n_longs - 1] = (1UL << (n_bits % BITMAP_ULONG_BITS)) - 1; + if (r_bits) { + bitmap[n_longs - 1] = (1UL << r_bits) - 1; + } return bitmap; }