btrfs-progs: reset errno before strtoull()
strtoull may return the boundary values, if the callers could expect that and verify it then the errno must be reset before the call. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
e9a66cde91
commit
a0468efe86
|
@ -158,6 +158,7 @@ u64 parse_size_from_string(const char *s)
|
|||
error("size value '%s' is less equal than 0", s);
|
||||
exit(1);
|
||||
}
|
||||
errno = 0;
|
||||
ret = strtoull(s, &endptr, 10);
|
||||
if (endptr == s) {
|
||||
error("size value '%s' is invalid", s);
|
||||
|
|
|
@ -108,6 +108,7 @@ int sysfs_read_file_u64(const char *name, u64 *value)
|
|||
if (ret < 0)
|
||||
goto out;
|
||||
/* Raw value in any numeric format should work, followed by a newline. */
|
||||
errno = 0;
|
||||
*value = strtoull(str, NULL, 0);
|
||||
out:
|
||||
close(fd);
|
||||
|
@ -127,6 +128,7 @@ int sysfs_read_fsid_file_u64(int fd, const char *name, u64 *value)
|
|||
if (ret < 0)
|
||||
goto out;
|
||||
/* Raw value in any numeric format should work, followed by a newline. */
|
||||
errno = 0;
|
||||
*value = strtoull(str, NULL, 0);
|
||||
out:
|
||||
close(fd);
|
||||
|
|
Loading…
Reference in New Issue