mirror of
https://github.com/systemd/systemd
synced 2024-09-06 08:46:19 +00:00
util: workaround two gcc warnings
gcc does not know that errno cannot be negative, and warns about unitialized variables later on. Kill the warnings by returning -errno only after checking that errno is positive.
This commit is contained in:
parent
6fe391c56d
commit
48deb058b6
|
@ -290,7 +290,7 @@ int safe_atou(const char *s, unsigned *ret_u) {
|
|||
l = strtoul(s, &x, 0);
|
||||
|
||||
if (!x || x == s || *x || errno)
|
||||
return errno ? -errno : -EINVAL;
|
||||
return errno > 0 ? -errno : -EINVAL;
|
||||
|
||||
if ((unsigned long) (unsigned) l != l)
|
||||
return -ERANGE;
|
||||
|
@ -310,7 +310,7 @@ int safe_atoi(const char *s, int *ret_i) {
|
|||
l = strtol(s, &x, 0);
|
||||
|
||||
if (!x || x == s || *x || errno)
|
||||
return errno ? -errno : -EINVAL;
|
||||
return errno > 0 ? -errno : -EINVAL;
|
||||
|
||||
if ((long) (int) l != l)
|
||||
return -ERANGE;
|
||||
|
|
Loading…
Reference in a new issue