@@ -73,6 +73,7 @@ OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t *
7373{
7474 char * default_tls = "rc_verbs,ud_verbs,rc_mlx5,dc_mlx5,ud_mlx5,cuda_ipc,rocm_ipc" ;
7575 char * default_devices = "mlx*" ;
76+ char * old_str = NULL ;
7677 int hook_index ;
7778 int verbose_index ;
7879 int progress_index ;
@@ -102,17 +103,9 @@ OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t *
102103 & opal_common_ucx .opal_mem_hooks );
103104
104105 if (NULL == opal_common_ucx .tls ) {
105- // Extra level of string indirection needed to make ompi_info
106- // happy since it will unload this library before the MCA base
107- // cleans up the MCA vars. This will cause the string to go
108- // out of scope unless we place the pointer to it on the heap.
109- opal_common_ucx .tls = (char * * ) malloc (sizeof (char * ));
110- * opal_common_ucx .tls = NULL ;
111- }
112-
113- if (NULL == * opal_common_ucx .tls ) {
114- * opal_common_ucx .tls = strdup (default_tls );
106+ opal_common_ucx .tls = strdup (default_tls );
115107 }
108+ old_str = opal_common_ucx .tls ;
116109
117110 tls_index = mca_base_var_register (
118111 "opal" , "opal_common" , "ucx" , "tls" ,
@@ -122,23 +115,21 @@ OPAL_DECLSPEC void opal_common_ucx_mca_var_register(const mca_base_component_t *
122115 "For example, in order to exclude on shared memory and TCP transports, "
123116 "please set to '^posix,sysv,self,tcp,cma,knem,xpmem'." ,
124117 MCA_BASE_VAR_TYPE_STRING , NULL , 0 , MCA_BASE_VAR_FLAG_SETTABLE | MCA_BASE_VAR_FLAG_DWG ,
125- OPAL_INFO_LVL_3 , MCA_BASE_VAR_SCOPE_LOCAL , opal_common_ucx .tls );
118+ OPAL_INFO_LVL_3 , MCA_BASE_VAR_SCOPE_LOCAL , & opal_common_ucx .tls );
119+ free (old_str );
126120
127121 if (NULL == opal_common_ucx .devices ) {
128- opal_common_ucx .devices = (char * * ) malloc (sizeof (char * ));
129- * opal_common_ucx .devices = NULL ;
130- }
131-
132- if (NULL == * opal_common_ucx .devices ) {
133- * opal_common_ucx .devices = strdup (default_devices );
122+ opal_common_ucx .devices = strdup (default_devices );
134123 }
124+ old_str = opal_common_ucx .tls ;
135125
136126 devices_index = mca_base_var_register (
137127 "opal" , "opal_common" , "ucx" , "devices" ,
138128 "List of device driver pattern names, which, if supported by UCX, will "
139129 "bump its priority above ob1. Special values: any (any available)" ,
140130 MCA_BASE_VAR_TYPE_STRING , NULL , 0 , MCA_BASE_VAR_FLAG_SETTABLE | MCA_BASE_VAR_FLAG_DWG ,
141- OPAL_INFO_LVL_3 , MCA_BASE_VAR_SCOPE_LOCAL , opal_common_ucx .devices );
131+ OPAL_INFO_LVL_3 , MCA_BASE_VAR_SCOPE_LOCAL , & opal_common_ucx .devices );
132+ free (old_str );
142133
143134 if (component ) {
144135 mca_base_var_register_synonym (verbose_index , component -> mca_project_name ,
@@ -270,12 +261,12 @@ OPAL_DECLSPEC opal_common_ucx_support_level_t opal_common_ucx_support_level(ucp_
270261 int ret ;
271262#endif
272263
273- if ((* opal_common_ucx .tls == NULL ) || (* opal_common_ucx .devices == NULL )) {
264+ if ((opal_common_ucx .tls == NULL ) || (opal_common_ucx .devices == NULL )) {
274265 opal_common_ucx_mca_var_register (NULL );
275266 }
276267
277- is_any_tl = !strcmp (* opal_common_ucx .tls , "any" );
278- is_any_device = !strcmp (* opal_common_ucx .devices , "any" );
268+ is_any_tl = !strcmp (opal_common_ucx .tls , "any" );
269+ is_any_device = !strcmp (opal_common_ucx .devices , "any" );
279270
280271 /* Check for special value "any" */
281272 if (is_any_tl && is_any_device ) {
@@ -286,19 +277,19 @@ OPAL_DECLSPEC opal_common_ucx_support_level_t opal_common_ucx_support_level(ucp_
286277
287278#if HAVE_DECL_OPEN_MEMSTREAM
288279 /* Split transports list */
289- negate = ('^' == (* opal_common_ucx .tls )[0 ]);
290- tl_list = opal_argv_split (* opal_common_ucx .tls + (negate ? 1 : 0 ), ',' );
280+ negate = ('^' == (opal_common_ucx .tls )[0 ]);
281+ tl_list = opal_argv_split (opal_common_ucx .tls + (negate ? 1 : 0 ), ',' );
291282 if (tl_list == NULL ) {
292283 MCA_COMMON_UCX_VERBOSE (1 , "failed to split tl list '%s', ucx is disabled" ,
293- * opal_common_ucx .tls );
284+ opal_common_ucx .tls );
294285 goto out ;
295286 }
296287
297288 /* Split devices list */
298- device_list = opal_argv_split (* opal_common_ucx .devices , ',' );
289+ device_list = opal_argv_split (opal_common_ucx .devices , ',' );
299290 if (device_list == NULL ) {
300291 MCA_COMMON_UCX_VERBOSE (1 , "failed to split devices list '%s', ucx is disabled" ,
301- * opal_common_ucx .devices );
292+ opal_common_ucx .devices );
302293 goto out_free_tl_list ;
303294 }
304295
0 commit comments