From 9f1a1f2047bc6cad9cd03a3535b15a84b2c68b9e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 7 Dec 2022 22:53:46 +0900 Subject: resolve: merge two boolean variables No functional changes, just refactoring. --- src/resolve/resolved-etc-hosts.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/resolve') 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) -- cgit v1.2.1