diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2002-05-20 13:39:57 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2002-05-20 13:39:57 (GMT) |
commit | c581a0723521cd20d62f16af39457106735a8629 (patch) | |
tree | 84034068e6c6db10fb0386cae36a5510cde54d5a /src/H5Shyper.c | |
parent | e12beea6244555171693821481db5c31e1090e0e (diff) | |
download | hdf5-c581a0723521cd20d62f16af39457106735a8629.zip hdf5-c581a0723521cd20d62f16af39457106735a8629.tar.gz hdf5-c581a0723521cd20d62f16af39457106735a8629.tar.bz2 |
[svn-r5439] Purpose:
Code cleanup
Description:
Change variable casts to use H5_ASSIGN_OVERFLOW, or check for overflow
before the cast with H5_CHECK_OVERFLOW.
Platforms tested:
FreeBSD 4.5 (sleipnir)
Diffstat (limited to 'src/H5Shyper.c')
-rw-r--r-- | src/H5Shyper.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 663817e..fda1b07 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -909,7 +909,8 @@ H5S_hyper_fread_opt (H5F_t *f, const struct H5O_layout_t *layout, leftover=file_space->select.sel_info.hslab.diminfo[fast_dim].block-((file_iter->hyp.off[fast_dim]-file_space->select.sel_info.hslab.diminfo[fast_dim].start)%file_space->select.sel_info.hslab.diminfo[fast_dim].stride); /* Make certain that we don't read too many */ - actual_read=(size_t)MIN(leftover,io_left); + H5_CHECK_OVERFLOW(leftover,hsize_t,size_t); + actual_read=MIN((size_t)leftover,io_left); actual_bytes=actual_read*elmt_size; /* Copy the location of the point to get */ @@ -992,7 +993,7 @@ H5S_hyper_fread_opt (H5F_t *f, const struct H5O_layout_t *layout, fast_dim_offset=fast_dim_start+file_space->select.offset[fast_dim]; /* Compute the number of blocks which would fit into the buffer */ - tot_blk_count=(size_t)io_left/(size_t)fast_dim_block; + H5_ASSIGN_OVERFLOW(tot_blk_count,(io_left/fast_dim_block),hsize_t,size_t); /* Compute the amount to wrap at the end of each row */ for(i=0; i<ndims; i++) @@ -1933,7 +1934,8 @@ H5S_hyper_fwrite_opt (H5F_t *f, const struct H5O_layout_t *layout, leftover=file_space->select.sel_info.hslab.diminfo[fast_dim].block-((file_iter->hyp.off[fast_dim]-file_space->select.sel_info.hslab.diminfo[fast_dim].start)%file_space->select.sel_info.hslab.diminfo[fast_dim].stride); /* Make certain that we don't write too many */ - actual_write=(size_t)MIN(leftover,io_left); + H5_CHECK_OVERFLOW(leftover,hsize_t,size_t); + actual_write=MIN((size_t)leftover,io_left); actual_bytes=actual_write*elmt_size; /* Copy the location of the point to get */ @@ -2016,7 +2018,7 @@ H5S_hyper_fwrite_opt (H5F_t *f, const struct H5O_layout_t *layout, fast_dim_offset=fast_dim_start+file_space->select.offset[fast_dim]; /* Compute the number of blocks which would fit into the buffer */ - tot_blk_count=(size_t)io_left/(size_t)fast_dim_block; + H5_ASSIGN_OVERFLOW(tot_blk_count,(io_left/fast_dim_block),hsize_t,size_t); /* Compute the amount to wrap at the end of each row */ for(i=0; i<ndims; i++) @@ -2855,18 +2857,17 @@ H5S_hyper_mread_opt (const void *_buf, size_t elmt_size, /* Check if we stopped in the middle of a sequence of elements */ if((mem_iter->hyp.off[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start)%mem_space->select.sel_info.hslab.diminfo[fast_dim].stride!=0 || ((mem_iter->hyp.off[fast_dim]!=mem_space->select.sel_info.hslab.diminfo[fast_dim].start) && mem_space->select.sel_info.hslab.diminfo[fast_dim].stride==1)) { - size_t leftover; /* The number of elements left over from the last sequence */ + hsize_t leftover; /* The number of elements left over from the last sequence */ /* Calculate the number of elements left in the sequence */ if(mem_space->select.sel_info.hslab.diminfo[fast_dim].stride==1) - leftover=(size_t)mem_space->select.sel_info.hslab.diminfo[fast_dim].block - -(size_t)(mem_iter->hyp.off[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start); + leftover=mem_space->select.sel_info.hslab.diminfo[fast_dim].block-(mem_iter->hyp.off[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start); else - leftover=(size_t)mem_space->select.sel_info.hslab.diminfo[fast_dim].block - -(size_t)((mem_iter->hyp.off[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start)%mem_space->select.sel_info.hslab.diminfo[fast_dim].stride); + leftover=mem_space->select.sel_info.hslab.diminfo[fast_dim].block-((mem_iter->hyp.off[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start)%mem_space->select.sel_info.hslab.diminfo[fast_dim].stride); /* Make certain that we don't write too many */ - actual_read=MIN(leftover,io_left); + H5_CHECK_OVERFLOW(leftover,hsize_t,size_t); + actual_read=MIN((size_t)leftover,io_left); actual_bytes=actual_read*elmt_size; /* Copy the location of the point to get */ @@ -2947,7 +2948,7 @@ H5S_hyper_mread_opt (const void *_buf, size_t elmt_size, fast_dim_offset=fast_dim_start+mem_space->select.offset[fast_dim]; /* Compute the number of blocks which would fit into the buffer */ - tot_blk_count=(size_t)io_left/(size_t)fast_dim_block; + H5_ASSIGN_OVERFLOW(tot_blk_count,(io_left/fast_dim_block),hsize_t,size_t); /* Compute the amount to wrap at the end of each row */ for(i=0; i<ndims; i++) @@ -3685,18 +3686,17 @@ H5S_hyper_mwrite_opt (const void *_tconv_buf, size_t elmt_size, /* Check if we stopped in the middle of a sequence of elements */ if((mem_iter->hyp.off[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start)%mem_space->select.sel_info.hslab.diminfo[fast_dim].stride!=0 || ((mem_iter->hyp.off[fast_dim]!=mem_space->select.sel_info.hslab.diminfo[fast_dim].start) && mem_space->select.sel_info.hslab.diminfo[fast_dim].stride==1)) { - size_t leftover; /* The number of elements left over from the last sequence */ + hsize_t leftover; /* The number of elements left over from the last sequence */ /* Calculate the number of elements left in the sequence */ if(mem_space->select.sel_info.hslab.diminfo[fast_dim].stride==1) - leftover=(size_t)mem_space->select.sel_info.hslab.diminfo[fast_dim].block - -(size_t)(mem_iter->hyp.off[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start); + leftover=mem_space->select.sel_info.hslab.diminfo[fast_dim].block-(mem_iter->hyp.off[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start); else - leftover=(size_t)mem_space->select.sel_info.hslab.diminfo[fast_dim].block - -(size_t)((mem_iter->hyp.off[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start)%mem_space->select.sel_info.hslab.diminfo[fast_dim].stride); + leftover=mem_space->select.sel_info.hslab.diminfo[fast_dim].block-((mem_iter->hyp.off[fast_dim]-mem_space->select.sel_info.hslab.diminfo[fast_dim].start)%mem_space->select.sel_info.hslab.diminfo[fast_dim].stride); /* Make certain that we don't write too many */ - actual_write=MIN(leftover,io_left); + H5_CHECK_OVERFLOW(leftover,hsize_t,size_t); + actual_write=MIN((size_t)leftover,io_left); actual_bytes=actual_write*elmt_size; /* Copy the location of the point to get */ @@ -3777,7 +3777,7 @@ H5S_hyper_mwrite_opt (const void *_tconv_buf, size_t elmt_size, fast_dim_offset=fast_dim_start+mem_space->select.offset[fast_dim]; /* Compute the number of blocks which would fit into the buffer */ - tot_blk_count=(size_t)io_left/(size_t)fast_dim_block; + H5_ASSIGN_OVERFLOW(tot_blk_count,(io_left/fast_dim_block),hsize_t,size_t); /* Compute the amount to wrap at the end of each row */ for(i=0; i<ndims; i++) @@ -5168,7 +5168,8 @@ H5S_hyper_select_serialize (const H5S_t *space, uint8_t *buf) len+=4; /* Add 8 bytes times the rank for each hyperslab selected */ - len+=(size_t)8*space->extent.u.simple.rank*(size_t)block_count; + H5_CHECK_OVERFLOW((8*space->extent.u.simple.rank*block_count),hssize_t,size_t); + len+=(size_t)(8*space->extent.u.simple.rank*block_count); /* Encode each hyperslab in selection */ H5S_hyper_select_serialize_helper(space->select.sel_info.hslab.span_lst,start,end,(hsize_t)0,&buf); |