[ofa-general] [PATCH TRIVIAL] opensm: don't alloc lmc related structures when lmc = 0

Sasha Khapyorsky sashak at voltaire.com
Sun Mar 4 09:24:45 PST 2007


Don't allocate memory for lmc optimizations buffers when lmc = 0.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 osm/opensm/osm_ucast_mgr.c |   38 ++++++++++++++++++++------------------
 1 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/osm/opensm/osm_ucast_mgr.c b/osm/opensm/osm_ucast_mgr.c
index 47c7ef7..d6af997 100644
--- a/osm/opensm/osm_ucast_mgr.c
+++ b/osm/opensm/osm_ucast_mgr.c
@@ -709,27 +709,29 @@ __osm_ucast_mgr_process_port(
 
   OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_process_port );
 
-  remote_sys_guids = malloc( 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. Insufficient memory\n");
-    goto Exit;
-  }
+  if (lids_per_port > 1) {
+    remote_sys_guids = malloc( 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. Insufficient memory\n");
+      goto Exit;
+    }
 
-  memset( remote_sys_guids, 0, sizeof(uint64_t) * lids_per_port );
+    memset( remote_sys_guids, 0, sizeof(uint64_t) * lids_per_port );
 
-  remote_node_guids = malloc( 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. Insufficient memory\n");
-    goto Exit;
-  }
+    remote_node_guids = malloc( 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. Insufficient memory\n");
+      goto Exit;
+    }
 
-  memset( remote_node_guids, 0, sizeof(uint64_t) * lids_per_port );
+    memset( remote_node_guids, 0, sizeof(uint64_t) * lids_per_port );
+  }
 
   osm_port_get_lid_range_ho( p_port, &min_lid_ho, &max_lid_ho );
 
-- 
1.5.0.1.26.gf5a92




More information about the general mailing list