From 0a91d7af4d5dbeffd8eebb63ed32482d44e83f08 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Sat, 8 Aug 2015 16:41:30 -0400 Subject: [PATCH] Fix issues identified by Coverity. --- ompi/mca/topo/treematch/treematch/tm_kpartitioning.c | 6 ++---- ompi/mca/topo/treematch/treematch/tm_mapping.c | 2 +- ompi/mca/topo/treematch/treematch/tm_tree.c | 9 ++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ompi/mca/topo/treematch/treematch/tm_kpartitioning.c b/ompi/mca/topo/treematch/treematch/tm_kpartitioning.c index d0770f6cff..c839e2a76c 100644 --- a/ompi/mca/topo/treematch/treematch/tm_kpartitioning.c +++ b/ompi/mca/topo/treematch/treematch/tm_kpartitioning.c @@ -480,19 +480,17 @@ tree_t *kpartition_build_tree_from_topology(tm_topology_t *topology,double **com /* we assume all objects have the same arity*/ /* assign the root of the tree*/ root = (tree_t*) MALLOC (sizeof(tree_t)); - - + root->id = 0; /*build the tree downward from the root*/ kpartition_build_level_topology(root, &com_mat, N+K, depth, topology, local_vertices, - constraints, nb_constraints, obj_weight, com_speed); + constraints, nb_constraints, obj_weight, com_speed); /*print_1D_tab(local_vertices,K+N);*/ if(verbose_level>=INFO) printf("Build (bottom-up) tree done!\n"); - FREE(local_vertices); diff --git a/ompi/mca/topo/treematch/treematch/tm_mapping.c b/ompi/mca/topo/treematch/treematch/tm_mapping.c index 1f664ad337..28ccadea6e 100644 --- a/ompi/mca/topo/treematch/treematch/tm_mapping.c +++ b/ompi/mca/topo/treematch/treematch/tm_mapping.c @@ -272,7 +272,7 @@ int build_binding_constraints(char *filename, int **ptab) n++; } - tab = (int*)MALLOC(n*sizeof(int)); + tab = (int*)MALLOC((n+1)*sizeof(int)); rewind(pf); fgets(line, LINE_SIZE, pf); diff --git a/ompi/mca/topo/treematch/treematch/tm_tree.c b/ompi/mca/topo/treematch/treematch/tm_tree.c index ab52e0f30f..a775ade62a 100644 --- a/ompi/mca/topo/treematch/treematch/tm_tree.c +++ b/ompi/mca/topo/treematch/treematch/tm_tree.c @@ -126,10 +126,11 @@ void FREE_tab_child(tree_t *tree) void FREE_non_constraint_tree(tree_t *tree) { - - FREE_list_child(tree); + int free_tree = tree->dumb; FREE_tab_child(tree); - FREE(tree); + FREE_list_child(tree); + if(free_tree) + FREE(tree); } 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 FREE(new_aff_mat); FREE(new_obj_weight); - FREE(new_obj_weight); - return res; }