1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

lib:util: Fix undefined behavior in bitmap.c

lib/util/bitmap.c:77: runtime error: left shift of 1 by 31 places cannot
be represented in type 'int'

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
This commit is contained in:
Andreas Schneider 2018-11-22 15:06:42 +01:00 committed by Gary Lockyer
parent 470a9b891a
commit 93ab0cef2a

View File

@ -74,7 +74,7 @@ bool bitmap_set(struct bitmap *bm, unsigned i)
i, bm->n)); i, bm->n));
return false; return false;
} }
bm->b[i/32] |= (1<<(i%32)); bm->b[i/32] |= (1U<<(i%32));
return true; return true;
} }
@ -88,7 +88,7 @@ bool bitmap_clear(struct bitmap *bm, unsigned i)
i, bm->n)); i, bm->n));
return false; return false;
} }
bm->b[i/32] &= ~(1<<(i%32)); bm->b[i/32] &= ~(1U<<(i%32));
return true; return true;
} }
@ -98,7 +98,7 @@ query a bit in a bitmap
bool bitmap_query(struct bitmap *bm, unsigned i) bool bitmap_query(struct bitmap *bm, unsigned i)
{ {
if (i >= bm->n) return false; if (i >= bm->n) return false;
if (bm->b[i/32] & (1<<(i%32))) { if (bm->b[i/32] & (1U<<(i%32))) {
return true; return true;
} }
return false; return false;