Fix new LISP Coverity warnings
authorFlorin Coras <[email protected]>
Mon, 1 Aug 2016 13:35:20 +0000 (15:35 +0200)
committerChris Luke <[email protected]>
Mon, 1 Aug 2016 17:21:17 +0000 (17:21 +0000)
Change-Id: I60ef5218110e596f77d11e3949284a7a7af7dedb
Signed-off-by: Florin Coras <[email protected]>
vnet/vnet/lisp-cp/control.c
vnet/vnet/lisp-cp/lisp_types.c
vnet/vnet/lisp-gpe/interface.c

index 5ef7889..b2a009e 100644 (file)
@@ -971,7 +971,6 @@ lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
   gid_address_t eid;
   u8 * dmac = gid_address_mac (&eid);
   u8 eid_set = 0;
-  u8 * s = 0;
   u32 vni, action = ~0, p, w;
   int rv;
 
@@ -1024,22 +1023,9 @@ lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
           vec_add1 (rlocs, rloc);
           curr_rloc = &rlocs[vec_len (rlocs) - 1];
         }
-      else if (unformat (line_input, "action %s", &s))
-        {
-          if (!strcmp ((char *)s, "no-action"))
-            action = LISP_NO_ACTION;
-          if (!strcmp ((char *)s, "natively-forward"))
-            action = LISP_FORWARD_NATIVE;
-          if (!strcmp ((char *)s, "send-map-request"))
-            action = LISP_SEND_MAP_REQUEST;
-          else if (!strcmp ((char *)s, "drop"))
-            action = LISP_DROP;
-          else
-            {
-              clib_warning ("invalid action: '%s'", s);
-              goto done;
-            }
-        }
+      else if (unformat (line_input, "action %U",
+                         unformat_negative_mapping_action, &action))
+        ;
       else
         {
           clib_warning ("parse error");
@@ -1093,8 +1079,6 @@ lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
 done:
   vec_free (rlocs);
   unformat_free (line_input);
-  if (s)
-    vec_free (s);
   return error;
 }
 
index f092659..196010e 100644 (file)
@@ -238,13 +238,11 @@ unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
 
   if (unformat (input, "%s", &s))
     {
-      int len = vec_len(s);
-      clib_warning ("len = %d", len);
       if (!strcmp ((char *) s, "no-action"))
         action[0] = LISP_NO_ACTION;
-      if (!strcmp ((char *) s, "natively-forward"))
+      else if (!strcmp ((char *) s, "natively-forward"))
         action[0] = LISP_FORWARD_NATIVE;
-      if (!strcmp ((char *) s, "send-map-request"))
+      else if (!strcmp ((char *) s, "send-map-request"))
         action[0] = LISP_SEND_MAP_REQUEST;
       else if (!strcmp ((char *) s, "drop"))
         action[0] = LISP_DROP;
@@ -252,12 +250,12 @@ unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
         {
           clib_warning("invalid action: '%s'", s);
           action[0] = LISP_DROP;
-          return 0;
         }
     }
   else
     return 0;
 
+  vec_free(s);
   return 1;
 }
 
index 1f40ea8..77ad9a3 100644 (file)
@@ -832,6 +832,11 @@ remove_lisp_gpe_iface (lisp_gpe_main_t * lgm, u32 hi_index, u32 dp_table,
 
   /* clean tunnel termination and vni to sw_if_index binding */
   vnip = hash_get(tuns->vni_by_sw_if_index, hi->sw_if_index);
+  if (0 == vnip)
+    {
+      clib_warning ("No vni associated to interface %d", hi->sw_if_index);
+      return;
+    }
   hash_unset(tuns->sw_if_index_by_vni, vnip[0]);
   hash_unset(tuns->vni_by_sw_if_index, hi->sw_if_index);
 }