Skip to content

Commit e17e3de

Browse files
edgargabrielkarasevb
authored andcommitted
fcoll/static: fix coverty warnings
fix coverty warnings CID 72144, CID 710677, CID 1364164
1 parent 71de03f commit e17e3de

File tree

3 files changed

+38
-29
lines changed

3 files changed

+38
-29
lines changed

ompi/mca/fcoll/static/fcoll_static_file_read_all.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,14 @@ mca_fcoll_static_file_read_all (mca_io_ompio_file_t *fh,
275275
}
276276

277277

278-
iovec_count_per_process = (int *) malloc (fh->f_procs_per_group * sizeof(int));
278+
iovec_count_per_process = (int *) calloc (fh->f_procs_per_group, sizeof(int));
279279
if (NULL == iovec_count_per_process){
280280
opal_output (1, "OUT OF MEMORY\n");
281281
ret = OMPI_ERR_OUT_OF_RESOURCE;
282282
goto exit;
283283
}
284284

285-
displs = (int *) malloc (fh->f_procs_per_group * sizeof(int));
285+
displs = (int *) calloc (fh->f_procs_per_group, sizeof(int));
286286
if (NULL == displs){
287287
opal_output (1, "OUT OF MEMORY\n");
288288
ret = OMPI_ERR_OUT_OF_RESOURCE;

ompi/mca/fcoll/static/fcoll_static_file_write_all.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ mca_fcoll_static_file_write_all (mca_io_ompio_file_t *fh,
278278
}
279279
}
280280

281-
iovec_count_per_process = (int *) malloc (fh->f_procs_per_group * sizeof(int));
281+
iovec_count_per_process = (int *) calloc (fh->f_procs_per_group, sizeof(int));
282282
if (NULL == iovec_count_per_process){
283283
opal_output (1, "OUT OF MEMORY\n");
284284
ret = OMPI_ERR_OUT_OF_RESOURCE;
285285
goto exit;
286286
}
287287

288-
displs = (int *) malloc (fh->f_procs_per_group * sizeof(int));
288+
displs = (int *) calloc (fh->f_procs_per_group, sizeof(int));
289289
if (NULL == displs){
290290
opal_output (1, "OUT OF MEMORY\n");
291291
ret = OMPI_ERR_OUT_OF_RESOURCE;
@@ -1050,6 +1050,11 @@ mca_fcoll_static_file_write_all (mca_io_ompio_file_t *fh,
10501050
sorted = NULL;
10511051
}
10521052

1053+
if (NULL != displs) {
1054+
free(displs);
1055+
displs = NULL;
1056+
}
1057+
10531058
return ret;
10541059
}
10551060

ompi/mca/io/ompio/io_ompio.c

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,7 @@ int mca_io_ompio_merge_groups(mca_io_ompio_file_t *fh,
18641864
{
18651865
int i = 0;
18661866
int *sizes_old_group;
1867-
1867+
int ret = OMPI_SUCCESS;
18681868
int *displs;
18691869

18701870

@@ -1886,17 +1886,22 @@ int mca_io_ompio_merge_groups(mca_io_ompio_file_t *fh,
18861886

18871887
//merge_aggrs[0] is considered the new aggregator
18881888
//New aggregator collects group sizes of the groups to be merged
1889-
fcoll_base_coll_allgather_array (&fh->f_init_procs_per_group,
1890-
1,
1891-
MPI_INT,
1892-
sizes_old_group,
1893-
1,
1894-
MPI_INT,
1895-
0,
1896-
merge_aggrs,
1897-
num_merge_aggrs,
1898-
fh->f_comm);
1889+
ret = fcoll_base_coll_allgather_array (&fh->f_init_procs_per_group,
1890+
1,
1891+
MPI_INT,
1892+
sizes_old_group,
1893+
1,
1894+
MPI_INT,
1895+
0,
1896+
merge_aggrs,
1897+
num_merge_aggrs,
1898+
fh->f_comm);
18991899

1900+
if ( OMPI_SUCCESS != ret ) {
1901+
free (displs);
1902+
free (sizes_old_group);
1903+
return ret;
1904+
}
19001905
fh->f_procs_per_group = 0;
19011906

19021907

@@ -1920,23 +1925,22 @@ int mca_io_ompio_merge_groups(mca_io_ompio_file_t *fh,
19201925
//New aggregator also collects the grouping distribution
19211926
//This is the actual merge
19221927
//use allgatherv array
1923-
fcoll_base_coll_allgatherv_array (fh->f_init_procs_in_group,
1924-
fh->f_init_procs_per_group,
1925-
MPI_INT,
1926-
fh->f_procs_in_group,
1927-
sizes_old_group,
1928-
displs,
1929-
MPI_INT,
1930-
0,
1931-
merge_aggrs,
1932-
num_merge_aggrs,
1933-
fh->f_comm);
1928+
ret = fcoll_base_coll_allgatherv_array (fh->f_init_procs_in_group,
1929+
fh->f_init_procs_per_group,
1930+
MPI_INT,
1931+
fh->f_procs_in_group,
1932+
sizes_old_group,
1933+
displs,
1934+
MPI_INT,
1935+
0,
1936+
merge_aggrs,
1937+
num_merge_aggrs,
1938+
fh->f_comm);
19341939

1935-
1936-
free(displs);
1940+
free (displs);
19371941
free (sizes_old_group);
19381942

1939-
return OMPI_SUCCESS;
1943+
return ret;
19401944

19411945
}
19421946

0 commit comments

Comments
 (0)