Browse Source

Collapse underflow and overflow checks into a single block.

ok djm@ millert@
OPENBSD_6_1
dtucker 7 years ago
parent
commit
73af3c1b7e
1 changed files with 4 additions and 7 deletions
  1. +4
    -7
      src/lib/libutil/fmt_scaled.c

+ 4
- 7
src/lib/libutil/fmt_scaled.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: fmt_scaled.c,v 1.14 2017/03/15 00:13:18 dtucker Exp $ */
/* $OpenBSD: fmt_scaled.c,v 1.15 2017/03/15 05:25:56 dtucker Exp $ */
/*
* Copyright (c) 2001, 2002, 2003 Ian F. Darwin. All rights reserved.
@ -166,12 +166,9 @@ scan_scaled(char *scaled, long long *result)
}
scale_fact = scale_factors[i];
if (whole >= LLONG_MAX / scale_fact) {
errno = ERANGE;
return -1;
}
if (whole <= LLONG_MIN / scale_fact) {
/* check for overflow and underflow after scaling */
if (whole > LLONG_MAX / scale_fact ||
whole < LLONG_MIN / scale_fact) {
errno = ERANGE;
return -1;
}


Loading…
Cancel
Save