uintmax_t is defined to have modulo-2^n semantics, and therefore the bottom
bits of (uintmax_t) are guaranteed to be all set. Therefore the checking of
the next character read is unnecessary, as it's already done in the loop
control statement itself. (This is not true about the bottom digit base 10,
which is why the check remains in the decimal case)
Signed-off-by: Phil Carmody <phil@dovecot.fi>
return -1;
do {
- if (n >= ((uintmax_t)-1 >> 4)) {
- if (n > (uintmax_t)-1 >> 4)
- return -1;
- if ((uintmax_t)hex > ((uintmax_t)-1 & 0x0f))
- return -1;
- }
+ if (n > (uintmax_t)-1 >> 4)
+ return -1;
n = (n << 4) + hex;
str++;
} while (_str_parse_hex(*str, &hex) >= 0);
return -1;
for (; *str >= '0' && *str <= '7'; str++) {
- if (n >= ((uintmax_t)-1 >> 3)) {
- if (n > (uintmax_t)-1 >> 3)
- return -1;
- if ((uintmax_t)(*str - '0') > ((uintmax_t)-1 & 0x03))
- return -1;
- }
+ if (n > (uintmax_t)-1 >> 3)
+ return -1;
n = (n << 3) + (*str - '0');
}
if (endp_r != NULL)