lib/strutils: parse_size() fix frac with zeros
Fix 0.001G as well as accept 0.000G as valid number. Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
5fcdf204b0
commit
482e0a0754
|
@ -122,6 +122,8 @@ check_suffix:
|
||||||
|
|
||||||
for (p = fstr; *p == '0'; p++)
|
for (p = fstr; *p == '0'; p++)
|
||||||
frac_zeros++;
|
frac_zeros++;
|
||||||
|
fstr = p;
|
||||||
|
if (isdigit(*fstr)) {
|
||||||
errno = 0, end = NULL;
|
errno = 0, end = NULL;
|
||||||
frac = strtoumax(fstr, &end, 0);
|
frac = strtoumax(fstr, &end, 0);
|
||||||
if (end == fstr ||
|
if (end == fstr ||
|
||||||
|
@ -129,6 +131,9 @@ check_suffix:
|
||||||
rc = errno ? -errno : -EINVAL;
|
rc = errno ? -errno : -EINVAL;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
end = (char *) p;
|
||||||
|
|
||||||
if (frac && (!end || !*end)) {
|
if (frac && (!end || !*end)) {
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
goto err; /* without suffix, but with frac */
|
goto err; /* without suffix, but with frac */
|
||||||
|
|
Loading…
Reference in New Issue