/* SPDX-License-Identifier: LGPL-2.1+ */
+#include <errno.h>
#include <string.h>
#include <sys/socket.h>
sc = lookup_af(name, strlen(name));
if (!sc)
- return AF_UNSPEC;
+ return -EINVAL;
return sc->id;
}
/* SPDX-License-Identifier: LGPL-2.1+ */
+#include <errno.h>
#include <net/if_arp.h>
#include <string.h>
sc = lookup_arphrd(name, strlen(name));
if (!sc)
- return 0;
+ return -EINVAL;
return sc->id;
}
int af;
af = af_from_name(*s);
- if (af <= 0)
- return -EINVAL;
+ if (af < 0)
+ return af;
if (!invert == c->address_families_whitelist) {
r = set_put(c->address_families, INT_TO_PTR(af));
r = socket_protocol_from_name(s);
if (r < 0)
- return -EINVAL;
+ return r;
if (!IN_SET(r, IPPROTO_UDPLITE, IPPROTO_SCTP))
return -EPROTONOSUPPORT;
}
af = af_from_name(word);
- if (af <= 0) {
- log_syntax(unit, LOG_ERR, filename, line, 0,
+ if (af < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, af,
"Failed to parse address family, ignoring: %s", word);
continue;
}
for (;;) {
_cleanup_free_ char *word = NULL;
- int cap;
r = extract_first_word(&rvalue, &word, NULL, 0);
if (r < 0) {
if (r == 0)
break;
- cap = capability_from_name(word);
- if (cap < 0) {
- log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse capability, ignoring: %s", word);
+ r = capability_from_name(word);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse capability, ignoring: %s", word);
continue;
}
- u |= UINT64_C(1) << cap;
+ u |= UINT64_C(1) << r;
}
if (u == 0)
else
minus = (uint64_t) -1;
} else {
- int cap;
-
- cap = capability_from_name(t);
- if (cap < 0)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "Failed to parse capability %s.", t);
+ r = capability_from_name(t);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse capability %s.", t);
if (c == ARG_CAPABILITY)
- plus |= 1ULL << (uint64_t) cap;
+ plus |= 1ULL << r;
else
- minus |= 1ULL << (uint64_t) cap;
+ minus |= 1ULL << r;
}
}
/* SPDX-License-Identifier: LGPL-2.1+ */
+#include <errno.h>
#include <netinet/in.h>
#include <string.h>
sc = lookup_socket_protocol(name, strlen(name));
if (!sc)
- return 0;
+ return -EINVAL;
return sc->id;
}
assert_se(af_to_name(af_max()) == NULL);
assert_se(af_to_name(-1) == NULL);
- assert_se(af_from_name("huddlduddl") == AF_UNSPEC);
- assert_se(af_from_name("") == AF_UNSPEC);
+ assert_se(af_from_name("huddlduddl") == -EINVAL);
+ assert_se(af_from_name("") == -EINVAL);
return 0;
}
assert_se(arphrd_to_name(arphrd_max()) == NULL);
assert_se(arphrd_to_name(0) == NULL);
- assert_se(arphrd_from_name("huddlduddl") == 0);
- assert_se(arphrd_from_name("") == 0);
+ assert_se(arphrd_from_name("huddlduddl") == -EINVAL);
+ assert_se(arphrd_from_name("") == -EINVAL);
return 0;
}