if value to be translated is larger than INT64_MAX, this function will not be convenient for caller to be aware of it, so change a little for this.
Signed-off-by: liguang <lig.f...@cn.fujitsu.com> --- cutils.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/cutils.c b/cutils.c index 4f0692f..da05c9e 100644 --- a/cutils.c +++ b/cutils.c @@ -219,7 +219,7 @@ static int64_t suffix_mul(char suffix, int64_t unit) int64_t strtosz_suffix_unit(const char *nptr, char **end, const char default_suffix, int64_t unit) { - int64_t retval = -1; + int64_t retval = EINVAL; char *endptr; unsigned char c; int mul_required = 0; @@ -246,6 +246,7 @@ int64_t strtosz_suffix_unit(const char *nptr, char **end, goto fail; } if ((val * mul >= INT64_MAX) || val < 0) { + retval = ERANGE; goto fail; } retval = val * mul; -- 1.7.2.5