misc: fix coverity warnings 70/24970/2
authorDave Barach <dave@barachs.net>
Tue, 11 Feb 2020 15:29:13 +0000 (10:29 -0500)
committerDamjan Marion <dmarion@me.com>
Tue, 11 Feb 2020 23:11:58 +0000 (23:11 +0000)
Type: fix
Ticket: VPP-1837

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I6b1ea13fc83460bf4ee75cb9249d83dddaa64ded

src/vlib/unix/cli.c
src/vlibmemory/socket_api.c
src/vnet/interface.c
src/vppinfra/mem.h

index 0a8041e..b0ed9d2 100644 (file)
@@ -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);
 
index eb0466d..6238746 100644 (file)
@@ -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* */
index 5ee3a74..dfefdba 100644 (file)
@@ -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);
index f35c495..0f8bd48 100644 (file)
@@ -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];
 }