diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2024-06-06 20:09:46 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-06-07 20:44:44 +0200 |
commit | bda80ef53f5b85917773ccebd3008f560658e342 (patch) | |
tree | 4d58ad4767da92fc2f0457a14e6a9bbcb2dc1fc9 /util.c | |
parent | 0e36fe1a4350dcdde2cc09eb7ba9c99361996ab9 (diff) | |
download | passt-bda80ef53f5b85917773ccebd3008f560658e342.tar passt-bda80ef53f5b85917773ccebd3008f560658e342.tar.gz passt-bda80ef53f5b85917773ccebd3008f560658e342.tar.bz2 passt-bda80ef53f5b85917773ccebd3008f560658e342.tar.lz passt-bda80ef53f5b85917773ccebd3008f560658e342.tar.xz passt-bda80ef53f5b85917773ccebd3008f560658e342.tar.zst passt-bda80ef53f5b85917773ccebd3008f560658e342.zip |
util: Use unsigned indices for bits in bitmaps
A negative bit index in a bitmap doesn't make sense. Avoid this by
construction by using unsigned indices. While we're there adjust
bitmap_isset() to return a bool instead of an int.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -232,7 +232,7 @@ int timespec_diff_ms(const struct timespec *a, const struct timespec *b) * @map: Pointer to bitmap * @bit: Bit number to set */ -void bitmap_set(uint8_t *map, int bit) +void bitmap_set(uint8_t *map, unsigned bit) { unsigned long *word = (unsigned long *)map + BITMAP_WORD(bit); @@ -244,7 +244,7 @@ void bitmap_set(uint8_t *map, int bit) * @map: Pointer to bitmap * @bit: Bit number to clear */ -void bitmap_clear(uint8_t *map, int bit) +void bitmap_clear(uint8_t *map, unsigned bit) { unsigned long *word = (unsigned long *)map + BITMAP_WORD(bit); @@ -256,9 +256,9 @@ void bitmap_clear(uint8_t *map, int bit) * @map: Pointer to bitmap * @bit: Bit number to check * - * Return: one if given bit is set, zero if it's not + * Return: true if given bit is set, false if it's not */ -int bitmap_isset(const uint8_t *map, int bit) +bool bitmap_isset(const uint8_t *map, unsigned bit) { const unsigned long *word = (const unsigned long *)map + BITMAP_WORD(bit); |