commit c322ed13a88860fa60115775f18a07d2f10aa42a
parent 60e5ff036844491e3ad78a4254171c218dec98c9
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)