From 40008b83a03f04812a7bfb2325c0e8006a7a25c8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 5 Mar 2024 10:34:47 +0100 Subject: [PATCH] =?UTF-8?q?resolved:=20rename=20variable=20found=5F{a|aaaa?= =?UTF-8?q?}=20=E2=86=92=20question=5Ffor=5F{a|aaaa}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Te variables indicate what kind of RRs we are looking for, but the name so far suggests it was about what we already found. Let's rename the variables to make the purpose clearer. --- src/resolve/resolved-etc-hosts.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/resolve/resolved-etc-hosts.c b/src/resolve/resolved-etc-hosts.c index 6af160a477..bd129cd2ca 100644 --- a/src/resolve/resolved-etc-hosts.c +++ b/src/resolve/resolved-etc-hosts.c @@ -491,7 +491,7 @@ static int etc_hosts_lookup_by_name( const char *name, DnsAnswer **answer) { - bool found_a = false, found_aaaa = false; + bool question_for_a = false, question_for_aaaa = false; const struct in_addr_data *a; EtcHostsItemByName *item; DnsResourceKey *t; @@ -513,6 +513,7 @@ static int etc_hosts_lookup_by_name( return 0; } + /* Determine whether we are looking for A and/or AAAA RRs */ DNS_QUESTION_FOREACH(t, q) { if (!IN_SET(t->type, DNS_TYPE_A, DNS_TYPE_AAAA, DNS_TYPE_ANY)) continue; @@ -526,20 +527,20 @@ static int etc_hosts_lookup_by_name( continue; if (IN_SET(t->type, DNS_TYPE_A, DNS_TYPE_ANY)) - found_a = true; + question_for_a = true; if (IN_SET(t->type, DNS_TYPE_AAAA, DNS_TYPE_ANY)) - found_aaaa = true; + question_for_aaaa = true; - if (found_a && found_aaaa) - break; + if (question_for_a && question_for_aaaa) + break; /* We are looking for both, no need to continue loop */ } SET_FOREACH(a, item ? item->addresses : NULL) { EtcHostsItemByAddress *item_by_addr; const char *canonical_name; - if ((!found_a && a->family == AF_INET) || - (!found_aaaa && a->family == AF_INET6)) + if ((!question_for_a && a->family == AF_INET) || + (!question_for_aaaa && a->family == AF_INET6)) continue; item_by_addr = hashmap_get(hosts->by_address, a); @@ -559,7 +560,7 @@ static int etc_hosts_lookup_by_name( return r; } - return found_a || found_aaaa; + return question_for_a || question_for_aaaa; } int manager_etc_hosts_lookup(Manager *m, DnsQuestion *q, DnsAnswer **answer) {