- Fix Coverity CID 477:
In _correct_ programs only when (group->grp_proc_count - n) > 0, we may fill ranks_included (callers of ompi_group_excl make sure)... Therefore move the ranks_included loop into the true block of the if (which is changed from "!= 0" to ">0"). Otherwise, the initilization of k=0 and ranks_included=NULL is good for the ompi_group_incl (and submethods ompi_group_*). Tested on Linux w/ mpi_test_suite and MPIch testsuite: 4 grouptest_coll 4 groupcreate 4 grouptest This commit was SVN r21172.
Этот коммит содержится в:
родитель
b8bb7865bc
Коммит
4ff860db1f
@ -239,15 +239,14 @@ int ompi_group_incl(ompi_group_t* group, int n, int *ranks, ompi_group_t **new_g
|
|||||||
|
|
||||||
int ompi_group_excl(ompi_group_t* group, int n, int *ranks, ompi_group_t **new_group)
|
int ompi_group_excl(ompi_group_t* group, int n, int *ranks, ompi_group_t **new_group)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i, j, k, result;
|
int i, j, k, result;
|
||||||
int *ranks_included=NULL;
|
int *ranks_included=NULL;
|
||||||
|
|
||||||
/* determine the list of included processes for the excl-method */
|
/* determine the list of included processes for the excl-method */
|
||||||
k = 0;
|
k = 0;
|
||||||
if (0 != (group->grp_proc_count - n)) {
|
if (0 < (group->grp_proc_count - n)) {
|
||||||
ranks_included = (int *)malloc( (group->grp_proc_count-n)*(sizeof(int)));
|
ranks_included = (int *)malloc( (group->grp_proc_count-n)*(sizeof(int)));
|
||||||
}
|
|
||||||
for (i=0 ; i<group->grp_proc_count ; i++) {
|
for (i=0 ; i<group->grp_proc_count ; i++) {
|
||||||
for(j=0 ; j<n ; j++) {
|
for(j=0 ; j<n ; j++) {
|
||||||
if(ranks[j] == i) break;
|
if(ranks[j] == i) break;
|
||||||
@ -257,13 +256,14 @@ int ompi_group_excl(ompi_group_t* group, int n, int *ranks, ompi_group_t **new_g
|
|||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result = ompi_group_incl(group, k, ranks_included, new_group);
|
result = ompi_group_incl(group, k, ranks_included, new_group);
|
||||||
|
|
||||||
if (NULL != ranks_included)
|
if (NULL != ranks_included) {
|
||||||
{
|
|
||||||
free(ranks_included);
|
free(ranks_included);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user