]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Nest: Several assumptions to tame the static analyzer
authorMaria Matejka <mq@ucw.cz>
Sat, 17 Aug 2019 08:20:46 +0000 (10:20 +0200)
committerMaria Matejka <mq@ucw.cz>
Fri, 1 May 2020 13:19:12 +0000 (15:19 +0200)
nest/rt-attr.c

index 8620d321d37b143622e6df0ca49b5392c6e724b8..3f83edceaf3b052ae40eb1886c71efe4f9558786 100644 (file)
@@ -202,7 +202,7 @@ nexthop__same(struct nexthop *x, struct nexthop *y)
 }
 
 static int
-nexthop_compare_node(const struct nexthop *x, const  struct nexthop *y)
+nexthop_compare_node(const struct nexthop *x, const struct nexthop *y)
 {
   int r;
 
@@ -278,18 +278,22 @@ nexthop_merge(struct nexthop *x, struct nexthop *y, int rx, int ry, int max, lin
   while ((x || y) && max--)
   {
     int cmp = nexthop_compare_node(x, y);
+
     if (cmp < 0)
     {
+      ASSUME(x);
       *n = rx ? x : nexthop_copy_node(x, lp);
       x = x->next;
     }
     else if (cmp > 0)
     {
+      ASSUME(y);
       *n = ry ? y : nexthop_copy_node(y, lp);
       y = y->next;
     }
     else
     {
+      ASSUME(x && y);
       *n = rx ? x : (ry ? y : nexthop_copy_node(x, lp));
       x = x->next;
       y = y->next;