summaryrefslogtreecommitdiff
path: root/ext2fs
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2023-02-02 00:37:00 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-02-02 00:37:00 +0100
commit0cc80b3913489e74f6d5a0ac9b8a4c5523d9cecd (patch)
tree162fe5f68fbf68498deb46482b5b5c3f2cb05261 /ext2fs
parentd21b09b328956996466f35a45b28c4ab51f1f4e3 (diff)
Avoid undefined-behavior
1 << 31 is undefined behavior, 1 needs to be made unsigned for << 31 to be defined behavior.
Diffstat (limited to 'ext2fs')
-rw-r--r--ext2fs/ext2fs.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/ext2fs/ext2fs.h b/ext2fs/ext2fs.h
index 88c9fe81..c17cf37c 100644
--- a/ext2fs/ext2fs.h
+++ b/ext2fs/ext2fs.h
@@ -127,7 +127,7 @@ EXT2FS_EI int
test_bit (unsigned num, unsigned char *bitmap)
{
const uint32_t *const bw = (uint32_t *) bitmap + (num >> 5);
- const uint_fast32_t mask = 1 << (num & 31);
+ const uint_fast32_t mask = 1U << (num & 31);
return *bw & mask;
}
@@ -137,7 +137,7 @@ EXT2FS_EI int
set_bit (unsigned num, unsigned char *bitmap)
{
uint32_t *const bw = (uint32_t *) bitmap + (num >> 5);
- const uint_fast32_t mask = 1 << (num & 31);
+ const uint_fast32_t mask = 1U << (num & 31);
return (*bw & mask) ?: (*bw |= mask, 0);
}
@@ -147,7 +147,7 @@ EXT2FS_EI int
clear_bit (unsigned num, unsigned char *bitmap)
{
uint32_t *const bw = (uint32_t *) bitmap + (num >> 5);
- const uint_fast32_t mask = 1 << (num & 31);
+ const uint_fast32_t mask = 1U << (num & 31);
return (*bw & mask) ? (*bw &= ~mask, mask) : 0;
}
#endif /* Use extern inlines. */