From f643d3349ed4f110401e009de2c04a8cb497fd5b Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Sun, 21 Feb 2016 16:18:04 +0100 Subject: 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 --- lib/strutils.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/strutils.c') diff --git a/lib/strutils.c b/lib/strutils.c index 03a367b91..64a6b992e 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; } -- cgit v1.2.3-55-g7522