The default type of an integer constant is int. This reduced the possible bits for a shift to 32. But the size of uintmax_t is most likely larger (64 bit). Thus the upper 32 bit cannot be accessed correctly with this bitarray implementation.
Signed-off-by: Sven Eckelmann sven@narfation.org --- bitarray.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bitarray.c b/bitarray.c index 133f6e7..354eddd 100644 --- a/bitarray.c +++ b/bitarray.c @@ -49,7 +49,7 @@ uint8_t get_bit_status( TYPE_OF_WORD *seq_bits, uint16_t last_seqno, uint16_t cu word_offset= ( last_seqno - curr_seqno ) % WORD_BIT_SIZE; /* which position in the selected word */ word_num = ( last_seqno - curr_seqno ) / WORD_BIT_SIZE; /* which word */
- if ( seq_bits[word_num] & 1<<word_offset ) /* get position status */ + if ( seq_bits[word_num] & (1ULL << word_offset)) /* get position status */ return 1; else return 0; @@ -72,7 +72,7 @@ void bit_mark( TYPE_OF_WORD *seq_bits, int32_t n ) { word_offset= n%WORD_BIT_SIZE; /* which position in the selected word */ word_num = n/WORD_BIT_SIZE; /* which word */
- seq_bits[word_num]|= 1<<word_offset; /* turn the position on */ + seq_bits[word_num] |= 1ULL << word_offset; /* turn the position on */ }
/* shift the packet array p by n places. */