summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkmu <kmu@hdfgroup.org>2020-01-23 21:12:00 (GMT)
committerkmu <kmu@hdfgroup.org>2020-01-23 21:12:00 (GMT)
commit838d4ec56bfc82266a2110635e14d36e075075cc (patch)
tree0da94266f7a4f65b4f2f9045c2913dce9ec89863 /src
parenta9aaad9be317ed92150ccc6b4e8574e596447dba (diff)
downloadhdf5-838d4ec56bfc82266a2110635e14d36e075075cc.zip
hdf5-838d4ec56bfc82266a2110635e14d36e075075cc.tar.gz
hdf5-838d4ec56bfc82266a2110635e14d36e075075cc.tar.bz2
squash cast warning fix
Diffstat (limited to 'src')
-rw-r--r--src/H5B2cache.c4
-rw-r--r--src/H5Cmpio.c39
-rw-r--r--src/H5Dchunk.c31
-rw-r--r--src/H5Dfill.c5
-rw-r--r--src/H5Dio.c22
-rw-r--r--src/H5Dmpio.c36
-rw-r--r--src/H5Rint.c3
-rw-r--r--src/H5Smpio.c37
-rw-r--r--src/H5Ztrans.c2
-rw-r--r--src/H5mpi.c6
-rw-r--r--src/H5overflow.txt1
11 files changed, 95 insertions, 91 deletions
diff --git a/src/H5B2cache.c b/src/H5B2cache.c
index 65286e6..80cb6c5 100644
--- a/src/H5B2cache.c
+++ b/src/H5B2cache.c
@@ -654,6 +654,7 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len,
uint32_t stored_chksum; /* Stored metadata checksum value */
unsigned u; /* Local index variable */
H5B2_internal_t *ret_value = NULL; /* Return value */
+ int node_nrec = 0;
FUNC_ENTER_STATIC
@@ -716,7 +717,8 @@ H5B2__cache_int_deserialize(const void *_image, size_t H5_ATTR_UNUSED len,
for(u = 0; u < (unsigned)(internal->nrec + 1); u++) {
/* Decode node pointer */
H5F_addr_decode(udata->f, (const uint8_t **)&image, &(int_node_ptr->addr));
- UINT64DECODE_VAR(image, int_node_ptr->node_nrec, udata->hdr->max_nrec_size);
+ UINT64DECODE_VAR(image, node_nrec, udata->hdr->max_nrec_size);
+ H5_CHECKED_ASSIGN(int_node_ptr->node_nrec, uint16_t, node_nrec, int);
if(udata->depth > 1)
UINT64DECODE_VAR(image, int_node_ptr->all_nrec, udata->hdr->node_info[udata->depth - 1].cum_max_nrec_size)
else
diff --git a/src/H5Cmpio.c b/src/H5Cmpio.c
index e784487..5a1063f 100644
--- a/src/H5Cmpio.c
+++ b/src/H5Cmpio.c
@@ -174,13 +174,13 @@ H5C_apply_candidate_list(H5F_t * f,
int mpi_size)
{
int i;
- int m;
- int n;
- unsigned first_entry_to_flush;
- unsigned last_entry_to_flush;
- unsigned total_entries_to_clear = 0;
- unsigned total_entries_to_flush = 0;
- int * candidate_assignment_table = NULL;
+ int m;
+ unsigned n;
+ unsigned first_entry_to_flush;
+ unsigned last_entry_to_flush;
+ unsigned total_entries_to_clear = 0;
+ unsigned total_entries_to_flush = 0;
+ unsigned * candidate_assignment_table = NULL;
unsigned entries_to_flush[H5C_RING_NTYPES];
unsigned entries_to_clear[H5C_RING_NTYPES];
haddr_t addr;
@@ -231,17 +231,20 @@ H5C_apply_candidate_list(H5F_t * f,
HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create skip list for entries")
} /* end if */
- n = num_candidates / mpi_size;
- m = num_candidates % mpi_size;
- HDassert(n >= 0);
- if(NULL == (candidate_assignment_table = (int *)H5MM_malloc(sizeof(int) * (size_t)(mpi_size + 1))))
+ if(num_candidates / (unsigned)mpi_size > INT_MAX)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "num_candidates overflow")
+ n = num_candidates / (unsigned)mpi_size;
+ if(num_candidates % (unsigned)mpi_size > INT_MAX)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "m overflow")
+ m = (int)(num_candidates % (unsigned)mpi_size);
+
+ if(NULL == (candidate_assignment_table = (unsigned *)H5MM_malloc(sizeof(unsigned) * (size_t)(mpi_size + 1))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for candidate assignment table")
candidate_assignment_table[0] = 0;
candidate_assignment_table[mpi_size] = num_candidates;
if(m == 0) { /* mpi_size is an even divisor of num_candidates */
- HDassert(n > 0);
for(i = 1; i < mpi_size; i++)
candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n;
} /* end if */
@@ -249,7 +252,7 @@ H5C_apply_candidate_list(H5F_t * f,
for(i = 1; i <= m; i++)
candidate_assignment_table[i] = candidate_assignment_table[i - 1] + n + 1;
- if(num_candidates < mpi_size) {
+ if(num_candidates < (unsigned)mpi_size) {
for(i = m + 1; i < mpi_size; i++)
candidate_assignment_table[i] = num_candidates;
} /* end if */
@@ -263,7 +266,7 @@ H5C_apply_candidate_list(H5F_t * f,
#if H5C_DO_SANITY_CHECKS
/* Verify that the candidate assignment table has the expected form */
for(i = 1; i < mpi_size - 1; i++) {
- int a, b;
+ unsigned a, b;
a = candidate_assignment_table[i] - candidate_assignment_table[i - 1];
b = candidate_assignment_table[i + 1] - candidate_assignment_table[i];
@@ -282,7 +285,7 @@ H5C_apply_candidate_list(H5F_t * f,
tbl_buf[i] = '\0';
HDsprintf(&(tbl_buf[0]), "candidate assignment table = ");
for(i = 0; i <= mpi_size; i++)
- HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " %d", candidate_assignment_table[i]);
+ HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), " %u", candidate_assignment_table[i]);
HDsprintf(&(tbl_buf[HDstrlen(tbl_buf)]), "\n");
HDfprintf(stdout, "%s", tbl_buf);
@@ -359,11 +362,11 @@ H5C_apply_candidate_list(H5F_t * f,
n = 0;
for(i = 0; i < H5C_RING_NTYPES; i++) {
m += (int)entries_to_flush[i];
- n += (int)entries_to_clear[i];
+ n += entries_to_clear[i];
} /* end if */
HDassert((unsigned)m == total_entries_to_flush);
- HDassert((unsigned)n == total_entries_to_clear);
+ HDassert(n == total_entries_to_clear);
#endif /* H5C_DO_SANITY_CHECKS */
#if H5C_APPLY_CANDIDATE_LIST__DEBUG
@@ -397,7 +400,7 @@ H5C_apply_candidate_list(H5F_t * f,
done:
if(candidate_assignment_table != NULL)
- candidate_assignment_table = (int *)H5MM_xfree((void *)candidate_assignment_table);
+ candidate_assignment_table = (unsigned *)H5MM_xfree((void *)candidate_assignment_table);
if(cache_ptr->coll_write_list) {
if(H5SL_close(cache_ptr->coll_write_list) < 0)
HDONE_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "failed to destroy skip list")
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 43cfd02..33950a4 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -1683,7 +1683,7 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t
/* Iterate through each chunk in the dataset */
while(sel_points) {
H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */
- hssize_t schunk_points; /* Number of elements in chunk selection */
+ hsize_t chunk_points; /* Number of elements in chunk selection */
/* Add temporary chunk to the list of chunks */
@@ -1727,12 +1727,11 @@ H5D__create_chunk_file_map_all(H5D_chunk_map_t *fm, const H5D_io_info_t
} /* end if */
/* Get number of elements selected in chunk */
- if((schunk_points = H5S_GET_SELECT_NPOINTS(new_chunk_info->fspace)) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements")
- H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, schunk_points, hssize_t);
+ chunk_points = H5S_GET_SELECT_NPOINTS(new_chunk_info->fspace);
+ H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, chunk_points, hsize_t);
/* Decrement # of points left in file selection */
- sel_points -= (hsize_t)schunk_points;
+ sel_points -= chunk_points;
/* Advance to next chunk if we are not done */
if(sel_points > 0) {
@@ -1870,7 +1869,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
/* (Casting away const OK - QAK) */
if(TRUE == H5S_SELECT_INTERSECT_BLOCK(fm->file_space, coords, end)) {
H5D_chunk_info_t *new_chunk_info; /* chunk information to insert into skip list */
- hssize_t schunk_points; /* Number of elements in chunk selection */
+ hsize_t chunk_points; /* Number of elements in chunk selection */
/* Create dataspace for chunk, 'AND'ing the overall selection with
* the current chunk.
@@ -1923,12 +1922,11 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t
} /* end if */
/* Get number of elements selected in chunk */
- if((schunk_points = H5S_GET_SELECT_NPOINTS(new_chunk_info->fspace)) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements")
- H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, schunk_points, hssize_t);
+ chunk_points = H5S_GET_SELECT_NPOINTS(new_chunk_info->fspace);
+ H5_CHECKED_ASSIGN(new_chunk_info->chunk_points, uint32_t, chunk_points, hsize_t);
/* Decrement # of points left in file selection */
- sel_points -= (hsize_t)schunk_points;
+ sel_points -= chunk_points;
/* Leave if we are done */
if(sel_points == 0)
@@ -4983,12 +4981,12 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info,
/* Distribute evenly the number of blocks between processes. */
if(mpi_size == 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Resulted in division by zero")
- num_blocks = chunk_info->num_io / mpi_size; /* value should be the same on all procs */
+ num_blocks = (size_t)(chunk_info->num_io / (size_t)mpi_size); /* value should be the same on all procs */
/* after evenly distributing the blocks between processes, are
there any leftover blocks for each individual process
(round-robin) */
- leftover_blocks = chunk_info->num_io % mpi_size;
+ leftover_blocks = (size_t)(chunk_info->num_io % (size_t)mpi_size);
/* Cast values to types needed by MPI */
H5_CHECKED_ASSIGN(blocks, int, num_blocks, size_t);
@@ -4997,9 +4995,9 @@ H5D__chunk_collective_fill(const H5D_t *dset, H5D_chunk_coll_info_t *chunk_info,
/* Allocate buffers */
/* (MSC - should not need block_lens if MPI_type_create_hindexed_block is working) */
- if(NULL == (block_lens = (int *)H5MM_malloc((blocks + 1) * sizeof(int))))
+ if(NULL == (block_lens = (int *)H5MM_malloc((size_t)(blocks + 1) * sizeof(int))))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk lengths buffer")
- if(NULL == (chunk_disp_array = (MPI_Aint *)H5MM_malloc((blocks + 1) * sizeof(MPI_Aint))))
+ if(NULL == (chunk_disp_array = (MPI_Aint *)H5MM_malloc((size_t)(blocks + 1) * sizeof(MPI_Aint))))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate chunk file displacement buffer")
for(i = 0 ; i < blocks ; i++) {
@@ -5104,7 +5102,7 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk)
const hsize_t *scaled = udata->common.scaled; /* Scaled chunk offset */
H5S_sel_iter_t *chunk_iter = NULL; /* Memory selection iteration info */
hbool_t chunk_iter_init = FALSE; /* Whether the chunk iterator has been initialized */
- hssize_t sel_nelmts; /* Number of elements in selection */
+ hsize_t sel_nelmts; /* Number of elements in selection */
hsize_t count[H5O_LAYOUT_NDIMS]; /* Element count of hyperslab */
size_t chunk_size; /*size of a chunk */
void *chunk; /* The file chunk */
@@ -5165,8 +5163,7 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk)
/* Get the number of elements in the selection */
sel_nelmts = H5S_GET_SELECT_NPOINTS(udata->chunk_space);
- HDassert(sel_nelmts >= 0);
- H5_CHECK_OVERFLOW(sel_nelmts, hssize_t, size_t);
+ H5_CHECK_OVERFLOW(sel_nelmts, hsize_t, size_t);
/* Check for VL datatype & non-default fill value */
if(udata->fb_info.has_vlen_fill_type)
diff --git a/src/H5Dfill.c b/src/H5Dfill.c
index 3ccee90..f5a5238 100644
--- a/src/H5Dfill.c
+++ b/src/H5Dfill.c
@@ -249,12 +249,11 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf,
* of the VL data.
*/
if(TRUE == H5T_detect_class(fill_type, H5T_VLEN, FALSE)) {
- hssize_t nelmts; /* Number of data elements */
+ hsize_t nelmts; /* Number of data elements */
/* Get the number of elements in the selection */
nelmts = H5S_GET_SELECT_NPOINTS(space);
- HDassert(nelmts >= 0);
- H5_CHECK_OVERFLOW(nelmts, hssize_t, size_t);
+ H5_CHECK_OVERFLOW(nelmts, hsize_t, size_t);
/* Allocate a temporary buffer */
if(NULL == (tmp_buf = H5FL_BLK_MALLOC(type_conv, (size_t)nelmts * buf_size)))
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 6b02b68..0f4e703 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -409,9 +409,8 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
/* Note that if this variable is used, the */
/* projected mem space must be discarded at the */
/* end of the function to avoid a memory leak. */
- H5D_storage_t store; /*union of EFL and chunk pointer in file space */
- hssize_t snelmts; /*total number of elmts (signed) */
- hsize_t nelmts; /*total number of elmts */
+ H5D_storage_t store; /* union of EFL and chunk pointer in file space */
+ hsize_t nelmts; /* total number of elmts */
hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */
char fake_char; /* Temporary variable for NULL buffer pointers */
herr_t ret_value = SUCCEED; /* Return value */
@@ -425,9 +424,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
file_space = dataset->shared->space;
if(!mem_space)
mem_space = file_space;
- if((snelmts = H5S_GET_SELECT_NPOINTS(mem_space)) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dst dataspace has invalid selection")
- H5_CHECKED_ASSIGN(nelmts, hsize_t, snelmts, hssize_t);
+ nelmts = H5S_GET_SELECT_NPOINTS(mem_space);
/* Set up datatype info for operation */
if(H5D__typeinfo_init(dataset, mem_type_id, FALSE, &type_info) < 0)
@@ -450,7 +447,7 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
#endif /*H5_HAVE_PARALLEL*/
/* Make certain that the number of elements in each selection is the same */
- if(nelmts != (hsize_t)H5S_GET_SELECT_NPOINTS(file_space))
+ if(nelmts != H5S_GET_SELECT_NPOINTS(file_space))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest dataspaces have different number of elements selected")
/* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */
@@ -623,9 +620,8 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
/* Note that if this variable is used, the */
/* projected mem space must be discarded at the */
/* end of the function to avoid a memory leak. */
- H5D_storage_t store; /*union of EFL and chunk pointer in file space */
- hssize_t snelmts; /*total number of elmts (signed) */
- hsize_t nelmts; /*total number of elmts */
+ H5D_storage_t store; /* union of EFL and chunk pointer in file space */
+ hsize_t nelmts; /* total number of elmts */
hbool_t io_op_init = FALSE; /* Whether the I/O op has been initialized */
char fake_char; /* Temporary variable for NULL buffer pointers */
herr_t ret_value = SUCCEED; /* Return value */
@@ -680,12 +676,10 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
if(!mem_space)
mem_space = file_space;
- if((snelmts = H5S_GET_SELECT_NPOINTS(mem_space)) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection")
- H5_CHECKED_ASSIGN(nelmts, hsize_t, snelmts, hssize_t);
+ nelmts = H5S_GET_SELECT_NPOINTS(mem_space);
/* Make certain that the number of elements in each selection is the same */
- if(nelmts != (hsize_t)H5S_GET_SELECT_NPOINTS(file_space))
+ if(nelmts != H5S_GET_SELECT_NPOINTS(file_space))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest dataspaces have different number of elements selected")
/* Check for a NULL buffer, after the H5S_ALL dataspace selection has been handled */
diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c
index 0dbbe9f..91557c3 100644
--- a/src/H5Dmpio.c
+++ b/src/H5Dmpio.c
@@ -2524,7 +2524,9 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm,
} /* end if */
/* Broadcasting the MPI_IO option info. and chunk address info. */
- if(MPI_SUCCESS != (mpi_code = MPI_Bcast(mergebuf, ((sizeof(haddr_t) + 1) * total_chunks), MPI_BYTE, root, comm)))
+ if((sizeof(haddr_t) + 1) * total_chunks > INT_MAX)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "result overflow")
+ if(MPI_SUCCESS != (mpi_code = MPI_Bcast(mergebuf, (int)((sizeof(haddr_t) + 1) * total_chunks), MPI_BYTE, root, comm)))
HMPI_GOTO_ERROR(FAIL, "MPI_BCast failed", mpi_code)
H5MM_memcpy(assign_io_mode, mergebuf, total_chunks);
@@ -2606,7 +2608,7 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ
H5D_chunk_info_t *chunk_info;
H5D_chunk_ud_t udata;
H5SL_node_t *chunk_node;
- hssize_t select_npoints;
+ hsize_t select_npoints;
hssize_t chunk_npoints;
if(NULL == (local_info_array = (H5D_filtered_collective_io_info_t *) H5MM_malloc(num_chunks_selected * sizeof(H5D_filtered_collective_io_info_t))))
@@ -2632,8 +2634,7 @@ H5D__construct_filtered_io_info_list(const H5D_io_info_t *io_info, const H5D_typ
H5MM_memcpy(local_info_array[i].scaled, chunk_info->scaled, sizeof(chunk_info->scaled));
- if ((select_npoints = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
+ select_npoints = H5S_GET_SELECT_NPOINTS(chunk_info->mspace);
local_info_array[i].io_size = (size_t) select_npoints * type_info->src_type_size;
/* Currently the full overwrite status of a chunk is only obtained on a per-process
@@ -2841,7 +2842,7 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty
if (mpi_rank != chunk_entry->owners.new_owner) {
H5D_chunk_info_t *chunk_info = NULL;
unsigned char *mod_data_p = NULL;
- hssize_t iter_nelmts;
+ hsize_t iter_nelmts;
size_t mod_data_size;
/* Look up the chunk and get its file and memory dataspaces */
@@ -2854,9 +2855,9 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty
if(H5S_encode(chunk_info->fspace, &mod_data_p, &mod_data_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "unable to get encoded dataspace size")
- if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
+ iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace);
+ H5_CHECK_OVERFLOW(iter_nelmts, hsize_t, size_t);
mod_data_size += (size_t) iter_nelmts * type_info->src_type_size;
if(NULL == (mod_data[num_send_requests] = (unsigned char *) H5MM_malloc(mod_data_size)))
@@ -3088,7 +3089,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
H5Z_EDC_t err_detect; /* Error detection info */
H5Z_cb_t filter_cb; /* I/O filter callback function */
unsigned filter_mask = 0;
- hssize_t iter_nelmts; /* Number of points to iterate over for the chunk IO operation */
+ hsize_t iter_nelmts; /* Number of points to iterate over for the chunk IO operation */
hssize_t extent_npoints;
hsize_t true_chunk_size;
hbool_t mem_iter_init = FALSE;
@@ -3193,17 +3194,15 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
file_iter_init = TRUE;
- if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
+ iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace);
- if(NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) iter_nelmts * type_info->src_type_size)))
+ if(NULL == (tmp_gath_buf = H5MM_malloc(iter_nelmts * type_info->src_type_size)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer")
if(!H5D__gather_mem(chunk_entry->buf, file_iter, (size_t) iter_nelmts, tmp_gath_buf))
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't gather from chunk buffer")
- if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
+ iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace);
if(H5D__scatter_mem(tmp_gath_buf, mem_iter, (size_t) iter_nelmts, io_info->u.rbuf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to read buffer")
@@ -3211,10 +3210,9 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
break;
case H5D_IO_OP_WRITE:
- if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
+ iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace);
- if(NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) iter_nelmts * type_info->src_type_size)))
+ if(NULL == (tmp_gath_buf = H5MM_malloc(iter_nelmts * type_info->src_type_size)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate temporary gather buffer")
/* Gather modification data from the application write buffer into a temporary buffer */
@@ -3230,8 +3228,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information")
mem_iter_init = TRUE;
- if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
+ iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace);
/* Scatter the owner's modification data into the chunk data buffer according to
* the file space.
@@ -3262,8 +3259,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE;
- if((iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
+ iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace);
/* Update the chunk data with the received modification data */
if(H5D__scatter_mem(mod_data_p, mem_iter, (size_t) iter_nelmts, chunk_entry->buf) < 0)
diff --git a/src/H5Rint.c b/src/H5Rint.c
index 33ebe53..1df8a20 100644
--- a/src/H5Rint.c
+++ b/src/H5Rint.c
@@ -819,6 +819,7 @@ H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token,
HDassert(token_size <= H5O_MAX_TOKEN_SIZE);
H5MM_memcpy(&ref->info.obj.token, obj_token, sizeof(H5O_token_t));
+ HDassert(token_size <= 255);
ref->token_size = (uint8_t)token_size;
FUNC_LEAVE_NOAPI(ret_value)
@@ -1200,7 +1201,7 @@ H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes,
/* Decode token */
H5MM_memcpy(obj_token, p, *token_size);
- *nbytes = (size_t)*token_size + H5_SIZEOF_UINT8_T;
+ *nbytes = (size_t)(*token_size + H5_SIZEOF_UINT8_T);
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Smpio.c b/src/H5Smpio.c
index 800913f..6397f4b 100644
--- a/src/H5Smpio.c
+++ b/src/H5Smpio.c
@@ -293,8 +293,8 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points,
for(i = 0; i < num_big_types; i++) {
#if MPI_VERSION >= 3
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(bigio_count,
- 1, &disp[i*bigio_count], elmt_type, &inner_types[i])))
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block((int)bigio_count,
+ 1, &disp[(hsize_t)i*bigio_count], elmt_type, &inner_types[i])))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code)
#else
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)bigio_count,
@@ -308,7 +308,7 @@ H5S__mpio_create_point_datatype(size_t elmt_size, hsize_t num_points,
if(remaining_points) {
#if MPI_VERSION >= 3
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(remaining_points,
- 1, &disp[num_big_types*bigio_count], elmt_type, &inner_types[num_big_types])))
+ 1, &disp[(hsize_t)num_big_types*bigio_count], elmt_type, &inner_types[num_big_types])))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code)
#else
if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)remaining_points,
@@ -403,8 +403,11 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ
curr = space->select.sel_info.pnt_lst->head;
for(u = 0 ; u < num_points ; u++) {
/* Calculate the displacement of the current point */
- disp[u] = H5VM_array_offset(space->extent.rank, space->extent.size, curr->pnt);
- disp[u] *= elmt_size;
+ hsize_t disp_tmp = H5VM_array_offset(space->extent.rank, space->extent.size, curr->pnt);
+ if(disp_tmp > LONG_MAX) /* Maximum value of type long */
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "disp overflow")
+ disp[u] = (MPI_Aint)disp_tmp;
+ disp[u] *= (MPI_Aint)elmt_size;
/* This is a File Space used to set the file view, so adjust the displacements
* to have them monotonically non-decreasing.
@@ -423,7 +426,7 @@ H5S__mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_typ
*/
if(do_permute) {
if(u > 0 && disp[u] < disp[u - 1]) {
- unsigned s = 0, l = u, m = u / 2;
+ hsize_t s = 0, l = u, m = u / 2;
*is_permuted = TRUE;
do {
@@ -565,7 +568,9 @@ H5S__mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute,
/* Loop, while bytes left in sequence */
while(curr_len > 0) {
/* Set the displacement of the current point */
- disp[u] = curr_off;
+ if(curr_off > LONG_MAX)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "curr_off overflow")
+ disp[u] = (MPI_Aint)curr_off;
/* This is a memory displacement, so for each point selected,
* apply the map that was generated by the file selection */
@@ -893,8 +898,14 @@ if(H5DEBUG(S))
****************************************/
/* Calculate start and extent values of this dimension */
- start_disp = d[i].start * offset[i] * elmt_size;
- new_extent = (MPI_Aint)elmt_size * max_xtent[i];
+ /* Check if value overflow to cast to type MPI_Aint */
+ if(d[i].start > LONG_MAX || offset[i] > LONG_MAX || elmt_size > LONG_MAX)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "result overflow")
+ start_disp = (MPI_Aint)d[i].start * (MPI_Aint)offset[i] * (MPI_Aint)elmt_size;
+
+ if(max_xtent[i] > LONG_MAX)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "max_xtent overflow")
+ new_extent = (MPI_Aint)elmt_size * (MPI_Aint)max_xtent[i];
if(MPI_SUCCESS != (mpi_code = MPI_Type_get_extent(outer_type, &lb, &extent_len)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_get_extent failed", mpi_code)
@@ -1161,7 +1172,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
nelmts = (span->high - span->low) + 1;
/* Store displacement & block length */
- disp[outercount] = (MPI_Aint)elmt_size * span->low;
+ disp[outercount] = (MPI_Aint)elmt_size * (MPI_Aint)span->low;
H5_CHECK_OVERFLOW(nelmts, hsize_t, int)
blocklen[outercount] = (int)nelmts;
@@ -1183,7 +1194,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
/* create the block type from elmt_type while checking the 32 bit int limit */
if((hsize_t)(blocklen[u]) > bigio_count) {
- if(H5_mpio_create_large_type(blocklen[u], 0, *elmt_type, &temp_type) < 0)
+ if(H5_mpio_create_large_type((hsize_t)blocklen[u], 0, *elmt_type, &temp_type) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection")
} /* end if */
else
@@ -1219,7 +1230,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of inner MPI datatypes")
/* Calculate the total bytes of the lower dimension */
- stride = (*down) * elmt_size;
+ stride = (MPI_Aint)(*down) * (MPI_Aint)elmt_size;
/* Loop over span nodes */
outercount = 0;
@@ -1251,7 +1262,7 @@ H5S__obtain_datatype(H5S_hyper_span_info_t *spans, const hsize_t *down,
/* Displacement should be in byte and should have dimension information */
/* First using MPI Type vector to build derived data type for this span only */
/* Need to calculate the disp in byte for this dimension. */
- disp[outercount] = span->low * stride;
+ disp[outercount] = (MPI_Aint)span->low * stride;
blocklen[outercount] = 1;
/* Generate MPI datatype for next dimension down */
diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c
index 2245bd3..6d07513 100644
--- a/src/H5Ztrans.c
+++ b/src/H5Ztrans.c
@@ -324,7 +324,7 @@ static void H5Z_print(H5Z_node *tree, FILE *stream);
#define H5Z_XFORM_DO_OP5(TYPE, SIZE) \
{ \
- TYPE val = (TYPE)((tree->type == H5Z_XFORM_INTEGER) ? tree->value.int_val : tree->value.float_val); \
+ TYPE val = ((tree->type == H5Z_XFORM_INTEGER) ? (TYPE)tree->value.int_val : (TYPE)tree->value.float_val); \
H5VM_array_fill(array, &val, sizeof(TYPE), (SIZE)); \
}
diff --git a/src/H5mpi.c b/src/H5mpi.c
index 15451d4..4e1bc95 100644
--- a/src/H5mpi.c
+++ b/src/H5mpi.c
@@ -482,7 +482,7 @@ H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes,
/* Calculate how many Big MPI datatypes are needed to represent the buffer */
num_big_types = (int)(num_elements/bigio_count);
- leftover = num_elements - num_big_types * (hsize_t)bigio_count;
+ leftover = (hsize_t)num_elements - (hsize_t)num_big_types * bigio_count;
H5_CHECKED_ASSIGN(remaining_bytes, int, leftover, hsize_t);
/* Create a contiguous datatype of size equal to the largest
@@ -491,11 +491,11 @@ H5_mpio_create_large_type(hsize_t num_elements, MPI_Aint stride_bytes,
* use type_hvector to create the type with the displacement provided
*/
if (0 == stride_bytes) {
- if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(bigio_count, old_type, &inner_type)))
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)bigio_count, old_type, &inner_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code)
} /* end if */
else
- if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector(bigio_count, 1, stride_bytes, old_type, &inner_type)))
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector((int)bigio_count, 1, stride_bytes, old_type, &inner_type)))
HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hvector failed", mpi_code)
/* Create a contiguous datatype of the buffer (minus the remaining < 2GB part)
diff --git a/src/H5overflow.txt b/src/H5overflow.txt
index ed71b98..9fb3b89 100644
--- a/src/H5overflow.txt
+++ b/src/H5overflow.txt
@@ -31,6 +31,7 @@
unsigned, UNSIGNED;
int8_t, SIGNED;
int, SIGNED;
+long, SIGNED;
int64_t, SIGNED;
uint8_t, UNSIGNED;
uint16_t, UNSIGNED;