1
1
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2
2
/*
3
- * Copyright (c) 2018-2020 The University of Tennessee and The University
3
+ * Copyright (c) 2018-2022 The University of Tennessee and The University
4
4
* of Tennessee Research Foundation. All rights
5
5
* reserved.
6
6
* Copyright (c) 2022 IBM Corporation. All rights reserved
@@ -65,6 +65,7 @@ mca_coll_han_init_dynamic_rules(void)
65
65
int algorithm_id ;
66
66
char * coll_name = NULL ;
67
67
char * algorithm_name = NULL ;
68
+ char * target_comp_name = NULL ;
68
69
collective_rule_t * coll_rules ;
69
70
70
71
/* Topo information */
@@ -135,6 +136,7 @@ mca_coll_han_init_dynamic_rules(void)
135
136
mca_coll_han_component .dynamic_rules .nb_collectives = i + 1 ;
136
137
137
138
/* Get the collective identifier */
139
+ free (coll_name );
138
140
if ( getnext_string (fptr , & coll_name ) < 0 ) {
139
141
opal_output_verbose (5 , mca_coll_han_component .han_output ,
140
142
"coll:han:mca_coll_han_init_dynamic_rules invalid collective at line %d."
@@ -155,9 +157,7 @@ mca_coll_han_init_dynamic_rules(void)
155
157
coll_name , fileline , ALLGATHER , COLLCOUNT );
156
158
goto file_reading_error ;
157
159
}
158
- if ( NULL != coll_name ) {
159
- free (coll_name );
160
- }
160
+ free (coll_name );
161
161
coll_name = strdup (mca_coll_base_colltype_to_str (coll_id ));
162
162
}
163
163
@@ -321,7 +321,6 @@ mca_coll_han_init_dynamic_rules(void)
321
321
322
322
/* Iterate on message size rules */
323
323
for ( l = 0 ; l < nb_msg_size ; l ++ ) {
324
- char * target_comp_name = NULL ;
325
324
conf_rules [k ].nb_msg_size = l + 1 ;
326
325
327
326
/* Get the message size */
@@ -338,6 +337,7 @@ mca_coll_han_init_dynamic_rules(void)
338
337
}
339
338
340
339
/* Get the component identifier for this message size rule */
340
+ free (target_comp_name );
341
341
if ( getnext_string (fptr , & target_comp_name ) < 0 ) {
342
342
opal_output_verbose (5 , mca_coll_han_component .han_output ,
343
343
"coll:han:mca_coll_han_init_dynamic_rules found an error on dynamic rules file %s "
@@ -353,38 +353,32 @@ mca_coll_han_init_dynamic_rules(void)
353
353
"reader encountered an unexpected EOF. Collective component id must be at "
354
354
"least %d and less than %d\n" ,
355
355
fname , fileline , target_comp_name , SELF , COMPONENTS_COUNT );
356
- free (target_comp_name );
357
- target_comp_name = NULL ;
358
356
goto file_reading_error ;
359
357
}
360
358
361
359
/* Get the optionnal algorithm for han */
362
360
algorithm_id = 0 ; // default for all collectives
363
361
if ((component == HAN ) && (1 == ompi_coll_base_file_peek_next_char_is (fptr , & fileline , '@' )) ) {
364
362
363
+ free (algorithm_name );
364
+ algorithm_name = NULL ;
365
365
if ( getnext_string (fptr , & algorithm_name ) < 0 ) {
366
366
opal_output_verbose (5 , mca_coll_han_component .han_output ,
367
367
"coll:han:mca_coll_han_init_dynamic_rules found an error on dynamic rules file %s "
368
368
"at line %d: cannot read the name/id of an algorithm\n" ,
369
369
fname , fileline );
370
- free (target_comp_name );
371
- target_comp_name = NULL ;
372
370
goto file_reading_error ;
373
371
}
374
372
algorithm_id = mca_coll_han_algorithm_name_to_id (coll_id , algorithm_name );
375
373
if (algorithm_id < 0 ) {
376
374
char * endp ;
377
375
algorithm_id = (int )strtol (algorithm_name , & endp , 10 );
378
376
char endc = * endp ;
379
- free (algorithm_name );
380
- algorithm_name = NULL ;
381
377
if (('\0' != endc ) || !mca_coll_han_algorithm_id_is_valid (coll_id , algorithm_id )) {
382
378
opal_output_verbose (5 , mca_coll_han_component .han_output ,
383
379
"coll:han:mca_coll_han_init_dynamic_rules found an error on dynamic rules file %s "
384
380
"at line %d: unknown algorithm '%s' for %s\n" ,
385
381
fname , fileline , algorithm_name , coll_name );
386
- free (target_comp_name );
387
- target_comp_name = NULL ;
388
382
goto file_reading_error ;
389
383
}
390
384
}
@@ -422,19 +416,13 @@ mca_coll_han_init_dynamic_rules(void)
422
416
"file %s line %d found end of file while reading the optional list "
423
417
"of segment lengths for collective %s component %s\n" ,
424
418
fname , fileline , coll_name , target_comp_name );
425
- free (target_comp_name );
426
419
goto file_reading_error ;
427
420
}
428
421
}
429
422
}
430
- free (target_comp_name );
431
423
}
432
424
}
433
425
}
434
- if ( NULL != coll_name ) {
435
- free (coll_name );
436
- coll_name = NULL ;
437
- }
438
426
}
439
427
440
428
if ( getnext_long (fptr , & nb_coll ) > 0 ) {
@@ -455,7 +443,9 @@ mca_coll_han_init_dynamic_rules(void)
455
443
fclose (fptr );
456
444
457
445
check_dynamic_rules ();
446
+ free (coll_name );
458
447
free (algorithm_name );
448
+ free (target_comp_name );
459
449
return OMPI_SUCCESS ;
460
450
461
451
cannot_allocate :
@@ -465,10 +455,9 @@ mca_coll_han_init_dynamic_rules(void)
465
455
opal_output_verbose (0 , mca_coll_han_component .han_output ,
466
456
"coll:han:mca_coll_han_init_dynamic_rules "
467
457
"cannot allocate dynamic rules\n" );
468
- if ( NULL != coll_name ) {
469
- free (coll_name );
470
- }
458
+ free (coll_name );
471
459
free (algorithm_name );
460
+ free (target_comp_name );
472
461
fclose (fptr );
473
462
/* We disable the module, we don't need to keep the rules */
474
463
mca_coll_han_free_dynamic_rules ();
@@ -481,10 +470,9 @@ mca_coll_han_init_dynamic_rules(void)
481
470
"Will use mca parameters defined rules. "
482
471
"To see error detail, please set "
483
472
"collective verbosity level over 5\n" );
484
- if ( NULL != coll_name ) {
485
- free (coll_name );
486
- }
473
+ free (coll_name );
487
474
free (algorithm_name );
475
+ free (target_comp_name );
488
476
fclose (fptr );
489
477
/* We disable the module, we don't need to keep the rules */
490
478
mca_coll_han_free_dynamic_rules ();
0 commit comments