Reported by Coverity as:
CID
1355338 (#1 of 1): Bad bit shift operation (BAD_SHIFT)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
} else {
v = (uint64_t) integer_definition->value._signed;
if (integer_declaration->len < 64) {
- /* Round length to the nearest 3-bit */
- uint8_t rounded_len =
- integer_declaration->len +
- ((integer_declaration->len + 2) % 3);
+ size_t len = integer_declaration->len;
+ size_t rounded_len;
+ assert(len != 0);
+ /* Round length to the nearest 3-bit */
+ rounded_len = (((len - 1) / 3) + 1) * 3;
v &= ((uint64_t) 1 << rounded_len) - 1;
}
}