mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 10:08:05 +02:00
platform: minor cleanup of nm_platform_ip6_address_sync()
Drop the "delete_remaining" variable, and instead rely on the value of "i_know" alone. Also, add a code comment explaining better what is happening.
This commit is contained in:
parent
b50d7cc653
commit
43dee5f192
1 changed files with 15 additions and 14 deletions
|
|
@ -3641,7 +3641,6 @@ nm_platform_ip6_address_sync (NMPlatform *self,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
if (plat_addresses) {
|
if (plat_addresses) {
|
||||||
gboolean delete_remaining;
|
|
||||||
guint known_addresses_len;
|
guint known_addresses_len;
|
||||||
|
|
||||||
known_addresses_len = known_addresses ? known_addresses->len : 0;
|
known_addresses_len = known_addresses ? known_addresses->len : 0;
|
||||||
|
|
@ -3702,28 +3701,30 @@ clear_and_next:
|
||||||
* right order to get their priority right. */
|
* right order to get their priority right. */
|
||||||
i_plat = plat_addresses->len;
|
i_plat = plat_addresses->len;
|
||||||
i_know = 0;
|
i_know = 0;
|
||||||
delete_remaining = FALSE;
|
|
||||||
while (i_plat > 0) {
|
while (i_plat > 0) {
|
||||||
const NMPlatformIP6Address *plat_addr = NMP_OBJECT_CAST_IP6_ADDRESS (plat_addresses->pdata[--i_plat]);
|
const NMPlatformIP6Address *plat_addr = NMP_OBJECT_CAST_IP6_ADDRESS (plat_addresses->pdata[--i_plat]);
|
||||||
|
|
||||||
if (!plat_addr)
|
if (!plat_addr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!delete_remaining) {
|
for (; i_know < known_addresses_len; i_know++) {
|
||||||
for (; i_know < known_addresses_len; i_know++) {
|
const NMPlatformIP6Address *know_addr = NMP_OBJECT_CAST_IP6_ADDRESS (known_addresses->pdata[i_know]);
|
||||||
const NMPlatformIP6Address *know_addr = NMP_OBJECT_CAST_IP6_ADDRESS (known_addresses->pdata[i_know]);
|
|
||||||
|
|
||||||
if (!know_addr)
|
if (!know_addr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (IN6_ARE_ADDR_EQUAL (&plat_addr->address, &know_addr->address)) {
|
if (IN6_ARE_ADDR_EQUAL (&plat_addr->address, &know_addr->address)) {
|
||||||
/* we have a match. Mark address as handled. */
|
/* we have a match. Mark address as handled. */
|
||||||
i_know++;
|
i_know++;
|
||||||
goto next_plat;
|
goto next_plat;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
delete_remaining = TRUE;
|
|
||||||
|
/* all remainging addresses need to be removed as well, so that we can
|
||||||
|
* re-add them in the correct order. Signal that, by setting @i_know
|
||||||
|
* so that the next @i_plat iteration, we won't enter the loop and
|
||||||
|
* delete the address right away */
|
||||||
|
i_know = known_addresses_len;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
nm_platform_ip6_address_delete (self, ifindex, plat_addr->address, plat_addr->plen);
|
nm_platform_ip6_address_delete (self, ifindex, plat_addr->address, plat_addr->plen);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue