mirror of
https://github.com/transmission/transmission
synced 2024-12-27 18:18:10 +00:00
in bitfield.c's countRange() function, make walk_end an invariant
This commit is contained in:
parent
8a2061f2cf
commit
3d5b43b5b4
1 changed files with 2 additions and 1 deletions
|
@ -90,6 +90,7 @@ countRange (const tr_bitfield * b, size_t begin, size_t end)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
uint8_t val;
|
uint8_t val;
|
||||||
|
const size_t walk_end = MIN (b->alloc_count, last_byte);
|
||||||
|
|
||||||
/* first byte */
|
/* first byte */
|
||||||
i = begin - (first_byte * 8);
|
i = begin - (first_byte * 8);
|
||||||
|
@ -99,7 +100,7 @@ countRange (const tr_bitfield * b, size_t begin, size_t end)
|
||||||
ret += trueBitCount[val];
|
ret += trueBitCount[val];
|
||||||
|
|
||||||
/* middle bytes */
|
/* middle bytes */
|
||||||
for (i=first_byte+1; i<b->alloc_count && i<last_byte; ++i)
|
for (i=first_byte+1; i<walk_end; ++i)
|
||||||
ret += trueBitCount[b->bits[i]];
|
ret += trueBitCount[b->bits[i]];
|
||||||
|
|
||||||
/* last byte */
|
/* last byte */
|
||||||
|
|
Loading…
Reference in a new issue