Skip to content

Commit 32966da

Browse files
authored
Merge pull request #13186 from hppritcha/fix_cids_1645545_1645542
coverity: address CIDs 1645542 and 1645543
2 parents 42e302f + 18cb0f2 commit 32966da

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

ompi/mpi/c/type_create_darray.c.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ PROTOTYPE ERROR_CLASS type_create_darray(INT size,
9393
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
9494
} else if( (MPI_DISTRIBUTE_DFLT_DARG != darg_array[i]) &&
9595
(MPI_DISTRIBUTE_BLOCK == distrib_array[i]) &&
96-
((darg_array[i] * psize_array[i]) < gsize_array[i]) ) {
96+
((MPI_Count)(darg_array[i] * psize_array[i]) < (MPI_Count)gsize_array[i]) ) {
9797
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);
9898
} else if( 1 > psize_array[i] )
9999
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(MPI_ERR_ARG, FUNC_NAME);

ompi/mpi/c/type_create_struct.c.in

+11-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ PROTOTYPE ERROR_CLASS type_create_struct(COUNT count,
4343
DATATYPE_ARRAY array_of_types,
4444
DATATYPE_OUT newtype)
4545
{
46-
int i, rc;
46+
int i, rc, icount = (int)count;
4747
int *iarray_of_blocklengths = NULL;
4848
MPI_Aint *iarray_of_displacements = NULL;
4949

@@ -77,6 +77,12 @@ PROTOTYPE ERROR_CLASS type_create_struct(COUNT count,
7777
FUNC_NAME);
7878
}
7979
}
80+
#if OMPI_BIGCOUNT_SRC
81+
OMPI_CHECK_MPI_COUNT_INT_CONVERSION_OVERFLOW(rc, count);
82+
if (OMPI_SUCCESS != rc) {
83+
return OMPI_ERRHANDLER_NOHANDLE_INVOKE(rc, FUNC_NAME);
84+
}
85+
#endif
8086
}
8187

8288
#if OMPI_BIGCOUNT_SRC
@@ -97,7 +103,7 @@ PROTOTYPE ERROR_CLASS type_create_struct(COUNT count,
97103
iarray_of_blocklengths = (int *)array_of_blocklengths;
98104
iarray_of_displacements = (MPI_Aint *)array_of_displacements;
99105
#endif
100-
rc = ompi_datatype_create_struct( count, iarray_of_blocklengths, iarray_of_displacements,
106+
rc = ompi_datatype_create_struct( icount, iarray_of_blocklengths, iarray_of_displacements,
101107
array_of_types, newtype );
102108
if( rc != MPI_SUCCESS ) {
103109
ompi_datatype_destroy( newtype );
@@ -110,10 +116,10 @@ PROTOTYPE ERROR_CLASS type_create_struct(COUNT count,
110116
}
111117

112118
{
113-
const int* a_i[2] = {(int *)&count, iarray_of_blocklengths};
119+
const int* a_i[2] = {(int *)&icount, iarray_of_blocklengths};
114120

115-
ompi_datatype_set_args( *newtype, count + 1, a_i, count, iarray_of_displacements,
116-
count, array_of_types, MPI_COMBINER_STRUCT );
121+
ompi_datatype_set_args( *newtype, icount + 1, a_i, icount, iarray_of_displacements,
122+
icount, array_of_types, MPI_COMBINER_STRUCT );
117123
}
118124
#if OMPI_BIGCOUNT_SRC
119125
free(iarray_of_blocklengths);

0 commit comments

Comments
 (0)