Skip to content

Commit e77ff6b

Browse files
committed
Merge pull request #789 from bosilca/topic/treematch_coverity
Fix treematch issues identified by Coverity.
2 parents acf64b2 + 0a91d7a commit e77ff6b

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

ompi/mca/topo/treematch/treematch/tm_kpartitioning.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,19 +480,17 @@ tree_t *kpartition_build_tree_from_topology(tm_topology_t *topology,double **com
480480
/* we assume all objects have the same arity*/
481481
/* assign the root of the tree*/
482482
root = (tree_t*) MALLOC (sizeof(tree_t));
483-
484-
483+
root->id = 0;
485484

486485
/*build the tree downward from the root*/
487486
kpartition_build_level_topology(root, &com_mat, N+K, depth, topology, local_vertices,
488-
constraints, nb_constraints, obj_weight, com_speed);
487+
constraints, nb_constraints, obj_weight, com_speed);
489488

490489
/*print_1D_tab(local_vertices,K+N);*/
491490
if(verbose_level>=INFO)
492491
printf("Build (bottom-up) tree done!\n");
493492

494493

495-
496494
FREE(local_vertices);
497495

498496

ompi/mca/topo/treematch/treematch/tm_mapping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ int build_binding_constraints(char *filename, int **ptab)
272272
n++;
273273
}
274274

275-
tab = (int*)MALLOC(n*sizeof(int));
275+
tab = (int*)MALLOC((n+1)*sizeof(int));
276276

277277
rewind(pf);
278278
fgets(line, LINE_SIZE, pf);

ompi/mca/topo/treematch/treematch/tm_tree.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,11 @@ void FREE_tab_child(tree_t *tree)
126126

127127
void FREE_non_constraint_tree(tree_t *tree)
128128
{
129-
130-
FREE_list_child(tree);
129+
int free_tree = tree->dumb;
131130
FREE_tab_child(tree);
132-
FREE(tree);
131+
FREE_list_child(tree);
132+
if(free_tree)
133+
FREE(tree);
133134
}
134135

135136
void FREE_constraint_tree(tree_t *tree)
@@ -1458,8 +1459,6 @@ tree_t *build_level_topology(tree_t *tab_node, affinity_mat_t *aff_mat,int arity
14581459
FREE(new_aff_mat);
14591460
FREE(new_obj_weight);
14601461

1461-
FREE(new_obj_weight);
1462-
14631462
return res;
14641463
}
14651464

0 commit comments

Comments
 (0)