]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Add NULL check in nexthop_group_equal*() iter
authorStephen Worley <sworley@cumulusnetworks.com>
Tue, 3 Sep 2019 20:43:42 +0000 (16:43 -0400)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:43 +0000 (11:13 -0400)
Add NULL checks in `nexthop_group_equal*()` iteration
before calling `nexthop_same()` to make Clang SA happy.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
lib/nexthop_group.c

index 54868d7fca78678dcfe29960a7471f7790176ad2..35599488bf5320b00318996947d2b41511c00704 100644 (file)
@@ -145,12 +145,19 @@ bool nexthop_group_equal_no_recurse(const struct nexthop_group *nhg1,
        if (!nhg1 && nhg2)
                return false;
 
+       if (nhg1 == nhg2)
+               return true;
+
        if (nexthop_group_nexthop_num_no_recurse(nhg1)
            != nexthop_group_nexthop_num_no_recurse(nhg2))
                return false;
 
        for (nh1 = nhg1->nexthop, nh2 = nhg2->nexthop; nh1 || nh2;
             nh1 = nh1->next, nh2 = nh2->next) {
+               if (nh1 && !nh2)
+                       return false;
+               if (!nh1 && nh2)
+                       return false;
                if (!nexthop_same(nh1, nh2))
                        return false;
        }
@@ -171,11 +178,18 @@ bool nexthop_group_equal(const struct nexthop_group *nhg1,
        if (!nhg1 && nhg2)
                return false;
 
+       if (nhg1 == nhg2)
+               return true;
+
        if (nexthop_group_nexthop_num(nhg1) != nexthop_group_nexthop_num(nhg2))
                return false;
 
        for (nh1 = nhg1->nexthop, nh2 = nhg2->nexthop; nh1 || nh2;
             nh1 = nexthop_next(nh1), nh2 = nexthop_next(nh2)) {
+               if (nh1 && !nh2)
+                       return false;
+               if (!nh1 && nh2)
+                       return false;
                if (!nexthop_same(nh1, nh2))
                        return false;
        }