l2: coverity woe in l2_api.c
[vpp.git] / src / vnet / l2 / l2_api.c
index 85e9c31..01e4ed1 100644 (file)
@@ -103,10 +103,8 @@ static void
 vl_api_l2_xconnect_dump_t_handler (vl_api_l2_xconnect_dump_t * mp)
 {
   vl_api_registration_t *reg;
-  vnet_main_t *vnm = vnet_get_main ();
-  vnet_interface_main_t *im = &vnm->interface_main;
   l2input_main_t *l2im = &l2input_main;
-  vnet_sw_interface_t *swif;
+  u32 sw_if_index;
   l2_input_config_t *config;
 
   reg = vl_api_client_index_to_registration (mp->client_index);
@@ -114,13 +112,13 @@ vl_api_l2_xconnect_dump_t_handler (vl_api_l2_xconnect_dump_t * mp)
     return;
 
   /* *INDENT-OFF* */
-  pool_foreach (swif, im->sw_interfaces)
-   {
-    config = vec_elt_at_index (l2im->configs, swif->sw_if_index);
-    if (l2_input_is_xconnect(config))
-      send_l2_xconnect_details (reg, mp->context, swif->sw_if_index,
-                                config->output_sw_if_index);
-  }
+  vec_foreach_index (sw_if_index, l2im->configs)
+    {
+      config = vec_elt_at_index (l2im->configs, sw_if_index);
+      if (l2_input_is_xconnect (config))
+       send_l2_xconnect_details (reg, mp->context, sw_if_index,
+                                 config->output_sw_if_index);
+    }
   /* *INDENT-ON* */
 }
 
@@ -1209,30 +1207,27 @@ l2_arp_term_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
            last_event = *event;
            last = now;
 
-            /* *INDENT-OFF* */
             pool_foreach (reg, vpe_api_main.l2_arp_term_events_registrations)
-             {
-              vl_api_registration_t *vl_reg;
-              vl_reg = vl_api_client_index_to_registration (reg->client_index);
-              ALWAYS_ASSERT (vl_reg != NULL);
-
-              if (reg && vl_api_can_send_msg (vl_reg))
-                {
-                  vl_api_l2_arp_term_event_t * vevent;
-                  vevent = vl_msg_api_alloc (sizeof *vevent);
-                  clib_memset (vevent, 0, sizeof *vevent);
-                  vevent->_vl_msg_id = htons (VL_API_L2_ARP_TERM_EVENT);
-                  vevent->client_index = reg->client_index;
-                  vevent->pid = reg->client_pid;
-                  ip_address_encode(&event->ip,
-                                    event->type,
-                                    &vevent->ip);
-                  vevent->sw_if_index = htonl(event->sw_if_index);
-                  mac_address_encode(&event->mac, vevent->mac);
-                  vl_api_send_msg (vl_reg, (u8 *) vevent);
-                }
-            }
-            /* *INDENT-ON* */
+             {
+               vl_api_registration_t *vl_reg;
+               vl_reg =
+                 vl_api_client_index_to_registration (reg->client_index);
+               ALWAYS_ASSERT (vl_reg != NULL);
+
+               if (vl_reg && vl_api_can_send_msg (vl_reg))
+                 {
+                   vl_api_l2_arp_term_event_t *vevent;
+                   vevent = vl_msg_api_alloc (sizeof *vevent);
+                   clib_memset (vevent, 0, sizeof *vevent);
+                   vevent->_vl_msg_id = htons (VL_API_L2_ARP_TERM_EVENT);
+                   vevent->client_index = reg->client_index;
+                   vevent->pid = reg->client_pid;
+                   ip_address_encode (&event->ip, event->type, &vevent->ip);
+                   vevent->sw_if_index = htonl (event->sw_if_index);
+                   mac_address_encode (&event->mac, vevent->mac);
+                   vl_api_send_msg (vl_reg, (u8 *) vevent);
+                 }
+             }
          }
          vec_reset_length (l2am->publish_events);
        }