[openib-general] [PATCH] opensm: remove obsolete p_report_buf

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Mon Oct 23 06:51:40 PDT 2006


Sasha Khapyorsky wrote:
> On 09:02 Mon 23 Oct     , Yevgeny Kliteynik wrote:
>> Hi Sasha.
>>
>> The removal of the sm->p_report_buf is a good idea. 
>> However, I do have one comment:
>> In several cases this buffer was printed using the osm_log_raw() 
>> function, and you replaced this with a plain fprintf(stdout,...).
>> Right now the osm_log_raw function just prints to stdout too, but 
>> this doesn't always have to be the case. Besides, osm_log_raw 
>> provides verbosity level checking, which is lost when you replace 
>> it with printf.
> 
> Both functions calls were and still be conditonalized by verbosity
> level, so it is not lost.

Right, there is a check in the beginning of the function, mea culpa.
Anyway, this wasn't the main point. I grep'ed the osm code, and the 
only cases where there is an explicit printing to stdout is when log 
is not initialized yet, or in console mode, and I think that this is 
a better way to manage logging (even though printing directly to stdout
is more efficient).

-- Yevgeny

> 
> Sasha
> 
>> --Yevgeny
>>
>> Sasha Khapyorsky wrote:
>>> This removes obsolete now shared sm->p_report_buf buffer and cleans
>>> up related code.
>>>
>>> Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
>>> ---
>>>  osm/include/opensm/osm_base.h      |    5 --
>>>  osm/include/opensm/osm_sm.h        |    2 -
>>>  osm/include/opensm/osm_state_mgr.h |    8 ---
>>>  osm/include/opensm/osm_ucast_mgr.h |    5 --
>>>  osm/opensm/osm_mcast_mgr.c         |   11 ++--
>>>  osm/opensm/osm_sm.c                |   15 +-----
>>>  osm/opensm/osm_state_mgr.c         |  104 ++++++++++-------------------------
>>>  osm/opensm/osm_ucast_mgr.c         |   70 +++++++-----------------
>>>  8 files changed, 57 insertions(+), 163 deletions(-)
>>>
>>> diff --git a/osm/include/opensm/osm_base.h b/osm/include/opensm/osm_base.h
>>> index 57dd4fd..20e2cc3 100644
>>> --- a/osm/include/opensm/osm_base.h
>>> +++ b/osm/include/opensm/osm_base.h
>>> @@ -714,11 +714,6 @@ typedef enum _osm_state_mgr_mode
>>>  *
>>>  **********/
>>>  
>>> -#define OSM_REPORT_BUF_SIZE				0x10000
>>> -#define OSM_REPORT_LINE_SIZE			0x256
>>> -#define OSM_REPORT_BUF_THRESHOLD (OSM_REPORT_BUF_SIZE / OSM_REPORT_LINE_SIZE)
>>> -
>>> -
>>>  /****d* OpenSM: Base/osm_sm_signal_t
>>>  * NAME
>>>  *	osm_sm_signal_t
>>> diff --git a/osm/include/opensm/osm_sm.h b/osm/include/opensm/osm_sm.h
>>> index bc812f3..05b87ac 100644
>>> --- a/osm/include/opensm/osm_sm.h
>>> +++ b/osm/include/opensm/osm_sm.h
>>> @@ -178,8 +178,6 @@ typedef struct _osm_sm
>>>    osm_vla_rcv_ctrl_t       vla_rcv_ctrl;
>>>    osm_pkey_rcv_t           pkey_rcv;
>>>    osm_pkey_rcv_ctrl_t      pkey_rcv_ctrl;
>>> -  char*                    p_report_buf;
>>> -
>>>  } osm_sm_t;
>>>  /*
>>>  * FIELDS
>>> diff --git a/osm/include/opensm/osm_state_mgr.h b/osm/include/opensm/osm_state_mgr.h
>>> index ad4afa0..7aaab58 100644
>>> --- a/osm/include/opensm/osm_state_mgr.h
>>> +++ b/osm/include/opensm/osm_state_mgr.h
>>> @@ -121,7 +121,6 @@ typedef struct _osm_state_mgr
>>>    cl_qlist_t					idle_time_list;
>>>    cl_plock_t					*p_lock;
>>>    cl_event_t					*p_subnet_up_event;
>>> -  char						   *p_report_buf;
>>>    osm_sm_state_t				state;
>>>    osm_state_mgr_mode_t     state_step_mode;
>>>    osm_signal_t             next_stage_signal;
>>> @@ -170,9 +169,6 @@ typedef struct _osm_state_mgr
>>>  *	p_subnet_up_event
>>>  *		Pointer to the event to set if/when the subnet comes up.
>>>  *
>>> -*	p_report_buf
>>> -*		Pointer to the large log buffer used for user reports.
>>> -*
>>>  *	state
>>>  *		State of the SM.
>>>  *
>>> @@ -380,7 +376,6 @@ osm_state_mgr_init(
>>>  	IN const osm_sm_mad_ctrl_t* const p_mad_ctrl,
>>>  	IN cl_plock_t*				const p_lock,
>>>  	IN cl_event_t*				const p_subnet_up_event,
>>> -	IN char*					const p_report_buf,
>>>  	IN osm_log_t*				const p_log );
>>>  /*
>>>  * PARAMETERS
>>> @@ -420,9 +415,6 @@ osm_state_mgr_init(
>>>  *	p_subnet_up_event
>>>  *		[in] Pointer to the event to set if/when the subnet comes up.
>>>  *
>>> -*	p_report_buf
>>> -*		[in] Pointer to the large log buffer used for user reports.
>>> -*
>>>  *	p_log
>>>  *		[in] Pointer to the log object.
>>>  *
>>> diff --git a/osm/include/opensm/osm_ucast_mgr.h b/osm/include/opensm/osm_ucast_mgr.h
>>> index 0fbfc66..1c10abb 100644
>>> --- a/osm/include/opensm/osm_ucast_mgr.h
>>> +++ b/osm/include/opensm/osm_ucast_mgr.h
>>> @@ -105,7 +105,6 @@ typedef struct _osm_ucast_mgr
>>>  	osm_req_t					*p_req;
>>>  	osm_log_t					*p_log;
>>>  	cl_plock_t					*p_lock;
>>> -	char						*p_report_buf;
>>>  } osm_ucast_mgr_t;
>>>  /*
>>>  * FIELDS
>>> @@ -204,7 +203,6 @@ osm_ucast_mgr_init(
>>>  	IN osm_ucast_mgr_t* const p_mgr,
>>>  	IN osm_req_t* const p_req,
>>>  	IN osm_subn_t* const p_subn,
>>> -	IN char* const p_report_buf,
>>>  	IN osm_log_t* const p_log,
>>>  	IN cl_plock_t* const p_lock );
>>>  /*
>>> @@ -218,9 +216,6 @@ osm_ucast_mgr_init(
>>>  *	p_subn
>>>  *		[in] Pointer to the Subnet object for this subnet.
>>>  *
>>> -*	p_report_buf
>>> -*		[in] Pointer to the large log buffer used for user reporting.
>>> -*
>>>  *	p_log
>>>  *		[in] Pointer to the log object.
>>>  *
>>> diff --git a/osm/opensm/osm_mcast_mgr.c b/osm/opensm/osm_mcast_mgr.c
>>> index 5a01578..82ef7c3 100644
>>> --- a/osm/opensm/osm_mcast_mgr.c
>>> +++ b/osm/opensm/osm_mcast_mgr.c
>>> @@ -1382,14 +1382,13 @@ static void
>>>  mcast_mgr_dump_sw_routes(
>>>    IN const osm_mcast_mgr_t*   const p_mgr,
>>>    IN const osm_switch_t*      const p_sw,
>>> -  IN FILE *p_mcfdbFile )
>>> +  IN FILE *file )
>>>  {
>>>    osm_mcast_tbl_t*      p_tbl;
>>>    int16_t               mlid_ho = 0;
>>>    int16_t               mlid_start_ho;
>>>    uint8_t               position = 0;
>>>    int16_t               block_num = 0;
>>> -  char                  line[OSM_REPORT_LINE_SIZE];
>>>    boolean_t             print_lid;
>>>    const osm_node_t*     p_node;
>>>    uint16_t              i, j;
>>> @@ -1404,7 +1403,7 @@ mcast_mgr_dump_sw_routes(
>>>  
>>>    p_tbl = osm_switch_get_mcast_tbl_ptr( p_sw );
>>>  
>>> -  fprintf( p_mcfdbFile, "\nSwitch 0x%016" PRIx64 "\n"
>>> +  fprintf( file, "\nSwitch 0x%016" PRIx64 "\n"
>>>             "LID    : Out Port(s)\n",
>>>             cl_ntoh64( osm_node_get_node_guid( p_node ) ) );  
>>>    while ( block_num <= p_tbl->max_block_in_use )
>>> @@ -1415,7 +1414,7 @@ mcast_mgr_dump_sw_routes(
>>>        mlid_ho = mlid_start_ho + i;
>>>        position = 0;
>>>        print_lid = FALSE;
>>> -      sprintf( line, "0x%04X :", mlid_ho + IB_LID_MCAST_START_HO );
>>> +      fprintf( file, "0x%04X :", mlid_ho + IB_LID_MCAST_START_HO );
>>>        while ( position <= p_tbl->max_position )
>>>        {
>>>          mask_entry = cl_ntoh16((*p_tbl->p_mask_tbl)[mlid_ho][position]);
>>> @@ -1428,13 +1427,13 @@ mcast_mgr_dump_sw_routes(
>>>          for (j = 0 ; j < 16 ; j++)
>>>          {
>>>            if ( (1 << j) & mask_entry )
>>> -            sprintf( line, "%s 0x%03X ", line, j+(position*16) );
>>> +            fprintf( file, " 0x%03X ", j+(position*16) );
>>>          }
>>>          position++;
>>>        }
>>>        if (print_lid)
>>>        {
>>> -        fprintf( p_mcfdbFile, "%s\n", line );
>>> +        fprintf( file, "\n" );
>>>        }
>>>      }
>>>      block_num++;
>>> diff --git a/osm/opensm/osm_sm.c b/osm/opensm/osm_sm.c
>>> index fef3cac..fb4f759 100644
>>> --- a/osm/opensm/osm_sm.c
>>> +++ b/osm/opensm/osm_sm.c
>>> @@ -256,9 +256,6 @@ osm_sm_destroy(
>>>     cl_event_destroy( &p_sm->signal );
>>>     cl_event_destroy( &p_sm->subnet_up_event );
>>>  
>>> -   if( p_sm->p_report_buf != NULL )
>>> -      free( p_sm->p_report_buf );
>>> -
>>>     osm_log( p_sm->p_log, OSM_LOG_SYS, "Exiting SM\n" ); /* Format Waived */
>>>     OSM_LOG_EXIT( p_sm->p_log );
>>>  }
>>> @@ -291,15 +288,6 @@ osm_sm_init(
>>>     p_sm->p_disp = p_disp;
>>>     p_sm->p_lock = p_lock;
>>>  
>>> -   p_sm->p_report_buf = malloc( OSM_REPORT_BUF_SIZE );
>>> -   if( p_sm->p_report_buf == NULL )
>>> -   {
>>> -      osm_log( p_sm->p_log, OSM_LOG_ERROR,
>>> -               "osm_sm_init: ERR 2E09: "
>>> -               "Can't allocate report buffer\n" );
>>> -      status = IB_INSUFFICIENT_MEMORY;
>>> -      goto Exit;
>>> -   }
>>>     status = cl_event_init( &p_sm->signal, FALSE );
>>>     if( status != CL_SUCCESS )
>>>        goto Exit;
>>> @@ -385,7 +373,6 @@ osm_sm_init(
>>>     status = osm_ucast_mgr_init( &p_sm->ucast_mgr,
>>>                                  &p_sm->req,
>>>                                  p_sm->p_subn,
>>> -                                p_sm->p_report_buf,
>>>                                  p_sm->p_log, p_sm->p_lock );
>>>     if( status != IB_SUCCESS )
>>>        goto Exit;
>>> @@ -409,7 +396,7 @@ osm_sm_init(
>>>                                  &p_sm->mad_ctrl,
>>>                                  p_sm->p_lock,
>>>                                  &p_sm->subnet_up_event,
>>> -                                p_sm->p_report_buf, p_sm->p_log );
>>> +                                p_sm->p_log );
>>>     if( status != IB_SUCCESS )
>>>        goto Exit;
>>>  
>>> diff --git a/osm/opensm/osm_state_mgr.c b/osm/opensm/osm_state_mgr.c
>>> index d43e9fc..9c159df 100644
>>> --- a/osm/opensm/osm_state_mgr.c
>>> +++ b/osm/opensm/osm_state_mgr.c
>>> @@ -118,7 +118,6 @@ osm_state_mgr_init(
>>>     IN const osm_sm_mad_ctrl_t * const p_mad_ctrl,
>>>     IN cl_plock_t * const p_lock,
>>>     IN cl_event_t * const p_subnet_up_event,
>>> -   IN char *const p_report_buf,
>>>     IN osm_log_t * const p_log )
>>>  {
>>>     cl_status_t status;
>>> @@ -136,7 +135,6 @@ osm_state_mgr_init(
>>>     CL_ASSERT( p_sm_state_mgr );
>>>     CL_ASSERT( p_mad_ctrl );
>>>     CL_ASSERT( p_lock );
>>> -   CL_ASSERT( p_report_buf );
>>>  
>>>     osm_state_mgr_construct( p_mgr );
>>>  
>>> @@ -154,7 +152,6 @@ osm_state_mgr_init(
>>>     p_mgr->state = OSM_SM_STATE_IDLE;
>>>     p_mgr->p_lock = p_lock;
>>>     p_mgr->p_subnet_up_event = p_subnet_up_event;
>>> -   p_mgr->p_report_buf = p_report_buf;
>>>     p_mgr->state_step_mode = OSM_STATE_STEP_CONTINUOUS;
>>>     p_mgr->next_stage_signal = OSM_SIGNAL_NONE;
>>>  
>>> @@ -1247,16 +1244,19 @@ __osm_state_mgr_report(
>>>     uint8_t port_num;
>>>     uint8_t start_port;
>>>     uint32_t num_ports;
>>> -   char line[OSM_REPORT_LINE_SIZE];
>>>     uint8_t node_type;
>>> -   uint32_t line_num = 0;
>>> +
>>> +   if( !osm_log_is_active( p_mgr->p_log, OSM_LOG_VERBOSE ) )
>>> +      return;
>>>  
>>>     OSM_LOG_ENTER( p_mgr->p_log, __osm_state_mgr_report );
>>>  
>>> -   if( !osm_log_is_active( p_mgr->p_log, OSM_LOG_VERBOSE ) )
>>> -   {
>>> -      goto Exit;
>>> -   }
>>> +   fprintf( stdout,
>>> +            "\n==================================================="
>>> +            "===================================================="
>>> +            "\nVendor      : Ty "
>>> +            ": #  : Sta : LID  : LMC : MTU  : LWA : LSA : Port GUID    "
>>> +            "    : Neighbor Port (Port #)\n" );
>>>  
>>>     p_tbl = &p_mgr->p_subn->port_guid_tbl;
>>>  
>>> @@ -1286,91 +1286,56 @@ __osm_state_mgr_report(
>>>        num_ports = osm_port_get_num_physp( p_port );
>>>        for( port_num = start_port; port_num < num_ports; port_num++ )
>>>        {
>>> -         if( line_num == 0 )
>>> -         {
>>> -            strcpy( p_mgr->p_report_buf,
>>> -                    "\n==================================================="
>>> -                    "====================================================" );
>>> -            strcat( p_mgr->p_report_buf,
>>> -                    "\nVendor      : Ty "
>>> -                    ": #  : Sta : LID  : LMC : MTU  : LWA : LSA : Port GUID    "
>>> -                    "    : Neighbor Port (Port #)\n" );
>>> -            line_num++;
>>> -         }
>>> -
>>>           p_physp = osm_port_get_phys_ptr( p_port, port_num );
>>>           if( ( p_physp == NULL ) || ( !osm_physp_is_valid( p_physp ) ) )
>>>              continue;
>>>  
>>> -         sprintf( line, "%s : %s : %02X :",
>>> +         fprintf( stdout, "%s : %s : %02X :",
>>>                    osm_get_manufacturer_str( cl_ntoh64
>>>                                              ( osm_node_get_node_guid
>>>                                                ( p_node ) ) ),
>>>                    osm_get_node_type_str_fixed_width( node_type ), port_num );
>>>  
>>> -         strcat( p_mgr->p_report_buf, line );
>>> -
>>>           p_pi = osm_physp_get_port_info_ptr( p_physp );
>>>  
>>>           /*
>>>            * Port state is not defined for switch port 0
>>>            */
>>>           if( port_num == 0 )
>>> -            strcat( p_mgr->p_report_buf, "     :" );
>>> +            fprintf( stdout, "     :" );
>>>           else
>>> -         {
>>> -            sprintf( line, " %s :",
>>> +            fprintf( stdout, " %s :",
>>>                       osm_get_port_state_str_fixed_width
>>>                       ( ib_port_info_get_port_state( p_pi ) ) );
>>> -            strcat( p_mgr->p_report_buf, line );
>>> -         }
>>>  
>>>           /*
>>>            * LID values are only meaningful in select cases.
>>>            */
>>> -         if( ib_port_info_get_port_state( p_pi ) != IB_LINK_DOWN )
>>> -         {
>>> -            if( ( ( node_type == IB_NODE_TYPE_SWITCH ) && ( port_num == 0 ) )
>>> -                || ( node_type != IB_NODE_TYPE_SWITCH ) )
>>> -            {
>>> -               sprintf( line, " %04X :  %01X  :",
>>> -                        cl_ntoh16( p_pi->base_lid ),
>>> -                        ib_port_info_get_lmc( p_pi ) );
>>> -
>>> -               strcat( p_mgr->p_report_buf, line );
>>> -            }
>>> -            else
>>> -               strcat( p_mgr->p_report_buf, "      :     :" );
>>> -         }
>>> +         if( ib_port_info_get_port_state( p_pi ) != IB_LINK_DOWN
>>> +             && ( ( node_type == IB_NODE_TYPE_SWITCH && port_num == 0 )
>>> +                  || node_type != IB_NODE_TYPE_SWITCH ) )
>>> +            fprintf( stdout, " %04X :  %01X  :",
>>> +                     cl_ntoh16( p_pi->base_lid ),
>>> +                     ib_port_info_get_lmc( p_pi ) );
>>>           else
>>> -            strcat( p_mgr->p_report_buf, "      :     :" );
>>> +            fprintf( stdout, "      :     :" );
>>>  
>>>           if( port_num != 0 )
>>> -         {
>>> -            sprintf( line, " %s : %s : %s ",
>>> +            fprintf( stdout, " %s : %s : %s ",
>>>                       osm_get_mtu_str( ib_port_info_get_neighbor_mtu( p_pi ) ),
>>>                       osm_get_lwa_str( p_pi->link_width_active ),
>>>                       osm_get_lsa_str( ib_port_info_get_link_speed_active
>>>                                        ( p_pi ) ) );
>>> -         }
>>>           else
>>> -         {
>>> -            sprintf( line, " %s : %s : %s ", "    ", "   ", "   " );
>>> -         }
>>> -         strcat( p_mgr->p_report_buf, line );
>>> +            fprintf( stdout, "      :     :     " );
>>>  
>>>           if( osm_physp_get_port_guid( p_physp ) ==
>>>               p_mgr->p_subn->sm_port_guid )
>>> -         {
>>> -            sprintf( line, "* %016" PRIx64 " *",
>>> +            fprintf( stdout, "* %016" PRIx64 " *",
>>>                       cl_ntoh64( osm_physp_get_port_guid( p_physp ) ) );
>>> -         }
>>>           else
>>> -         {
>>> -            sprintf( line, ": %016" PRIx64 " :",
>>> +            fprintf( stdout, ": %016" PRIx64 " :",
>>>                       cl_ntoh64( osm_physp_get_port_guid( p_physp ) ) );
>>> -         }
>>> -         strcat( p_mgr->p_report_buf, line );
>>>  
>>>           if( port_num &&
>>>               ( ib_port_info_get_port_state( p_pi ) != IB_LINK_DOWN ) )
>>> @@ -1378,36 +1343,27 @@ __osm_state_mgr_report(
>>>              p_remote_physp = osm_physp_get_remote( p_physp );
>>>              if( p_remote_physp && osm_physp_is_valid( p_remote_physp ) )
>>>              {
>>> -               sprintf( line, " %016" PRIx64 " (%02X)",
>>> +               fprintf( stdout, " %016" PRIx64 " (%02X)",
>>>                          cl_ntoh64( osm_physp_get_port_guid
>>>                                     ( p_remote_physp ) ),
>>>                          osm_physp_get_port_num( p_remote_physp ) );
>>> -               strcat( p_mgr->p_report_buf, line );
>>>              }
>>>              else
>>> -               strcat( p_mgr->p_report_buf, " UNKNOWN" );
>>> +               fprintf( stdout, " UNKNOWN" );
>>>           }
>>>  
>>> -         strcat( p_mgr->p_report_buf, "\n" );
>>> -
>>> -         if( ++line_num >= OSM_REPORT_BUF_THRESHOLD )
>>> -         {
>>> -            osm_log_raw( p_mgr->p_log, OSM_LOG_VERBOSE, p_mgr->p_report_buf );
>>> -            line_num = 0;
>>> -         }
>>> +         fprintf( stdout, "\n" );
>>>        }
>>> -      strcat( p_mgr->p_report_buf,
>>> +
>>> +      fprintf( stdout,
>>>                "------------------------------------------------------"
>>>                "------------------------------------------------\n" );
>>>        p_port = ( osm_port_t * ) cl_qmap_next( &p_port->map_item );
>>>     }
>>>  
>>> -   CL_PLOCK_RELEASE( p_mgr->p_lock );
>>> -
>>> -   if( line_num != 0 )
>>> -      osm_log_raw( p_mgr->p_log, OSM_LOG_VERBOSE, p_mgr->p_report_buf );
>>> +   fflush(stdout);
>>>  
>>> - Exit:
>>> +   CL_PLOCK_RELEASE( p_mgr->p_lock );
>>>     OSM_LOG_EXIT( p_mgr->p_log );
>>>  }
>>>  
>>> diff --git a/osm/opensm/osm_ucast_mgr.c b/osm/opensm/osm_ucast_mgr.c
>>> index 39d6899..da9e9f2 100644
>>> --- a/osm/opensm/osm_ucast_mgr.c
>>> +++ b/osm/opensm/osm_ucast_mgr.c
>>> @@ -103,7 +103,6 @@ osm_ucast_mgr_init(
>>>    IN osm_ucast_mgr_t* const p_mgr,
>>>    IN osm_req_t* const p_req,
>>>    IN osm_subn_t* const p_subn,
>>> -  IN char* const p_report_buf,
>>>    IN osm_log_t* const p_log,
>>>    IN cl_plock_t* const p_lock )
>>>  {
>>> @@ -121,7 +120,6 @@ osm_ucast_mgr_init(
>>>    p_mgr->p_subn = p_subn;
>>>    p_mgr->p_lock = p_lock;
>>>    p_mgr->p_req = p_req;
>>> -  p_mgr->p_report_buf = p_report_buf;
>>>  
>>>    OSM_LOG_EXIT( p_mgr->p_log );
>>>    return( status );
>>> @@ -140,14 +138,13 @@ __osm_ucast_mgr_dump_path_distribution(
>>>    uint8_t num_ports;
>>>    uint32_t num_paths;
>>>    ib_net64_t remote_guid_ho;
>>> -  char line[OSM_REPORT_LINE_SIZE];
>>>  
>>>    OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_dump_path_distribution );
>>>  
>>>    p_node = osm_switch_get_node_ptr( p_sw );
>>>    num_ports = osm_switch_get_num_ports( p_sw );
>>>  
>>> -  sprintf( p_mgr->p_report_buf, "__osm_ucast_mgr_dump_path_distribution: "
>>> +  fprintf( stdout, "__osm_ucast_mgr_dump_path_distribution: "
>>>             "Switch 0x%" PRIx64 "\n"
>>>             "Port : Path Count Through Port",
>>>             cl_ntoh64( osm_node_get_node_guid( p_node ) ) );
>>> @@ -155,11 +152,10 @@ __osm_ucast_mgr_dump_path_distribution(
>>>    for( i = 0; i < num_ports; i++ )
>>>    {
>>>      num_paths = osm_switch_path_count_get( p_sw , i );
>>> -    sprintf( line, "\n %03u : %u", i, num_paths );
>>> -    strcat( p_mgr->p_report_buf, line );
>>> +    fprintf( stdout, "\n %03u : %u", i, num_paths );
>>>      if( i == 0 )
>>>      {
>>> -      strcat( p_mgr->p_report_buf, " (switch management port)" );
>>> +      fprintf( stdout, " (switch management port)" );
>>>        continue;
>>>      }
>>>  
>>> @@ -172,26 +168,23 @@ __osm_ucast_mgr_dump_path_distribution(
>>>      switch(  osm_node_get_remote_type( p_node, i ) )
>>>      {
>>>      case IB_NODE_TYPE_SWITCH:
>>> -      strcat( p_mgr->p_report_buf, " (link to switch" );
>>> +      fprintf( stdout, " (link to switch" );
>>>        break;
>>>      case IB_NODE_TYPE_ROUTER:
>>> -      strcat( p_mgr->p_report_buf, " (link to router" );
>>> +      fprintf( stdout, " (link to router" );
>>>        break;
>>>      case IB_NODE_TYPE_CA:
>>> -      strcat( p_mgr->p_report_buf, " (link to CA" );
>>> +      fprintf( stdout, " (link to CA" );
>>>        break;
>>>      default:
>>> -      strcat( p_mgr->p_report_buf, " (link to unknown node type" );
>>> +      fprintf( stdout, " (link to unknown node type" );
>>>        break;
>>>      }
>>>  
>>> -    sprintf( line, " 0x%" PRIx64 ")", remote_guid_ho );
>>> -    strcat( p_mgr->p_report_buf, line );
>>> +    fprintf( stdout, " 0x%" PRIx64 ")", remote_guid_ho );
>>>    }
>>>  
>>> -  strcat( p_mgr->p_report_buf, "\n" );
>>> -
>>> -  osm_log_raw( p_mgr->p_log, OSM_LOG_ROUTING, p_mgr->p_report_buf );
>>> +  fprintf( stdout, "\n" );
>>>  
>>>    OSM_LOG_EXIT( p_mgr->p_log );
>>>  }
>>> @@ -202,7 +195,7 @@ static void
>>>  __osm_ucast_mgr_dump_ucast_routes(
>>>    IN const osm_ucast_mgr_t*   const p_mgr,
>>>    IN const osm_switch_t*      const p_sw,
>>> -  IN FILE *p_fdbFile )
>>> +  IN FILE *file )
>>>  {
>>>    const osm_node_t*        p_node;
>>>    uint8_t                  port_num;
>>> @@ -211,8 +204,6 @@ __osm_ucast_mgr_dump_ucast_routes(
>>>    uint8_t                  best_port;
>>>    uint16_t                 max_lid_ho;
>>>    uint16_t                 lid_ho;
>>> -  char                     line[OSM_REPORT_LINE_SIZE];
>>> -  uint32_t                 line_num = 0;
>>>    boolean_t                ui_ucast_fdb_assign_func_defined;
>>>    
>>>    OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_dump_ucast_routes );
>>> @@ -221,16 +212,13 @@ __osm_ucast_mgr_dump_ucast_routes(
>>>  
>>>    max_lid_ho = osm_switch_get_max_lid_ho( p_sw );
>>>  
>>> +  fprintf( file, "__osm_ucast_mgr_dump_ucast_routes: "
>>> +           "Switch 0x%016" PRIx64 "\n"
>>> +           "LID    : Port : Hops : Optimal\n",
>>> +           cl_ntoh64( osm_node_get_node_guid( p_node ) ) );
>>>    for( lid_ho = 1; lid_ho <= max_lid_ho; lid_ho++ )
>>>    {
>>> -    if( line_num == 0 )
>>> -    {
>>> -      sprintf( p_mgr->p_report_buf, "__osm_ucast_mgr_dump_ucast_routes: "
>>> -               "Switch 0x%016" PRIx64 "\n"
>>> -               "LID    : Port : Hops : Optimal\n",
>>> -               cl_ntoh64( osm_node_get_node_guid( p_node ) ) );
>>> -      line_num++;
>>> -    }
>>> +    fprintf(file, "0x%04X : ", lid_ho);
>>>  
>>>      port_num = osm_switch_get_port_by_lid( p_sw, lid_ho );
>>>      if( port_num == OSM_NO_PATH )
>>> @@ -241,9 +229,7 @@ __osm_ucast_mgr_dump_ucast_routes(
>>>          will reassign and compress the LID range.  The
>>>          subnet should work fine either way.
>>>        */
>>> -      sprintf( line, "0x%04X : UNREACHABLE\n", lid_ho );
>>> -      strcat( p_mgr->p_report_buf, line );
>>> -      line_num++;
>>> +      fprintf( file, "UNREACHABLE\n" );
>>>        continue;
>>>      }
>>>      /*
>>> @@ -255,19 +241,15 @@ __osm_ucast_mgr_dump_ucast_routes(
>>>      num_hops = osm_switch_get_hop_count( p_sw, lid_ho, port_num );
>>>      if( num_hops == OSM_NO_PATH )
>>>      {
>>> -      sprintf( line, "0x%04X : UNREACHABLE\n", lid_ho );
>>> -      strcat( p_mgr->p_report_buf, line );
>>> -      line_num++;
>>> +      fprintf( file, "UNREACHABLE\n" );
>>>        continue;
>>>      }
>>>  
>>>      best_hops = osm_switch_get_least_hops( p_sw, lid_ho );
>>> -    sprintf( line, "0x%04X : %03u  : %02u   : ",
>>> -             lid_ho, port_num, num_hops );
>>> -    strcat( p_mgr->p_report_buf, line );
>>> +    fprintf( file, "%03u  : %02u   : ", port_num, num_hops );
>>>  
>>>      if( best_hops == num_hops )
>>> -      strcat( p_mgr->p_report_buf, "yes" );
>>> +      fprintf( file, "yes" );
>>>      else
>>>      {
>>>        if (p_mgr->p_subn->p_osm->routing_engine.ucast_fdb_assign)
>>> @@ -282,23 +264,13 @@ __osm_ucast_mgr_dump_ucast_routes(
>>>          p_sw, lid_ho, TRUE,
>>>          NULL, NULL, NULL, NULL, /* No LMC Optimization */
>>>          ui_ucast_fdb_assign_func_defined );
>>> -      sprintf( line, "No %u hop path possible via port %u!",
>>> +      fprintf( file, "No %u hop path possible via port %u!",
>>>                 best_hops, best_port );
>>> -      strcat( p_mgr->p_report_buf, line );
>>>      }
>>>  
>>> -    strcat( p_mgr->p_report_buf, "\n" );
>>> -
>>> -    if( ++line_num >= OSM_REPORT_BUF_THRESHOLD )
>>> -    {
>>> -      fprintf(p_fdbFile,"%s",p_mgr->p_report_buf );
>>> -      line_num = 0;
>>> -    }
>>> +    fprintf( file, "\n" );
>>>    }
>>>  
>>> -  if( line_num != 0 )
>>> -    fprintf(p_fdbFile,"%s\n",p_mgr->p_report_buf );
>>> -
>>>    OSM_LOG_EXIT( p_mgr->p_log );
>>>  }
>>>  
> 




More information about the general mailing list