mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-19 16:50:46 +08:00
[svn-r6296] Purpose:
Code cleanup Description: Reduce warnings on Windows Platforms tested: FreeBSD 4.7 (sleipnir)
This commit is contained in:
parent
6f667500c1
commit
1208e94eff
@ -229,7 +229,7 @@ test(fill_t fill_style, const double splits[],
|
||||
/*
|
||||
workaround for a bug in the Metrowerks version 6.0 open function
|
||||
*/
|
||||
if ((fd=open(FILE_NAME_1, O_RDONLY))<0) goto error;
|
||||
if ((fd=HDopen(FILE_NAME_1, O_RDONLY, 0666))<0) goto error;
|
||||
#endif
|
||||
|
||||
for (i=1; i<=cur_size[0]; i++) {
|
||||
@ -246,11 +246,11 @@ test(fill_t fill_style, const double splits[],
|
||||
hs_start[0] = i%2 ? i/2 : cur_size[0]-i/2;
|
||||
break;
|
||||
case FILL_OUTWARD:
|
||||
j = (cur_size[0]-i)+1;
|
||||
j = (int)(cur_size[0]-i)+1;
|
||||
hs_start[0] = j%2 ? j/2 : (hssize_t)cur_size[0]-j/2;
|
||||
break;
|
||||
case FILL_RANDOM:
|
||||
for (j=rand()%cur_size[0]; had[j]; j=(j+1)%cur_size[0]) /*void*/;
|
||||
for (j=HDrand()%(int)cur_size[0]; had[j]; j=(j+1)%(int)cur_size[0]) /*void*/;
|
||||
hs_start[0] = j;
|
||||
had[j] = 1;
|
||||
break;
|
||||
@ -326,7 +326,7 @@ test(fill_t fill_style, const double splits[],
|
||||
|
||||
|
||||
#if !defined( __MWERKS__)
|
||||
close(fd);
|
||||
HDclose(fd);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@ -339,7 +339,7 @@ test(fill_t fill_style, const double splits[],
|
||||
H5Pclose(xfer);
|
||||
H5Fclose(file);
|
||||
free(had);
|
||||
close(fd);
|
||||
HDclose(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
36
src/H5D.c
36
src/H5D.c
@ -1926,21 +1926,27 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type,
|
||||
break;
|
||||
|
||||
case H5D_COMPACT:
|
||||
/*
|
||||
* Compact dataset is stored in dataset object header message of
|
||||
* layout.
|
||||
*/
|
||||
new_dset->layout.size = H5S_get_simple_extent_npoints(space) *
|
||||
H5T_get_size(type);
|
||||
/* Verify data size is smaller than maximum header message size
|
||||
* (64KB) minus other layout message fields.
|
||||
*/
|
||||
comp_data_size=H5O_MAX_SIZE-H5O_layout_meta_size(file, &(new_dset->layout));
|
||||
if(new_dset->layout.size > comp_data_size)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "compact dataset size is bigger than header message maximum size");
|
||||
if ((ndims=H5S_get_simple_extent_dims(space, new_dset->layout.dim, max_dim))<0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize dimension size of compact dataset storage");
|
||||
/* remember to check if size is small enough to fit header message */
|
||||
{
|
||||
hssize_t tmp_size; /* Temporary holder for raw data size */
|
||||
|
||||
/*
|
||||
* Compact dataset is stored in dataset object header message of
|
||||
* layout.
|
||||
*/
|
||||
tmp_size = H5S_get_simple_extent_npoints(space) *
|
||||
H5T_get_size(type);
|
||||
H5_ASSIGN_OVERFLOW(new_dset->layout.size,tmp_size,hssize_t,size_t);
|
||||
/* Verify data size is smaller than maximum header message size
|
||||
* (64KB) minus other layout message fields.
|
||||
*/
|
||||
comp_data_size=H5O_MAX_SIZE-H5O_layout_meta_size(file, &(new_dset->layout));
|
||||
if(new_dset->layout.size > comp_data_size)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "compact dataset size is bigger than header message maximum size");
|
||||
if ((ndims=H5S_get_simple_extent_dims(space, new_dset->layout.dim, max_dim))<0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize dimension size of compact dataset storage");
|
||||
/* remember to check if size is small enough to fit header message */
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
@ -2431,7 +2431,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
|
||||
/* Check if there are filters which need to be applied to the chunk */
|
||||
if (pline.nfilters>0) {
|
||||
unsigned filter_mask=0;
|
||||
size_t buf_size=chunk_size;
|
||||
size_t buf_size=(size_t)chunk_size;
|
||||
size_t nbytes=(size_t)chunk_size;
|
||||
|
||||
/* Push the chunk through the filters */
|
||||
@ -2476,7 +2476,8 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
|
||||
udata.mesg = *layout;
|
||||
udata.key.filter_mask = 0;
|
||||
udata.addr = HADDR_UNDEF;
|
||||
udata.key.nbytes = chunk_size;
|
||||
H5_CHECK_OVERFLOW(chunk_size,hsize_t,size_t);
|
||||
udata.key.nbytes = (size_t)chunk_size;
|
||||
for (u=0; u<layout->ndims; u++)
|
||||
udata.key.offset[u] = chunk_offset[u];
|
||||
|
||||
|
@ -1786,7 +1786,7 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
|
||||
size_t new_accum_size; /* Size of new accumulator buffer */
|
||||
|
||||
/* Calculate the size of the overlap with the accumulator, etc. */
|
||||
overlap_size=(addr+size)-file->accum_loc;
|
||||
H5_ASSIGN_OVERFLOW(overlap_size,(addr+size)-file->accum_loc,haddr_t,size_t);
|
||||
new_accum_size=file->accum_size-overlap_size;
|
||||
|
||||
/* Move the accumulator buffer information to eliminate the freed block */
|
||||
@ -1800,7 +1800,7 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
|
||||
/* Block to free must start within the accumulator */
|
||||
else {
|
||||
/* Calculate the size of the overlap with the accumulator */
|
||||
overlap_size=(file->accum_loc+file->accum_size)-addr;
|
||||
H5_ASSIGN_OVERFLOW(overlap_size,(file->accum_loc+file->accum_size)-addr,haddr_t,size_t);
|
||||
|
||||
/* Block to free is in the middle of the accumulator */
|
||||
if(H5F_addr_lt(addr,file->accum_loc+file->accum_size)) {
|
||||
@ -1809,7 +1809,7 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
|
||||
|
||||
/* Calculate the address & size of the tail to write */
|
||||
tail_addr=addr+size;
|
||||
tail_size=(file->accum_loc+file->accum_size)-tail_addr;
|
||||
H5_ASSIGN_OVERFLOW(tail_size,(file->accum_loc+file->accum_size)-tail_addr,haddr_t,size_t);
|
||||
|
||||
/* Write out the part of the accumulator after the block to free */
|
||||
if (H5FD_write(file, H5FD_MEM_DEFAULT, H5P_DATASET_XFER_DEFAULT, tail_addr, tail_size, file->meta_accum+(tail_addr-file->accum_loc))<0)
|
||||
|
@ -2431,7 +2431,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
|
||||
/* Check if there are filters which need to be applied to the chunk */
|
||||
if (pline.nfilters>0) {
|
||||
unsigned filter_mask=0;
|
||||
size_t buf_size=chunk_size;
|
||||
size_t buf_size=(size_t)chunk_size;
|
||||
size_t nbytes=(size_t)chunk_size;
|
||||
|
||||
/* Push the chunk through the filters */
|
||||
@ -2476,7 +2476,8 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
|
||||
udata.mesg = *layout;
|
||||
udata.key.filter_mask = 0;
|
||||
udata.addr = HADDR_UNDEF;
|
||||
udata.key.nbytes = chunk_size;
|
||||
H5_CHECK_OVERFLOW(chunk_size,hsize_t,size_t);
|
||||
udata.key.nbytes = (size_t)chunk_size;
|
||||
for (u=0; u<layout->ndims; u++)
|
||||
udata.key.offset[u] = chunk_offset[u];
|
||||
|
||||
|
@ -646,7 +646,8 @@ H5S_all_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_i
|
||||
|
||||
/* Compute the offset in the dataset */
|
||||
off[0]=iter->all.offset*elem_size;
|
||||
len[0]=MIN(maxbytes,bytes_left);
|
||||
H5_CHECK_OVERFLOW(bytes_left,hsize_t,size_t);
|
||||
len[0]=MIN(maxbytes,(size_t)bytes_left);
|
||||
|
||||
/* Should only need one sequence for 'all' selections */
|
||||
*nseq=1;
|
||||
|
@ -5099,7 +5099,8 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
|
||||
ispan=iter->hyp.span;
|
||||
|
||||
/* Set the amount of elements to perform I/O on, etc. */
|
||||
start_io_bytes_left=io_bytes_left=MIN(maxbytes,(iter->hyp.elmt_left*elem_size));
|
||||
H5_CHECK_OVERFLOW( (iter->hyp.elmt_left*elem_size) ,hsize_t,size_t);
|
||||
start_io_bytes_left=io_bytes_left=MIN(maxbytes,(size_t)(iter->hyp.elmt_left*elem_size));
|
||||
nelem=io_bytes_left/elem_size;
|
||||
|
||||
/* Compute the cumulative size of dataspace dimensions */
|
||||
@ -5563,10 +5564,11 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
|
||||
size_t leftover; /* The number of elements left over from the last sequence */
|
||||
|
||||
/* Calculate the number of elements left in the sequence */
|
||||
H5_CHECK_OVERFLOW( tdiminfo[fast_dim].block-(iter->hyp.off[fast_dim]-tdiminfo[fast_dim].start) ,hsize_t,size_t);
|
||||
if(tdiminfo[fast_dim].stride==1)
|
||||
leftover=tdiminfo[fast_dim].block-(iter->hyp.off[fast_dim]-tdiminfo[fast_dim].start);
|
||||
leftover=(size_t)(tdiminfo[fast_dim].block-(iter->hyp.off[fast_dim]-tdiminfo[fast_dim].start));
|
||||
else
|
||||
leftover=tdiminfo[fast_dim].block-((iter->hyp.off[fast_dim]-tdiminfo[fast_dim].start)%tdiminfo[fast_dim].stride);
|
||||
leftover=(size_t)(tdiminfo[fast_dim].block-((iter->hyp.off[fast_dim]-tdiminfo[fast_dim].start)%tdiminfo[fast_dim].stride));
|
||||
|
||||
/* Make certain that we don't write too many */
|
||||
actual_elem=MIN(leftover,io_left);
|
||||
@ -5651,7 +5653,8 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
|
||||
fast_dim_offset=fast_dim_start+sel_off[fast_dim];
|
||||
|
||||
/* Compute the number of blocks which would fit into the buffer */
|
||||
tot_blk_count=io_left/fast_dim_block;
|
||||
H5_CHECK_OVERFLOW(io_left/fast_dim_block,hsize_t,size_t);
|
||||
tot_blk_count=(size_t)(io_left/fast_dim_block);
|
||||
|
||||
/* Don't go over the maximum number of sequences allowed */
|
||||
tot_blk_count=MIN(tot_blk_count,(maxseq-curr_seq));
|
||||
@ -5748,7 +5751,8 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
|
||||
} /* end if */
|
||||
|
||||
/* Compute the number of entire rows to read in */
|
||||
curr_rows=total_rows=tot_blk_count/tdiminfo[fast_dim].count;
|
||||
H5_CHECK_OVERFLOW( tot_blk_count/tdiminfo[fast_dim].count ,hsize_t,size_t);
|
||||
curr_rows=total_rows=(size_t)(tot_blk_count/tdiminfo[fast_dim].count);
|
||||
|
||||
/* Reset copy of number of blocks in fastest dimension */
|
||||
H5_ASSIGN_OVERFLOW(fast_dim_count,tdiminfo[fast_dim].count,hsize_t,size_t);
|
||||
@ -5910,10 +5914,12 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
|
||||
/* Adjust the number of blocks & elements left to transfer */
|
||||
|
||||
/* Decrement number of elements left */
|
||||
io_left -= actual_elem*(total_rows*tdiminfo[fast_dim].count);
|
||||
H5_CHECK_OVERFLOW( actual_elem*(total_rows*tdiminfo[fast_dim].count) ,hsize_t,size_t);
|
||||
io_left -= (size_t)(actual_elem*(total_rows*tdiminfo[fast_dim].count));
|
||||
|
||||
/* Decrement number of blocks left */
|
||||
tot_blk_count -= (total_rows*tdiminfo[fast_dim].count);
|
||||
H5_CHECK_OVERFLOW( (total_rows*tdiminfo[fast_dim].count) ,hsize_t,size_t);
|
||||
tot_blk_count -= (size_t)(total_rows*tdiminfo[fast_dim].count);
|
||||
|
||||
/* Read in partial row of blocks */
|
||||
if(io_left>0 && curr_seq<maxseq) {
|
||||
|
@ -1242,7 +1242,8 @@ H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter,
|
||||
*nseq=curr_seq;
|
||||
|
||||
/* Set the number of bytes used */
|
||||
*nbytes=(start_bytes_left-bytes_left);
|
||||
H5_CHECK_OVERFLOW( (start_bytes_left-bytes_left) ,hsize_t,size_t);
|
||||
*nbytes=(size_t)(start_bytes_left-bytes_left);
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value);
|
||||
|
@ -1216,7 +1216,14 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, H5P_genplist_t *dc_plist,
|
||||
mem_iter_init=1; /* Memory selection iteration info has been initialized */
|
||||
|
||||
/* Get number of bytes in selection */
|
||||
maxbytes=(*file_space->select.get_npoints)(file_space)*elmt_size;
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
hsize_t tmp_maxbytes=(*file_space->select.get_npoints)(file_space)*elmt_size;
|
||||
H5_ASSIGN_OVERFLOW(maxbytes,tmp_maxbytes,hsize_t,size_t);
|
||||
}
|
||||
#else /* NDEBUG */
|
||||
maxbytes=(size_t)((*file_space->select.get_npoints)(file_space)*elmt_size);
|
||||
#endif /* NDEBUG */
|
||||
|
||||
/* Initialize sequence counts */
|
||||
curr_mem_seq=curr_file_seq=0;
|
||||
@ -1443,7 +1450,14 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, H5P_genplist_t *dc_plist,
|
||||
mem_iter_init=1; /* Memory selection iteration info has been initialized */
|
||||
|
||||
/* Get number of bytes in selection */
|
||||
maxbytes=(*file_space->select.get_npoints)(file_space)*elmt_size;
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
hsize_t tmp_maxbytes=(*file_space->select.get_npoints)(file_space)*elmt_size;
|
||||
H5_ASSIGN_OVERFLOW(maxbytes,tmp_maxbytes,hsize_t,size_t);
|
||||
}
|
||||
#else /* NDEBUG */
|
||||
maxbytes=(size_t)((*file_space->select.get_npoints)(file_space)*elmt_size);
|
||||
#endif /* NDEBUG */
|
||||
|
||||
/* Initialize sequence counts */
|
||||
curr_mem_seq=curr_file_seq=0;
|
||||
|
@ -2272,16 +2272,13 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
|
||||
uint8_t *tmp=bg_ptr;
|
||||
UINT32DECODE(tmp, bg_seq_len);
|
||||
if(bg_seq_len>0) {
|
||||
if(tmp_buf_size<bg_seq_len*MAX(src_base_size,
|
||||
dst_base_size)) {
|
||||
tmp_buf_size=bg_seq_len*MAX(src_base_size,
|
||||
dst_base_size);
|
||||
if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf,
|
||||
tmp_buf_size))==NULL)
|
||||
H5_CHECK_OVERFLOW( bg_seq_len*MAX(src_base_size,dst_base_size) ,hsize_t,size_t);
|
||||
if(tmp_buf_size<(size_t)(bg_seq_len*MAX(src_base_size, dst_base_size))) {
|
||||
tmp_buf_size=bg_seq_len*MAX(src_base_size, dst_base_size);
|
||||
if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf, tmp_buf_size))==NULL)
|
||||
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
|
||||
}
|
||||
H5F_addr_decode(dst->u.vlen.f, (const uint8_t **)&tmp,
|
||||
&(bg_hobjid.addr));
|
||||
H5F_addr_decode(dst->u.vlen.f, (const uint8_t **)&tmp, &(bg_hobjid.addr));
|
||||
INT32DECODE(tmp, bg_hobjid.idx);
|
||||
if(H5HG_read(dst->u.vlen.f,&bg_hobjid,tmp_buf)==NULL)
|
||||
HGOTO_ERROR (H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL sequence into background buffer");
|
||||
|
12
test/big.c
12
test/big.c
@ -79,12 +79,12 @@ is_sparse(void)
|
||||
int fd;
|
||||
h5_stat_t sb;
|
||||
|
||||
if ((fd=open("x.h5", O_RDWR|O_TRUNC|O_CREAT, 0666))<0) return 0;
|
||||
if (lseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0;
|
||||
if (5!=write(fd, "hello", 5)) return 0;
|
||||
if (close(fd)<0) return 0;
|
||||
if (stat("x.h5", &sb)<0) return 0;
|
||||
if (unlink("x.h5")<0) return 0;
|
||||
if ((fd=HDopen("x.h5", O_RDWR|O_TRUNC|O_CREAT, 0666))<0) return 0;
|
||||
if (HDlseek(fd, (off_t)(1024*1024), SEEK_SET)!=1024*1024) return 0;
|
||||
if (5!=HDwrite(fd, "hello", 5)) return 0;
|
||||
if (HDclose(fd)<0) return 0;
|
||||
if (HDstat("x.h5", &sb)<0) return 0;
|
||||
if (HDunlink("x.h5")<0) return 0;
|
||||
#ifdef H5_HAVE_STAT_ST_BLOCKS
|
||||
return ((unsigned long)sb.st_blocks*512 < (unsigned long)sb.st_size);
|
||||
#else
|
||||
|
@ -689,7 +689,7 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval,
|
||||
(hssize_t)((size_t)(nelmts*sizeof(comp_datatype))));
|
||||
buf_c = (comp_datatype*)calloc((size_t)nelmts,sizeof(comp_datatype));
|
||||
for (i=0; i<nelmts; i++) {
|
||||
buf_c[i].a = 1111.11;
|
||||
buf_c[i].a = (float)1111.11;
|
||||
buf_c[i].x = 2222;
|
||||
buf_c[i].y = 3333.3333;
|
||||
buf_c[i].z = 'd';
|
||||
|
@ -394,7 +394,7 @@ typedef struct h5tools_context_t {
|
||||
int prev_multiline; /*was prev datum multiline? */
|
||||
size_t prev_prefix_len;/*length of previous prefix */
|
||||
int continuation; /*continuation of previous data?*/
|
||||
int size_last_dim; /*the size of the last dimension,
|
||||
hsize_t size_last_dim; /*the size of the last dimension,
|
||||
*needed so we can break after each
|
||||
*row */
|
||||
int indent_level; /*the number of times we need some
|
||||
|
@ -196,7 +196,6 @@ main (int argc, char *argv[])
|
||||
h5_stat_t sb;
|
||||
|
||||
int verbose=FALSE; /*display file names? */
|
||||
size_t left_overs=0; /*amount of zeros left over */
|
||||
|
||||
const char *src_gen_name; /*general source name */
|
||||
char src_name[NAMELEN]; /*source member name */
|
||||
@ -211,15 +210,17 @@ main (int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
_int64 src_offset=0; /*offset in source member */
|
||||
_int64 dst_offset=0; /*offset in destination member */
|
||||
_int64 src_size; /*source logical member size */
|
||||
_int64 left_overs=0; /*amount of zeros left over */
|
||||
_int64 src_offset=0; /*offset in source member */
|
||||
_int64 dst_offset=0; /*offset in destination member */
|
||||
_int64 src_size; /*source logical member size */
|
||||
_int64 src_act_size; /*source actual member size */
|
||||
_int64 dst_size=1 GB; /*destination logical memb size */
|
||||
#else
|
||||
off_t src_offset=0; /*offset in source member */
|
||||
off_t dst_offset=0; /*offset in destination member */
|
||||
off_t src_size; /*source logical member size */
|
||||
off_t left_overs=0; /*amount of zeros left over */
|
||||
off_t src_offset=0; /*offset in source member */
|
||||
off_t dst_offset=0; /*offset in destination member */
|
||||
off_t src_size; /*source logical member size */
|
||||
off_t src_act_size; /*source actual member size */
|
||||
off_t dst_size=1 GB; /*destination logical memb size */
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user