sd-network: make sd_network_link_get_dns() or friends return -ENODATA

To make them consistent with other functions.
This commit is contained in:
Yu Watanabe
2022-09-27 10:42:31 +09:00
parent 778e3da95e
commit e05dd7718d
3 changed files with 6 additions and 16 deletions
+4 -14
View File
@@ -68,10 +68,8 @@ static int network_get_strv(const char *key, char ***ret) {
r = parse_env_file(NULL, "/run/systemd/netif/state", key, &s);
if (r < 0)
return r;
if (isempty(s)) {
*ret = NULL;
return 0;
}
if (isempty(s))
return -ENODATA;
a = strv_split(s, NULL);
if (!a)
@@ -132,7 +130,6 @@ static int network_link_get_boolean(int ifindex, const char *key) {
}
static int network_link_get_strv(int ifindex, const char *key, char ***ret) {
char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex)];
_cleanup_strv_free_ char **a = NULL;
_cleanup_free_ char *s = NULL;
int r;
@@ -140,14 +137,9 @@ static int network_link_get_strv(int ifindex, const char *key, char ***ret) {
assert_return(ifindex > 0, -EINVAL);
assert_return(ret, -EINVAL);
xsprintf(path, "/run/systemd/netif/links/%i", ifindex);
r = parse_env_file(NULL, path, key, &s);
r = network_link_get_string(ifindex, key, &s);
if (r < 0)
return r;
if (isempty(s)) {
*ret = NULL;
return 0;
}
a = strv_split(s, NULL);
if (!a)
@@ -261,7 +253,6 @@ int sd_network_link_get_dns_default_route(int ifindex) {
}
static int network_link_get_ifindexes(int ifindex, const char *key, int **ret) {
char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex)];
_cleanup_free_ int *ifis = NULL;
_cleanup_free_ char *s = NULL;
size_t c = 0;
@@ -270,8 +261,7 @@ static int network_link_get_ifindexes(int ifindex, const char *key, int **ret) {
assert_return(ifindex > 0, -EINVAL);
assert_return(ret, -EINVAL);
xsprintf(path, "/run/systemd/netif/links/%i", ifindex);
r = parse_env_file(NULL, path, key, &s);
r = network_link_get_string(ifindex, key, &s);
if (r < 0)
return r;
+1 -1
View File
@@ -469,7 +469,7 @@ static int link_update_dnssec_negative_trust_anchors(Link *l) {
r = sd_network_link_get_dnssec_negative_trust_anchors(l->ifindex, &ntas);
if (r == -ENODATA)
return r;
return 0;
if (r < 0)
return r;
+1 -1
View File
@@ -972,7 +972,7 @@ static int manager_network_read_link_servers(Manager *m) {
if (r < 0) {
if (r == -ENOMEM)
log_oom();
else
else if (r != -ENODATA)
log_debug_errno(r, "Failed to get link NTP servers: %m");
goto clear;
}