router: skip if branch in PIO clear functions
authorÁlvaro Fernández Rojas <[email protected]>
Thu, 4 Dec 2025 14:48:44 +0000 (15:48 +0100)
committerÁlvaro Fernández Rojas <[email protected]>
Thu, 4 Dec 2025 14:55:07 +0000 (15:55 +0100)
We can skip the if branch that replaces the expired/duplicated ra_pio
value in the router_clear_*_ra_pio() functions.

Suggested-by: Paul Donald <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/336
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/router.c

index 0e7a1109e5b7853683f1852bba12f58033b2f66b..afb64aec1e638fd393a5e44a951b45b258e91fea 100644 (file)
@@ -544,9 +544,7 @@ static void router_clear_duplicated_ra_pio(struct interface *iface)
                                     inet_ntop(AF_INET6, &pio_a->prefix, ipv6_str, sizeof(ipv6_str)),
                                     pio_a->length);
 
-                               if (j + 1 < iface->pio_cnt)
-                                       iface->pios[j] = iface->pios[iface->pio_cnt - 1];
-
+                               iface->pios[j] = iface->pios[iface->pio_cnt - 1];
                                iface->pio_cnt--;
                        } else {
                                j++;
@@ -577,9 +575,7 @@ static void router_clear_expired_ra_pio(time_t now,
                             inet_ntop(AF_INET6, &cur_pio->prefix, ipv6_str, sizeof(ipv6_str)),
                             cur_pio->length);
 
-                       if (i + 1 < iface->pio_cnt)
-                               iface->pios[i] = iface->pios[iface->pio_cnt - 1];
-
+                       iface->pios[i] = iface->pios[iface->pio_cnt - 1];
                        iface->pio_cnt--;
                } else {
                        i++;