l2: fix coverity warnings in l2_fwd.c

Type: fix
Ticket: VPP-1837

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: Ibf468970b56fc6bf8d5fb6ba491dd3e727464fc0
This commit is contained in:
Dave Barach
2020-04-30 15:42:44 -04:00
committed by Florin Coras
parent 1a18d11eaf
commit 6068601c25

View File

@ -61,8 +61,7 @@ typedef struct
typedef struct typedef struct
{ {
/* per-pkt trace data */ /* per-pkt trace data */
u8 dst[6]; u8 dst_and_src[12];
u8 src[6];
u32 sw_if_index; u32 sw_if_index;
u16 bd_index; u16 bd_index;
l2fib_entry_result_t result; l2fib_entry_result_t result;
@ -79,8 +78,9 @@ format_l2fwd_trace (u8 * s, va_list * args)
s = s =
format (s, format (s,
"l2-fwd: sw_if_index %d dst %U src %U bd_index %d result [0x%llx, %d] %U", "l2-fwd: sw_if_index %d dst %U src %U bd_index %d result [0x%llx, %d] %U",
t->sw_if_index, format_ethernet_address, t->dst, t->sw_if_index, format_ethernet_address, t->dst_and_src,
format_ethernet_address, t->src, t->bd_index, t->result.raw, format_ethernet_address, t->dst_and_src + 6,
t->bd_index, t->result.raw,
t->result.fields.sw_if_index, format_l2fib_entry_result_flags, t->result.fields.sw_if_index, format_l2fib_entry_result_flags,
t->result.fields.flags); t->result.fields.flags);
return s; return s;
@ -324,7 +324,7 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t)); l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
t->sw_if_index = sw_if_index0; t->sw_if_index = sw_if_index0;
t->bd_index = vnet_buffer (b[0])->l2.bd_index; t->bd_index = vnet_buffer (b[0])->l2.bd_index;
clib_memcpy_fast (t->dst, h0->dst_address, clib_memcpy_fast (t->dst_and_src, h0->dst_address,
sizeof (h0->dst_address) + sizeof (h0->dst_address) +
sizeof (h0->src_address)); sizeof (h0->src_address));
t->result = result0; t->result = result0;
@ -334,7 +334,7 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[1], sizeof (*t)); l2fwd_trace_t *t = vlib_add_trace (vm, node, b[1], sizeof (*t));
t->sw_if_index = sw_if_index1; t->sw_if_index = sw_if_index1;
t->bd_index = vnet_buffer (b[1])->l2.bd_index; t->bd_index = vnet_buffer (b[1])->l2.bd_index;
clib_memcpy_fast (t->dst, h1->dst_address, clib_memcpy_fast (t->dst_and_src, h1->dst_address,
sizeof (h1->dst_address) + sizeof (h1->dst_address) +
sizeof (h1->src_address)); sizeof (h1->src_address));
t->result = result1; t->result = result1;
@ -344,7 +344,7 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[2], sizeof (*t)); l2fwd_trace_t *t = vlib_add_trace (vm, node, b[2], sizeof (*t));
t->sw_if_index = sw_if_index2; t->sw_if_index = sw_if_index2;
t->bd_index = vnet_buffer (b[2])->l2.bd_index; t->bd_index = vnet_buffer (b[2])->l2.bd_index;
clib_memcpy_fast (t->dst, h2->dst_address, clib_memcpy_fast (t->dst_and_src, h2->dst_address,
sizeof (h2->dst_address) + sizeof (h2->dst_address) +
sizeof (h2->src_address)); sizeof (h2->src_address));
t->result = result2; t->result = result2;
@ -354,7 +354,7 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[3], sizeof (*t)); l2fwd_trace_t *t = vlib_add_trace (vm, node, b[3], sizeof (*t));
t->sw_if_index = sw_if_index3; t->sw_if_index = sw_if_index3;
t->bd_index = vnet_buffer (b[3])->l2.bd_index; t->bd_index = vnet_buffer (b[3])->l2.bd_index;
clib_memcpy_fast (t->dst, h3->dst_address, clib_memcpy_fast (t->dst_and_src, h3->dst_address,
sizeof (h3->dst_address) + sizeof (h3->dst_address) +
sizeof (h3->src_address)); sizeof (h3->src_address));
t->result = result3; t->result = result3;
@ -391,7 +391,7 @@ l2fwd_node_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t)); l2fwd_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
t->sw_if_index = sw_if_index0; t->sw_if_index = sw_if_index0;
t->bd_index = vnet_buffer (b[0])->l2.bd_index; t->bd_index = vnet_buffer (b[0])->l2.bd_index;
clib_memcpy_fast (t->dst, h0->dst_address, clib_memcpy_fast (t->dst_and_src, h0->dst_address,
sizeof (h0->dst_address) + sizeof (h0->dst_address) +
sizeof (h0->src_address)); sizeof (h0->src_address));
t->result = result0; t->result = result0;