diff options
author | ache <ache@FreeBSD.org> | 2001-09-04 21:28:01 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-09-04 21:28:01 +0000 |
commit | c516d85954afe1aa395f00ff5e9aa3e0ffa952e3 (patch) | |
tree | d8429c8d89fac31d0a1c7c632e6796b7deff3bb2 /lib/libc/stdlib | |
parent | 13bdb37167dd1e967ed266d727cbe61d6eb6de69 (diff) | |
download | FreeBSD-src-c516d85954afe1aa395f00ff5e9aa3e0ffa952e3.zip FreeBSD-src-c516d85954afe1aa395f00ff5e9aa3e0ffa952e3.tar.gz |
Portability fix: use unsigned cast to guaranteed positive part of expression
in case {L}LONG_MAX > abs({L}LONG_MIN). Non-functional change - we don't
have any such platforms.
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r-- | lib/libc/stdlib/strtol.c | 2 | ||||
-rw-r--r-- | lib/libc/stdlib/strtoll.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/stdlib/strtol.c b/lib/libc/stdlib/strtol.c index f57d45f..3bb13e1 100644 --- a/lib/libc/stdlib/strtol.c +++ b/lib/libc/stdlib/strtol.c @@ -107,7 +107,7 @@ strtol(nptr, endptr, base) * Set 'any' if any `digits' consumed; make it negative to indicate * overflow. */ - cutoff = neg ? (unsigned long)-(LONG_MIN + LONG_MAX) + LONG_MAX + cutoff = neg ? -(LONG_MIN + LONG_MAX) + (unsigned long)LONG_MAX : LONG_MAX; cutlim = cutoff % base; cutoff /= base; diff --git a/lib/libc/stdlib/strtoll.c b/lib/libc/stdlib/strtoll.c index 121ef55..0ce3909 100644 --- a/lib/libc/stdlib/strtoll.c +++ b/lib/libc/stdlib/strtoll.c @@ -107,7 +107,7 @@ strtoll(nptr, endptr, base) * Set 'any' if any `digits' consumed; make it negative to indicate * overflow. */ - cutoff = neg ? (unsigned long long)-(LLONG_MIN + LLONG_MAX) + LLONG_MAX + cutoff = neg ? -(LLONG_MIN + LLONG_MAX) + (unsigned long long)LLONG_MAX : LLONG_MAX; cutlim = cutoff % base; cutoff /= base; |