[openib-general] [PATCH] [TRIVIAL] OpenSM: Move more asserts before variable is used

Hal Rosenstock halr at voltaire.com
Wed Nov 30 11:34:42 PST 2005


OpenSM: Move more asserts before variable is used

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

Index: osm_pkey_rcv.c
===================================================================
--- osm_pkey_rcv.c	(revision 4257)
+++ osm_pkey_rcv.c	(working copy)
@@ -71,9 +71,10 @@ void
 osm_pkey_rcv_destroy(
   IN osm_pkey_rcv_t* const p_rcv )
 {
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_pkey_rcv_destroy );
 
-  CL_ASSERT( p_rcv );
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 
@@ -124,9 +125,10 @@ osm_pkey_rcv_process(
   uint8_t  port_num;
   uint16_t block_num;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_pkey_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_smp = osm_madw_get_smp_ptr( p_madw );
Index: osm_sm_state_mgr.c
===================================================================
--- osm_sm_state_mgr.c	(revision 4257)
+++ osm_sm_state_mgr.c	(working copy)
@@ -406,10 +406,10 @@ void
 osm_sm_state_mgr_destroy(
    IN osm_sm_state_mgr_t * const p_sm_mgr )
 {
-   OSM_LOG_ENTER( p_sm_mgr->p_log, osm_sm_state_mgr_destroy );
-
    CL_ASSERT( p_sm_mgr );
 
+   OSM_LOG_ENTER( p_sm_mgr->p_log, osm_sm_state_mgr_destroy );
+
    cl_spinlock_destroy( &p_sm_mgr->state_lock );
    cl_timer_destroy( &p_sm_mgr->polling_timer );
 
@@ -500,10 +500,10 @@ osm_sm_state_mgr_process(
 {
    ib_api_status_t status = IB_SUCCESS;
 
-   OSM_LOG_ENTER( p_sm_mgr->p_log, osm_sm_state_mgr_process );
-
    CL_ASSERT( p_sm_mgr );
 
+   OSM_LOG_ENTER( p_sm_mgr->p_log, osm_sm_state_mgr_process );
+
    /*
     * The state lock prevents many race conditions from screwing
     * up the state transition process.
@@ -760,10 +760,10 @@ osm_sm_state_mgr_check_legality(
 {
    ib_api_status_t status = IB_SUCCESS;
 
-   OSM_LOG_ENTER( p_sm_mgr->p_log, osm_sm_state_mgr_check_legality );
-
    CL_ASSERT( p_sm_mgr );
 
+   OSM_LOG_ENTER( p_sm_mgr->p_log, osm_sm_state_mgr_check_legality );
+
    /*
     * The state lock prevents many race conditions from screwing
     * up the state transition process.
Index: osm_state_mgr.c
===================================================================
--- osm_state_mgr.c	(revision 4257)
+++ osm_state_mgr.c	(working copy)
@@ -86,10 +86,10 @@ void
 osm_state_mgr_destroy(
    IN osm_state_mgr_t * const p_mgr )
 {
-   OSM_LOG_ENTER( p_mgr->p_log, osm_state_mgr_destroy );
-
    CL_ASSERT( p_mgr );
 
+   OSM_LOG_ENTER( p_mgr->p_log, osm_state_mgr_destroy );
+
    /*  destroy the locks */
    cl_spinlock_destroy( &p_mgr->state_lock );
    cl_spinlock_destroy( &p_mgr->idle_lock );
@@ -1881,9 +1881,10 @@ osm_state_mgr_process(
    ib_api_status_t status;
    osm_remote_sm_t *p_remote_sm;
 
-   OSM_LOG_ENTER( p_mgr->p_log, osm_state_mgr_process );
    CL_ASSERT( p_mgr );
 
+   OSM_LOG_ENTER( p_mgr->p_log, osm_state_mgr_process );
+
    /* if we are exiting do nothing */
    if( osm_exit_flag )
       signal = OSM_SIGNAL_NONE;
Index: osm_sa_vlarb_record.c
===================================================================
--- osm_sa_vlarb_record.c	(revision 4261)
+++ osm_sa_vlarb_record.c	(working copy)
@@ -348,6 +348,8 @@ osm_vlarb_rec_rcv_process(
   ib_net64_t                     comp_mask;
   osm_physp_t*                p_req_physp;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_vlarb_rec_rcv_process );
 
   /* update the requestor physical port. */
@@ -362,7 +364,6 @@ osm_vlarb_rec_rcv_process(
     goto Exit;
   }
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_rcvd_mad = osm_madw_get_sa_mad_ptr( p_madw );
Index: osm_sa_lft_record.c
===================================================================
--- osm_sa_lft_record.c	(revision 4258)
+++ osm_sa_lft_record.c	(working copy)
@@ -329,9 +329,10 @@ osm_lftr_rcv_process(
   ib_api_status_t           status;
   osm_physp_t*              p_req_physp;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_lftr_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_rcvd_mad = osm_madw_get_sa_mad_ptr( p_madw );
Index: osm_sa_portinfo_record.c
===================================================================
--- osm_sa_portinfo_record.c	(revision 4260)
+++ osm_sa_portinfo_record.c	(working copy)
@@ -551,9 +551,10 @@ osm_pir_rcv_process(
   osm_physp_t*             p_req_physp;
   boolean_t                trusted_req = TRUE;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_pir_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_rcvd_mad = osm_madw_get_sa_mad_ptr( p_madw );
Index: osm_sa_pkey_record.c
===================================================================
--- osm_sa_pkey_record.c	(revision 4260)
+++ osm_sa_pkey_record.c	(working copy)
@@ -344,9 +344,10 @@ osm_pkey_rec_rcv_process(
   ib_net64_t                comp_mask;
   osm_physp_t*              p_req_physp;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_pkey_rec_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_rcvd_mad = osm_madw_get_sa_mad_ptr( p_madw );
Index: osm_lin_fwd_rcv.c
===================================================================
--- osm_lin_fwd_rcv.c	(revision 4257)
+++ osm_lin_fwd_rcv.c	(working copy)
@@ -75,9 +75,10 @@ void
 osm_lft_rcv_destroy(
   IN osm_lft_rcv_t* const p_rcv )
 {
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_lft_rcv_destroy );
 
-  CL_ASSERT( p_rcv );
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 
@@ -120,9 +121,10 @@ osm_lft_rcv_process(
   ib_net64_t node_guid;
   ib_api_status_t status;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_lft_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_sw_tbl = &p_rcv->p_subn->sw_guid_tbl;
Index: osm_sa_slvl_record.c
===================================================================
--- osm_sa_slvl_record.c	(revision 4261)
+++ osm_sa_slvl_record.c	(working copy)
@@ -324,9 +324,10 @@ osm_slvl_rec_rcv_process(
   ib_net64_t                  comp_mask;
   osm_physp_t*                p_req_physp;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_slvl_rec_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_rcvd_mad = osm_madw_get_sa_mad_ptr( p_madw );
Index: osm_sminfo_rcv.c
===================================================================
--- osm_sminfo_rcv.c	(revision 4257)
+++ osm_sminfo_rcv.c	(working copy)
@@ -80,9 +80,10 @@ void
 osm_sminfo_rcv_destroy(
   IN osm_sminfo_rcv_t* const p_rcv )
 {
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_sminfo_rcv_destroy );
 
-  CL_ASSERT( p_rcv );
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 
Index: osm_node_info_rcv.c
===================================================================
--- osm_node_info_rcv.c	(revision 4257)
+++ osm_node_info_rcv.c	(working copy)
@@ -287,8 +287,6 @@ __osm_ni_rcv_process_new_node(
   p_ni = (ib_node_info_t*)ib_smp_get_payload_ptr( p_smp );
   port_num = ib_node_info_get_local_port_num( p_ni );
 
-  CL_ASSERT( p_node );
-
   /*
     Request PortInfo & NodeDescription attributes for the port
     that responded to the NodeInfo attribute.
@@ -354,7 +352,6 @@ __osm_ni_rcv_get_node_desc(
   p_ni = (ib_node_info_t*)ib_smp_get_payload_ptr( p_smp );
   port_num = ib_node_info_get_local_port_num( p_ni );
 
-
   /*
     Request PortInfo & NodeDescription attributes for the port
     that responded to the NodeInfo attribute.
@@ -968,9 +965,10 @@ void
 osm_ni_rcv_destroy(
   IN osm_ni_rcv_t* const p_rcv )
 {
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_ni_rcv_destroy );
 
-  CL_ASSERT( p_rcv );
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 
Index: osm_mcast_mgr.c
===================================================================
--- osm_mcast_mgr.c	(revision 4257)
+++ osm_mcast_mgr.c	(working copy)
@@ -394,9 +394,10 @@ void
 osm_mcast_mgr_destroy(
   IN osm_mcast_mgr_t* const p_mgr )
 {
+  CL_ASSERT( p_mgr );
+
   OSM_LOG_ENTER( p_mgr->p_log, osm_mcast_mgr_destroy );
 
-  CL_ASSERT( p_mgr );
   OSM_LOG_EXIT( p_mgr->p_log );
 }
 
@@ -448,9 +449,10 @@ __osm_mcast_mgr_set_tbl(
   ib_net16_t               block[IB_MCAST_BLOCK_SIZE];
   osm_signal_t          signal = OSM_SIGNAL_DONE;
 
+  CL_ASSERT( p_mgr );
+
   OSM_LOG_ENTER( p_mgr->p_log, __osm_mcast_mgr_set_tbl );
 
-  CL_ASSERT( p_mgr );
   CL_ASSERT( p_sw );
 
   p_node = osm_switch_get_node_ptr( p_sw );
Index: osm_sa_sminfo_record.c
===================================================================
--- osm_sa_sminfo_record.c	(revision 4261)
+++ osm_sa_sminfo_record.c	(working copy)
@@ -89,9 +89,10 @@ void
 osm_smir_rcv_destroy(
   IN osm_smir_rcv_t* const p_rcv )
 {
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_smir_rcv_destroy );
 
-  CL_ASSERT( p_rcv );
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 
@@ -141,9 +142,10 @@ osm_smir_rcv_process(
   ib_net64_t                  local_guid;
   osm_port_t*                 local_port;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_smir_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_sa_mad = osm_madw_get_sa_mad_ptr( p_madw );
Index: osm_trap_rcv.c
===================================================================
--- osm_trap_rcv.c	(revision 4257)
+++ osm_trap_rcv.c	(working copy)
@@ -189,11 +189,12 @@ void
 osm_trap_rcv_destroy(
   IN osm_trap_rcv_t* const p_rcv )
 {
-  OSM_LOG_ENTER( p_rcv->p_log, osm_trap_rcv_destroy );
-
   CL_ASSERT( p_rcv );
 
+  OSM_LOG_ENTER( p_rcv->p_log, osm_trap_rcv_destroy );
+
   cl_event_wheel_destroy( &p_rcv->trap_aging_tracker );
+
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 
Index: osm_ucast_mgr.c
===================================================================
--- osm_ucast_mgr.c	(revision 4257)
+++ osm_ucast_mgr.c	(working copy)
@@ -90,9 +90,10 @@ void
 osm_ucast_mgr_destroy(
   IN osm_ucast_mgr_t* const p_mgr )
 {
+  CL_ASSERT( p_mgr );
+
   OSM_LOG_ENTER( p_mgr->p_log, osm_ucast_mgr_destroy );
 
-  CL_ASSERT( p_mgr );
   OSM_LOG_EXIT( p_mgr->p_log );
 }
 
@@ -784,9 +785,10 @@ __osm_ucast_mgr_set_table(
   uint32_t block_id_ho = 0;
   uint8_t block[IB_SMP_DATA_SIZE];
 
+  CL_ASSERT( p_mgr );
+
   OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_set_table );
 
-  CL_ASSERT( p_mgr );
   CL_ASSERT( p_sw );
 
   p_node = osm_switch_get_node_ptr( p_sw );
Index: osm_sa_node_record.c
===================================================================
--- osm_sa_node_record.c	(revision 4260)
+++ osm_sa_node_record.c	(working copy)
@@ -434,9 +434,10 @@ osm_nr_rcv_process(
   ib_api_status_t          status;
   osm_physp_t*             p_req_physp;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_nr_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_rcvd_mad = osm_madw_get_sa_mad_ptr( p_madw );
Index: osm_sw_info_rcv.c
===================================================================
--- osm_sw_info_rcv.c	(revision 4257)
+++ osm_sw_info_rcv.c	(working copy)
@@ -363,9 +363,10 @@ __osm_si_rcv_process_new(
   ib_smp_t *p_smp;
   cl_qmap_t *p_sw_guid_tbl;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, __osm_si_rcv_process_new );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_sw_guid_tbl = &p_rcv->p_subn->sw_guid_tbl;
@@ -581,9 +582,10 @@ void
 osm_si_rcv_destroy(
   IN osm_si_rcv_t* const p_rcv )
 {
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_si_rcv_destroy );
 
-  CL_ASSERT( p_rcv );
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 
@@ -629,9 +631,10 @@ osm_si_rcv_process(
   ib_net64_t node_guid;
   osm_si_context_t *p_context;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_si_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_node_guid_tbl = &p_rcv->p_subn->node_guid_tbl;
Index: osm_mcast_fwd_rcv.c
===================================================================
--- osm_mcast_fwd_rcv.c	(revision 4257)
+++ osm_mcast_fwd_rcv.c	(working copy)
@@ -77,9 +77,10 @@ void
 osm_mft_rcv_destroy(
   IN osm_mft_rcv_t* const p_rcv )
 {
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_mft_rcv_destroy );
 
-  CL_ASSERT( p_rcv );
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 
@@ -123,9 +124,10 @@ osm_mft_rcv_process(
   ib_net64_t node_guid;
   ib_api_status_t status;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_mft_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_sw_tbl = &p_rcv->p_subn->sw_guid_tbl;
Index: osm_slvl_map_rcv.c
===================================================================
--- osm_slvl_map_rcv.c	(revision 4257)
+++ osm_slvl_map_rcv.c	(working copy)
@@ -83,9 +83,10 @@ void
 osm_slvl_rcv_destroy(
   IN osm_slvl_rcv_t* const p_rcv )
 {
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_slvl_rcv_destroy );
 
-  CL_ASSERT( p_rcv );
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 
@@ -135,9 +136,10 @@ osm_slvl_rcv_process(
   ib_net64_t node_guid;
   uint8_t out_port_num, in_port_num;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_slvl_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_smp = osm_madw_get_smp_ptr( p_madw );
Index: osm_node_desc_rcv.c
===================================================================
--- osm_node_desc_rcv.c	(revision 4257)
+++ osm_node_desc_rcv.c	(working copy)
@@ -109,9 +109,10 @@ void
 osm_nd_rcv_destroy(
   IN osm_nd_rcv_t* const p_rcv )
 {
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_nd_rcv_destroy );
 
-  CL_ASSERT( p_rcv );
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 
@@ -151,9 +152,10 @@ osm_nd_rcv_process(
   osm_node_t *p_node;
   ib_net64_t node_guid;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_nd_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_guid_tbl = &p_rcv->p_subn->node_guid_tbl;
Index: osm_sa_mcmember_record.c
===================================================================
--- osm_sa_mcmember_record.c	(revision 4259)
+++ osm_sa_mcmember_record.c	(working copy)
@@ -109,10 +109,12 @@ void
 osm_mcmr_rcv_destroy(
   IN osm_mcmr_recv_t* const p_rcv )
 {
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_mcmr_rcv_destroy );
 
-  CL_ASSERT( p_rcv );
   cl_qlock_pool_destroy( &p_rcv->pool );
+
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 
@@ -1965,9 +1967,10 @@ osm_mcmr_query_mgrp(IN osm_mcmr_recv_t* 
   osm_physp_t*             p_req_physp;
   boolean_t                trusted_req = TRUE;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_mcmr_query_mgrp );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_rcvd_mad = osm_madw_get_sa_mad_ptr( p_madw );
@@ -2170,9 +2173,10 @@ osm_mcmr_rcv_process(
   ib_member_rec_t *p_recvd_mcmember_rec;
   boolean_t valid;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_mcmr_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_sa_mad = osm_madw_get_sa_mad_ptr( p_madw );
Index: osm_drop_mgr.c
===================================================================
--- osm_drop_mgr.c	(revision 4257)
+++ osm_drop_mgr.c	(working copy)
@@ -81,9 +81,10 @@ void
 osm_drop_mgr_destroy(
   IN osm_drop_mgr_t* const p_mgr )
 {
+  CL_ASSERT( p_mgr );
+
   OSM_LOG_ENTER( p_mgr->p_log, osm_drop_mgr_destroy );
 
-  CL_ASSERT( p_mgr );
   OSM_LOG_EXIT( p_mgr->p_log );
 }
 
@@ -596,10 +597,10 @@ osm_drop_mgr_process(
   uint8_t      port_num;
   osm_physp_t *p_physp;
 
-  OSM_LOG_ENTER( p_mgr->p_log, osm_drop_mgr_process );
-
   CL_ASSERT( p_mgr );
 
+  OSM_LOG_ENTER( p_mgr->p_log, osm_drop_mgr_process );
+
   p_node_guid_tbl = &p_mgr->p_subn->node_guid_tbl;
   p_port_guid_tbl = &p_mgr->p_subn->port_guid_tbl;
   p_lsweep_ports = &p_mgr->p_subn->light_sweep_physp_list;
Index: osm_lid_mgr.c
===================================================================
--- osm_lid_mgr.c	(revision 4257)
+++ osm_lid_mgr.c	(working copy)
@@ -1312,10 +1312,10 @@ osm_lid_mgr_process_subnet(
   osm_physp_t    *p_physp;
   int             lid_changed;
 
-  OSM_LOG_ENTER( p_mgr->p_log, osm_lid_mgr_process_subnet );
-
   CL_ASSERT( p_mgr );
 
+  OSM_LOG_ENTER( p_mgr->p_log, osm_lid_mgr_process_subnet );
+
   CL_PLOCK_EXCL_ACQUIRE( p_mgr->p_lock );
 
   CL_ASSERT( p_mgr->p_subn->sm_port_guid );
Index: osm_vl_arb_rcv.c
===================================================================
--- osm_vl_arb_rcv.c	(revision 4257)
+++ osm_vl_arb_rcv.c	(working copy)
@@ -83,9 +83,10 @@ void
 osm_vla_rcv_destroy(
   IN osm_vla_rcv_t* const p_rcv )
 {
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_vla_rcv_destroy );
 
-  CL_ASSERT( p_rcv );
   OSM_LOG_EXIT( p_rcv->p_log );
 }
 
@@ -135,9 +136,10 @@ osm_vla_rcv_process(
   ib_net64_t node_guid;
   uint8_t port_num, block_num;
 
+  CL_ASSERT( p_rcv );
+
   OSM_LOG_ENTER( p_rcv->p_log, osm_vla_rcv_process );
 
-  CL_ASSERT( p_rcv );
   CL_ASSERT( p_madw );
 
   p_smp = osm_madw_get_smp_ptr( p_madw );






More information about the general mailing list