summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2016-04-15 22:08:57 +0200
committerMarek Olšák <[email protected]>2016-04-18 19:51:24 +0200
commit9434aa8103e93c9a80421b20f04b526ef543d46e (patch)
tree0ec7ffc7c9a0a0ffc36eedc95b1232385f2b16eb /src
parente50e1f86b092d09a24e21122e1284054c54fb3cd (diff)
gallium/util: fix u_bit_scan_consecutive_range for mask == 0xffffffff
The second ffs returns 0, yielding count == -1. v2: change 1 to 1u Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/util/u_math.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
index b4ac0db3c50..0a829158b11 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -518,9 +518,15 @@ u_bit_scan64(uint64_t *mask)
static inline void
u_bit_scan_consecutive_range(unsigned *mask, int *start, int *count)
{
+ if (*mask == 0xffffffff) {
+ *start = 0;
+ *count = 32;
+ *mask = 0;
+ return;
+ }
*start = ffs(*mask) - 1;
*count = ffs(~(*mask >> *start)) - 1;
- *mask &= ~(((1 << *count) - 1) << *start);
+ *mask &= ~(((1u << *count) - 1) << *start);
}
/**