[openib-general] [PATCH] OpenSM/SA: Eliminate some no longer needed code

Hal Rosenstock halr at voltaire.com
Tue Jun 27 04:15:05 PDT 2006


OpenSM/SA: Eliminate some no longer needed code

No longer a need to check whether the LID is beyond the vector table
size. In fact, this turns an edge case into an error (when LMC > 0 and
a non base LID is requested which is above the last base LID but within
that port's LID range). In any case, osm_get_port_by_base_lid uses
cl_ptr_vector_get_at which does this check at the proper time.

Signed-off-by: Hal Rosenstock <halr at voltaire.com>

Index: opensm/osm_sa_pkey_record.c
===================================================================
--- opensm/osm_sa_pkey_record.c	(revision 8236)
+++ opensm/osm_sa_pkey_record.c	(working copy)
@@ -419,25 +419,14 @@ osm_pkey_rec_rcv_process(
 
     CL_ASSERT( cl_ptr_vector_get_size(p_tbl) < 0x10000 );
 
-    if ((uint16_t)cl_ptr_vector_get_size(p_tbl) > cl_ntoh16(p_rcvd_rec->lid))
+    status = osm_get_port_by_base_lid( p_rcv->p_subn, p_rcvd_rec->lid, &p_port );
+    if ( ( status != IB_SUCCESS ) || ( p_port == NULL ) )
     {
-      status = osm_get_port_by_base_lid( p_rcv->p_subn, p_rcvd_rec->lid, &p_port );
-      if ( ( status != IB_SUCCESS ) || ( p_port == NULL ) )
-      {
-        status = IB_NOT_FOUND;
-        osm_log( p_rcv->p_log, OSM_LOG_ERROR,
-                 "osm_pkey_rec_rcv_process: ERR 460B: "
-                 "No port found with LID 0x%x\n",
-                 cl_ntoh16(p_rcvd_rec->lid) );
-      }
-    }
-    else
-    { /* LID out of range */
       status = IB_NOT_FOUND;
       osm_log( p_rcv->p_log, OSM_LOG_ERROR,
-               "osm_pkey_rec_rcv_process: ERR 4609: "
-               "Given LID (0x%X) is out of range:0x%X\n",
-               cl_ntoh16(p_rcvd_rec->lid), cl_ptr_vector_get_size(p_tbl) );
+               "osm_pkey_rec_rcv_process: ERR 460B: "
+               "No port found with LID 0x%x\n",
+               cl_ntoh16(p_rcvd_rec->lid) );
     }
   }
 
Index: opensm/osm_sa_portinfo_record.c
===================================================================
--- opensm/osm_sa_portinfo_record.c	(revision 8236)
+++ opensm/osm_sa_portinfo_record.c	(working copy)
@@ -677,25 +677,14 @@ osm_pir_rcv_process(
   */
   if( comp_mask & IB_PIR_COMPMASK_LID )
   {
-    if ((uint16_t)cl_ptr_vector_get_size(p_tbl) > cl_ntoh16(p_rcvd_rec->lid))
-    {
-      status = osm_get_port_by_base_lid( p_rcv->p_subn, p_rcvd_rec->lid, &p_port );
-      if ( ( status != IB_SUCCESS ) || ( p_port == NULL ) )
-      {
-        status = IB_NOT_FOUND;
-        osm_log( p_rcv->p_log, OSM_LOG_ERROR,
-                 "osm_pir_rcv_process: ERR 2109: "
-                 "No port found with LID 0x%x\n",
-                 cl_ntoh16(p_rcvd_rec->lid) );
-      }
-    }
-    else
+    status = osm_get_port_by_base_lid( p_rcv->p_subn, p_rcvd_rec->lid, &p_port );
+    if ( ( status != IB_SUCCESS ) || ( p_port == NULL ) )
     {
       status = IB_NOT_FOUND;
       osm_log( p_rcv->p_log, OSM_LOG_ERROR,
-               "osm_pir_rcv_process: ERR 2101: "
-               "Given LID (0x%X) is out of range:0x%X\n",
-               cl_ntoh16(p_rcvd_rec->lid), cl_ptr_vector_get_size(p_tbl) );
+               "osm_pir_rcv_process: ERR 2109: "
+               "No port found with LID 0x%x\n",
+               cl_ntoh16(p_rcvd_rec->lid) );
     }
   }
   else
Index: opensm/osm_sa_slvl_record.c
===================================================================
--- opensm/osm_sa_slvl_record.c	(revision 8236)
+++ opensm/osm_sa_slvl_record.c	(working copy)
@@ -387,25 +387,14 @@ osm_slvl_rec_rcv_process(
 
     CL_ASSERT( cl_ptr_vector_get_size(p_tbl) < 0x10000 );
 
-    if ((uint16_t)cl_ptr_vector_get_size(p_tbl) > cl_ntoh16(p_rcvd_rec->lid))
+    status = osm_get_port_by_base_lid( p_rcv->p_subn, p_rcvd_rec->lid, &p_port );
+    if ( ( status != IB_SUCCESS ) || ( p_port == NULL ) )
     {
-      status = osm_get_port_by_base_lid( p_rcv->p_subn, p_rcvd_rec->lid, &p_port );
-      if ( ( status != IB_SUCCESS ) || ( p_port == NULL ) )
-      {
-        status = IB_NOT_FOUND;
-        osm_log( p_rcv->p_log, OSM_LOG_ERROR,
-                 "osm_slvl_rec_rcv_process: ERR 2608: "
-                 "No port found with LID 0x%x\n",
-                 cl_ntoh16(p_rcvd_rec->lid) );
-      }
-    }
-    else
-    { /* LID out of range */
       status = IB_NOT_FOUND;
       osm_log( p_rcv->p_log, OSM_LOG_ERROR,
-               "osm_slvl_rec_rcv_process: ERR 2601: "
-               "Given LID (0x%X) is out of range:0x%X\n",
-               cl_ntoh16(p_rcvd_rec->lid), cl_ptr_vector_get_size(p_tbl));
+               "osm_slvl_rec_rcv_process: ERR 2608: "
+               "No port found with LID 0x%x\n",
+               cl_ntoh16(p_rcvd_rec->lid) );
     }
   }
 
Index: opensm/osm_sa_vlarb_record.c
===================================================================
--- opensm/osm_sa_vlarb_record.c	(revision 8236)
+++ opensm/osm_sa_vlarb_record.c	(working copy)
@@ -407,25 +407,14 @@ osm_vlarb_rec_rcv_process(
 
     CL_ASSERT( cl_ptr_vector_get_size(p_tbl) < 0x10000 );
 
-    if ((uint16_t)cl_ptr_vector_get_size(p_tbl) > cl_ntoh16(p_rcvd_rec->lid))
+    status = osm_get_port_by_base_lid( p_rcv->p_subn, p_rcvd_rec->lid, &p_port );
+    if ( ( status != IB_SUCCESS ) || ( p_port == NULL ) )
     {
-      status = osm_get_port_by_base_lid( p_rcv->p_subn, p_rcvd_rec->lid, &p_port );
-      if ( ( status != IB_SUCCESS ) || ( p_port == NULL ) )
-      {
-        status = IB_NOT_FOUND;
-        osm_log( p_rcv->p_log, OSM_LOG_ERROR,
-                 "osm_vlarb_rec_rcv_process: ERR 2A09: "
-                 "No port found with LID 0x%x\n",
-                 cl_ntoh16(p_rcvd_rec->lid) );
-      }
-    }
-    else
-    { /* LID out of range */
       status = IB_NOT_FOUND;
       osm_log( p_rcv->p_log, OSM_LOG_ERROR,
-               "osm_vlarb_rec_rcv_process: ERR 2A01: "
-               "Given LID (0x%X) is out of range:0x%X\n",
-               cl_ntoh16(p_rcvd_rec->lid), cl_ptr_vector_get_size(p_tbl) );
+               "osm_vlarb_rec_rcv_process: ERR 2A09: "
+               "No port found with LID 0x%x\n",
+               cl_ntoh16(p_rcvd_rec->lid) );
     }
   }
 







More information about the general mailing list