diff options
Diffstat (limited to 'nest')
-rw-r--r-- | nest/protocol.h | 2 | ||||
-rw-r--r-- | nest/route.h | 2 | ||||
-rw-r--r-- | nest/rt-attr.c | 12 | ||||
-rw-r--r-- | nest/rt-show.c | 6 | ||||
-rw-r--r-- | nest/rt-table.c | 2 |
5 files changed, 17 insertions, 7 deletions
diff --git a/nest/protocol.h b/nest/protocol.h index e97e59dd..a934c047 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -80,7 +80,7 @@ struct protocol { void (*cleanup)(struct proto *); /* Called after shutdown when protocol became hungry/down */ void (*get_status)(struct proto *, byte *buf); /* Get instance status (for `show protocols' command) */ void (*get_route_info)(struct rte *, byte *buf); /* Get route information (for `show route' command) */ - int (*get_attr)(struct eattr *, byte *buf, int buflen); /* ASCIIfy dynamic attribute (returns GA_*) */ + int (*get_attr)(const struct eattr *, byte *buf, int buflen); /* ASCIIfy dynamic attribute (returns GA_*) */ void (*show_proto_info)(struct proto *); /* Show protocol info (for `show protocols all' command) */ void (*copy_config)(struct proto_config *, struct proto_config *); /* Copy config from given protocol instance */ }; diff --git a/nest/route.h b/nest/route.h index 5421ece5..1b4f2866 100644 --- a/nest/route.h +++ b/nest/route.h @@ -577,7 +577,7 @@ void ea_merge(ea_list *from, ea_list *to); /* Merge sub-lists to allocated buffe int ea_same(ea_list *x, ea_list *y); /* Test whether two ea_lists are identical */ uint ea_hash(ea_list *e); /* Calculate 16-bit hash value */ ea_list *ea_append(ea_list *to, ea_list *what); -void ea_format_bitfield(struct eattr *a, byte *buf, int bufsize, const char **names, int min, int max); +void ea_format_bitfield(const struct eattr *a, byte *buf, int bufsize, const char **names, int min, int max); #define ea_normalize(ea) do { \ if (ea->next) { \ diff --git a/nest/rt-attr.c b/nest/rt-attr.c index 8620d321..28d956bc 100644 --- a/nest/rt-attr.c +++ b/nest/rt-attr.c @@ -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; @@ -786,7 +790,7 @@ ea_free(ea_list *o) } static int -get_generic_attr(eattr *a, byte **buf, int buflen UNUSED) +get_generic_attr(const eattr *a, byte **buf, int buflen UNUSED) { if (a->id == EA_GEN_IGP_METRIC) { @@ -798,7 +802,7 @@ get_generic_attr(eattr *a, byte **buf, int buflen UNUSED) } void -ea_format_bitfield(struct eattr *a, byte *buf, int bufsize, const char **names, int min, int max) +ea_format_bitfield(const struct eattr *a, byte *buf, int bufsize, const char **names, int min, int max) { byte *bound = buf + bufsize - 32; u32 data = a->u.data; @@ -894,7 +898,7 @@ ea_show_lc_set(struct cli *c, const struct adata *ad, byte *pos, byte *buf, byte * get_attr() hook, it's consulted first. */ void -ea_show(struct cli *c, eattr *e) +ea_show(struct cli *c, const eattr *e) { struct protocol *p; int status = GA_UNKNOWN; diff --git a/nest/rt-show.c b/nest/rt-show.c index 3431293a..bd0df9ee 100644 --- a/nest/rt-show.c +++ b/nest/rt-show.c @@ -104,6 +104,12 @@ rt_show_net(struct cli *c, net *n, struct rt_show_data *d) rte *e, *ee; byte ia[NET_MAX_TEXT_LENGTH+1]; struct channel *ec = d->tab->export_channel; + + /* The Clang static analyzer complains that ec may be NULL. + * It should be ensured to be not NULL by rt_show_prepare_tables() */ + if (d->export_mode) + ASSUME(ec); + int first = 1; int pass = 0; diff --git a/nest/rt-table.c b/nest/rt-table.c index a46eeb77..ae5a8444 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -2304,7 +2304,7 @@ rt_commit(struct config *new, struct config *old) WALK_LIST(r, new->tables) if (!r->table) { - rtable *t = mb_alloc(rt_table_pool, sizeof(struct rtable)); + rtable *t = mb_allocz(rt_table_pool, sizeof(struct rtable)); DBG("\t%s: created\n", r->name); rt_setup(rt_table_pool, t, r); add_tail(&routing_tables, &t->n); |