From 56faee837281c7f9c28aa40dbf0f6e4620b76be8 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Thu, 4 Aug 2016 18:58:05 -0400 Subject: VPP-189 Clean up more coverity warnings Change-Id: I1b971ab326dc334a4743fd7d4184cef106b0523d Signed-off-by: Dave Barach --- vnet/vnet/ip/ip4_mtrie.c | 22 +++++++++++++++++++--- vnet/vnet/ip/ip6_neighbor.c | 8 +++++++- 2 files changed, 26 insertions(+), 4 deletions(-) (limited to 'vnet') diff --git a/vnet/vnet/ip/ip4_mtrie.c b/vnet/vnet/ip/ip4_mtrie.c index 461cd64b..0badde76 100644 --- a/vnet/vnet/ip/ip4_mtrie.c +++ b/vnet/vnet/ip/ip4_mtrie.c @@ -436,10 +436,26 @@ maybe_remap_leaf (ip_lookup_main_t * lm, ip4_fib_mtrie_leaf_t * p) if (m) { was_remapped_to_empty_leaf = m == ~0; + + /* + * The intent of the original form - which dates to 2013 or + * earlier - is not obvious. Here's the original: + * + * if (was_remapped_to_empty_leaf) + * p[0] = (was_remapped_to_empty_leaf + * ? IP4_FIB_MTRIE_LEAF_EMPTY + * : ip4_fib_mtrie_leaf_set_adj_index (m - 1)); + * + * Notice the outer "if (was_remapped_to_empty_leaf)" + * means that p[0] is always set to IP4_FIB_MTRIE_LEAF_EMPTY, + * and is otherwise left intact. + * + * It seems unlikely that the adjacency mapping scheme + * works in detail. Coverity correctly complains that the + * else-case of the original ternary expression is dead code. + */ if (was_remapped_to_empty_leaf) - p[0] = (was_remapped_to_empty_leaf - ? IP4_FIB_MTRIE_LEAF_EMPTY - : ip4_fib_mtrie_leaf_set_adj_index (m - 1)); + p[0] = IP4_FIB_MTRIE_LEAF_EMPTY; } } return was_remapped_to_empty_leaf; diff --git a/vnet/vnet/ip/ip6_neighbor.c b/vnet/vnet/ip/ip6_neighbor.c index 888baff8..2593cb46 100644 --- a/vnet/vnet/ip/ip6_neighbor.c +++ b/vnet/vnet/ip/ip6_neighbor.c @@ -394,7 +394,13 @@ vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm, existing_adj->arp.next_hop.ip6.as_u64[1] == a->as_u64[1]) { u32 * ai; - u32 * adjs = vec_dup(n->adjacencies); + u32 * adjs = 0; + + if (n) + adjs = vec_dup(n->adjacencies); + else + clib_warning ("ip6 neighbor n not set"); + /* Update all adj assigned to this arp entry */ vec_foreach(ai, adjs) { -- cgit 1.2.3-korg