summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-link.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-17 01:39:46 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-17 01:42:26 +0200
commita2ba62c719224a4b47751623ca5e8b0333f49721 (patch)
tree9d8d2332a7c63ab55089e83c6fd82ca85bd73efc /src/resolve/resolved-link.c
parentb45d9e86e41c453e0b57f2f8316bef06dee42e5a (diff)
sd-network: remove redundant array size parameter from functions that return arrays
As long as the number of array entries is relatively small it's nicer to simply return the number of entries directly, instead of using a size_t* return parameter for it.
Diffstat (limited to 'src/resolve/resolved-link.c')
-rw-r--r--src/resolve/resolved-link.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c
index 61b112cb05..e309b80728 100644
--- a/src/resolve/resolved-link.c
+++ b/src/resolve/resolved-link.c
@@ -100,11 +100,9 @@ int link_update_rtnl(Link *l, sd_rtnl_message *m) {
static int update_dhcp_dns_servers(Link *l) {
_cleanup_dhcp_lease_unref_ sd_dhcp_lease *lease = NULL;
- struct in_addr *nameservers = NULL;
+ const struct in_addr *nameservers = NULL;
DnsServer *s, *nx;
- unsigned i;
- size_t n;
- int r;
+ int r, n, i;
assert(l);
@@ -119,9 +117,11 @@ static int update_dhcp_dns_servers(Link *l) {
LIST_FOREACH(servers, s, l->dhcp_dns_servers)
s->marked = true;
- r = sd_dhcp_lease_get_dns(lease, &nameservers, &n);
- if (r < 0)
+ n = sd_dhcp_lease_get_dns(lease, &nameservers);
+ if (n < 0) {
+ r = n;
goto clear;
+ }
for (i = 0; i < n; i++) {
union in_addr_union a = { .in = nameservers[i] };
@@ -153,18 +153,18 @@ static int update_link_dns_servers(Link *l) {
_cleanup_free_ struct in_addr *nameservers = NULL;
_cleanup_free_ struct in6_addr *nameservers6 = NULL;
DnsServer *s, *nx;
- unsigned i;
- size_t n;
- int r;
+ int r, n, i;
assert(l);
LIST_FOREACH(servers, s, l->link_dns_servers)
s->marked = true;
- r = sd_network_get_dns(l->ifindex, &nameservers, &n);
- if (r < 0)
+ n = sd_network_get_dns(l->ifindex, &nameservers);
+ if (n < 0) {
+ r = n;
goto clear;
+ }
for (i = 0; i < n; i++) {
union in_addr_union a = { .in = nameservers[i] };
@@ -179,9 +179,11 @@ static int update_link_dns_servers(Link *l) {
}
}
- r = sd_network_get_dns6(l->ifindex, &nameservers6, &n);
- if (r < 0)
+ n = sd_network_get_dns6(l->ifindex, &nameservers6);
+ if (n < 0) {
+ r = n;
goto clear;
+ }
for (i = 0; i < n; i++) {
union in_addr_union a = { .in6 = nameservers6[i] };