tree-wide: make use of errno_or_else() everywhere

This commit is contained in:
Lennart Poettering
2019-07-11 23:20:31 +02:00
parent fed813778f
commit 66855de739
16 changed files with 60 additions and 58 deletions
+5 -4
View File
@@ -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;
}