memif: fix coverity warnings as of 9/7
[vpp.git] / src / plugins / memif / memif_api.c
index 533e848..89afdb8 100644 (file)
@@ -91,7 +91,6 @@ do {                                                            \
 #define foreach_memif_plugin_api_msg                     \
 _(MEMIF_CREATE, memif_create)                            \
 _(MEMIF_DELETE, memif_delete)                            \
-_(MEMIF_DETAILS, memif_details)                          \
 _(MEMIF_DUMP, memif_dump)                                \
 
 /**
@@ -133,10 +132,20 @@ vl_api_memif_create_t_handler (vl_api_memif_create_t * mp)
 
   /* role */
   args.is_master = (mp->role == 0);
+
+  /* rx/tx queues */
   if (args.is_master == 0)
     {
-      args.rx_queues = mp->rx_queues;
-      args.tx_queues = mp->tx_queues;
+      args.rx_queues = MEMIF_DEFAULT_RX_QUEUES;
+      args.tx_queues = MEMIF_DEFAULT_TX_QUEUES;
+      if (mp->rx_queues)
+       {
+         args.rx_queues = mp->rx_queues;
+       }
+      if (mp->tx_queues)
+       {
+         args.tx_queues = mp->tx_queues;
+       }
     }
 
   /* ring size */
@@ -192,13 +201,16 @@ vl_api_memif_delete_t_handler (vl_api_memif_delete_t * mp)
   vl_api_memif_delete_reply_t *rmp;
   vnet_hw_interface_t *hi =
     vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
-  memif_if_t *mif = pool_elt_at_index (mm->interfaces, hi->dev_instance);
+  memif_if_t *mif;
   int rv = 0;
 
   if (hi == NULL || memif_device_class.index != hi->dev_class_index)
     rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
   else
-    rv = memif_delete_if (vm, mif);
+    {
+      mif = pool_elt_at_index (mm->interfaces, hi->dev_instance);
+      rv = memif_delete_if (vm, mif);
+    }
 
   REPLY_MACRO (VL_API_MEMIF_DELETE_REPLY);
 }
@@ -278,16 +290,6 @@ vl_api_memif_dump_t_handler (vl_api_memif_dump_t * mp)
   vec_free (if_name);
 }
 
-/**
- * @brief Message handler for memif_details API.
- * @param mp vl_api_memif_details_t * mp the api message
- */
-void
-vl_api_memif_details_t_handler (vl_api_memif_details_t * mp)
-{
-  clib_warning ("BUG");
-}
-
 #define vl_msg_name_crc_list
 #include <memif/memif_all_api_h.h>
 #undef vl_msg_name_crc_list