summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-02-27 12:36:28 -0500
committerFlorin Coras <florin.coras@gmail.com>2019-02-27 20:55:46 +0000
commita2aefef1fd3fc423430531d7e965c9da7d9ec0d5 (patch)
treeee535683147416f818b2711c801257de4c1dce1f /src
parentb93452b531f8c4d3fdcd77a3b3c8ede1a511cbc6 (diff)
VPP-1576: fix Coverity issues
Change-Id: I8b59b2e1c0525abf4b0492e50a7af57df4cd3ce2 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src')
-rw-r--r--src/vlib/main.c44
-rw-r--r--src/vnet/interface_output.c3
-rw-r--r--src/vppinfra/pmalloc.c2
3 files changed, 20 insertions, 29 deletions
diff --git a/src/vlib/main.c b/src/vlib/main.c
index 552e693aaf6..c5cb155b1ee 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -2105,15 +2105,12 @@ pcap_dispatch_trace_command_internal (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd, int rx_tx)
{
-#define PCAP_DEF_PKT_TO_CAPTURE (100)
-
unformat_input_t _line_input, *line_input = &_line_input;
pcap_main_t *pm = &vm->dispatch_pcap_main;
- u8 *filename;
- u8 *chroot_filename = 0;
- u32 max = 0;
+ u8 *filename = 0;
+ u32 max = 1000;
int enabled = 0;
- int errorFlag = 0;
+ int is_error = 0;
clib_error_t *error = 0;
u32 node_index, add;
vlib_trace_main_t *tm;
@@ -2134,7 +2131,7 @@ pcap_dispatch_trace_command_internal (vlib_main_t * vm,
else
{
vlib_cli_output (vm, "pcap dispatch capture already on...");
- errorFlag = 1;
+ is_error = 1;
break;
}
}
@@ -2158,7 +2155,7 @@ pcap_dispatch_trace_command_internal (vlib_main_t * vm,
else
{
vlib_cli_output (vm, "pcap tx capture already off...");
- errorFlag = 1;
+ is_error = 1;
break;
}
}
@@ -2169,7 +2166,7 @@ pcap_dispatch_trace_command_internal (vlib_main_t * vm,
vlib_cli_output
(vm,
"can't change max value while pcap tx capture active...");
- errorFlag = 1;
+ is_error = 1;
break;
}
pm->n_packets_to_capture = max;
@@ -2182,7 +2179,7 @@ pcap_dispatch_trace_command_internal (vlib_main_t * vm,
{
vlib_cli_output
(vm, "can't change file while pcap tx capture active...");
- errorFlag = 1;
+ is_error = 1;
break;
}
}
@@ -2227,32 +2224,27 @@ pcap_dispatch_trace_command_internal (vlib_main_t * vm,
{
error = clib_error_return (0, "unknown input `%U'",
format_unformat_error, line_input);
- errorFlag = 1;
+ is_error = 1;
break;
}
}
unformat_free (line_input);
-
- if (errorFlag == 0)
+ if (is_error == 0)
{
- /* Since no error, save configured values. */
- if (chroot_filename)
- {
- if (pm->file_name)
- vec_free (pm->file_name);
- vec_add1 (chroot_filename, 0);
- pm->file_name = (char *) chroot_filename;
- }
+ /* Clean up from previous run */
+ vec_free (pm->file_name);
+ vec_free (pm->pcap_data);
- if (max)
- pm->n_packets_to_capture = max;
+ memset (pm, 0, sizeof (*pm));
+ pm->n_packets_to_capture = max;
if (enabled)
{
- if (pm->file_name == 0)
- pm->file_name = (char *) format (0, "/tmp/dispatch.pcap%c", 0);
+ if (filename == 0)
+ filename = format (0, "/tmp/dispatch.pcap%c", 0);
+ pm->file_name = (char *) filename;
pm->n_packets_captured = 0;
pm->packet_type = PCAP_PACKET_TYPE_vpp;
if (pm->lock == 0)
@@ -2261,8 +2253,6 @@ pcap_dispatch_trace_command_internal (vlib_main_t * vm,
vlib_cli_output (vm, "pcap dispatch capture on...");
}
}
- else if (chroot_filename)
- vec_free (chroot_filename);
return error;
}
diff --git a/src/vnet/interface_output.c b/src/vnet/interface_output.c
index 6c2345be270..99aa1f110fb 100644
--- a/src/vnet/interface_output.c
+++ b/src/vnet/interface_output.c
@@ -383,7 +383,8 @@ tso_segment_buffer (vlib_main_t * vm, vnet_interface_per_thread_data_t * ptd,
int nloops = 2000;
while (total_src_left)
{
- ASSERT (nloops-- > 0);
+ if (nloops-- <= 0)
+ clib_panic ("infinite loop detected");
u16 bytes_to_copy = clib_min (src_left, dst_left);
clib_memcpy_fast (dst_ptr, src_ptr, bytes_to_copy);
diff --git a/src/vppinfra/pmalloc.c b/src/vppinfra/pmalloc.c
index f421665e934..9f908f40cc9 100644
--- a/src/vppinfra/pmalloc.c
+++ b/src/vppinfra/pmalloc.c
@@ -264,7 +264,7 @@ pmalloc_map_pages (clib_pmalloc_main_t * pm, clib_pmalloc_arena_t * a,
int old_mpol = -1;
long unsigned int mask[16] = { 0 };
long unsigned int old_mask[16] = { 0 };
- uword page_size = 1 << a->log2_subpage_sz;
+ uword page_size = 1ULL << a->log2_subpage_sz;
uword size = (uword) n_pages << pm->def_log2_page_sz;
clib_error_free (pm->error);