[openib-general] [PATCH] Opensm - osm_ucast_mgr.c - use dynamic alloc

Yael Kalka yael at mellanox.co.il
Mon Feb 6 02:05:45 PST 2006


Hi Hal,

The original static allocation doesn't compile in Windows. 
The attached patch replaces it with dynamic allocation.

Thanks,
Yael

Signed-off-by:  Yael Kalka <yael at mellanox.co.il>

Index: opensm/osm_ucast_mgr.c
===================================================================
--- opensm/osm_ucast_mgr.c      (revision 5307)
+++ opensm/osm_ucast_mgr.c      (working copy)
@@ -633,13 +633,31 @@ __osm_ucast_mgr_process_port(
     in providing better routing in LMC > 0 situations
   */
   uint16_t lids_per_port = 1 << p_mgr->p_subn->opt.lmc;
-  uint64_t remote_sys_guids[lids_per_port];
-  uint64_t remote_node_guids[lids_per_port];
+  uint64_t* remote_sys_guids = NULL;
+  uint64_t* remote_node_guids = NULL;
   uint16_t num_used_sys = 0;
   uint16_t num_used_nodes = 0;
 
   OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_process_port );
 
+  remote_sys_guids = cl_zalloc( sizeof(uint64_t) * lids_per_port );
+  if( remote_sys_guids == NULL )
+  {
+    osm_log( p_mgr->p_log, OSM_LOG_ERROR,
+             "__osm_ucast_mgr_process_port: ERR 3A09: "
+             "Cannot allocate array. Memory insufficient.\n");
+    goto Exit;
+  }
+
+  remote_node_guids = cl_zalloc( sizeof(uint64_t) * lids_per_port );
+  if( remote_node_guids == NULL )
+  {
+    osm_log( p_mgr->p_log, OSM_LOG_ERROR,
+             "__osm_ucast_mgr_process_port: ERR 3A0A: "
+             "Cannot allocate array. Memory insufficient.\n");
+    goto Exit;
+  }
+
   osm_port_get_lid_range_ho( p_port, &min_lid_ho, &max_lid_ho );
 
   /* If the lids are zero - then there was some problem with the initialization.
@@ -767,6 +785,8 @@ __osm_ucast_mgr_process_port(
     osm_switch_set_path( p_sw, lid_ho, port, is_ignored_by_port_prof);
   }
  Exit:
+  if (remote_sys_guids) cl_free(remote_sys_guids);
+  if (remote_node_guids) cl_free(remote_node_guids);
   OSM_LOG_EXIT( p_mgr->p_log );
 }





More information about the general mailing list