Fix coverity warnings, VPP-486 27/3927/2
authorDave Barach <dave@barachs.net>
Tue, 22 Nov 2016 20:23:41 +0000 (15:23 -0500)
committerDamjan Marion <dmarion.lists@gmail.com>
Tue, 22 Nov 2016 21:25:47 +0000 (21:25 +0000)
Change-Id: I4ec49e116fdb418ebf9d84000f2a0cec1cf78b14
Signed-off-by: Dave Barach <dave@barachs.net>
vlib/vlib/threads_cli.c
vnet/vnet/l2tp/decap.c
vpp/vpp-api/api.c

index aef6757..6651a4d 100644 (file)
@@ -444,9 +444,9 @@ test_frame_queue_nelts (vlib_main_t * vm, unformat_input_t * input,
 
   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
     {
-      if (unformat (line_input, "nelts %u"), &nelts)
+      if (unformat (line_input, "nelts %u", &nelts))
        ;
-      else if (unformat (line_input, "index %u"), &index)
+      else if (unformat (line_input, "index %u", &index))
        ;
       else
        return clib_error_return (0, "parse error: '%U'",
@@ -511,9 +511,9 @@ test_frame_queue_threshold (vlib_main_t * vm, unformat_input_t * input,
 
   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
     {
-      if (unformat (line_input, "threshold %u"), &threshold)
+      if (unformat (line_input, "threshold %u", &threshold))
        ;
-      else if (unformat (line_input, "index %u"), &index)
+      else if (unformat (line_input, "index %u", &index))
        ;
       else
        return clib_error_return (0, "parse error: '%U'",
index ee307b6..e898693 100644 (file)
@@ -218,8 +218,8 @@ done:
       else
        {
          /* Go to next node on the ip6 configuration chain */
-         ASSERT (session);
-         vnet_feature_next (session->sw_if_index, &next_index, b);
+         if (PREDICT_TRUE (session != 0))
+           vnet_feature_next (session->sw_if_index, &next_index, b);
        }
     }
 
index 330b915..91726e1 100644 (file)
@@ -9166,14 +9166,14 @@ vl_api_ipsec_spd_dump_t_handler (vl_api_ipsec_spd_dump_t * mp)
   spd_index = p[0];
   spd = pool_elt_at_index (im->spds, spd_index);
 
-  pool_foreach (policy, spd->policies, (
-                                        {
-                                        if (mp->sa_id == ~(0)
-                                            || ntohl (mp->sa_id) ==
-                                            policy->sa_id)
-                                        send_ipsec_spd_details (policy, q,
-                                                                mp->context);}
-               ));
+  /* *INDENT-OFF* */
+  pool_foreach (policy, spd->policies,
+  ({
+    if (mp->sa_id == ~(0) || ntohl (mp->sa_id) == policy->sa_id)
+      send_ipsec_spd_details (policy, q,
+                              mp->context);}
+    ));
+  /* *INDENT-ON* */
 #else
   clib_warning ("unimplemented");
 #endif
@@ -9184,9 +9184,12 @@ vl_api_feature_enable_disable_t_handler (vl_api_feature_enable_disable_t * mp)
 {
   vl_api_feature_enable_disable_reply_t *rmp;
   int rv = 0;
+  u8 *arc_name, *feature_name;
 
-  u8 *arc_name = format (0, "%s%c", mp->arc_name, 0);
-  u8 *feature_name = format (0, "%s%c", mp->feature_name, 0);
+  VALIDATE_SW_IF_INDEX (mp);
+
+  arc_name = format (0, "%s%c", mp->arc_name, 0);
+  feature_name = format (0, "%s%c", mp->feature_name, 0);
 
   vnet_feature_registration_t *reg;
   reg =
@@ -9216,6 +9219,8 @@ vl_api_feature_enable_disable_t_handler (vl_api_feature_enable_disable_t * mp)
   vec_free (feature_name);
   vec_free (arc_name);
 
+  BAD_SW_IF_INDEX_LABEL;
+
   REPLY_MACRO (VL_API_FEATURE_ENABLE_DISABLE_REPLY);
 }