From: Ruediger Meier Date: Sun, 21 Feb 2016 15:18:04 +0000 (+0100) Subject: lib/strutils: parse_size(), sync errno and return value X-Git-Tag: v2.28-rc1~77^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f643d3349ed4f110401e009de2c04a8cb497fd5b;p=thirdparty%2Futil-linux.git lib/strutils: parse_size(), sync errno and return value Maybe strtosize_or_err() is the only function which uses this errno (wrongly). But it doesnt hurt to maintain rc as well as errno. Signed-off-by: Ruediger Meier --- diff --git a/lib/strutils.c b/lib/strutils.c index 03a367b910..64a6b992ef 100644 --- a/lib/strutils.c +++ b/lib/strutils.c @@ -91,7 +91,7 @@ int parse_size(const char *str, uintmax_t *res, int *power) if (p == str || (errno != 0 && (x == UINTMAX_MAX || x == 0))) { - rc = errno ? -errno : -1; + rc = errno ? -errno : -EINVAL; goto err; } if (!p || !*p) @@ -119,7 +119,7 @@ check_suffix: frac = strtoumax(fstr, &p, 0); if (p == fstr || (errno != 0 && (frac == UINTMAX_MAX || frac == 0))) { - rc = errno ? -errno : -1; + rc = errno ? -errno : -EINVAL; goto err; } if (frac && (!p || !*p)) { @@ -164,6 +164,8 @@ check_suffix: done: *res = x; err: + if (rc < 0) + errno = -rc; return rc; }