VPP-1440: clean up coverity warnings
Change-Id: Ic6823fb617ecae547a5f0e28b1e037848e40f682 Signed-off-by: Dave Barach <dave@barachs.net>
This commit is contained in:
committed by
Florin Coras
parent
bf49590c07
commit
819d5fdb39
@@ -646,13 +646,14 @@ lb_nodeport_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
|
||||
entry0 = hash_get_mem(lbm->vip_index_by_nodeport, &(udp_0->dst_port));
|
||||
|
||||
//Enqueue to next
|
||||
vnet_buffer(p0)->ip.adj_index[VLIB_TX] = entry0[0];
|
||||
vnet_buffer(p0)->ip.adj_index[VLIB_TX] = entry0 ? entry0[0]
|
||||
: ADJ_INDEX_INVALID;
|
||||
|
||||
if (PREDICT_FALSE(p0->flags & VLIB_BUFFER_IS_TRACED))
|
||||
{
|
||||
lb_nodeport_trace_t *tr = vlib_add_trace (vm, node, p0,
|
||||
sizeof(*tr));
|
||||
tr->vip_index = entry0[0];
|
||||
tr->vip_index = entry0 ? entry0[0] : ADJ_INDEX_INVALID;
|
||||
tr->node_port = (u32) clib_net_to_host_u16 (udp_0->dst_port);
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,10 @@ nsim_inline (vlib_main_t * vm,
|
||||
ep->current_length);
|
||||
}
|
||||
else /* out of wheel space, drop pkt */
|
||||
b[0]->error = no_buffer_error;
|
||||
{
|
||||
b[0]->error = no_buffer_error;
|
||||
is_drop0 = 1;
|
||||
}
|
||||
|
||||
if (is_trace)
|
||||
{
|
||||
@@ -134,8 +137,7 @@ nsim_inline (vlib_main_t * vm,
|
||||
nsim_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
|
||||
t->expires = expires;
|
||||
t->is_drop = is_drop0;
|
||||
if (is_drop0 == 0)
|
||||
t->tx_sw_if_index = ep->tx_sw_if_index;
|
||||
t->tx_sw_if_index = (is_drop0 == 0) ? ep->tx_sw_if_index : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,12 +102,14 @@ stat_segment_connect (char *socket_name)
|
||||
if (connect (sock, (struct sockaddr *) &un, sizeof (struct sockaddr_un)) <
|
||||
0)
|
||||
{
|
||||
close (sock);
|
||||
perror ("connect");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((mfd = recv_fd (sock)) < 0)
|
||||
{
|
||||
close (sock);
|
||||
fprintf (stderr, "Receiving file descriptor failed\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -119,12 +121,14 @@ stat_segment_connect (char *socket_name)
|
||||
|
||||
if (fstat (mfd, &st) == -1)
|
||||
{
|
||||
close (sock);
|
||||
perror ("mmap");
|
||||
return -1;
|
||||
}
|
||||
if ((memaddr =
|
||||
mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, mfd, 0)) == MAP_FAILED)
|
||||
{
|
||||
close (sock);
|
||||
perror ("mmap");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -157,6 +157,7 @@ vlib_stats_register_error_index (u8 * name, u64 * em_vec, u64 index)
|
||||
e.name[vec_len (name)] = '\0';
|
||||
e.type = STAT_DIR_TYPE_ERROR_INDEX;
|
||||
e.offset = index;
|
||||
e.offset_vector = 0;
|
||||
vec_add1 (sm->directory_vector, e);
|
||||
|
||||
/* Warn clients to refresh any pointers they might be holding */
|
||||
|
||||
@@ -908,6 +908,7 @@ u8 *CV (format_cuckoo) (u8 * s, va_list * args)
|
||||
uword free = 0;
|
||||
uword used = 0;
|
||||
uword use_count_total = 0;
|
||||
float load_factor;
|
||||
CVT (clib_cuckoo_bucket) * b;
|
||||
/* *INDENT-OFF* */
|
||||
clib_cuckoo_foreach_bucket (b, h, {
|
||||
@@ -935,8 +936,11 @@ u8 *CV (format_cuckoo) (u8 * s, va_list * args)
|
||||
s = format (s, "Used slots: %wu\n", used);
|
||||
s = format (s, "Use count total: %wu\n", use_count_total);
|
||||
s = format (s, "Free slots: %wu\n", free);
|
||||
s =
|
||||
format (s, "Load factor: %.2f\n", (float) (used) / (float) (free + used));
|
||||
if (free + used != 0)
|
||||
load_factor = ((float) used) / ((float) (free + used));
|
||||
else
|
||||
load_factor = 0.0;
|
||||
s = format (s, "Load factor: %.2f\n", load_factor);
|
||||
#if CLIB_CUCKOO_DEBUG_COUNTERS
|
||||
s = format (s, "BFS attempts limited by max steps: %lld\n",
|
||||
h->steps_exceeded);
|
||||
@@ -968,7 +972,10 @@ float CV (clib_cuckoo_calculate_load_factor) (CVT (clib_cuckoo) * h)
|
||||
}
|
||||
});
|
||||
/* *INDENT-ON* */
|
||||
return (float) nonfree / (float) all;
|
||||
if (all)
|
||||
return (float) nonfree / (float) all;
|
||||
else
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/** @endcond */
|
||||
|
||||
Reference in New Issue
Block a user