summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-02-11 10:29:13 -0500
committerDamjan Marion <dmarion@me.com>2020-02-11 23:11:58 +0000
commita6ef36b2c25de47824a1b45e147ab2fbf67c3a33 (patch)
tree01f29603e11b22763a1a539db10975171ad29f00
parent44476c6b271bdebb7458590398b5f140c9a7d353 (diff)
misc: fix coverity warnings
Type: fix Ticket: VPP-1837 Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I6b1ea13fc83460bf4ee75cb9249d83dddaa64ded
-rw-r--r--src/vlib/unix/cli.c10
-rw-r--r--src/vlibmemory/socket_api.c6
-rw-r--r--src/vnet/interface.c10
-rw-r--r--src/vppinfra/mem.h2
4 files changed, 19 insertions, 9 deletions
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c
index 0a8041e4ac4..b0ed9d2db14 100644
--- a/src/vlib/unix/cli.c
+++ b/src/vlib/unix/cli.c
@@ -3089,9 +3089,11 @@ unix_cli_config (vlib_main_t * vm, unformat_input_t * input)
clib_panic ("sigaction");
/* Retrieve the current terminal size */
- ioctl (STDIN_FILENO, TIOCGWINSZ, &ws);
- cf->width = ws.ws_col;
- cf->height = ws.ws_row;
+ if (ioctl (STDIN_FILENO, TIOCGWINSZ, &ws) == 0)
+ {
+ cf->width = ws.ws_col;
+ cf->height = ws.ws_row;
+ }
if (cf->width == 0 || cf->height == 0)
{
@@ -3328,7 +3330,7 @@ unix_cli_exec (vlib_main_t * vm,
unformat_free (&sub_input);
done:
- if (fd > 0)
+ if (fd >= 0)
close (fd);
vec_free (file_name);
diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c
index eb0466dc76d..6238746525a 100644
--- a/src/vlibmemory/socket_api.c
+++ b/src/vlibmemory/socket_api.c
@@ -469,8 +469,10 @@ vl_api_sockclnt_create_t_handler (vl_api_sockclnt_create_t * mp)
hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
({
rp->message_table[i].index = htons(hp->value[0]);
- strncpy_s((char *)rp->message_table[i].name, 64 /* bytes of space at dst */,
- (char *)hp->key, 64-1 /* chars to copy, without zero byte. */);
+ (void) strncpy_s((char *)rp->message_table[i].name,
+ 64 /* bytes of space at dst */,
+ (char *)hp->key,
+ 64-1 /* chars to copy, without zero byte. */);
i++;
}));
/* *INDENT-ON* */
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index 5ee3a74fe0b..dfefdbac921 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -200,8 +200,14 @@ unserialize_vnet_interface_state (serialize_main_t * m, va_list * va)
pool_foreach (hif, im->hw_interfaces, ({
unserialize_cstring (m, &class_name);
p = hash_get_mem (im->hw_interface_class_by_name, class_name);
- ASSERT (p != 0);
- error = vnet_hw_interface_set_class_helper (vnm, hif->hw_if_index, p[0], /* redistribute */ 0);
+ if (p)
+ {
+ error = vnet_hw_interface_set_class_helper
+ (vnm, hif->hw_if_index, p[0], /* redistribute */ 0);
+ }
+ else
+ error = clib_error_return (0, "hw class %s AWOL?", class_name);
+
if (error)
clib_error_report (error);
vec_free (class_name);
diff --git a/src/vppinfra/mem.h b/src/vppinfra/mem.h
index f35c495eb25..0f8bd482a90 100644
--- a/src/vppinfra/mem.h
+++ b/src/vppinfra/mem.h
@@ -84,7 +84,7 @@ clib_mem_set_per_cpu_heap (u8 * new_heap)
always_inline void *
clib_mem_get_per_numa_heap (u32 numa_id)
{
- ASSERT (numa_id >= 0 && numa_id < ARRAY_LEN (clib_per_numa_mheaps));
+ ASSERT (numa_id < ARRAY_LEN (clib_per_numa_mheaps));
return clib_per_numa_mheaps[numa_id];
}