api: remove legacy pd msg handlers 23/34123/2
authorKlement Sekera <ksekera@cisco.com>
Mon, 18 Oct 2021 10:28:48 +0000 (12:28 +0200)
committerKlement Sekera <ksekera@cisco.com>
Mon, 18 Oct 2021 10:32:47 +0000 (12:32 +0200)
While looking at a coverity warning it was discovered that it's caused
by return value modified by pd msg handlers. As these are legacy, it's
a good time to remove them and also fix the warning this way.

Type: fix
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: Ic72ab8b2b7a2e55188d1c31cfd18a74b7cf82c43

src/vlibapi/api_common.h
src/vlibapi/api_helper_macros.h
src/vlibapi/api_shared.c
src/vnet/gre/gre_api.c
src/vnet/ipip/ipip_api.c

index a955636..320e7c4 100644 (file)
@@ -232,8 +232,6 @@ typedef struct api_main_t
 {
   /** Message handler vector  */
   void (**msg_handlers) (void *);
-  /** Plaform-dependent (aka hardware) message handler vector */
-  int (**pd_msg_handlers) (void *, int);
 
   /** non-default message cleanup handler vector */
   void (**msg_cleanup_handlers) (void *);
index 2e0a622..7a04bb0 100644 (file)
@@ -30,7 +30,6 @@
 #define REPLY_MACRO(t)                                                  \
 do {                                                                    \
     vl_api_registration_t *rp;                                          \
-    rv = vl_msg_api_pd_handler (mp, rv);                                \
     rp = vl_api_client_index_to_registration (mp->client_index);        \
     if (rp == 0)                                                        \
       return;                                                           \
@@ -46,7 +45,6 @@ do {                                                                    \
 #define REPLY_MACRO_END(t)                                              \
 do {                                                                    \
     vl_api_registration_t *rp;                                          \
-    rv = vl_msg_api_pd_handler (mp, rv);                                \
     rp = vl_api_client_index_to_registration (mp->client_index);        \
     if (rp == 0)                                                        \
       return;                                                           \
@@ -65,7 +63,6 @@ do {                                                                    \
 #define REPLY_MACRO2(t, body)                                           \
 do {                                                                    \
     vl_api_registration_t *rp;                                          \
-    rv = vl_msg_api_pd_handler (mp, rv);                                \
     rp = vl_api_client_index_to_registration (mp->client_index);        \
     if (rp == 0)                                                        \
       return;                                                           \
@@ -81,7 +78,6 @@ do {                                                                    \
 #define REPLY_MACRO2_END(t, body)                                       \
 do {                                                                    \
     vl_api_registration_t *rp;                                          \
-    rv = vl_msg_api_pd_handler (mp, rv);                                \
     rp = vl_api_client_index_to_registration (mp->client_index);        \
     if (rp == 0)                                                        \
       return;                                                           \
@@ -101,7 +97,6 @@ do {                                                                    \
 #define REPLY_MACRO2_ZERO(t, body)                                      \
 do {                                                                    \
     vl_api_registration_t *rp;                                          \
-    rv = vl_msg_api_pd_handler (mp, rv);                                \
     rp = vl_api_client_index_to_registration (mp->client_index);        \
     if (rp == 0)                                                        \
       return;                                                           \
@@ -117,7 +112,6 @@ do {                                                                    \
 #define REPLY_MACRO_DETAILS2(t, body)                                   \
 do {                                                                    \
     vl_api_registration_t *rp;                                          \
-    rv = vl_msg_api_pd_handler (mp, rv);                                \
     rp = vl_api_client_index_to_registration (mp->client_index);        \
     if (rp == 0)                                                        \
       return;                                                           \
@@ -141,7 +135,6 @@ do {                                                                    \
 #define REPLY_MACRO3(t, n, body)                                        \
 do {                                                                    \
     vl_api_registration_t *rp;                                          \
-    rv = vl_msg_api_pd_handler (mp, rv);                                \
     rp = vl_api_client_index_to_registration (mp->client_index);        \
     if (rp == 0)                                                        \
       return;                                                           \
@@ -157,7 +150,6 @@ do {                                                                    \
 #define REPLY_MACRO3_ZERO(t, n, body)                                   \
 do {                                                                    \
     vl_api_registration_t *rp;                                          \
-    rv = vl_msg_api_pd_handler (mp, rv);                                \
     rp = vl_api_client_index_to_registration (mp->client_index);        \
     if (rp == 0)                                                        \
       return;                                                           \
@@ -174,7 +166,6 @@ do {                                                                    \
 do {                                                                    \
     vl_api_registration_t *rp;                                          \
     u8 is_error = 0;                                                    \
-    rv = vl_msg_api_pd_handler (mp, rv);                                \
                                                                         \
     rp = vl_api_client_index_to_registration (mp->client_index);        \
     if (rp == 0)                                                        \
index 52e66f4..dd51ee5 100644 (file)
@@ -1081,41 +1081,6 @@ vl_msg_api_post_mortem_dump (void)
 
 /* Layered message handling support */
 
-void
-vl_msg_api_register_pd_handler (void *fp, u16 msg_id_host_byte_order)
-{
-  api_main_t *am = vlibapi_get_main ();
-
-  /* Mild idiot proofing */
-  if (msg_id_host_byte_order > 10000)
-    clib_warning ("msg_id_host_byte_order endian issue? %d arg vs %d",
-                 msg_id_host_byte_order,
-                 clib_net_to_host_u16 (msg_id_host_byte_order));
-  vec_validate (am->pd_msg_handlers, msg_id_host_byte_order);
-  am->pd_msg_handlers[msg_id_host_byte_order] = fp;
-}
-
-int
-vl_msg_api_pd_handler (void *mp, int rv)
-{
-  api_main_t *am = vlibapi_get_main ();
-  int (*fp) (void *, int);
-  u16 msg_id;
-
-  if (clib_arch_is_little_endian)
-    msg_id = clib_net_to_host_u16 (*((u16 *) mp));
-  else
-    msg_id = *((u16 *) mp);
-
-  if (msg_id >= vec_len (am->pd_msg_handlers)
-      || am->pd_msg_handlers[msg_id] == 0)
-    return rv;
-
-  fp = am->pd_msg_handlers[msg_id];
-  rv = (*fp) (mp, rv);
-  return rv;
-}
-
 void
 vl_msg_api_set_first_available_msg_id (u16 first_avail)
 {
index e83635a..3b42c76 100644 (file)
@@ -130,7 +130,6 @@ static void send_gre_tunnel_details
   (gre_tunnel_t * t, vl_api_gre_tunnel_dump_t * mp)
 {
   vl_api_gre_tunnel_details_t *rmp;
-  int rv = 0;
 
   /* *INDENT-OFF* */
   REPLY_MACRO_DETAILS2(VL_API_GRE_TUNNEL_DETAILS,
index f44c72c..50b6731 100644 (file)
@@ -112,7 +112,6 @@ send_ipip_tunnel_details (ipip_tunnel_t * t, vl_api_ipip_tunnel_dump_t * mp)
   vl_api_ipip_tunnel_details_t *rmp;
   bool is_ipv6 = t->transport == IPIP_TRANSPORT_IP6 ? true : false;
   fib_table_t *ft;
-  int rv = 0;
 
   ft = fib_table_get (t->fib_index, (is_ipv6 ? FIB_PROTOCOL_IP6 :
                                     FIB_PROTOCOL_IP4));