mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
nss-myhostname: trivial style fixes
This commit is contained in:
parent
6307c39b94
commit
68a9c7c4f0
@ -155,8 +155,7 @@ int local_addresses(sd_netlink *context, int ifindex, int af, struct local_addre
|
||||
n_list++;
|
||||
};
|
||||
|
||||
if (n_list > 0)
|
||||
qsort(list, n_list, sizeof(struct local_address), address_compare);
|
||||
qsort_safe(list, n_list, sizeof(struct local_address), address_compare);
|
||||
|
||||
*ret = list;
|
||||
list = NULL;
|
||||
|
@ -127,7 +127,8 @@ enum nss_status _nss_myhostname_gethostbyname4_r(
|
||||
memcpy(r_name, canonical, l+1);
|
||||
idx = ALIGN(l+1);
|
||||
|
||||
if (n_addresses <= 0) {
|
||||
assert(n_addresses >= 0);
|
||||
if (n_addresses == 0) {
|
||||
/* Second, fill in IPv6 tuple */
|
||||
r_tuple = (struct gaih_addrtuple*) (buffer + idx);
|
||||
r_tuple->next = r_tuple_prev;
|
||||
@ -453,34 +454,29 @@ enum nss_status _nss_myhostname_gethostbyaddr2_r(
|
||||
}
|
||||
|
||||
n_addresses = local_addresses(NULL, 0, AF_UNSPEC, &addresses);
|
||||
if (n_addresses > 0) {
|
||||
for (a = addresses, n = 0; (int) n < n_addresses; n++, a++) {
|
||||
if (af != a->family)
|
||||
continue;
|
||||
for (a = addresses, n = 0; (int) n < n_addresses; n++, a++) {
|
||||
if (af != a->family)
|
||||
continue;
|
||||
|
||||
if (memcmp(addr, &a->address, FAMILY_ADDRESS_SIZE(af)) == 0)
|
||||
goto found;
|
||||
}
|
||||
if (memcmp(addr, &a->address, FAMILY_ADDRESS_SIZE(af)) == 0)
|
||||
goto found;
|
||||
}
|
||||
|
||||
addresses = mfree(addresses);
|
||||
|
||||
n_addresses = local_gateways(NULL, 0, AF_UNSPEC, &addresses);
|
||||
if (n_addresses > 0) {
|
||||
for (a = addresses, n = 0; (int) n < n_addresses; n++, a++) {
|
||||
if (af != a->family)
|
||||
continue;
|
||||
for (a = addresses, n = 0; (int) n < n_addresses; n++, a++) {
|
||||
if (af != a->family)
|
||||
continue;
|
||||
|
||||
if (memcmp(addr, &a->address, FAMILY_ADDRESS_SIZE(af)) == 0) {
|
||||
canonical = "gateway";
|
||||
goto found;
|
||||
}
|
||||
if (memcmp(addr, &a->address, FAMILY_ADDRESS_SIZE(af)) == 0) {
|
||||
canonical = "gateway";
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
|
||||
*errnop = ENOENT;
|
||||
*h_errnop = HOST_NOT_FOUND;
|
||||
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
|
||||
found:
|
||||
|
Loading…
Reference in New Issue
Block a user