summaryrefslogtreecommitdiff
path: root/src/resolve
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-12-07 22:53:46 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-12-13 20:29:16 +0900
commit9f1a1f2047bc6cad9cd03a3535b15a84b2c68b9e (patch)
tree383e389454c11f1a8b09a29de610a27126c84f84 /src/resolve
parente4e340990f1d4bad0045dcacd865065bbeb86ead (diff)
downloadsystemd-9f1a1f2047bc6cad9cd03a3535b15a84b2c68b9e.tar.gz
resolve: merge two boolean variables
No functional changes, just refactoring.
Diffstat (limited to 'src/resolve')
-rw-r--r--src/resolve/resolved-etc-hosts.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/resolve/resolved-etc-hosts.c b/src/resolve/resolved-etc-hosts.c
index f41b028b96..547c5fe17d 100644
--- a/src/resolve/resolved-etc-hosts.c
+++ b/src/resolve/resolved-etc-hosts.c
@@ -189,8 +189,6 @@ static void strip_localhost(EtcHosts *hosts) {
},
};
- EtcHostsItemByAddress *item;
-
assert(hosts);
/* Removes the 'localhost' entry from what we loaded. But only if the mapping is exclusively between
@@ -201,7 +199,8 @@ static void strip_localhost(EtcHosts *hosts) {
* mappings. */
for (size_t j = 0; j < ELEMENTSOF(local_in_addrs); j++) {
- bool all_localhost, in_order;
+ bool all_localhost, all_local_address;
+ EtcHostsItemByAddress *item;
item = hashmap_get(hosts->by_address, local_in_addrs + j);
if (!item)
@@ -220,10 +219,9 @@ static void strip_localhost(EtcHosts *hosts) {
/* Now check if the names listed for this address actually all point back just to this
* address (or the other loopback address). If not, let's stay away from this too. */
- in_order = true;
+ all_local_address = true;
STRV_FOREACH(i, item->names) {
EtcHostsItemByName *n;
- bool all_local_address;
n = hashmap_get(hosts->by_name, *i);
if (!n) /* No reverse entry? Then almost certainly the entry already got deleted from
@@ -231,20 +229,17 @@ static void strip_localhost(EtcHosts *hosts) {
break;
/* Now check if the addresses of this item are all localhost addresses */
- all_local_address = true;
for (size_t m = 0; m < n->n_addresses; m++)
if (!in_addr_is_localhost(n->addresses[m]->family, &n->addresses[m]->address)) {
all_local_address = false;
break;
}
- if (!all_local_address) {
- in_order = false;
+ if (!all_local_address)
break;
- }
}
- if (!in_order)
+ if (!all_local_address)
continue;
STRV_FOREACH(i, item->names)