commit 45e99485dbe03c5ed1019ba3eca2d2ed750a7149
parent efc025bc3038571204f54c10aa73921ef898d2c1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Mon, 31 Dec 2018 10:32:28 +0000
[libc] Simplify strtol* functions
Checking inside of the loop makes easier the overflow check
Diffstat:
2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/libc/stdlib/strtol.c b/src/libc/stdlib/strtol.c
@@ -46,11 +46,8 @@ strtol(const char *s, char **end, int base)
if (-d < LONG_MIN - n)
goto overflow;
n -= d;
- }
-
- if (n == LONG_MIN && sign < 0) {
- --t;
- goto overflow;
+ if (n == LONG_MIN && sign < 0)
+ goto overflow;
}
if (end && t != s)
diff --git a/src/libc/stdlib/strtoll.c b/src/libc/stdlib/strtoll.c
@@ -46,11 +46,8 @@ strtoll(const char *s, char **end, int base)
if (-d < LLONG_MIN - n)
goto overflow;
n -= d;
- }
-
- if (n == LLONG_MIN && sign < 0) {
- --t;
- goto overflow;
+ if (n == LONG_MIN && sign < 0)
+ goto overflow;
}
if (end && t != s)