tree-wide: check if errno is greater then zero
gcc is confused by the common idiom of
return errno ? -errno : -ESOMETHING
and thinks a positive value may be returned. Replace this condition
with errno > 0 to help gcc and avoid many spurious warnings. I filed
a gcc rfe a long time ago, but it hard to say if it will ever be
implemented [1].
Both conventions were used in the codebase, this change makes things
more consistent. This is a follow up to bcb161b023.
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61846
This commit is contained in:
@@ -219,7 +219,7 @@ int in_addr_to_string(int family, const union in_addr_union *u, char **ret) {
|
||||
errno = 0;
|
||||
if (!inet_ntop(family, u, x, l)) {
|
||||
free(x);
|
||||
return errno ? -errno : -EINVAL;
|
||||
return errno > 0 ? -errno : -EINVAL;
|
||||
}
|
||||
|
||||
*ret = x;
|
||||
@@ -236,7 +236,7 @@ int in_addr_from_string(int family, const char *s, union in_addr_union *ret) {
|
||||
|
||||
errno = 0;
|
||||
if (inet_pton(family, s, ret) <= 0)
|
||||
return errno ? -errno : -EINVAL;
|
||||
return errno > 0 ? -errno : -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user