From 34ce5b73e72eeff2b9232d3aa3839726cfdcbf0f Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sat, 18 Aug 2018 12:03:36 +0200
Subject: Fixed a bug when counting the number of set bits in a bitfield.

---
 src/common/bits.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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);
-- 
cgit v0.11.2-87-g4458