misc: fix coverity warnings

Type: fix
Ticket: VPP-1837

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I6b1ea13fc83460bf4ee75cb9249d83dddaa64ded
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c
index 0a8041e..b0ed9d2 100644
--- a/src/vlib/unix/cli.c
+++ b/src/vlib/unix/cli.c
@@ -3089,9 +3089,11 @@
 	    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 @@
   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 eb0466d..6238746 100644
--- a/src/vlibmemory/socket_api.c
+++ b/src/vlibmemory/socket_api.c
@@ -469,8 +469,10 @@
   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 5ee3a74..dfefdba 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -200,8 +200,14 @@
     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 f35c495..0f8bd48 100644
--- a/src/vppinfra/mem.h
+++ b/src/vppinfra/mem.h
@@ -84,7 +84,7 @@
 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];
 }