[openib-general] [PATCH TRIVIAL] opensm: remove osm_physp_get_port_info_ptr() checks

Sasha Khapyorsky sashak at voltaire.com
Sun Jan 7 13:47:44 PST 2007


This function returns address of osm_physp's port_info field, the result
cannot be NULL (unless physp itself is valid pointer). Not need to check.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 osm/opensm/osm_lid_mgr.c            |    9 ++-------
 osm/opensm/osm_pkey_mgr.c           |   13 +------------
 osm/opensm/osm_qos.c                |   15 ++++-----------
 osm/opensm/osm_sa_mcmember_record.c |   23 ++++-------------------
 4 files changed, 11 insertions(+), 49 deletions(-)

diff --git a/osm/opensm/osm_lid_mgr.c b/osm/opensm/osm_lid_mgr.c
index aba243a..e6fb893 100644
--- a/osm/opensm/osm_lid_mgr.c
+++ b/osm/opensm/osm_lid_mgr.c
@@ -937,19 +937,14 @@ __osm_lid_mgr_set_remote_pi_state_to_init(
   IN osm_lid_mgr_t *       const p_mgr,
   IN osm_physp_t*          const p_physp)
 {
-  ib_port_info_t *p_pi;
   osm_physp_t *p_rem_physp = osm_physp_get_remote(p_physp);
 
   if ( p_rem_physp == NULL )
     return;
 
   if (osm_physp_is_valid( p_rem_physp ))
-  {
-    p_pi = osm_physp_get_port_info_ptr( p_rem_physp );
-    /* but in some rare cases the remote side might be irresponsive  */
-    if (p_pi)
-      ib_port_info_set_port_state( p_pi, IB_LINK_INIT );
-  }
+    ib_port_info_set_port_state( osm_physp_get_port_info_ptr( p_rem_physp ),
+                                 IB_LINK_INIT );
 }
 
 /**********************************************************************
diff --git a/osm/opensm/osm_pkey_mgr.c b/osm/opensm/osm_pkey_mgr.c
index 9e3e35a..5581ce1 100644
--- a/osm/opensm/osm_pkey_mgr.c
+++ b/osm/opensm/osm_pkey_mgr.c
@@ -219,18 +219,7 @@ pkey_mgr_enforce_partition(
   ib_port_info_t *p_pi;
   ib_api_status_t status;
 
-  if (!(p_pi = osm_physp_get_port_info_ptr( p_physp )))
-  {
-    osm_log( p_log, OSM_LOG_ERROR,
-             "pkey_mgr_enforce_partition: ERR 0507: "
-             "No port info for "
-             "node 0x%016" PRIx64 " port %u\n",
-             cl_ntoh64(
-               osm_node_get_node_guid( 
-                  osm_physp_get_node_ptr( p_physp ))),
-             osm_physp_get_port_num( p_physp ) );
-    return FALSE;
-  }
+  p_pi = osm_physp_get_port_info_ptr( p_physp );
 
   if ((p_pi->vl_enforce & 0xc) == (0xc)*(enforce == TRUE)) 
   {
diff --git a/osm/opensm/osm_qos.c b/osm/opensm/osm_qos.c
index 0dd5dc7..92fe6fc 100644
--- a/osm/opensm/osm_qos.c
+++ b/osm/opensm/osm_qos.c
@@ -80,8 +80,7 @@ static ib_api_status_t vlarb_update_table_block(osm_req_t * p_req,
 	ib_port_info_t *p_pi;
 	unsigned vl_mask, i;
 
-	if (!(p_pi = osm_physp_get_port_info_ptr(p)))
-		return IB_ERROR;
+	p_pi = osm_physp_get_port_info_ptr(p);
 
 	vl_mask = (1 << (ib_port_info_get_op_vls(p_pi) - 1)) - 1;
 
@@ -115,8 +114,7 @@ static ib_api_status_t vlarb_update(osm_req_t * p_req,
 	ib_port_info_t *p_pi;
 	unsigned len;
 
-	if (!(p_pi = osm_physp_get_port_info_ptr(p)))
-		return IB_ERROR;
+	p_pi = osm_physp_get_port_info_ptr(p);
 
 	if (p_pi->vl_arb_low_cap > 0) {
 		len = p_pi->vl_arb_low_cap < IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK ?
@@ -166,8 +164,7 @@ static ib_api_status_t sl2vl_update_table(osm_req_t * p_req,
 	uint8_t vl1, vl2;
 	int i;
 
-	if (!(p_pi = osm_physp_get_port_info_ptr(p)))
-		return IB_ERROR;
+	p_pi = osm_physp_get_port_info_ptr(p);
 
 	vl_mask = (1 << (ib_port_info_get_op_vls(p_pi) - 1)) - 1;
 
@@ -204,9 +201,6 @@ static ib_api_status_t sl2vl_update(osm_req_t * p_req, osm_port_t * p_port,
 	ib_port_info_t *p_pi = osm_physp_get_port_info_ptr(p);
 	osm_physp_t *p_physp;
 
-	if (!p_pi)
-		return IB_ERROR;
-
 	if (osm_node_get_type(osm_physp_get_node_ptr(p)) == IB_NODE_TYPE_SWITCH) {
 		if (ib_port_info_get_vl_cap(p_pi) == 1) {
 			/* Check port 0's capability mask */
@@ -240,8 +234,7 @@ static ib_api_status_t vl_high_limit_update(osm_req_t * p_req,
 	osm_madw_context_t context;
 	ib_port_info_t *p_pi;
 
-	if (!(p_pi = osm_physp_get_port_info_ptr(p)))
-		return IB_ERROR;
+	p_pi = osm_physp_get_port_info_ptr(p);
 
 	if (p_pi->vl_high_limit == qcfg->vl_high_limit)
 		return IB_SUCCESS;
diff --git a/osm/opensm/osm_sa_mcmember_record.c b/osm/opensm/osm_sa_mcmember_record.c
index 90d7300..a3a8bac 100644
--- a/osm/opensm/osm_sa_mcmember_record.c
+++ b/osm/opensm/osm_sa_mcmember_record.c
@@ -706,23 +706,12 @@ __validate_port_caps(
   const osm_mgrp_t *p_mgrp,
   const osm_physp_t *p_physp)
 {
-  ib_port_info_t *p_pi;
   uint8_t mtu_required;
   uint8_t mtu_mgrp;
   uint8_t rate_required;
   uint8_t rate_mgrp;
 
-  p_pi = osm_physp_get_port_info_ptr(p_physp);
-  if (!p_pi)
-  {
-    osm_log( p_log, OSM_LOG_DEBUG,
-             "__validate_port_caps: "
-             "Cannot get Port's 0x%016" PRIx64 " PortInfo\n",
-             cl_ntoh64( osm_physp_get_port_guid(p_physp) ) );
-    return FALSE;
-  }
-
-  mtu_required = ib_port_info_get_mtu_cap(p_pi);
+  mtu_required = ib_port_info_get_mtu_cap(&p_physp->port_info);
   mtu_mgrp = (uint8_t)(p_mgrp->mcmember_rec.mtu & 0x3F);
   if (mtu_required < mtu_mgrp)
   {
@@ -733,7 +722,7 @@ __validate_port_caps(
     return FALSE;
   }
 
-  rate_required = ib_port_info_compute_rate(p_pi);
+  rate_required = ib_port_info_compute_rate(&p_physp->port_info);
   rate_mgrp = (uint8_t)(p_mgrp->mcmember_rec.rate & 0x3F);
   if (rate_required < rate_mgrp)
   {
@@ -1075,13 +1064,9 @@ __mgrp_request_is_realizable(
   uint8_t rate_sel = 2; /* exactly */
   uint8_t rate_required, rate, port_rate;
   osm_log_t *p_log = p_rcv->p_log;
-  ib_port_info_t *p_pi = NULL;
 
   OSM_LOG_ENTER( p_rcv->p_log,  __mgrp_request_is_realizable );
 
-  if (p_physp != NULL)
-     p_pi = osm_physp_get_port_info_ptr(p_physp);
-
   /*
    * End of o15-0.2.3 specifies:
    * ....
@@ -1093,7 +1078,7 @@ __mgrp_request_is_realizable(
    * so we might also need to assign RATE/MTU if they are not comp masked in.
    */
 
-  port_mtu = p_pi ? ib_port_info_get_mtu_cap(p_pi) : 0;
+  port_mtu = p_physp ? ib_port_info_get_mtu_cap(&p_physp->port_info) : 0;
   if (!(comp_mask & IB_MCR_COMPMASK_MTU) ||
 		  !(comp_mask & IB_MCR_COMPMASK_MTU_SEL) ||
 		  (mtu_sel = (p_mcm_rec->mtu >> 6)) == 3)
@@ -1146,7 +1131,7 @@ __mgrp_request_is_realizable(
   }
   p_mcm_rec->mtu = (mtu_sel<<6) | mtu;
 
-  port_rate = p_pi ? ib_port_info_compute_rate(p_pi) : 0;
+  port_rate = p_physp ? ib_port_info_compute_rate(&p_physp->port_info) : 0;
   if (!(comp_mask & IB_MCR_COMPMASK_RATE) ||
 		  !(comp_mask & IB_MCR_COMPMASK_RATE_SEL) ||
 		  (rate_sel = (p_mcm_rec->rate >> 6)) == 3)
-- 
1.5.0.rc0.g2484-dirty





More information about the general mailing list