From: Christian Franke <[email protected]> Given that the && is evaluated lazily from left to right, i < OSPF6_MULTI_PATH_LIMIT should be checked prior to calling ospf6_nexthop_is_set on the array element, not the other way around.
Signed-off-by: Christian Franke <[email protected]> --- ospf6d/ospf6_intra.c | 4 ++-- ospf6d/ospf6_route.c | 8 ++++---- ospf6d/ospf6_spf.c | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ospf6d/ospf6_intra.c b/ospf6d/ospf6_intra.c index 6606c96..f003a80 100644 --- a/ospf6d/ospf6_intra.c +++ b/ospf6d/ospf6_intra.c @@ -1314,8 +1314,8 @@ ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa) } else { - for (i = 0; ospf6_nexthop_is_set (&ls_entry->nexthop[i]) && - i < OSPF6_MULTI_PATH_LIMIT; i++) + for (i = 0; i < OSPF6_MULTI_PATH_LIMIT && + ospf6_nexthop_is_set (&ls_entry->nexthop[i]); i++) ospf6_nexthop_copy (&route->nexthop[i], &ls_entry->nexthop[i]); } diff --git a/ospf6d/ospf6_route.c b/ospf6d/ospf6_route.c index 5057556..07a4e09 100644 --- a/ospf6d/ospf6_route.c +++ b/ospf6d/ospf6_route.c @@ -821,8 +821,8 @@ ospf6_route_show (struct vty *vty, struct ospf6_route *route) OSPF6_PATH_TYPE_SUBSTR (route->path.type), destination, nexthop, IFNAMSIZ, ifname, duration, VNL); - for (i = 1; ospf6_nexthop_is_set (&route->nexthop[i]) && - i < OSPF6_MULTI_PATH_LIMIT; i++) + for (i = 1; i < OSPF6_MULTI_PATH_LIMIT && + ospf6_nexthop_is_set (&route->nexthop[i]); i++) { /* nexthop */ inet_ntop (AF_INET6, &route->nexthop[i].address, nexthop, @@ -918,8 +918,8 @@ ospf6_route_show_detail (struct vty *vty, struct ospf6_route *route) /* Nexthops */ vty_out (vty, "Nexthop:%s", VNL); - for (i = 0; ospf6_nexthop_is_set (&route->nexthop[i]) && - i < OSPF6_MULTI_PATH_LIMIT; i++) + for (i = 0; i < OSPF6_MULTI_PATH_LIMIT && + ospf6_nexthop_is_set (&route->nexthop[i]); i++) { /* nexthop */ inet_ntop (AF_INET6, &route->nexthop[i].address, nexthop, diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index 858398e..6d2e536 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -307,8 +307,8 @@ ospf6_spf_install (struct ospf6_vertex *v, if (IS_OSPF6_DEBUG_SPF (PROCESS)) zlog_debug (" another path found, merge"); - for (i = 0; ospf6_nexthop_is_set (&v->nexthop[i]) && - i < OSPF6_MULTI_PATH_LIMIT; i++) + for (i = 0; i < OSPF6_MULTI_PATH_LIMIT && + ospf6_nexthop_is_set (&v->nexthop[i]); i++) { for (j = 0; j < OSPF6_MULTI_PATH_LIMIT; j++) { @@ -356,8 +356,8 @@ ospf6_spf_install (struct ospf6_vertex *v, route->path.options[1] = v->options[1]; route->path.options[2] = v->options[2]; - for (i = 0; ospf6_nexthop_is_set (&v->nexthop[i]) && - i < OSPF6_MULTI_PATH_LIMIT; i++) + for (i = 0; i < OSPF6_MULTI_PATH_LIMIT && + ospf6_nexthop_is_set (&v->nexthop[i]); i++) ospf6_nexthop_copy (&route->nexthop[i], &v->nexthop[i]); if (v->parent) @@ -499,8 +499,8 @@ ospf6_spf_calculation (u_int32_t router_id, ospf6_nexthop_calc (w, v, lsdesc); else { - for (i = 0; ospf6_nexthop_is_set (&v->nexthop[i]) && - i < OSPF6_MULTI_PATH_LIMIT; i++) + for (i = 0; i < OSPF6_MULTI_PATH_LIMIT && + ospf6_nexthop_is_set (&v->nexthop[i]); i++) ospf6_nexthop_copy (&w->nexthop[i], &v->nexthop[i]); } -- 2.8.0 _______________________________________________ Quagga-dev mailing list [email protected] https://lists.quagga.net/mailman/listinfo/quagga-dev
