tree-wide: make use of errno_or_else() everywhere
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "in-addr-util.h"
|
||||
#include "macro.h"
|
||||
#include "parse-util.h"
|
||||
@@ -315,7 +316,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))
|
||||
return errno > 0 ? -errno : -EINVAL;
|
||||
return errno_or_else(EINVAL);
|
||||
|
||||
*ret = TAKE_PTR(x);
|
||||
return 0;
|
||||
@@ -345,7 +346,7 @@ int in_addr_prefix_to_string(int family, const union in_addr_union *u, unsigned
|
||||
|
||||
errno = 0;
|
||||
if (!inet_ntop(family, u, x, l))
|
||||
return errno > 0 ? -errno : -EINVAL;
|
||||
return errno_or_else(EINVAL);
|
||||
|
||||
p = x + strlen(x);
|
||||
l -= strlen(x);
|
||||
@@ -384,7 +385,7 @@ int in_addr_ifindex_to_string(int family, const union in_addr_union *u, int ifin
|
||||
|
||||
errno = 0;
|
||||
if (!inet_ntop(family, u, x, l))
|
||||
return errno > 0 ? -errno : -EINVAL;
|
||||
return errno_or_else(EINVAL);
|
||||
|
||||
sprintf(strchr(x, 0), "%%%i", ifindex);
|
||||
|
||||
@@ -404,7 +405,7 @@ int in_addr_from_string(int family, const char *s, union in_addr_union *ret) {
|
||||
|
||||
errno = 0;
|
||||
if (inet_pton(family, s, ret ?: &buffer) <= 0)
|
||||
return errno > 0 ? -errno : -EINVAL;
|
||||
return errno_or_else(EINVAL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user