Fix a batch of coverity warnings, VPP-486
authorDave Barach <[email protected]>
Wed, 9 Nov 2016 16:28:36 +0000 (11:28 -0500)
committerDave Barach <[email protected]>
Wed, 9 Nov 2016 16:29:58 +0000 (11:29 -0500)
Change-Id: I0379844824b4c2eb42588d0fb8e1a7eb441e923f
Signed-off-by: Dave Barach <[email protected]>
vlib-api/vlibapi/api_shared.c
vnet/vnet/devices/dpdk/cli.c
vnet/vnet/devices/dpdk/init.c
vnet/vnet/ip/ip6_neighbor.c
vpp-api-test/vat/api_format.c
vpp/vpp-api/test_client.c

index c62ac5b..c133922 100644 (file)
@@ -847,6 +847,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
       if (!cfgp)
        {
          vlib_cli_output (vm, "Ugh: msg id %d no trace config\n", msg_id);
+         munmap (hp, file_size);
          return;
        }
       size = cfgp->size;
@@ -872,6 +873,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
       if (!cfgp)
        {
          vlib_cli_output (vm, "Ugh: msg id %d no trace config\n", msg_id);
+         munmap (hp, file_size);
          return;
        }
       size = cfgp->size;
index 85c3e80..c8a1d06 100644 (file)
@@ -1188,6 +1188,10 @@ set_dpdk_if_hqos_tctbl (vlib_main_t * vm, unformat_input_t * input,
 
   /* Detect the set of worker threads */
   uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
+  /* Should never happen, shut up Coverity warning */
+  if (p == 0)
+    return clib_error_return (0, "no worker registrations?");
+
   vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
   int worker_thread_first = tr->first_index;
   int worker_thread_count = tr->count;
@@ -1224,6 +1228,10 @@ set_dpdk_if_hqos_pktfield (vlib_main_t * vm, unformat_input_t * input,
 
   /* Detect the set of worker threads */
   uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
+  /* Should never happen, shut up Coverity warning */
+  if (p == 0)
+    return clib_error_return (0, "no worker registrations?");
+
   vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
   int worker_thread_first = tr->first_index;
   int worker_thread_count = tr->count;
@@ -1426,6 +1434,11 @@ show_dpdk_if_hqos (vlib_main_t * vm, unformat_input_t * input,
 
   /* Detect the set of worker threads */
   p = hash_get_mem (tm->thread_registrations_by_name, "workers");
+
+  /* Should never happen, shut up Coverity warning */
+  if (p == 0)
+    return clib_error_return (0, "no worker registrations?");
+
   tr = (vlib_thread_registration_t *) p[0];
 
   cfg = &devconf->hqos;
index e06d6bf..ee22b9a 100644 (file)
@@ -739,7 +739,7 @@ dpdk_lib_init (dpdk_main_t * dm)
       if (devconf->hqos_enabled)
        {
          rv = dpdk_port_setup_hqos (xd, &devconf->hqos);
-         if (rv < 0)
+         if (rv)
            return rv;
        }
 
index 7a63a73..5585c95 100644 (file)
@@ -1063,7 +1063,8 @@ icmp6_neighbor_solicitation_or_advertisement (vlib_main_t * vm,
               vlib_buffer_advance(p0, - ethernet_buffer_header_size(p0));
               eth0 = vlib_buffer_get_current(p0);
               clib_memcpy(eth0->dst_address, eth0->src_address, 6);
-              clib_memcpy(eth0->src_address, eth_if0->address, 6);
+              if (eth_if0)
+                clib_memcpy(eth0->src_address, eth_if0->address, 6);
 
               /* Setup input and output sw_if_index for packet */
               ASSERT(vnet_buffer(p0)->sw_if_index[VLIB_RX] == sw_if_index0);
index 120c39c..fb3b2d3 100644 (file)
@@ -6325,9 +6325,6 @@ api_mpls_ip_bind_unbind (vat_main_t * vam)
 
   /* Wait for a reply... */
   W;
-
-  /* Return the good/bad news */
-  return (vam->retval);
 }
 
 static int
index d619249..cb265ee 100644 (file)
@@ -878,7 +878,7 @@ connect_unix_tap (test_main_t * tm, char *name)
   mp->_vl_msg_id = ntohs (VL_API_TAP_CONNECT);
   mp->client_index = tm->my_client_index;
   mp->context = 0xdeadbeef;
-  clib_memcpy (mp->tap_name, name, strlen (name));
+  strncpy ((char *) mp->tap_name, name, sizeof (mp->tap_name) - 1);
   mp->use_random_mac = 1;
   vl_msg_api_send_shmem (tm->vl_input_queue, (u8 *) & mp);
 }