summaryrefslogtreecommitdiffstats
path: root/src/H5Tvlen.c
diff options
context:
space:
mode:
authorMuQun Yang <ymuqun@hdfgroup.org>2002-05-02 18:56:32 (GMT)
committerMuQun Yang <ymuqun@hdfgroup.org>2002-05-02 18:56:32 (GMT)
commit84d5daad4faa490f541aa87aa2b8ce8dd047cfce (patch)
treecf90fe5db2f277c54503554281d43240621c89ae /src/H5Tvlen.c
parent5979d5776fe92998fe07768aa070c76f75459324 (diff)
downloadhdf5-84d5daad4faa490f541aa87aa2b8ce8dd047cfce.zip
hdf5-84d5daad4faa490f541aa87aa2b8ce8dd047cfce.tar.gz
hdf5-84d5daad4faa490f541aa87aa2b8ce8dd047cfce.tar.bz2
[svn-r5326]
Purpose: code clean-up Description: Many warnings are generated on windows due to seemingly large-size data type converting to small-size data type, 1.5 branch has been cleaned up, make 1.4 catch up with 1.5. Solution: If meeting with the break-up of the current tests on other platforms, will resume the previous one Platforms tested: windows 2000, linux 2.2.18
Diffstat (limited to 'src/H5Tvlen.c')
-rw-r--r--src/H5Tvlen.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c
index bf5a616..7491b8a 100644
--- a/src/H5Tvlen.c
+++ b/src/H5Tvlen.c
@@ -205,7 +205,8 @@ herr_t H5T_vlen_seq_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t l
herr_t H5T_vlen_seq_mem_write(const H5D_xfer_t *xfer_parms, H5F_t UNUSED *f, void *vl_addr, void *buf, hsize_t seq_len, hsize_t base_size)
{
hvl_t *vl=(hvl_t *)vl_addr; /* Pointer to the user's hvl_t information */
- size_t len=seq_len*base_size;
+ size_t len;
+ H5_ASSIGN_OVERFLOW(len,(seq_len*base_size),hsize_t,size_t);
FUNC_ENTER (H5T_vlen_seq_mem_write, FAIL);
@@ -215,13 +216,12 @@ herr_t H5T_vlen_seq_mem_write(const H5D_xfer_t *xfer_parms, H5F_t UNUSED *f, voi
if(seq_len!=0) {
/* Use the user's memory allocation routine is one is defined */
- assert((seq_len*base_size)==(hsize_t)((size_t)(seq_len*base_size))); /*check for overflow*/
if(xfer_parms->vlen_alloc!=NULL) {
- if(NULL==(vl->p=(xfer_parms->vlen_alloc)((size_t)(seq_len*base_size),xfer_parms->alloc_info)))
+ if(NULL==(vl->p=(xfer_parms->vlen_alloc)(len,xfer_parms->alloc_info)))
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
} /* end if */
else { /* Default to system malloc */
- if(NULL==(vl->p=H5MM_malloc((size_t)(seq_len*base_size))))
+ if(NULL==(vl->p=H5MM_malloc(len)))
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
} /* end else */
@@ -233,7 +233,7 @@ herr_t H5T_vlen_seq_mem_write(const H5D_xfer_t *xfer_parms, H5F_t UNUSED *f, voi
vl->p=NULL;
/* Set the sequence length */
- vl->len=seq_len;
+ H5_ASSIGN_OVERFLOW(vl->len,seq_len,hsize_t,size_t);
FUNC_LEAVE (SUCCEED);
} /* end H5T_vlen_seq_mem_write() */
@@ -316,7 +316,8 @@ herr_t H5T_vlen_str_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t l
herr_t H5T_vlen_str_mem_write(const H5D_xfer_t *xfer_parms, H5F_t UNUSED *f, void *vl_addr, void *buf, hsize_t seq_len, hsize_t base_size)
{
char **s=(char **)vl_addr; /* Pointer to the user's hvl_t information */
- size_t len=seq_len*base_size;
+ size_t len;
+ H5_CHECK_OVERFLOW(((seq_len+1)*base_size),hsize_t,size_t);
FUNC_ENTER (H5T_vlen_str_mem_write, FAIL);
@@ -324,7 +325,7 @@ herr_t H5T_vlen_str_mem_write(const H5D_xfer_t *xfer_parms, H5F_t UNUSED *f, voi
assert(buf);
/* Use the user's memory allocation routine is one is defined */
- assert(((seq_len+1)*base_size)==(hsize_t)((size_t)((seq_len+1)*base_size))); /*check for overflow*/
+
if(xfer_parms->vlen_alloc!=NULL) {
if(NULL==(*s=(xfer_parms->vlen_alloc)((size_t)((seq_len+1)*base_size),xfer_parms->alloc_info)))
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
@@ -334,6 +335,7 @@ herr_t H5T_vlen_str_mem_write(const H5D_xfer_t *xfer_parms, H5F_t UNUSED *f, voi
HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
} /* end else */
+ len=(size_t)seq_len*base_size;
HDmemcpy(*s,buf,len);
(*s)[len]='\0';
@@ -434,7 +436,7 @@ herr_t H5T_vlen_disk_write(const H5D_xfer_t UNUSED *xfer_parms, H5F_t *f, void *
{
uint8_t *vl=(uint8_t *)vl_addr; /* Pointer to the user's hvl_t information */
H5HG_t hobjid;
- size_t len=seq_len*base_size;
+ size_t len;
FUNC_ENTER (H5T_vlen_disk_write, FAIL);
@@ -444,11 +446,13 @@ herr_t H5T_vlen_disk_write(const H5D_xfer_t UNUSED *xfer_parms, H5F_t *f, void *
assert(f);
/* Set the length of the sequence */
+ H5_CHECK_OVERFLOW(seq_len,hsize_t,size_t);
UINT32ENCODE(vl, seq_len);
/* Check if this sequence actually has any data */
if(seq_len!=0) {
/* Write the VL information to disk (allocates space also) */
+ H5_ASSIGN_OVERFLOW(len,(seq_len*base_size),hsize_t,size_t);
if(H5HG_insert(f,len,buf,&hobjid)<0)
HRETURN_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to write VL information");
} /* end if */