From 967c84ebb0dff1cb020e3fec21a31fd8794698d7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 3 Sep 2024 10:46:52 +0200 Subject: resolved: simplify dns_scope_get_n_dns_servers(), don't count each time --- src/resolve/resolved-dns-scope.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c index 58e08e8dc4..734728f905 100644 --- a/src/resolve/resolved-dns-scope.c +++ b/src/resolve/resolved-dns-scope.c @@ -138,23 +138,15 @@ DnsServer *dns_scope_get_dns_server(DnsScope *s) { } unsigned dns_scope_get_n_dns_servers(DnsScope *s) { - unsigned n = 0; - DnsServer *i; - assert(s); if (s->protocol != DNS_PROTOCOL_DNS) return 0; if (s->link) - i = s->link->dns_servers; + return s->link->n_dns_servers; else - i = s->manager->dns_servers; - - for (; i; i = i->servers_next) - n++; - - return n; + return s->manager->n_dns_servers; } void dns_scope_next_dns_server(DnsScope *s, DnsServer *if_current) { -- cgit v1.2.3