From: Maria Matejka Date: Sat, 17 Aug 2019 08:20:46 +0000 (+0200) Subject: Nest: Several assumptions to tame the static analyzer X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f81a9035ac93c248d6d3b0044544b6943b3edd4;p=thirdparty%2Fbird.git Nest: Several assumptions to tame the static analyzer --- diff --git a/nest/rt-attr.c b/nest/rt-attr.c index 3cbd25b02..be70689ba 100644 --- a/nest/rt-attr.c +++ b/nest/rt-attr.c @@ -186,7 +186,7 @@ nexthop__same(struct nexthop *x, struct nexthop *y) } static int -nexthop_compare_node(struct nexthop *x, struct nexthop *y) +nexthop_compare_node(const struct nexthop *x, const struct nexthop *y) { int r; @@ -262,18 +262,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;