diff options
author | Harald Welte <laforge@osmocom.org> | 2020-10-09 10:08:44 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2020-10-09 10:10:07 +0200 |
commit | cb11a60d25d87d1576571fb94c6c84d0b1291165 (patch) | |
tree | 351f47f96669318e0b9dd6cf2f6c6591022babba /src | |
parent | f445150c57ab5205f52ba98924b9e3c9602b2701 (diff) |
osmo_float_str_to_int: When using strtoll(), use LLONG_{MAX,MIN}
When we use strtoll(), the return type is "long long" and we cannot
compare against LONG_MAX and LONG_MIN but must compare against LLONG_MAX
and LLONG_MIN.
Change-Id: I9c18ac237b4aacd56639d1faffa6841c8ad7b8da
Closes: OS#4787
Diffstat (limited to 'src')
-rw-r--r-- | src/utils.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/utils.c b/src/utils.c index c0ab1667..7fd7223a 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1263,7 +1263,7 @@ int osmo_float_str_to_int(int64_t *val, const char *str, unsigned int precision) if (!point || point > str) { errno = 0; integer = strtoll(str, &endptr, 10); - if ((errno == ERANGE && (integer == LONG_MAX || integer == LONG_MIN)) + if ((errno == ERANGE && (integer == LLONG_MAX || integer == LLONG_MIN)) || (errno != 0 && integer == 0)) return -ERANGE; @@ -1295,7 +1295,7 @@ int osmo_float_str_to_int(int64_t *val, const char *str, unsigned int precision) } errno = 0; decimal = strtoll(decimal_str + skip_digits, &endptr, 10); - if ((errno == ERANGE && (decimal == LONG_MAX || decimal == LONG_MIN)) + if ((errno == ERANGE && (decimal == LLONG_MAX || decimal == LLONG_MIN)) || (errno != 0 && decimal == 0)) return -ERANGE; |