diff options
author | Ruediger Meier | 2016-02-21 16:18:04 +0100 |
---|---|---|
committer | Ruediger Meier | 2016-02-21 18:10:00 +0100 |
commit | f643d3349ed4f110401e009de2c04a8cb497fd5b (patch) | |
tree | 4276472dd98d98f029a54d0442793679ac2e99d1 /lib/strutils.c | |
parent | lib/strutils: add more ERANGE messages (diff) | |
download | kernel-qcow2-util-linux-f643d3349ed4f110401e009de2c04a8cb497fd5b.tar.gz kernel-qcow2-util-linux-f643d3349ed4f110401e009de2c04a8cb497fd5b.tar.xz kernel-qcow2-util-linux-f643d3349ed4f110401e009de2c04a8cb497fd5b.zip |
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 <ruediger.meier@ga-group.nl>
Diffstat (limited to 'lib/strutils.c')
-rw-r--r-- | lib/strutils.c | 6 |
1 files changed, 4 insertions, 2 deletions
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; } |