Skip to content

Commit 7b8094a

Browse files
committed
coll/base: silence misc warning
as reported by Coverity with CIDs 1363349-1363362 Offset temporary buffer when a non zero lower bound datatype is used. Thanks Hristo Iliev for the report (cherry picked from commit 0e39319)
1 parent 678d086 commit 7b8094a

9 files changed

+16
-16
lines changed

ompi/mca/coll/basic/coll_basic_allgather.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ mca_coll_basic_allgather_inter(const void *sbuf, int scount,
106106
if (OMPI_SUCCESS != err) { line = __LINE__; goto exit; }
107107

108108
/* Step 2: exchange the resuts between the root processes */
109-
span = opal_datatype_span(&sdtype->super, scount * size, &gap);
109+
span = opal_datatype_span(&sdtype->super, (int64_t)scount * (int64_t)size, &gap);
110110
tmpbuf_free = (char *) malloc(span);
111111
if (NULL == tmpbuf_free) { line = __LINE__; err = OMPI_ERR_OUT_OF_RESOURCE; goto exit; }
112112
tmpbuf = tmpbuf_free - gap;

ompi/mca/coll/basic/coll_basic_reduce_scatter_block.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ mca_coll_basic_reduce_scatter_block_inter(const void *sbuf, void *rbuf, int rcou
127127
int totalcounts;
128128
ptrdiff_t gap, span;
129129
char *tmpbuf = NULL, *tmpbuf2 = NULL;
130-
char *lbuf, *buf;
130+
char *lbuf = NULL, *buf;
131131
ompi_request_t *req;
132132

133133
rank = ompi_comm_rank(comm);

ompi/mca/coll/inter/coll_inter_allgather.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ mca_coll_inter_allgather_inter(const void *sbuf, int scount,
4848
struct ompi_communicator_t *comm,
4949
mca_coll_base_module_t *module)
5050
{
51-
int rank, root = 0, size, rsize, err;
52-
char *ptmp_free = NULL, *ptmp;
51+
int rank, root = 0, size, rsize, err = OMPI_SUCCESS;
52+
char *ptmp_free = NULL, *ptmp = NULL;
5353
ptrdiff_t gap, span;
5454
ompi_request_t *req[2];
5555

@@ -59,7 +59,7 @@ mca_coll_inter_allgather_inter(const void *sbuf, int scount,
5959

6060
/* Perform the gather locally at the root */
6161
if ( scount > 0 ) {
62-
span = opal_datatype_span(&sdtype->super, scount*size, &gap);
62+
span = opal_datatype_span(&sdtype->super, (int64_t)scount*(int64_t)size, &gap);
6363
ptmp_free = (char*)malloc(span);
6464
if (NULL == ptmp_free) {
6565
return OMPI_ERR_OUT_OF_RESOURCE;

ompi/mca/coll/inter/coll_inter_allgatherv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ mca_coll_inter_allgatherv_inter(const void *sbuf, int scount,
4949
{
5050
int i, rank, size, size_local, total=0, err;
5151
int *count=NULL,*displace=NULL;
52-
char *ptmp_free=NULL, *ptmp;
52+
char *ptmp_free=NULL, *ptmp=NULL;
5353
ompi_datatype_t *ndtype = NULL;
5454
ompi_request_t *req[2];
5555

ompi/mca/coll/inter/coll_inter_gather.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ mca_coll_inter_gather_inter(const void *sbuf, int scount,
6161
int size_local;
6262
ptrdiff_t gap, span;
6363

64-
size_local = ompi_comm_size(comm->c_local_comm);
65-
span = opal_datatype_span(&sdtype->super, scount*size_local, &gap);
64+
size_local = ompi_comm_size(comm->c_local_comm);
65+
span = opal_datatype_span(&sdtype->super, (int64_t)scount*(int64_t)size_local, &gap);
6666

67-
ptmp_free = (char*)malloc(span);
68-
if (NULL == ptmp_free) {
67+
ptmp_free = (char*)malloc(span);
68+
if (NULL == ptmp_free) {
6969
return OMPI_ERR_OUT_OF_RESOURCE;
7070
}
7171
ptmp = ptmp_free - gap;

ompi/mca/coll/inter/coll_inter_gatherv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ mca_coll_inter_gatherv_inter(const void *sbuf, int scount,
4646
{
4747
int i, rank, size, size_local, total=0, err;
4848
int *count=NULL, *displace=NULL;
49-
char *ptmp_free=NULL, *ptmp;
49+
char *ptmp_free=NULL, *ptmp=NULL;
5050
ompi_datatype_t *ndtype;
5151

5252
if (MPI_PROC_NULL == root) { /* do nothing */

ompi/mca/coll/inter/coll_inter_scatter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ mca_coll_inter_scatter_inter(const void *sbuf, int scount,
5656
err = OMPI_SUCCESS;
5757
} else if (MPI_ROOT != root) {
5858
/* First process receives the data from root */
59-
char *ptmp_free = NULL, *ptmp;
59+
char *ptmp_free = NULL, *ptmp = NULL;
6060
if(0 == rank) {
6161
int size_local;
6262
ptrdiff_t gap, span;
6363

6464
size_local = ompi_comm_size(comm->c_local_comm);
65-
span = opal_datatype_span(&rdtype->super, rcount*size_local, &gap);
65+
span = opal_datatype_span(&rdtype->super, (int64_t)rcount*(int64_t)size_local, &gap);
6666
ptmp_free = malloc(span);
6767
if (NULL == ptmp_free) {
6868
return OMPI_ERR_OUT_OF_RESOURCE;

ompi/mca/coll/inter/coll_inter_scatterv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ mca_coll_inter_scatterv_inter(const void *sbuf, const int *scounts,
4747
{
4848
int i, rank, size, err, total=0, size_local;
4949
int *counts=NULL,*displace=NULL;
50-
char *ptmp_free=NULL, *ptmp;
50+
char *ptmp_free=NULL, *ptmp=NULL;
5151
ompi_datatype_t *ndtype;
5252

5353
/* Initialize */

ompi/mca/coll/libnbc/nbc_iexscan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ int ompi_coll_libnbc_iexscan(const void* sendbuf, void* recvbuf, int count, MPI_
7272
return OMPI_ERR_OUT_OF_RESOURCE;
7373
}
7474
if (inplace) {
75-
NBC_Copy(recvbuf, count, datatype, (char *)handle->tmpbuf-gap, count, datatype, comm);
75+
res = NBC_Copy(recvbuf, count, datatype, (char *)handle->tmpbuf-gap, count, datatype, comm);
7676
} else {
77-
NBC_Copy(sendbuf, count, datatype, (char *)handle->tmpbuf-gap, count, datatype, comm);
77+
res = NBC_Copy(sendbuf, count, datatype, (char *)handle->tmpbuf-gap, count, datatype, comm);
7878
}
7979
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
8080
NBC_Return_handle (handle);

0 commit comments

Comments
 (0)