summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-08-18 10:03:36 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-08-18 10:03:36 (GMT)
commit34ce5b73e72eeff2b9232d3aa3839726cfdcbf0f (patch)
treee6ea52aa1386ed1f898789d273f6cd1d582f57de /src/common
parentef66e5930efdfccb6b7db125ada6908650e745da (diff)
Fixed a bug when counting the number of set bits in a bitfield.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/bits.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/common/bits.c b/src/common/bits.c
index cdcef85..32041b9 100644
--- a/src/common/bits.c
+++ b/src/common/bits.c
@@ -582,7 +582,7 @@ size_t popcount_for_bit_field(const bitfield_t *field)
value = field->bits[i];
if (remaining < (8 * sizeof(unsigned long)))
- value &= 1 << (remaining - 1);
+ value &= (1lu << (remaining + 1)) - 1;
#if __WORDSIZE == 64
result += popcount_64(value);