diff options
88 files changed, 4776 insertions, 4469 deletions
diff --git a/src/.indent.pro b/src/.indent.pro index 45bab39..da9eadb 100644 --- a/src/.indent.pro +++ b/src/.indent.pro @@ -1 +1,155 @@ --bap -sob -l78 -br -ce -cli0 -ss -npcs -di24 -nbc -nfca -psl -i4 -lp -lps -T uint8 -T int8 -T uint16 -T int16 -T uint32 -T int32 -T intn -T uintn -T float32 -T float64 -T H5AC_class_t -T H5AC_prot_t -T H5AC_slot_t -T H5AC_subid_t -T H5AC_t -T H5A_t -T H5Asearch_func_t -T H5B_class_t -T H5B_ins_t -T H5B_key_t -T H5B_subid_t -T H5B_t -T H5C_class_t -T H5C_t -T H5D_create_t -T H5D_layout_t -T H5D_t -T H5D_xfer_t -T H5E_error_t -T H5E_major_mesg_t -T H5E_major_t -T H5E_minor_mesg_t -T H5E_minor_t -T H5E_t -T H5F_create_t -T H5F_file_t -T H5F_isop_t -T H5F_istore_key_t -T H5F_istore_ud1_t -T H5F_low_class_t -T H5F_low_t -T H5F_search_t -T H5F_t -T H5Fget_create_t -T H5G_bt_ud1_t -T H5G_bt_ud2_t -T H5G_cache_t -T H5G_cwgstk_t -T H5G_entry_t -T H5G_node_key_t -T H5G_node_t -T H5G_t -T H5G_type_t -T H5H_free_t -T H5H_t -T H5H_type_t -T H5M_find_t -T H5O_chunk_t -T H5O_class_t -T H5O_cont_t -T H5O_efl_t -T H5O_layout_t -T H5O_mesg_t -T H5O_name_t -T H5O_stab_t -T H5O_t -T H5P_class_t -T H5P_simple_t -T H5P_t -T H5T_class_t -T H5T_conv_t -T H5T_cset_t -T H5T_member_t -T H5T_norm_t -T H5T_order_t -T H5T_pad_t -T H5T_path_t -T H5T_sign_t -T H5T_soft_t -T H5T_str_t -T H5T_t -T H5Tget_member_t -T H5_exit_t -T H5_init_t -T H5_t -T H5_term_t -T access_t -T atom_group_t -T atom_info_t -T cache_t -T child_t -T chunk_t -T create_t -T data_t -T detected_t -T group_t -T haddr_t -T hbool_t -T heap_t -T herr_t -T hid_t -T hobjtype_t -T ino_t -T mem_t -T memb_t -T mesg_t -T message_t -T meta_func_t -T new_t -T off_t -T size_t -T ssize_t -T time_t +-bad /* Blank line after declarations */ +-bap /* Blank line after procedure */ +-bbb /* No blank line before boxed comments */ +-sob /* Swallow optional blank lines */ +-nfca /* Don't format comments on their own line */ +-d0 /* Align comments on their own line with the surrounding code */ +-c33 /* Start comments after code in column 33 */ +-cd33 /* Start comments after declarations in column 33 */ +-cp0 /* Start comments after pre-processor directives immediately after the directive */ +-ncdb /* Don't put comment delimiters on their own lines */ +-sc /* Put stars at the beginning of multi-line comments */ +-br /* Put braces on the same line as the statement */ +-ce /* "Cuddle" else statements onto the same line as the closing if statement's brace */ +-cdw /* "Cuddle" while statements onto the same line as the closing do statement's brace */ +-cli4 /* Indent case statements 4 spaces to right of switch statement */ +-cbi0 /* Indent braces below a case statement 0 spaces to right of case statement */ +-ss /* Put a space before the semicolon if its the only statement in a for or while loop */ +-npcs /* Don't put a space between the procedure name and it's parameters */ +-ncs /* Don't put a space between a cast operator and it's object */ +-nbs /* Don't put a space between a sizeof operator and it's object */ +-nsaf /* Don't put a space between a for statement and it's initial parentheses */ +-nsai /* Don't put a space between an if statement and it's initial parentheses */ +-nsaw /* Don't put a space between a while statement and it's initial parentheses */ +-nprs /* Don't add spaces around parentheses */ +-di24 /* Align identifiers in declarations in column 24 */ +-nbc /* Don't force newlines after commas in declarations */ +-nbfda /* Don't force newlines after commas in function argument declarations */ +-psl /* Force the return type of a procedure to be on it's own line */ +-brs /* Put braces for struct definitions on the same line as the struct keyword */ +-i4 /* Indent space spaces */ +-nlp /* Don't align lines continued onto further lines with the opening parentheses */ +-ci8 /* Align continued code 8 spaces from initial indention */ +-ip4 /* Don't add any extra indention for nested parentheses */ +-lps /* Leave spaces in preprocessor directives alone */ +-l78 /* Try to break long lines in column 78 */ +-bbo /* Try to break long lines at boolean operators && and || */ +-hnl /* Honor existing new-lines in long boolen statements */ +-pmt /* Preserve modification times on modified files */ +/* The rest are typedefs used by the library, feel free to add missing ones, */ +/* but try to keep them alphabetized */ +-T uint8 +-T int8 +-T uint16 +-T int16 +-T uint32 +-T int32 +-T intn +-T uintn +-T float32 +-T float64 +-T H5AC_class_t +-T H5AC_prot_t +-T H5AC_slot_t +-T H5AC_subid_t +-T H5AC_t +-T H5A_t +-T H5Asearch_func_t +-T H5B_class_t +-T H5B_ins_t +-T H5B_key_t +-T H5B_subid_t +-T H5B_t +-T H5C_class_t +-T H5C_t +-T H5D_create_t +-T H5D_layout_t +-T H5D_t +-T H5D_xfer_t +-T H5E_error_t +-T H5E_major_mesg_t +-T H5E_major_t +-T H5E_minor_mesg_t +-T H5E_minor_t +-T H5E_t +-T H5F_create_t +-T H5F_file_t +-T H5F_isop_t +-T H5F_istore_key_t +-T H5F_istore_ud1_t +-T H5F_low_class_t +-T H5F_low_t +-T H5F_search_t +-T H5F_t +-T H5Fget_create_t +-T H5G_bt_ud1_t +-T H5G_bt_ud2_t +-T H5G_cache_t +-T H5G_cwgstk_t +-T H5G_entry_t +-T H5G_node_key_t +-T H5G_node_t +-T H5G_t +-T H5G_type_t +-T H5H_free_t +-T H5H_t +-T H5H_type_t +-T H5M_find_t +-T H5O_chunk_t +-T H5O_class_t +-T H5O_cont_t +-T H5O_efl_t +-T H5O_layout_t +-T H5O_mesg_t +-T H5O_name_t +-T H5O_stab_t +-T H5O_t +-T H5P_class_t +-T H5P_simple_t +-T H5P_t +-T H5T_class_t +-T H5T_conv_t +-T H5T_cset_t +-T H5T_member_t +-T H5T_norm_t +-T H5T_order_t +-T H5T_pad_t +-T H5T_path_t +-T H5T_sign_t +-T H5T_soft_t +-T H5T_str_t +-T H5T_t +-T H5Tget_member_t +-T H5_exit_t +-T H5_init_t +-T H5_t +-T H5_term_t +-T access_t +-T atom_group_t +-T atom_info_t +-T cache_t +-T child_t +-T chunk_t +-T create_t +-T data_t +-T detected_t +-T group_t +-T haddr_t +-T hbool_t +-T heap_t +-T herr_t +-T hid_t +-T hobjtype_t +-T hsize_t +-T hssize_t +-T ino_t +-T mem_t +-T memb_t +-T mesg_t +-T message_t +-T meta_func_t +-T new_t +-T off_t +-T size_t +-T ssize_t +-T time_t @@ -512,7 +512,8 @@ H5A_open(H5G_entry_t *ent, unsigned idx) assert(ent); /* Read in attribute with H5O_read() */ - if (NULL==(attr=H5O_read(ent, H5O_ATTR, idx, attr))) { + H5_CHECK_OVERFLOW(idx,unsigned,int); + if (NULL==(attr=H5O_read(ent, H5O_ATTR, (int)idx, attr))) { HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from dataset header"); } @@ -616,13 +617,13 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, void *buf) { uint8_t *tconv_buf = NULL; /* data type conv buffer */ uint8_t *bkg_buf = NULL; /* temp conversion buffer */ - size_t nelmts; /* elements in attribute */ + hsize_t nelmts; /* elements in attribute */ H5T_path_t *tpath = NULL; /* conversion information*/ hid_t src_id = -1, dst_id = -1;/* temporary type atoms */ size_t src_type_size; /* size of source type */ size_t dst_type_size; /* size of destination type*/ - size_t buf_size; /* desired buffer size */ - int idx; /* index of attribute in object header */ + hsize_t buf_size; /* desired buffer size */ + int idx; /* index of attribute in object header */ herr_t ret_value = FAIL; FUNC_ENTER(H5A_write, FAIL); @@ -640,15 +641,16 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, void *buf) /* Get the maximum buffer size needed and allocate it */ buf_size = nelmts*MAX(src_type_size,dst_type_size); - if (NULL==(tconv_buf = H5MM_malloc (buf_size)) || - NULL==(bkg_buf = H5MM_malloc(buf_size))) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, + assert(buf_size==(hsize_t)((size_t)buf_size)); /*check for overflow*/ + if (NULL==(tconv_buf = H5MM_malloc ((size_t)buf_size)) || + NULL==(bkg_buf = H5MM_calloc((size_t)buf_size))) { + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } - HDmemset(bkg_buf, 0, buf_size); /* Copy the user's data into the buffer for conversion */ - HDmemcpy(tconv_buf,buf,src_type_size*nelmts); + assert((src_type_size*nelmts)==(hsize_t)((size_t)(src_type_size*nelmts))); /*check for overflow*/ + HDmemcpy(tconv_buf,buf,(size_t)(src_type_size*nelmts)); /* Convert memory buffer into disk buffer */ /* Set up type conversion function */ @@ -668,7 +670,7 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, void *buf) /* Perform data type conversion */ if (H5T_convert(tpath, src_id, dst_id, nelmts, 0, 0, tconv_buf, bkg_buf, H5P_DEFAULT)<0) { - HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, + HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "data type conversion failed"); } @@ -698,7 +700,7 @@ done: if (dst_id >= 0) H5I_dec_ref(dst_id); if (bkg_buf) - H5MM_xfree(bkg_buf); + H5MM_xfree(bkg_buf); FUNC_LEAVE(ret_value); } /* H5A_write() */ @@ -778,12 +780,12 @@ H5A_read(H5A_t *attr, const H5T_t *mem_type, void *buf) { uint8_t *tconv_buf = NULL; /* data type conv buffer*/ uint8_t *bkg_buf = NULL; /* background buffer */ - size_t nelmts; /* elements in attribute*/ + hsize_t nelmts; /* elements in attribute*/ H5T_path_t *tpath = NULL; /* type conversion info */ hid_t src_id = -1, dst_id = -1;/* temporary type atoms*/ size_t src_type_size; /* size of source type */ size_t dst_type_size; /* size of destination type */ - size_t buf_size; /* desired buffer size */ + hsize_t buf_size; /* desired buffer size */ herr_t ret_value = FAIL; FUNC_ENTER(H5A_read, FAIL); @@ -800,21 +802,23 @@ H5A_read(H5A_t *attr, const H5T_t *mem_type, void *buf) dst_type_size = H5T_get_size(mem_type); /* Check if the attribute has any data yet, if not, fill with zeroes */ + assert((dst_type_size*nelmts)==(hsize_t)((size_t)(dst_type_size*nelmts))); /*check for overflow*/ if(attr->ent_opened && !attr->initialized) { - HDmemset(buf,0,dst_type_size*nelmts); + HDmemset(buf,0,(size_t)(dst_type_size*nelmts)); } /* end if */ else { /* Attribute exists and has a value */ /* Get the maximum buffer size needed and allocate it */ buf_size = nelmts*MAX(src_type_size,dst_type_size); - if (NULL==(tconv_buf = H5MM_malloc (buf_size)) || - NULL==(bkg_buf = H5MM_malloc(buf_size))) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, + assert(buf_size==(hsize_t)((size_t)buf_size)); /*check for overflow*/ + if (NULL==(tconv_buf = H5MM_malloc ((size_t)buf_size)) || + NULL==(bkg_buf = H5MM_calloc((size_t)buf_size))) { + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } - HDmemset(bkg_buf, 0, buf_size); /* Copy the attribute data into the buffer for conversion */ - HDmemcpy(tconv_buf,attr->data,src_type_size*nelmts); + assert((src_type_size*nelmts)==(hsize_t)((size_t)(src_type_size*nelmts))); /*check for overflow*/ + HDmemcpy(tconv_buf,attr->data,(size_t)(src_type_size*nelmts)); /* Convert memory buffer into disk buffer */ /* Set up type conversion function */ @@ -824,22 +828,22 @@ H5A_read(H5A_t *attr, const H5T_t *mem_type, void *buf) } else if (!H5T_IS_NOOP(tpath)) { if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(attr->dt, H5T_COPY_ALL)))<0 || - (dst_id = H5I_register(H5I_DATATYPE, + (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL)))<0) { HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); } } - /* Perform data type conversion. */ - if (H5T_convert(tpath, src_id, dst_id, nelmts, 0, 0, tconv_buf, bkg_buf, - H5P_DEFAULT)<0) { - HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, - "data type conversion failed"); - } + /* Perform data type conversion. */ + if (H5T_convert(tpath, src_id, dst_id, nelmts, 0, 0, tconv_buf, bkg_buf, + H5P_DEFAULT)<0) { + HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, + "data type conversion failed"); + } /* Copy the converted data into the user's buffer */ - HDmemcpy(buf,tconv_buf,dst_type_size*nelmts); + HDmemcpy(buf,tconv_buf,(size_t)(dst_type_size*nelmts)); } /* end else */ ret_value=SUCCEED; @@ -100,13 +100,13 @@ H5AC_create(H5F_t *f, intn size_hint) "memory allocation failed"); } cache->nslots = size_hint; - cache->slot = H5FL_ARR_ALLOC(H5AC_info_ptr_t,cache->nslots,1); + cache->slot = H5FL_ARR_ALLOC(H5AC_info_ptr_t,(hsize_t)cache->nslots,1); if (NULL==cache->slot) { f->shared->cache = H5FL_FREE (H5AC_t,f->shared->cache); HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } #ifdef H5AC_DEBUG - if ((cache->prot = H5FL_ARR_ALLOC(H5AC_prot_t,cache->nslots,1))==NULL) { + if ((cache->prot = H5FL_ARR_ALLOC(H5AC_prot_t,(hsize_t)cache->nslots,1))==NULL) { cache->slot = H5FL_ARR_FREE (H5AC_info_ptr_t,cache->slot); f->shared->cache = H5FL_FREE (H5AC_t,f->shared->cache); HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); @@ -414,10 +414,10 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy) * Sort the cache entries by address since flushing them in * ascending order by address may be much more efficient. */ - if (NULL==(map=H5FL_ARR_ALLOC(intn,cache->nslots,0))) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, + if (NULL==(map=H5FL_ARR_ALLOC(intn,(hsize_t)cache->nslots,0))) { + HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - } + } for (i = nslots = 0; i < cache->nslots; i++) { if (cache->slot[i]!=NULL) map[nslots++] = i; @@ -124,7 +124,7 @@ static H5B_t *H5B_load(H5F_t *f, haddr_t addr, const void *_type, void *udata); static herr_t H5B_decode_key(H5F_t *f, H5B_t *bt, intn idx); static herr_t H5B_decode_keys(H5F_t *f, H5B_t *bt, intn idx); static hsize_t H5B_nodesize(H5F_t *f, const H5B_class_t *type, - size_t *total_nkey_size, size_t sizeof_rkey); + hsize_t *total_nkey_size, size_t sizeof_rkey); static herr_t H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt, haddr_t old_addr, intn idx, const double split_ratios[], void *udata, @@ -192,7 +192,7 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, H5B_t *bt = NULL; size_t sizeof_rkey; hsize_t size; - size_t total_native_keysize; + hsize_t total_native_keysize; size_t offset; intn i; herr_t ret_value = FAIL; @@ -229,8 +229,8 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, bt->nchildren = 0; if (NULL==(bt->page=H5FL_BLK_ALLOC(page,size,1)) || NULL==(bt->native=H5FL_BLK_ALLOC(native_block,total_native_keysize,0)) || - NULL==(bt->child=H5FL_ARR_ALLOC(haddr_t,2*H5B_K(f,type),0)) || - NULL==(bt->key=H5FL_ARR_ALLOC(H5B_key_t,(2*H5B_K(f,type)+1),0))) { + NULL==(bt->child=H5FL_ARR_ALLOC(haddr_t,(hsize_t)(2*H5B_K(f,type)),0)) || + NULL==(bt->key=H5FL_ARR_ALLOC(H5B_key_t,(hsize_t)(2*H5B_K(f,type)+1),0))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node"); } @@ -307,7 +307,7 @@ static H5B_t * H5B_load(H5F_t *f, haddr_t addr, const void *_type, void *udata) { const H5B_class_t *type = (const H5B_class_t *) _type; - size_t total_nkey_size; + hsize_t total_nkey_size; hsize_t size; H5B_t *bt = NULL; intn i; @@ -333,8 +333,8 @@ H5B_load(H5F_t *f, haddr_t addr, const void *_type, void *udata) bt->ndirty = 0; if (NULL==(bt->page=H5FL_BLK_ALLOC(page,size,0)) || NULL==(bt->native=H5FL_BLK_ALLOC(native_block,total_nkey_size,0)) || - NULL==(bt->key=H5FL_ARR_ALLOC(H5B_key_t,(2*H5B_K(f,type)+1),0)) || - NULL==(bt->child=H5FL_ARR_ALLOC(haddr_t,2*H5B_K(f,type),0))) { + NULL==(bt->key=H5FL_ARR_ALLOC(H5B_key_t,(hsize_t)(2*H5B_K(f,type)+1),0)) || + NULL==(bt->child=H5FL_ARR_ALLOC(haddr_t,(hsize_t)(2*H5B_K(f,type)),0))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } @@ -1563,7 +1563,7 @@ H5B_iterate (H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) * We've reached the left-most leaf. Now follow the right-sibling * pointer from leaf to leaf until we've processed all leaves. */ - if (NULL==(child=H5FL_ARR_ALLOC(haddr_t,2*H5B_K(f,type),0)) || + if (NULL==(child=H5FL_ARR_ALLOC(haddr_t,(hsize_t)(2*H5B_K(f,type)),0)) || NULL==(key=H5MM_malloc((2*H5B_K(f, type)+1)*type->sizeof_nkey))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); @@ -2000,7 +2000,7 @@ H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata) */ static hsize_t H5B_nodesize(H5F_t *f, const H5B_class_t *type, - size_t *total_nkey_size/*out*/, size_t sizeof_rkey) + hsize_t *total_nkey_size/*out*/, size_t sizeof_rkey) { hsize_t size; @@ -2052,9 +2052,9 @@ static H5B_t * H5B_copy(H5F_t *f, const H5B_t *old_bt) { H5B_t *ret_value = NULL; - size_t total_native_keysize; + hsize_t total_native_keysize; hsize_t size; - uintn nkeys; + hsize_t nkeys; uintn u; FUNC_ENTER(H5B_copy, NULL); @@ -2093,9 +2093,12 @@ H5B_copy(H5F_t *f, const H5B_t *old_bt) /* Copy the other structures */ assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ HDmemcpy(ret_value->page,old_bt->page,(size_t)size); - HDmemcpy(ret_value->native,old_bt->native,total_native_keysize); - HDmemcpy(ret_value->child,old_bt->child,sizeof(haddr_t)*nkeys); - HDmemcpy(ret_value->key,old_bt->key,sizeof(H5B_key_t)*(nkeys+1)); + assert(total_native_keysize==(hsize_t)((size_t)total_native_keysize)); /*check for overflow*/ + HDmemcpy(ret_value->native,old_bt->native,(size_t)total_native_keysize); + assert((sizeof(haddr_t)*nkeys)==(hsize_t)((size_t)(sizeof(haddr_t)*nkeys))); /*check for overflow*/ + HDmemcpy(ret_value->child,old_bt->child,(size_t)(sizeof(haddr_t)*nkeys)); + assert((sizeof(H5B_key_t)*(nkeys+1))==(hsize_t)((size_t)(sizeof(H5B_key_t)*(nkeys+1)))); /*check for overflow*/ + HDmemcpy(ret_value->key,old_bt->key,(size_t)(sizeof(H5B_key_t)*(nkeys+1))); /* * Translate the keys from pointers into the old 'page' buffer into @@ -948,6 +948,7 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type, H5D_t *new_dset = NULL; H5D_t *ret_value = NULL; intn i, ndims; + uintn u; hsize_t max_dim[H5O_LAYOUT_NDIMS]={0}; H5O_efl_t *efl = NULL; H5F_t *f = NULL; @@ -960,23 +961,21 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type, assert (type); assert (space); assert (create_parms); - if (create_parms->pline.nfilters>0 && - H5D_CHUNKED!=create_parms->layout) { - HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, NULL, + if (create_parms->pline.nfilters>0 && H5D_CHUNKED!=create_parms->layout) { + HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, NULL, "filters can only be used with chunked layout"); } /* What file is the dataset being added to? */ if (NULL==(f=H5G_insertion_file(loc, name))) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to locate insertion point"); } #ifdef H5_HAVE_PARALLEL /* If MPIO is used, no filter support yet. */ - if (IS_H5FD_MPIO(f) && - create_parms->pline.nfilters>0) { - HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, + if (IS_H5FD_MPIO(f) && create_parms->pline.nfilters>0) { + HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, "Parallel IO does not support filters yet"); } #endif @@ -1004,99 +1003,98 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type, new_dset->layout.dim[new_dset->layout.ndims-1] = H5T_get_size(new_dset->type); switch (new_dset->create_parms->layout) { - case H5D_CONTIGUOUS: - /* - * The maximum size of the dataset cannot exceed the storage size. - * Also, only the slowest varying dimension of a simple data space - * can be extendible. - */ - 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 contiguous storage"); - } - for (i=1; i<ndims; i++) { - if (max_dim[i]>new_dset->layout.dim[i]) { - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, - "only the first dimension can be extendible"); - } - } - if (efl->nused>0) { - hsize_t max_points = H5S_get_npoints_max (space); - hsize_t max_storage = H5O_efl_total_size (efl); - - if (H5S_UNLIMITED==max_points) { - if (H5O_EFL_UNLIMITED!=max_storage) { - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, - "unlimited data space but finite storage"); - } - } else if (max_points * H5T_get_size (type) < max_points) { - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, - "data space * type size overflowed"); - } else if (max_points * H5T_get_size (type) > max_storage) { - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, - "data space size exceeds external storage size"); - } - } else if (ndims>0 && max_dim[0]>new_dset->layout.dim[0]) { - HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, - "extendible contiguous non-external dataset"); - } - break; + case H5D_CONTIGUOUS: + /* + * The maximum size of the dataset cannot exceed the storage size. + * Also, only the slowest varying dimension of a simple data space + * can be extendible. + */ + 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 contiguous storage"); + } + for (i=1; i<ndims; i++) { + if (max_dim[i]>new_dset->layout.dim[i]) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "only the first dimension can be extendible"); + } + } + if (efl->nused>0) { + hsize_t max_points = H5S_get_npoints_max (space); + hsize_t max_storage = H5O_efl_total_size (efl); + + if (H5S_UNLIMITED==max_points) { + if (H5O_EFL_UNLIMITED!=max_storage) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "unlimited data space but finite storage"); + } + } else if (max_points * H5T_get_size (type) < max_points) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "data space * type size overflowed"); + } else if (max_points * H5T_get_size (type) > max_storage) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "data space size exceeds external storage size"); + } + } else if (ndims>0 && max_dim[0]>new_dset->layout.dim[0]) { + HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, + "extendible contiguous non-external dataset"); + } + break; - case H5D_CHUNKED: - /* - * Chunked storage allows any type of data space extension, so we - * don't even bother checking. - */ - if (new_dset->create_parms->chunk_ndims != - H5S_get_simple_extent_ndims(space)) { - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, - "dimensionality of chunks doesn't match the data space"); - } - if (efl->nused>0) { - HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, NULL, - "external storage not supported with chunked layout"); - } - for (i=0; i<new_dset->layout.ndims-1; i++) { - new_dset->layout.dim[i] = new_dset->create_parms->chunk_size[i]; - } - break; + case H5D_CHUNKED: + /* + * Chunked storage allows any type of data space extension, so we + * don't even bother checking. + */ + if (new_dset->create_parms->chunk_ndims != H5S_get_simple_extent_ndims(space)) { + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, + "dimensionality of chunks doesn't match the data space"); + } + if (efl->nused>0) { + HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, NULL, + "external storage not supported with chunked layout"); + } + for (u=0; u<new_dset->layout.ndims-1; u++) { + new_dset->layout.dim[u] = new_dset->create_parms->chunk_size[u]; + } + break; - default: - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet"); + default: + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet"); } /* Create (open for write access) an object header */ if (H5O_create(f, 256, &(new_dset->ent)) < 0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset object header"); } /* Convert the fill value to the dataset type and write the message */ if (H5O_fill_convert(&(new_dset->create_parms->fill), new_dset->type)<0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to convert fill value to dataset type"); } if (new_dset->create_parms->fill.buf && - H5O_modify(&(new_dset->ent), H5O_FILL, 0, H5O_FLAG_CONSTANT, + H5O_modify(&(new_dset->ent), H5O_FILL, 0, H5O_FLAG_CONSTANT, &(new_dset->create_parms->fill))<0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to update fill value header message"); } /* Update the type and space header messages */ if (H5O_modify(&(new_dset->ent), H5O_DTYPE, 0, H5O_FLAG_CONSTANT|H5O_FLAG_SHARED, new_dset->type)<0 || - H5S_modify(&(new_dset->ent), space) < 0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, + H5S_modify(&(new_dset->ent), space) < 0) { + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to update type or space header messages"); } /* Update the filters message */ if (new_dset->create_parms->pline.nfilters>0 && - H5O_modify (&(new_dset->ent), H5O_PLINE, 0, H5O_FLAG_CONSTANT, + H5O_modify (&(new_dset->ent), H5O_PLINE, 0, H5O_FLAG_CONSTANT, &(new_dset->create_parms->pline))<0) { - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "unable to update filter header message"); } @@ -1104,7 +1102,7 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type, * Add a modification time message. */ if (H5O_touch(&(new_dset->ent), TRUE)<0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to update modification time message"); } @@ -1113,7 +1111,7 @@ printf("%s: check 0.5\n",FUNC); #endif /* QAK */ /* Give the dataset a name */ if (H5G_insert(loc, name, &(new_dset->ent)) < 0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset"); } /* @@ -1125,12 +1123,12 @@ printf("%s: check 0.5\n",FUNC); printf("%s: check 1.0\n",FUNC); #endif /* QAK */ if (0==efl->nused) { - if (H5F_arr_create(f, &(new_dset->layout)) < 0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, - "unable to initialize storage"); - } + if (H5F_arr_create(f, &(new_dset->layout)) < 0) { + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, + "unable to initialize storage"); + } } else { - new_dset->layout.addr = HADDR_UNDEF; + new_dset->layout.addr = HADDR_UNDEF; } #ifdef QAK @@ -1139,7 +1137,7 @@ printf("%s: check 2.0\n",FUNC); /* Update layout message */ if (H5O_modify (&(new_dset->ent), H5O_LAYOUT, 0, H5O_FLAG_CONSTANT, &(new_dset->layout)) < 0) { - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "unable to update layout message"); } @@ -1148,31 +1146,30 @@ printf("%s: check 3.0\n",FUNC); #endif /* QAK */ /* Update external storage message */ if (efl->nused>0) { - size_t heap_size = H5HL_ALIGN (1); - for (i=0; i<efl->nused; i++) { - heap_size += H5HL_ALIGN (HDstrlen (efl->slot[i].name)+1); - } - if (H5HL_create (f, heap_size, &(efl->heap_addr)/*out*/)<0 || - (size_t)(-1)==H5HL_insert(f, efl->heap_addr, 1, "")) { - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, - "unable to create external file list name heap"); - } - for (i=0; i<efl->nused; i++) { - size_t offset = H5HL_insert(f, efl->heap_addr, - HDstrlen(efl->slot[i].name)+1, - efl->slot[i].name); - assert(0==efl->slot[i].name_offset); - if ((size_t)(-1)==offset) { - HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, NULL, - "unable to insert URL into name heap"); - } - efl->slot[i].name_offset = offset; - } - if (H5O_modify (&(new_dset->ent), H5O_EFL, 0, H5O_FLAG_CONSTANT, - efl)<0) { - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, - "unable to update external file list message"); - } + size_t heap_size = H5HL_ALIGN (1); + + for (i=0; i<efl->nused; i++) { + heap_size += H5HL_ALIGN (HDstrlen (efl->slot[i].name)+1); + } + if (H5HL_create (f, heap_size, &(efl->heap_addr)/*out*/)<0 || + (size_t)(-1)==H5HL_insert(f, efl->heap_addr, 1, "")) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "unable to create external file list name heap"); + } + for (i=0; i<efl->nused; i++) { + size_t offset = H5HL_insert(f, efl->heap_addr, + HDstrlen(efl->slot[i].name)+1, efl->slot[i].name); + assert(0==efl->slot[i].name_offset); + if ((size_t)(-1)==offset) { + HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, NULL, + "unable to insert URL into name heap"); + } + efl->slot[i].name_offset = offset; + } + if (H5O_modify (&(new_dset->ent), H5O_EFL, 0, H5O_FLAG_CONSTANT, efl)<0) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, + "unable to update external file list message"); + } } #ifdef QAK @@ -1180,7 +1177,7 @@ printf("%s: check 4.0\n",FUNC); #endif /* QAK */ /* Initialize the raw data */ if (H5D_init_storage(new_dset, space)<0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize storage"); } @@ -1192,16 +1189,17 @@ printf("%s: check 6.0\n",FUNC); done: if (!ret_value && new_dset) { - if (new_dset->type) H5T_close(new_dset->type); - if (new_dset->create_parms) { - H5P_close (new_dset->create_parms); - new_dset->create_parms = NULL; - } - if (H5F_addr_defined(new_dset->ent.header)) { - H5O_close(&(new_dset->ent)); - } - new_dset->ent.file = NULL; - H5FL_FREE(H5D_t,new_dset); + if (new_dset->type) + H5T_close(new_dset->type); + if (new_dset->create_parms) { + H5P_close (new_dset->create_parms); + new_dset->create_parms = NULL; + } + if (H5F_addr_defined(new_dset->ent.header)) { + H5O_close(&(new_dset->ent)); + } + new_dset->ent.file = NULL; + H5FL_FREE(H5D_t,new_dset); } FUNC_LEAVE(ret_value); } @@ -1331,7 +1329,7 @@ H5D_open_oid(H5G_entry_t *ent) H5D_t *dataset = NULL; /*new dataset struct */ H5D_t *ret_value = NULL; /*return value */ H5S_t *space = NULL; /*data space */ - intn i; + uintn u; FUNC_ENTER(H5D_open_oid, NULL); @@ -1380,8 +1378,7 @@ H5D_open_oid(H5G_entry_t *ent) #ifdef H5_HAVE_PARALLEL /* If MPIO is used, no filter support yet. */ - if (IS_H5FD_MPIO(dataset->ent.file) && - dataset->create_parms->pline.nfilters>0){ + if (IS_H5FD_MPIO(dataset->ent.file) && dataset->create_parms->pline.nfilters>0) { HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, "Parallel IO does not support filters yet"); } @@ -1410,8 +1407,8 @@ H5D_open_oid(H5G_entry_t *ent) */ dataset->create_parms->layout = H5D_CHUNKED; dataset->create_parms->chunk_ndims = dataset->layout.ndims - 1; - for (i = 0; i < dataset->layout.ndims - 1; i++) { - dataset->create_parms->chunk_size[i] = dataset->layout.dim[i]; + for (u = 0; u < dataset->layout.ndims - 1; u++) { + dataset->create_parms->chunk_size[u] = dataset->layout.dim[u]; } break; @@ -1423,7 +1420,7 @@ H5D_open_oid(H5G_entry_t *ent) /* Get the external file list message, which might not exist */ if (NULL==H5O_read (&(dataset->ent), H5O_EFL, 0, &(dataset->create_parms->efl)) && - !H5F_addr_defined (dataset->layout.addr)) { + !H5F_addr_defined (dataset->layout.addr)) { HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "storage address is undefined an no external file list"); } @@ -1434,7 +1431,7 @@ H5D_open_oid(H5G_entry_t *ent) * be fully populated before I/O can happen. */ if ((H5F_get_intent(dataset->ent.file) & H5F_ACC_RDWR) && - H5D_CHUNKED==dataset->layout.type) { + H5D_CHUNKED==dataset->layout.type) { if (H5D_init_storage(dataset, space)<0) { HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize file storage"); @@ -1562,27 +1559,27 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, hid_t dxpl_id, void *buf/*out*/) { const H5D_xfer_t *xfer_parms = NULL; - hssize_t nelmts; /*number of elements */ - size_t smine_start; /*strip mine start loc */ - size_t n, smine_nelmts; /*elements per strip */ + hssize_t nelmts; /*number of elements */ + hsize_t smine_start; /*strip mine start loc */ + hsize_t n, smine_nelmts; /*elements per strip */ uint8_t *tconv_buf = NULL; /*data type conv buffer */ uint8_t *bkg_buf = NULL; /*background buffer */ - H5T_path_t *tpath = NULL; /*type conversion info */ + H5T_path_t *tpath = NULL; /*type conversion info */ hid_t src_id = -1, dst_id = -1;/*temporary type atoms */ - H5S_conv_t *sconv=NULL; /*space conversion funcs*/ - H5S_sel_iter_t mem_iter; /*mem selection iteration info*/ - H5S_sel_iter_t bkg_iter; /*background iteration info*/ - H5S_sel_iter_t file_iter; /*file selection iter info*/ + H5S_conv_t *sconv=NULL; /*space conversion funcs*/ + H5S_sel_iter_t mem_iter; /*mem selection iteration info*/ + H5S_sel_iter_t bkg_iter; /*background iteration info*/ + H5S_sel_iter_t file_iter; /*file selection iter info*/ herr_t ret_value = FAIL; /*return value */ - herr_t status; /*function return status*/ + herr_t status; /*function return status*/ size_t src_type_size; /*size of source type */ - size_t dst_type_size; /*size of destination type*/ - size_t target_size; /*desired buffer size */ - size_t request_nelmts; /*requested strip mine */ - size_t min_elem_out=1;/*Minimum # of elements to output*/ - H5T_bkg_t need_bkg; /*type of background buf*/ - H5S_t *free_this_space=NULL; /*data space to free */ - hbool_t must_convert; /*have to xfer the slow way*/ + size_t dst_type_size; /*size of destination type*/ + hsize_t target_size; /*desired buffer size */ + hsize_t request_nelmts; /*requested strip mine */ + size_t min_elem_out=1; /*Minimum # of elements to output*/ + H5T_bkg_t need_bkg; /*type of background buf*/ + H5S_t *free_this_space=NULL; /*data space to free */ + hbool_t must_convert; /*have to xfer the slow way*/ #ifdef H5_HAVE_PARALLEL H5FD_mpio_dxpl_t *dx = NULL; H5FD_mpio_xfer_t xfer_mode; /*xfer_mode for this request */ @@ -1620,7 +1617,8 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, } file_space = free_this_space; } - if (!mem_space) mem_space = file_space; + if (!mem_space) + mem_space = file_space; nelmts = H5S_get_select_npoints(mem_space); #ifdef H5_HAVE_PARALLEL @@ -1826,14 +1824,11 @@ printf("%s: check 2.0, src_type_size=%d, dst_type_size=%d, target_size=%d, min_e #endif /* Start strip mining... */ - assert(nelmts==(hssize_t)((size_t)nelmts)); /*check for overflow*/ - for (smine_start=0; - smine_start<(size_t)nelmts; - smine_start+=smine_nelmts) { + H5_CHECK_OVERFLOW(nelmts,hssize_t,hsize_t); + for (smine_start=0; smine_start<(hsize_t)nelmts; smine_start+=smine_nelmts) { /* Go figure out how many elements to read from the file */ smine_nelmts = (sconv->f->avail)(file_space,&file_iter, - MIN(request_nelmts, - (nelmts-smine_start))); + MIN(request_nelmts, (nelmts-smine_start))); #ifdef QAK printf("%s: check 5.0, nelmts=%d, smine_start=%d, smine_nelmts=%d\n", FUNC,(int)nelmts,(int)smine_start,(int)smine_nelmts); @@ -1881,21 +1876,22 @@ printf("%s: check 2.0, src_type_size=%d, dst_type_size=%d, target_size=%d, min_e if (H5T_BKG_YES==need_bkg) { #ifdef H5S_DEBUG - H5_timer_begin(&timer); + H5_timer_begin(&timer); #endif n = (sconv->m->gath)(buf, dst_type_size, mem_space, &bkg_iter, smine_nelmts, bkg_buf/*out*/); #ifdef H5S_DEBUG - H5_timer_end(&(sconv->stats[1].bkg_timer), &timer); - sconv->stats[1].bkg_nbytes += n * dst_type_size; - sconv->stats[1].bkg_ncalls++; + H5_timer_end(&(sconv->stats[1].bkg_timer), &timer); + sconv->stats[1].bkg_nbytes += n * dst_type_size; + sconv->stats[1].bkg_ncalls++; #endif - if (n!=smine_nelmts) { + if (n!=smine_nelmts) { HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "mem gather failed"); } } else if (need_bkg) { - HDmemset(bkg_buf, 0, request_nelmts*dst_type_size); - } + assert((request_nelmts*dst_type_size)==(hsize_t)((size_t)(request_nelmts*dst_type_size))); /*check for overflow*/ + HDmemset(bkg_buf, 0, (size_t)(request_nelmts*dst_type_size)); + } #ifdef QAK printf("%s: check 7.0\n",FUNC); @@ -1904,8 +1900,8 @@ printf("%s: check 2.0, src_type_size=%d, dst_type_size=%d, target_size=%d, min_e /* * Perform data type conversion. */ - if (H5T_convert(tpath, src_id, dst_id, smine_nelmts, 0, 0, tconv_buf, - bkg_buf, dxpl_id)<0) { + if (H5T_convert(tpath, src_id, dst_id, smine_nelmts, 0, 0, tconv_buf, + bkg_buf, dxpl_id)<0) { HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data type conversion failed"); } @@ -2006,27 +2002,27 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, hid_t dxpl_id, const void *buf) { const H5D_xfer_t *xfer_parms = NULL; - hssize_t nelmts; /*total number of elmts */ - size_t smine_start; /*strip mine start loc */ - size_t n, smine_nelmts; /*elements per strip */ + hssize_t nelmts; /*total number of elmts */ + hsize_t smine_start; /*strip mine start loc */ + hsize_t n, smine_nelmts; /*elements per strip */ uint8_t *tconv_buf = NULL; /*data type conv buffer */ uint8_t *bkg_buf = NULL; /*background buffer */ - H5T_path_t *tpath = NULL; /*type conversion info */ + H5T_path_t *tpath = NULL; /*type conversion info */ hid_t src_id = -1, dst_id = -1;/*temporary type atoms */ - H5S_conv_t *sconv=NULL; /*space conversion funcs*/ - H5S_sel_iter_t mem_iter; /*memory selection iteration info*/ - H5S_sel_iter_t bkg_iter; /*background iteration info*/ - H5S_sel_iter_t file_iter; /*file selection iteration info*/ + H5S_conv_t *sconv=NULL; /*space conversion funcs*/ + H5S_sel_iter_t mem_iter; /*memory selection iteration info*/ + H5S_sel_iter_t bkg_iter; /*background iteration info*/ + H5S_sel_iter_t file_iter; /*file selection iteration info*/ herr_t ret_value = FAIL; /*return value */ - herr_t status; /*function return status*/ + herr_t status; /*function return status*/ size_t src_type_size; /*size of source type */ - size_t dst_type_size; /*size of destination type*/ - size_t target_size; /*desired buffer size */ - size_t request_nelmts; /*requested strip mine */ - size_t min_elem_out=1;/*Minimum # of elements to output*/ - H5T_bkg_t need_bkg; /*type of background buf*/ + size_t dst_type_size; /*size of destination type*/ + hsize_t target_size; /*desired buffer size */ + hsize_t request_nelmts; /*requested strip mine */ + size_t min_elem_out=1; /*Minimum # of elements to output*/ + H5T_bkg_t need_bkg; /*type of background buf*/ H5S_t *free_this_space=NULL; /*data space to free */ - hbool_t must_convert; /*have to xfer the slow way*/ + hbool_t must_convert; /*have to xfer the slow way*/ #ifdef H5_HAVE_PARALLEL H5FD_mpio_dxpl_t *dx = NULL; H5FD_mpio_xfer_t xfer_mode; /*xfer_mode for this request */ @@ -2294,14 +2290,11 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, #endif /* Start strip mining... */ - assert(nelmts==(hssize_t)((size_t)nelmts)); /*check for overflow*/ - for (smine_start=0; - smine_start<(size_t)nelmts; - smine_start+=smine_nelmts) { + H5_CHECK_OVERFLOW(nelmts,hssize_t,hsize_t); + for (smine_start=0; smine_start<(hsize_t)nelmts; smine_start+=smine_nelmts) { /* Go figure out how many elements to read from the file */ smine_nelmts = (sconv->f->avail)(file_space,&file_iter, - MIN(request_nelmts, - (nelmts-smine_start))); + MIN(request_nelmts, (nelmts-smine_start))); #ifdef QAK printf("%s: check 5.0, nelmts=%d, smine_start=%d, smine_nelmts=%d\n", @@ -2370,7 +2363,8 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, #ifdef QAK printf("%s: check 6.2, need_bkg=%d\n",FUNC,(int)need_bkg); #endif - HDmemset(bkg_buf, 0, request_nelmts*dst_type_size); + H5_CHECK_OVERFLOW(request_nelmts*dst_type_size,hsize_t,size_t); + HDmemset(bkg_buf, 0, (size_t)(request_nelmts*dst_type_size)); } /* @@ -2634,8 +2628,8 @@ H5D_get_file (const H5D_t *dset) static herr_t H5D_init_storage(H5D_t *dset, const H5S_t *space) { - hssize_t npoints, ptsperbuf; - size_t size, bufsize=8*1024; + hssize_t npoints, ptsperbuf; + hsize_t size, bufsize=8*1024; haddr_t addr; herr_t ret_value = FAIL; void *buf = NULL; @@ -2645,93 +2639,93 @@ H5D_init_storage(H5D_t *dset, const H5S_t *space) assert(space); switch (dset->layout.type) { - case H5D_CONTIGUOUS: - /* - * If the fill value is set then write it to the specified selection - * even if it is all zero. This allows the application to force - * filling when the underlying storage isn't initialized to zero. - */ - npoints = H5S_get_simple_extent_npoints(space); - if (dset->create_parms->fill.buf && - npoints==H5S_get_select_npoints(space)) { - /* - * Fill the entire current extent with the fill value. We can do - * this quite efficiently by making sure we copy the fill value - * in relatively large pieces. - */ - ptsperbuf = (hssize_t)MAX(1, - bufsize/dset->create_parms->fill.size); - bufsize = ptsperbuf * dset->create_parms->fill.size; - - /* Allocate temporary buffer */ - if ((buf=H5FL_BLK_ALLOC(fill_conv,bufsize,0))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for fill buffer"); - - H5V_array_fill(buf, dset->create_parms->fill.buf, - dset->create_parms->fill.size, ptsperbuf); - if (dset->create_parms->efl.nused) { - addr = 0; - } else { - addr = dset->layout.addr; - } - - while (npoints>0) { - size = MIN(ptsperbuf, npoints) * dset->create_parms->fill.size; - if (dset->create_parms->efl.nused) { - if (H5O_efl_write(dset->ent.file, - &(dset->create_parms->efl), - addr, size, buf)<0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to write fill value to dataset"); - } - } else { - if (H5F_block_write(dset->ent.file, H5FD_MEM_DRAW, addr, size, - H5P_DEFAULT, buf)<0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to write fill value to dataset"); - } - } - npoints -= MIN(ptsperbuf, npoints); - addr += size; - } - } else if (dset->create_parms->fill.buf) { - /* - * Fill the specified selection with the fill value. - */ - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, - "unable to initialize dataset with fill value"); - } - break; + case H5D_CONTIGUOUS: + /* + * If the fill value is set then write it to the specified selection + * even if it is all zero. This allows the application to force + * filling when the underlying storage isn't initialized to zero. + */ + npoints = H5S_get_simple_extent_npoints(space); + if (dset->create_parms->fill.buf && + npoints==H5S_get_select_npoints(space)) { + /* + * Fill the entire current extent with the fill value. We can do + * this quite efficiently by making sure we copy the fill value + * in relatively large pieces. + */ + ptsperbuf = (hssize_t)MAX(1, + bufsize/dset->create_parms->fill.size); + bufsize = ptsperbuf * dset->create_parms->fill.size; + + /* Allocate temporary buffer */ + if ((buf=H5FL_BLK_ALLOC(fill_conv,bufsize,0))==NULL) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for fill buffer"); + + assert(ptsperbuf==(hssize_t)((size_t)ptsperbuf)); /*check for overflow*/ + H5V_array_fill(buf, dset->create_parms->fill.buf, + dset->create_parms->fill.size, (size_t)ptsperbuf); + if (dset->create_parms->efl.nused) { + addr = 0; + } else { + addr = dset->layout.addr; + } + + while (npoints>0) { + size = MIN(ptsperbuf, npoints) * dset->create_parms->fill.size; + if (dset->create_parms->efl.nused) { + if (H5O_efl_write(dset->ent.file, + &(dset->create_parms->efl), addr, size, buf)<0) { + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to write fill value to dataset"); + } + } else { + if (H5F_block_write(dset->ent.file, H5FD_MEM_DRAW, addr, + size, H5P_DEFAULT, buf)<0) { + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to write fill value to dataset"); + } + } + npoints -= MIN(ptsperbuf, npoints); + addr += size; + } + } else if (dset->create_parms->fill.buf) { + /* + * Fill the specified selection with the fill value. + */ + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "unable to initialize dataset with fill value"); + } + break; - case H5D_CHUNKED: + case H5D_CHUNKED: #ifdef H5_HAVE_PARALLEL - /* - * If the dataset is accessed via parallel I/O, allocate file space - * for all chunks now and initialize each chunk with the fill value. - */ - if (IS_H5FD_MPIO(dset->ent.file)) { - /* We only handle simple data spaces so far */ - intn ndims; - hsize_t dim[H5O_LAYOUT_NDIMS]; - - if ((ndims=H5S_get_simple_extent_dims(space, dim, NULL))<0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to get simple data space info"); - } - dim[ndims] = dset->layout.dim[ndims]; - ndims++; - - if (H5F_istore_allocate(dset->ent.file, H5P_DEFAULT, - &(dset->layout), dim, - &(dset->create_parms->pline), - &(dset->create_parms->fill))<0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to allocate all chunks of dataset"); - } - } + /* + * If the dataset is accessed via parallel I/O, allocate file space + * for all chunks now and initialize each chunk with the fill value. + */ + if (IS_H5FD_MPIO(dset->ent.file)) { + /* We only handle simple data spaces so far */ + intn ndims; + hsize_t dim[H5O_LAYOUT_NDIMS]; + + if ((ndims=H5S_get_simple_extent_dims(space, dim, NULL))<0) { + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to get simple data space info"); + } + dim[ndims] = dset->layout.dim[ndims]; + ndims++; + + if (H5F_istore_allocate(dset->ent.file, H5P_DEFAULT, + &(dset->layout), dim, + &(dset->create_parms->pline), + &(dset->create_parms->fill))<0) { + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to allocate all chunks of dataset"); + } + } #endif /*H5_HAVE_PARALLEL*/ - break; + break; } ret_value = SUCCEED; @@ -2802,17 +2796,17 @@ hsize_t H5D_get_storage_size(H5D_t *dset) { hsize_t size; - int i; + uintn u; FUNC_ENTER(H5D_get_storage_size, 0); if (H5D_CHUNKED==dset->layout.type) { - size = H5F_istore_allocated(dset->ent.file, dset->layout.ndims, + size = H5F_istore_allocated(dset->ent.file, dset->layout.ndims, dset->layout.addr); } else { - for (i=0, size=1; i<dset->layout.ndims; i++) { - size *= dset->layout.dim[i]; - } + for (u=0, size=1; u<dset->layout.ndims; u++) { + size *= dset->layout.dim[u]; + } } FUNC_LEAVE(size); @@ -2980,7 +2974,7 @@ void *H5D_vlen_get_buf_size_alloc(size_t size, void *info) FUNC_ENTER(H5D_vlen_get_buf_size_alloc, NULL); /* Get a temporary pointer to space for the VL data */ - if ((vlen_bufsize->vl_tbuf=H5FL_BLK_REALLOC(vlen_vl_buf,vlen_bufsize->vl_tbuf,size))!=NULL) + if ((vlen_bufsize->vl_tbuf=H5FL_BLK_REALLOC(vlen_vl_buf,vlen_bufsize->vl_tbuf,(hsize_t)size))!=NULL) vlen_bufsize->size+=size; FUNC_LEAVE(vlen_bufsize->vl_tbuf); @@ -3031,7 +3025,7 @@ H5D_vlen_get_buf_size(void UNUSED *elem, hid_t type_id, hsize_t UNUSED ndim, hss HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* Make certain there is enough fixed-length buffer available */ - if ((vlen_bufsize->fl_tbuf=H5FL_BLK_REALLOC(vlen_fl_buf,vlen_bufsize->fl_tbuf,H5T_get_size(dt)))==NULL) + if ((vlen_bufsize->fl_tbuf=H5FL_BLK_REALLOC(vlen_fl_buf,vlen_bufsize->fl_tbuf,(hsize_t)H5T_get_size(dt)))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't resize tbuf"); /* Select point to read in */ @@ -3107,9 +3101,9 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't create dataspace"); /* Grab the temporary buffers required */ - if((vlen_bufsize.fl_tbuf=H5FL_BLK_ALLOC(vlen_fl_buf,1,0))==NULL) + if((vlen_bufsize.fl_tbuf=H5FL_BLK_ALLOC(vlen_fl_buf,(hsize_t)1,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available"); - if((vlen_bufsize.vl_tbuf=H5FL_BLK_ALLOC(vlen_vl_buf,1,0))==NULL) + if((vlen_bufsize.vl_tbuf=H5FL_BLK_ALLOC(vlen_vl_buf,(hsize_t)1,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available"); /* Change to the custom memory allocation routines for reading VL data */ diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 14fdda7..b1dad47 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -151,7 +151,8 @@ H5F_contig_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hid_t dxp } /* end if */ else { /* Allocate room for the data sieve buffer */ - if (NULL==(f->shared->sieve_buf=H5MM_malloc(f->shared->sieve_buf_size))) { + assert(f->shared->sieve_buf_size==(hsize_t)((size_t)f->shared->sieve_buf_size)); /*check for overflow*/ + if (NULL==(f->shared->sieve_buf=H5MM_malloc((size_t)f->shared->sieve_buf_size))) { HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } @@ -325,7 +326,8 @@ H5F_contig_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, } /* end if */ else { /* Allocate room for the data sieve buffer */ - if (NULL==(f->shared->sieve_buf=H5MM_malloc(f->shared->sieve_buf_size))) { + assert(f->shared->sieve_buf_size==(hsize_t)((size_t)f->shared->sieve_buf_size)); /*check for overflow*/ + if (NULL==(f->shared->sieve_buf=H5MM_malloc((size_t)f->shared->sieve_buf_size))) { HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } diff --git a/src/H5Distore.c b/src/H5Distore.c index 8c4d816..8b98743 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -153,10 +153,10 @@ typedef struct H5F_istore_key_t { } H5F_istore_key_t; typedef struct H5F_istore_ud1_t { - H5F_istore_key_t key; /*key values */ + H5F_istore_key_t key; /*key values */ haddr_t addr; /*file address of chunk */ - H5O_layout_t mesg; /*layout message */ - hsize_t total_storage; /*output from iterator */ + H5O_layout_t mesg; /*layout message */ + hsize_t total_storage; /*output from iterator */ FILE *stream; /*debug output stream */ } H5F_istore_ud1_t; @@ -220,7 +220,7 @@ H5F_istore_chunk_alloc(size_t chunk_size) FUNC_ENTER(H5F_istore_chunk_alloc, NULL); - ret_value=H5FL_BLK_ALLOC(istore_chunk,chunk_size,0); + ret_value=H5FL_BLK_ALLOC(istore_chunk,(hsize_t)chunk_size,0); FUNC_LEAVE(ret_value); } /* end H5F_istore_chunk_alloc() */ @@ -280,7 +280,7 @@ H5F_istore_chunk_realloc(void *chunk, size_t new_size) FUNC_ENTER(H5F_istore_chunk_realloc, NULL); - ret_value=H5FL_BLK_REALLOC(istore_chunk,chunk,new_size); + ret_value=H5FL_BLK_REALLOC(istore_chunk,chunk,(hsize_t)new_size); FUNC_LEAVE(ret_value); } /* end H5F_istore_chunk_realloc() */ @@ -424,7 +424,7 @@ H5F_istore_debug_key (FILE *stream, intn indent, intn fwidth, { const H5F_istore_key_t *key = (const H5F_istore_key_t *)_key; const H5F_istore_ud1_t *udata = (const H5F_istore_ud1_t *)_udata; - int i; + uintn u; FUNC_ENTER (H5F_istore_debug_key, FAIL); assert (key); @@ -435,8 +435,8 @@ H5F_istore_debug_key (FILE *stream, intn indent, intn fwidth, "Filter mask:", key->filter_mask); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:"); - for (i=0; i<udata->mesg.ndims; i++) { - HDfprintf (stream, "%s%Hd", i?", ":"", key->offset[i]); + for (u=0; u<udata->mesg.ndims; u++) { + HDfprintf (stream, "%s%Hd", u?", ":"", key->offset[u]); } HDfputs ("}\n", stream); @@ -572,7 +572,7 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op, H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key; H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key; H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata; - intn i; + uintn u; FUNC_ENTER(H5F_istore_new_node, FAIL); #ifdef AKC @@ -591,9 +591,8 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op, #ifdef AKC printf("calling H5MF_alloc for new chunk\n"); #endif - if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_DRAW, - udata->key.nbytes))) { - HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL, + if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)udata->key.nbytes))) { + HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "couldn't allocate new file storage"); } udata->addr = *addr_p; @@ -604,8 +603,8 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op, */ lt_key->nbytes = udata->key.nbytes; lt_key->filter_mask = udata->key.filter_mask; - for (i=0; i<udata->mesg.ndims; i++) { - lt_key->offset[i] = udata->key.offset[i]; + for (u=0; u<udata->mesg.ndims; u++) { + lt_key->offset[u] = udata->key.offset[u]; } /* @@ -613,15 +612,15 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op, * chunk. */ if (H5B_INS_LEFT != op) { - rt_key->nbytes = 0; - rt_key->filter_mask = 0; - for (i=0; i<udata->mesg.ndims; i++) { - assert (udata->mesg.dim[i] < HSSIZET_MAX); - assert (udata->key.offset[i]+(hssize_t)(udata->mesg.dim[i]) > - udata->key.offset[i]); - rt_key->offset[i] = udata->key.offset[i] + - (hssize_t)(udata->mesg.dim[i]); - } + rt_key->nbytes = 0; + rt_key->filter_mask = 0; + for (u=0; u<udata->mesg.ndims; u++) { + assert (udata->mesg.dim[u] < HSSIZET_MAX); + assert (udata->key.offset[u]+(hssize_t)(udata->mesg.dim[u]) > + udata->key.offset[u]); + rt_key->offset[u] = udata->key.offset[u] + + (hssize_t)(udata->mesg.dim[u]); + } } FUNC_LEAVE(SUCCEED); @@ -661,7 +660,7 @@ H5F_istore_found(H5F_t UNUSED *f, haddr_t addr, const void *_lt_key, { H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata; const H5F_istore_key_t *lt_key = (const H5F_istore_key_t *) _lt_key; - int i; + uintn u; FUNC_ENTER(H5F_istore_found, FAIL); @@ -672,11 +671,10 @@ H5F_istore_found(H5F_t UNUSED *f, haddr_t addr, const void *_lt_key, assert(lt_key); /* Is this *really* the requested chunk? */ - for (i=0; i<udata->mesg.ndims; i++) { - if (udata->key.offset[i] >= - lt_key->offset[i]+(hssize_t)(udata->mesg.dim[i])) { - HRETURN(FAIL); - } + for (u=0; u<udata->mesg.ndims; u++) { + if (udata->key.offset[u] >= lt_key->offset[u]+(hssize_t)(udata->mesg.dim[u])) { + HRETURN(FAIL); + } } /* Initialize return values */ @@ -684,8 +682,8 @@ H5F_istore_found(H5F_t UNUSED *f, haddr_t addr, const void *_lt_key, udata->key.nbytes = lt_key->nbytes; udata->key.filter_mask = lt_key->filter_mask; assert (lt_key->nbytes>0); - for (i = 0; i < udata->mesg.ndims; i++) { - udata->key.offset[i] = lt_key->offset[i]; + for (u = 0; u < udata->mesg.ndims; u++) { + udata->key.offset[u] = lt_key->offset[u]; } FUNC_LEAVE(SUCCEED); @@ -735,7 +733,8 @@ H5F_istore_insert(H5F_t *f, haddr_t addr, void *_lt_key, H5F_istore_key_t *md_key = (H5F_istore_key_t *) _md_key; H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key; H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata; - intn i, cmp; + intn cmp; + uintn u; H5B_ins_t ret_value = H5B_INS_ERROR; FUNC_ENTER(H5F_istore_insert, H5B_INS_ERROR); @@ -758,72 +757,72 @@ H5F_istore_insert(H5F_t *f, haddr_t addr, void *_lt_key, assert(cmp <= 0); if (cmp < 0) { - /* Negative indices not supported yet */ - assert("HDF5 INTERNAL ERROR -- see rpm" && 0); - HRETURN_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, + /* Negative indices not supported yet */ + assert("HDF5 INTERNAL ERROR -- see rpm" && 0); + HRETURN_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error"); } else if (H5V_vector_eq_s (udata->mesg.ndims, udata->key.offset, lt_key->offset) && lt_key->nbytes>0) { - /* - * Already exists. If the new size is not the same as the old size - * then we should reallocate storage. - */ - if (lt_key->nbytes != udata->key.nbytes) { + /* + * Already exists. If the new size is not the same as the old size + * then we should reallocate storage. + */ + if (lt_key->nbytes != udata->key.nbytes) { #ifdef AKC - printf("calling H5MF_realloc for new chunk\n"); + printf("calling H5MF_realloc for new chunk\n"); #endif - if (HADDR_UNDEF==(*new_node_p=H5MF_realloc(f, H5FD_MEM_DRAW, addr, - lt_key->nbytes, - udata->key.nbytes))) { - HRETURN_ERROR (H5E_STORAGE, H5E_WRITEERROR, H5B_INS_ERROR, - "unable to reallocate chunk storage"); - } - lt_key->nbytes = udata->key.nbytes; - lt_key->filter_mask = udata->key.filter_mask; - *lt_key_changed = TRUE; - udata->addr = *new_node_p; - ret_value = H5B_INS_CHANGE; - } else { - udata->addr = addr; - ret_value = H5B_INS_NOOP; - } + if (HADDR_UNDEF==(*new_node_p=H5MF_realloc(f, H5FD_MEM_DRAW, addr, + (hsize_t)lt_key->nbytes, + (hsize_t)udata->key.nbytes))) { + HRETURN_ERROR (H5E_STORAGE, H5E_WRITEERROR, H5B_INS_ERROR, + "unable to reallocate chunk storage"); + } + lt_key->nbytes = udata->key.nbytes; + lt_key->filter_mask = udata->key.filter_mask; + *lt_key_changed = TRUE; + udata->addr = *new_node_p; + ret_value = H5B_INS_CHANGE; + } else { + udata->addr = addr; + ret_value = H5B_INS_NOOP; + } } else if (H5V_hyper_disjointp(udata->mesg.ndims, lt_key->offset, udata->mesg.dim, udata->key.offset, udata->mesg.dim)) { - assert(H5V_hyper_disjointp(udata->mesg.ndims, + assert(H5V_hyper_disjointp(udata->mesg.ndims, rt_key->offset, udata->mesg.dim, udata->key.offset, udata->mesg.dim)); - /* - * Split this node, inserting the new new node to the right of the - * current node. The MD_KEY is where the split occurs. - */ - md_key->nbytes = udata->key.nbytes; - md_key->filter_mask = udata->key.filter_mask; - for (i=0; i<udata->mesg.ndims; i++) { - assert(0 == udata->key.offset[i] % udata->mesg.dim[i]); - md_key->offset[i] = udata->key.offset[i]; - } - - /* - * Allocate storage for the new chunk - */ + /* + * Split this node, inserting the new new node to the right of the + * current node. The MD_KEY is where the split occurs. + */ + md_key->nbytes = udata->key.nbytes; + md_key->filter_mask = udata->key.filter_mask; + for (u=0; u<udata->mesg.ndims; u++) { + assert(0 == udata->key.offset[u] % udata->mesg.dim[u]); + md_key->offset[u] = udata->key.offset[u]; + } + + /* + * Allocate storage for the new chunk + */ #ifdef AKC - printf("calling H5MF_alloc for new chunk\n"); + printf("calling H5MF_alloc for new chunk\n"); #endif - if (HADDR_UNDEF==(*new_node_p=H5MF_alloc(f, H5FD_MEM_DRAW, - udata->key.nbytes))) { - HRETURN_ERROR(H5E_IO, H5E_CANTINIT, H5B_INS_ERROR, - "file allocation failed"); - } - udata->addr = *new_node_p; - ret_value = H5B_INS_RIGHT; + if (HADDR_UNDEF==(*new_node_p=H5MF_alloc(f, H5FD_MEM_DRAW, + (hsize_t)udata->key.nbytes))) { + HRETURN_ERROR(H5E_IO, H5E_CANTINIT, H5B_INS_ERROR, + "file allocation failed"); + } + udata->addr = *new_node_p; + ret_value = H5B_INS_RIGHT; } else { - assert("HDF5 INTERNAL ERROR -- see rpm" && 0); - HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR, + assert("HDF5 INTERNAL ERROR -- see rpm" && 0); + HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error"); } @@ -856,25 +855,25 @@ H5F_istore_iterate (H5F_t UNUSED *f, void *_lt_key, haddr_t UNUSED addr, { H5F_istore_ud1_t *bt_udata = (H5F_istore_ud1_t *)_udata; H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key; - int i; + uintn u; FUNC_ENTER(H5F_istore_iterate, FAIL); if (bt_udata->stream) { - if (0==bt_udata->total_storage) { - fprintf(bt_udata->stream, " Address:\n"); - fprintf(bt_udata->stream, - " Flags Bytes Address Logical Offset\n"); - fprintf(bt_udata->stream, - " ========== ======== ========== " - "==============================\n"); - } - HDfprintf(bt_udata->stream, " 0x%08x %8Zu %10a [", - lt_key->filter_mask, lt_key->nbytes, addr); - for (i=0; i<bt_udata->mesg.ndims; i++) { - HDfprintf(bt_udata->stream, "%s%Hd", i?", ":"", lt_key->offset[i]); - } - fputs("]\n", bt_udata->stream); + if (0==bt_udata->total_storage) { + fprintf(bt_udata->stream, " Address:\n"); + fprintf(bt_udata->stream, + " Flags Bytes Address Logical Offset\n"); + fprintf(bt_udata->stream, + " ========== ======== ========== " + "==============================\n"); + } + HDfprintf(bt_udata->stream, " 0x%08x %8Zu %10a [", + lt_key->filter_mask, lt_key->nbytes, addr); + for (u=0; u<bt_udata->mesg.ndims; u++) { + HDfprintf(bt_udata->stream, "%s%Hd", u?", ":"", lt_key->offset[u]); + } + fputs("]\n", bt_udata->stream); } bt_udata->total_storage += lt_key->nbytes; @@ -907,7 +906,8 @@ H5F_istore_init (H5F_t *f) HDmemset (rdcc, 0, sizeof(H5F_rdcc_t)); if (f->shared->rdcc_nbytes>0 && f->shared->rdcc_nelmts>0) { rdcc->nslots = f->shared->rdcc_nelmts; - rdcc->slot = H5FL_ARR_ALLOC (H5F_rdcc_ent_ptr_t,rdcc->nslots,1); + assert(rdcc->nslots>=0); + rdcc->slot = H5FL_ARR_ALLOC (H5F_rdcc_ent_ptr_t,(hsize_t)rdcc->nslots,1); if (NULL==rdcc->slot) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); @@ -940,7 +940,7 @@ H5F_istore_flush_entry(H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t reset) { herr_t ret_value=FAIL; /*return value */ H5F_istore_ud1_t udata; /*pass through B-tree */ - intn i; /*counters */ + uintn u; /*counters */ void *buf=NULL; /*temporary buffer */ size_t alloc; /*bytes allocated for BUF */ hbool_t point_of_no_return = FALSE; @@ -952,82 +952,83 @@ H5F_istore_flush_entry(H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t reset) buf = ent->chunk; if (ent->dirty) { - udata.mesg = *(ent->layout); - udata.key.filter_mask = 0; - udata.addr = HADDR_UNDEF; - udata.key.nbytes = ent->chunk_size; - for (i=0; i<ent->layout->ndims; i++) { - udata.key.offset[i] = ent->offset[i]; - } - alloc = ent->alloc_size; - - /* Should the chunk be filtered before writing it to disk? */ - if (ent->pline && ent->pline->nfilters) { - if (!reset) { - /* - * Copy the chunk to a new buffer before running it through - * the pipeline because we'll want to save the original buffer - * for later. - */ - alloc = ent->chunk_size; - if (NULL==(buf = H5F_istore_chunk_alloc(alloc))) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for pipeline"); - } - HDmemcpy(buf, ent->chunk, ent->chunk_size); - } else { - /* - * If we are reseting and something goes wrong after this - * point then it's too late to recover because we may have - * destroyed the original data by calling H5Z_pipeline(). - * The only safe option is to continue with the reset - * even if we can't write the data to disk. - */ - point_of_no_return = TRUE; - ent->chunk = NULL; - } - if (H5Z_pipeline(f, ent->pline, 0, &(udata.key.filter_mask), - &(udata.key.nbytes), &alloc, &buf)<0) { - HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, - "output pipeline failed"); - } - } - - /* - * Create the chunk it if it doesn't exist, or reallocate the chunk if - * its size changed. Then write the data into the file. - */ - if (H5B_insert(f, H5B_ISTORE, ent->layout->addr, ent->split_ratios, - &udata)<0) { - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "unable to allocate chunk"); - } - if (H5F_block_write(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, H5P_DEFAULT, - buf)<0) { - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "unable to write raw data to file"); - } - - /* Mark cache entry as clean */ - ent->dirty = FALSE; - f->shared->rdcc.nflushes++; + udata.mesg = *(ent->layout); + udata.key.filter_mask = 0; + udata.addr = HADDR_UNDEF; + udata.key.nbytes = ent->chunk_size; + for (u=0; u<ent->layout->ndims; u++) { + udata.key.offset[u] = ent->offset[u]; + } + alloc = ent->alloc_size; + + /* Should the chunk be filtered before writing it to disk? */ + if (ent->pline && ent->pline->nfilters) { + if (!reset) { + /* + * Copy the chunk to a new buffer before running it through + * the pipeline because we'll want to save the original buffer + * for later. + */ + alloc = ent->chunk_size; + if (NULL==(buf = H5F_istore_chunk_alloc(alloc))) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for pipeline"); + } + HDmemcpy(buf, ent->chunk, ent->chunk_size); + } else { + /* + * If we are reseting and something goes wrong after this + * point then it's too late to recover because we may have + * destroyed the original data by calling H5Z_pipeline(). + * The only safe option is to continue with the reset + * even if we can't write the data to disk. + */ + point_of_no_return = TRUE; + ent->chunk = NULL; + } + if (H5Z_pipeline(f, ent->pline, 0, &(udata.key.filter_mask), + &(udata.key.nbytes), &alloc, &buf)<0) { + HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, + "output pipeline failed"); + } + } + + /* + * Create the chunk it if it doesn't exist, or reallocate the chunk if + * its size changed. Then write the data into the file. + */ + if (H5B_insert(f, H5B_ISTORE, ent->layout->addr, ent->split_ratios, + &udata)<0) { + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "unable to allocate chunk"); + } + if (H5F_block_write(f, H5FD_MEM_DRAW, udata.addr, (hsize_t)udata.key.nbytes, H5P_DEFAULT, + buf)<0) { + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "unable to write raw data to file"); + } + + /* Mark cache entry as clean */ + ent->dirty = FALSE; + f->shared->rdcc.nflushes++; } /* Reset, but do not free or removed from list */ if (reset) { - point_of_no_return = FALSE; - ent->layout = H5O_free(H5O_LAYOUT, ent->layout); - ent->pline = H5O_free(H5O_PLINE, ent->pline); - if (buf==ent->chunk) buf = NULL; - if(ent->chunk!=NULL) - ent->chunk = H5F_istore_chunk_free(ent->chunk); + point_of_no_return = FALSE; + ent->layout = H5O_free(H5O_LAYOUT, ent->layout); + ent->pline = H5O_free(H5O_PLINE, ent->pline); + if (buf==ent->chunk) buf = NULL; + if(ent->chunk!=NULL) + ent->chunk = H5F_istore_chunk_free(ent->chunk); } ret_value = SUCCEED; - done: +done: /* Free the temp buffer only if it's different than the entry chunk */ - if (buf!=ent->chunk) H5F_istore_chunk_free(buf); + if (buf!=ent->chunk) + H5F_istore_chunk_free(buf); /* * If we reached the point of no return then we have no choice but to @@ -1036,10 +1037,10 @@ H5F_istore_flush_entry(H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t reset) * list. */ if (ret_value<0 && point_of_no_return) { - ent->layout = H5O_free(H5O_LAYOUT, ent->layout); - ent->pline = H5O_free(H5O_PLINE, ent->pline); - if(ent->chunk) - ent->chunk = H5F_istore_chunk_free(ent->chunk); + ent->layout = H5O_free(H5O_LAYOUT, ent->layout); + ent->pline = H5O_free(H5O_PLINE, ent->pline); + if(ent->chunk) + ent->chunk = H5F_istore_chunk_free(ent->chunk); } FUNC_LEAVE(ret_value); } @@ -1336,11 +1337,12 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, const hssize_t offset[], hbool_t relax, intn *idx_hint/*in,out*/) { - uintn idx=0; /*hash index number */ + intn idx=0; /*hash index number */ + uintn temp_idx=0; /* temporary index number */ hbool_t found = FALSE; /*already in cache? */ H5F_rdcc_t *rdcc = &(f->shared->rdcc);/*raw data chunk cache*/ H5F_rdcc_ent_t *ent = NULL; /*cache entry */ - intn i; /*counters */ + uintn u; /*counters */ H5F_istore_ud1_t udata; /*B-tree pass-through */ size_t chunk_size=0; /*size of a chunk */ size_t chunk_alloc=0; /*allocated chunk size */ @@ -1351,230 +1353,228 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, FUNC_ENTER (H5F_istore_lock, NULL); if (rdcc->nslots>0) { - /* We don't care about loss of precision in the following statement. */ - for (i=0, idx=0; i<layout->ndims; i++) { - idx *= layout->dim[i]; - idx += offset[i]; - } - idx += (uintn)(layout->addr); - idx=H5F_HASH(f,idx); - ent = rdcc->slot[idx]; - - if (ent && - layout->ndims==ent->layout->ndims && - H5F_addr_eq(layout->addr, ent->layout->addr)) { - for (i=0, found=TRUE; i<ent->layout->ndims; i++) { - if (offset[i]!=ent->offset[i]) { - found = FALSE; - break; - } - } - } + /* We don't care about loss of precision in the following statement. */ + for (u=0, temp_idx=0; u<layout->ndims; u++) { + temp_idx *= layout->dim[u]; + temp_idx += offset[u]; + } + temp_idx += (uintn)(layout->addr); + idx=H5F_HASH(f,temp_idx); + ent = rdcc->slot[idx]; + + if (ent && layout->ndims==ent->layout->ndims && + H5F_addr_eq(layout->addr, ent->layout->addr)) { + for (u=0, found=TRUE; u<ent->layout->ndims; u++) { + if (offset[u]!=ent->offset[u]) { + found = FALSE; + break; + } + } + } } if (found) { - /* - * Already in the cache. Count a hit. - */ - rdcc->nhits++; + /* + * Already in the cache. Count a hit. + */ + rdcc->nhits++; } else if (!found && relax) { - /* - * Not in the cache, but we're about to overwrite the whole thing - * anyway, so just allocate a buffer for it but don't initialize that - * buffer with the file contents. Count this as a hit instead of a - * miss because we saved ourselves lots of work. - */ + /* + * Not in the cache, but we're about to overwrite the whole thing + * anyway, so just allocate a buffer for it but don't initialize that + * buffer with the file contents. Count this as a hit instead of a + * miss because we saved ourselves lots of work. + */ #ifdef H5F_ISTORE_DEBUG - putc('w', stderr); - fflush(stderr); + putc('w', stderr); + fflush(stderr); #endif - rdcc->nhits++; - for (i=0, chunk_size=1; i<layout->ndims; i++) { - chunk_size *= layout->dim[i]; - } - chunk_alloc = chunk_size; - if (NULL==(chunk=H5F_istore_chunk_alloc (chunk_alloc))) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed for raw data chunk"); - } - + rdcc->nhits++; + for (u=0, chunk_size=1; u<layout->ndims; u++) { + chunk_size *= layout->dim[u]; + } + chunk_alloc = chunk_size; + if (NULL==(chunk=H5F_istore_chunk_alloc (chunk_alloc))) { + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk"); + } + } else { - /* - * Not in the cache. Read it from the file and count this as a miss - * if it's in the file or an init if it isn't. - */ - for (i=0, chunk_size=1; i<layout->ndims; i++) { - udata.key.offset[i] = offset[i]; - chunk_size *= layout->dim[i]; - } - chunk_alloc = chunk_size; - udata.mesg = *layout; - udata.addr = HADDR_UNDEF; - status = H5B_find (f, H5B_ISTORE, layout->addr, &udata); - H5E_clear (); - if (NULL==(chunk = H5F_istore_chunk_alloc (chunk_alloc))) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed for raw data chunk"); - } - if (status>=0 && H5F_addr_defined(udata.addr)) { - /* - * The chunk exists on disk. - */ - if (H5F_block_read(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, H5P_DEFAULT, - chunk)<0) { - HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL, - "unable to read raw data chunk"); - } - if (H5Z_pipeline(f, pline, H5Z_FLAG_REVERSE, - &(udata.key.filter_mask), &(udata.key.nbytes), - &chunk_alloc, &chunk)<0 || - udata.key.nbytes!=chunk_size) { - HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL, - "data pipeline read failed"); - } - rdcc->nmisses++; - } else if (fill && fill->buf) { - /* - * The chunk doesn't exist in the file. Replicate the fill - * value throughout the chunk. - */ - assert(0==chunk_size % fill->size); - H5V_array_fill(chunk, fill->buf, fill->size, - chunk_size/fill->size); - rdcc->ninits++; - - } else { - /* - * The chunk doesn't exist in the file and no fill value was - * specified. Assume all zeros. - */ - HDmemset (chunk, 0, chunk_size); - rdcc->ninits++; - } + /* + * Not in the cache. Read it from the file and count this as a miss + * if it's in the file or an init if it isn't. + */ + for (u=0, chunk_size=1; u<layout->ndims; u++) { + udata.key.offset[u] = offset[u]; + chunk_size *= layout->dim[u]; + } + chunk_alloc = chunk_size; + udata.mesg = *layout; + udata.addr = HADDR_UNDEF; + status = H5B_find (f, H5B_ISTORE, layout->addr, &udata); + H5E_clear (); + if (NULL==(chunk = H5F_istore_chunk_alloc (chunk_alloc))) { + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk"); + } + if (status>=0 && H5F_addr_defined(udata.addr)) { + /* + * The chunk exists on disk. + */ + if (H5F_block_read(f, H5FD_MEM_DRAW, udata.addr, (hsize_t)udata.key.nbytes, H5P_DEFAULT, + chunk)<0) { + HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL, + "unable to read raw data chunk"); + } + if (H5Z_pipeline(f, pline, H5Z_FLAG_REVERSE, + &(udata.key.filter_mask), &(udata.key.nbytes), + &chunk_alloc, &chunk)<0 || udata.key.nbytes!=chunk_size) { + HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL, + "data pipeline read failed"); + } + rdcc->nmisses++; + } else if (fill && fill->buf) { + /* + * The chunk doesn't exist in the file. Replicate the fill + * value throughout the chunk. + */ + assert(0==chunk_size % fill->size); + H5V_array_fill(chunk, fill->buf, fill->size, chunk_size/fill->size); + rdcc->ninits++; + } else { + /* + * The chunk doesn't exist in the file and no fill value was + * specified. Assume all zeros. + */ + HDmemset (chunk, 0, chunk_size); + rdcc->ninits++; + } } assert (found || chunk_size>0); if (!found && rdcc->nslots>0 && chunk_size<=f->shared->rdcc_nbytes && - (!ent || !ent->locked)) { - /* - * Add the chunk to the cache only if the slot is not already locked. - * Preempt enough things from the cache to make room. - */ - if (ent) { + (!ent || !ent->locked)) { + /* + * Add the chunk to the cache only if the slot is not already locked. + * Preempt enough things from the cache to make room. + */ + if (ent) { #ifdef H5F_ISTORE_DEBUG - putc('#', stderr); - fflush(stderr); + putc('#', stderr); + fflush(stderr); #endif #if 0 - HDfprintf(stderr, "\ncollision %3d %10a {", - idx, ent->layout->addr); - for (i=0; i<layout->ndims; i++) { - HDfprintf(stderr, "%s%Zu", i?",":"", ent->offset[i]); - } - HDfprintf(stderr, "}\n %10a {", layout->addr); - for (i=0; i<layout->ndims; i++) { - HDfprintf(stderr, "%s%Zu", i?",":"", offset[i]); - } - fprintf(stderr, "}\n"); + HDfprintf(stderr, "\ncollision %3d %10a {", + idx, ent->layout->addr); + for (u=0; u<layout->ndims; u++) { + HDfprintf(stderr, "%s%Zu", u?",":"", ent->offset[u]); + } + HDfprintf(stderr, "}\n %10a {", layout->addr); + for (u=0; u<layout->ndims; u++) { + HDfprintf(stderr, "%s%Zu", u?",":"", offset[u]); + } + fprintf(stderr, "}\n"); #endif - if (H5F_istore_preempt(f, ent)<0) { - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, - "unable to preempt chunk from cache"); - } - } - if (H5F_istore_prune(f, chunk_size)<0) { - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, - "unable to preempt chunk(s) from cache"); - } - - /* Create a new entry */ - ent = H5FL_ALLOC(H5F_rdcc_ent_t,0); - ent->locked = 0; - ent->dirty = FALSE; - ent->chunk_size = chunk_size; - ent->alloc_size = chunk_size; - ent->layout = H5O_copy(H5O_LAYOUT, layout, NULL); - ent->pline = H5O_copy(H5O_PLINE, pline, NULL); - for (i=0; i<layout->ndims; i++) { - ent->offset[i] = offset[i]; - } - ent->rd_count = chunk_size; - ent->wr_count = chunk_size; - ent->chunk = chunk; - - { - H5D_xfer_t *dxpl; - dxpl = (H5P_DEFAULT==dxpl_id) ? &H5D_xfer_dflt : (H5D_xfer_t *)H5I_object(dxpl_id); - ent->split_ratios[0] = dxpl->split_ratios[0]; - ent->split_ratios[1] = dxpl->split_ratios[1]; - ent->split_ratios[2] = dxpl->split_ratios[2]; - } - - /* Add it to the cache */ - assert(NULL==rdcc->slot[idx]); - rdcc->slot[idx] = ent; - ent->idx = idx; - rdcc->nbytes += chunk_size; - rdcc->nused++; - - /* Add it to the linked list */ - ent->next = NULL; - if (rdcc->tail) { - rdcc->tail->next = ent; - ent->prev = rdcc->tail; - rdcc->tail = ent; - } else { - rdcc->head = rdcc->tail = ent; - ent->prev = NULL; - } - found = TRUE; - + if (H5F_istore_preempt(f, ent)<0) { + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, + "unable to preempt chunk from cache"); + } + } + if (H5F_istore_prune(f, chunk_size)<0) { + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, + "unable to preempt chunk(s) from cache"); + } + + /* Create a new entry */ + ent = H5FL_ALLOC(H5F_rdcc_ent_t,0); + ent->locked = 0; + ent->dirty = FALSE; + ent->chunk_size = chunk_size; + ent->alloc_size = chunk_size; + ent->layout = H5O_copy(H5O_LAYOUT, layout, NULL); + ent->pline = H5O_copy(H5O_PLINE, pline, NULL); + for (u=0; u<layout->ndims; u++) { + ent->offset[u] = offset[u]; + } + ent->rd_count = chunk_size; + ent->wr_count = chunk_size; + ent->chunk = chunk; + + { + H5D_xfer_t *dxpl; + dxpl = (H5P_DEFAULT==dxpl_id) ? &H5D_xfer_dflt : (H5D_xfer_t *)H5I_object(dxpl_id); + ent->split_ratios[0] = dxpl->split_ratios[0]; + ent->split_ratios[1] = dxpl->split_ratios[1]; + ent->split_ratios[2] = dxpl->split_ratios[2]; + } + + /* Add it to the cache */ + assert(NULL==rdcc->slot[idx]); + rdcc->slot[idx] = ent; + ent->idx = idx; + rdcc->nbytes += chunk_size; + rdcc->nused++; + + /* Add it to the linked list */ + ent->next = NULL; + if (rdcc->tail) { + rdcc->tail->next = ent; + ent->prev = rdcc->tail; + rdcc->tail = ent; + } else { + rdcc->head = rdcc->tail = ent; + ent->prev = NULL; + } + found = TRUE; + } else if (!found) { - /* - * The chunk is larger than the entire cache so we don't cache it. - * This is the reason all those arguments have to be repeated for the - * unlock function. - */ - ent = NULL; - idx = -999; + /* + * The chunk is larger than the entire cache so we don't cache it. + * This is the reason all those arguments have to be repeated for the + * unlock function. + */ + ent = NULL; + idx = INT_MIN; } else if (found) { - /* - * The chunk is not at the beginning of the cache; move it backward - * by one slot. This is how we implement the LRU preemption - * algorithm. - */ - if (ent->next) { - if (ent->next->next) { - ent->next->next->prev = ent; - } else { - rdcc->tail = ent; - } - ent->next->prev = ent->prev; - if (ent->prev) { - ent->prev->next = ent->next; - } else { - rdcc->head = ent->next; - } - ent->prev = ent->next; - ent->next = ent->next->next; - ent->prev->next = ent; - } + /* + * The chunk is not at the beginning of the cache; move it backward + * by one slot. This is how we implement the LRU preemption + * algorithm. + */ + if (ent->next) { + if (ent->next->next) { + ent->next->next->prev = ent; + } else { + rdcc->tail = ent; + } + ent->next->prev = ent->prev; + if (ent->prev) { + ent->prev->next = ent->next; + } else { + rdcc->head = ent->next; + } + ent->prev = ent->next; + ent->next = ent->next->next; + ent->prev->next = ent; + } } /* Lock the chunk into the cache */ if (ent) { - assert (!ent->locked); - ent->locked = TRUE; - chunk = ent->chunk; + assert (!ent->locked); + ent->locked = TRUE; + chunk = ent->chunk; } - if (idx_hint) *idx_hint = idx; + if (idx_hint) + *idx_hint = idx; ret_value = chunk; done: - if (!ret_value) H5F_istore_chunk_free (chunk); + if (!ret_value) + H5F_istore_chunk_free (chunk); FUNC_LEAVE (ret_value); } @@ -1613,11 +1613,12 @@ H5F_istore_unlock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, { H5F_rdcc_t *rdcc = &(f->shared->rdcc); H5F_rdcc_ent_t *ent = NULL; - intn i, found = -1; + intn found = -1; + uintn u; FUNC_ENTER (H5F_istore_unlock, FAIL); - if (-999==*idx_hint) { + if (INT_MIN==*idx_hint) { /*not in cache*/ } else { assert(*idx_hint>=0 && *idx_hint<rdcc->nslots); @@ -1627,50 +1628,51 @@ H5F_istore_unlock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, } if (found<0) { - /* - * It's not in the cache, probably because it's too big. If it's - * dirty then flush it to disk. In any case, free the chunk. - * Note: we have to copy the layout and filter messages so we - * don't discard the `const' qualifier. - */ - if (dirty) { - H5F_rdcc_ent_t x; - HDmemset (&x, 0, sizeof x); - x.dirty = TRUE; - x.layout = H5O_copy (H5O_LAYOUT, layout, NULL); - x.pline = H5O_copy (H5O_PLINE, pline, NULL); - for (i=0, x.chunk_size=1; i<layout->ndims; i++) { - x.offset[i] = offset[i]; - x.chunk_size *= layout->dim[i]; - } - x.alloc_size = x.chunk_size; - x.chunk = chunk; - { - H5D_xfer_t *dxpl; - dxpl = (H5P_DEFAULT==dxpl_id) ? &H5D_xfer_dflt : (H5D_xfer_t *)H5I_object(dxpl_id); - x.split_ratios[0] = dxpl->split_ratios[0]; - x.split_ratios[1] = dxpl->split_ratios[1]; - x.split_ratios[2] = dxpl->split_ratios[2]; - } - - H5F_istore_flush_entry (f, &x, TRUE); - } else { - if(chunk) - H5F_istore_chunk_free (chunk); - } + /* + * It's not in the cache, probably because it's too big. If it's + * dirty then flush it to disk. In any case, free the chunk. + * Note: we have to copy the layout and filter messages so we + * don't discard the `const' qualifier. + */ + if (dirty) { + H5F_rdcc_ent_t x; + + HDmemset (&x, 0, sizeof x); + x.dirty = TRUE; + x.layout = H5O_copy (H5O_LAYOUT, layout, NULL); + x.pline = H5O_copy (H5O_PLINE, pline, NULL); + for (u=0, x.chunk_size=1; u<layout->ndims; u++) { + x.offset[u] = offset[u]; + x.chunk_size *= layout->dim[u]; + } + x.alloc_size = x.chunk_size; + x.chunk = chunk; + { + H5D_xfer_t *dxpl; + dxpl = (H5P_DEFAULT==dxpl_id) ? &H5D_xfer_dflt : (H5D_xfer_t *)H5I_object(dxpl_id); + x.split_ratios[0] = dxpl->split_ratios[0]; + x.split_ratios[1] = dxpl->split_ratios[1]; + x.split_ratios[2] = dxpl->split_ratios[2]; + } + + H5F_istore_flush_entry (f, &x, TRUE); + } else { + if(chunk) + H5F_istore_chunk_free (chunk); + } } else { - /* - * It's in the cache so unlock it. - */ - ent = rdcc->slot[found]; - assert (ent->locked); - if (dirty) { - ent->dirty = TRUE; - ent->wr_count -= MIN (ent->wr_count, naccessed); - } else { - ent->rd_count -= MIN (ent->rd_count, naccessed); - } - ent->locked = FALSE; + /* + * It's in the cache so unlock it. + */ + ent = rdcc->slot[found]; + assert (ent->locked); + if (dirty) { + ent->dirty = TRUE; + ent->wr_count -= MIN (ent->wr_count, naccessed); + } else { + ent->rd_count -= MIN (ent->rd_count, naccessed); + } + ent->locked = FALSE; } FUNC_LEAVE (SUCCEED); @@ -1709,6 +1711,7 @@ H5F_istore_read(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, hssize_t sub_offset_m[H5O_LAYOUT_NDIMS]; hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; intn i, carry; + uintn u; size_t naccessed; /*bytes accessed in chnk*/ uint8_t *chunk=NULL; /*ptr to a chunk buffer */ intn idx_hint=0; /*cache index hint */ @@ -1728,18 +1731,18 @@ H5F_istore_read(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, * For now, a hyperslab of the file must be read into an array in * memory.We do not yet support reading into a hyperslab of memory. */ - for (i=0; i<layout->ndims; i++) { - offset_m[i] = 0; - size_m[i] = size[i]; + for (u=0; u<layout->ndims; u++) { + offset_m[u] = 0; + size_m[u] = size[u]; } #ifndef NDEBUG - for (i=0; i<layout->ndims; i++) { - assert(offset_f[i]>=0); /*negative offsets not supported*/ - assert(offset_m[i]>=0); /*negative offsets not supported*/ - assert(size[i]<SIZET_MAX); - assert(offset_m[i]+(hssize_t)size[i]<=(hssize_t)size_m[i]); - assert(layout->dim[i]>0); + for (u=0; u<layout->ndims; u++) { + assert(offset_f[u]>=0); /*negative offsets not supported*/ + assert(offset_m[u]>=0); /*negative offsets not supported*/ + assert(size[u]<SIZET_MAX); + assert(offset_m[u]+(hssize_t)size[u]<=(hssize_t)size_m[u]); + assert(layout->dim[u]>0); } #endif @@ -1748,99 +1751,101 @@ H5F_istore_read(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, * loop through the chunks copying each to its final destination in the * application buffer. */ - for (i=0; i<layout->ndims; i++) { - idx_min[i] = offset_f[i] / layout->dim[i]; - idx_max[i] = (offset_f[i]+size[i]-1) / layout->dim[i] + 1; - idx_cur[i] = idx_min[i]; + for (u=0; u<layout->ndims; u++) { + idx_min[u] = offset_f[u] / layout->dim[u]; + idx_max[u] = (offset_f[u]+size[u]-1) / layout->dim[u] + 1; + idx_cur[u] = idx_min[u]; } /* Loop over all chunks */ while (1) { - for (i=0, naccessed=1; i<layout->ndims; i++) { - /* The location and size of the chunk being accessed */ - assert(layout->dim[i] < HSSIZET_MAX); - chunk_offset[i] = idx_cur[i] * (hssize_t)(layout->dim[i]); - - /* The offset and size wrt the chunk */ - offset_wrt_chunk[i] = MAX(offset_f[i], chunk_offset[i]) - - chunk_offset[i]; - sub_size[i] = MIN((idx_cur[i]+1)*layout->dim[i], - offset_f[i]+size[i]) - - (chunk_offset[i] + offset_wrt_chunk[i]); - naccessed *= sub_size[i]; - - /* Offset into mem buffer */ - sub_offset_m[i] = chunk_offset[i] + offset_wrt_chunk[i] + - offset_m[i] - offset_f[i]; - } + for (u=0, naccessed=1; u<layout->ndims; u++) { + /* The location and size of the chunk being accessed */ + assert(layout->dim[u] < HSSIZET_MAX); + chunk_offset[u] = idx_cur[u] * (hssize_t)(layout->dim[u]); + + /* The offset and size wrt the chunk */ + offset_wrt_chunk[u] = MAX(offset_f[u], chunk_offset[u]) - + chunk_offset[u]; + sub_size[u] = MIN((idx_cur[u]+1)*layout->dim[u], + offset_f[u]+size[u]) - + (chunk_offset[u] + offset_wrt_chunk[u]); + naccessed *= sub_size[u]; + + /* Offset into mem buffer */ + sub_offset_m[u] = chunk_offset[u] + offset_wrt_chunk[u] + + offset_m[u] - offset_f[u]; + } #ifdef H5_HAVE_PARALLEL - /* - * If MPIO is used, must bypass the chunk-cache scheme because other - * MPI processes could be writing to other elements in the same chunk. - * Do a direct write-through of only the elements requested. - */ - if (IS_H5FD_MPIO(f)) { - H5F_istore_ud1_t udata; - H5O_layout_t l; /* temporary layout */ - - if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to locate raw data chunk"); - }; - - /* - * use default transfer mode as we do not support collective - * transfer mode since each data write could decompose into - * multiple chunk writes and we are not doing the calculation yet. - */ - l.type = H5D_CONTIGUOUS; - l.ndims = layout->ndims; - for (i=l.ndims; i-- > 0; /*void*/) l.dim[i] = layout->dim[i]; - l.addr = udata.addr; - if (H5F_arr_read(f, H5P_DEFAULT, &l, pline, fill, NULL/*no efl*/, - sub_size, size_m, sub_offset_m, offset_wrt_chunk, - buf)<0){ - HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, - "unable to read raw data from file"); - } - } else { + /* + * If MPIO is used, must bypass the chunk-cache scheme because other + * MPI processes could be writing to other elements in the same chunk. + * Do a direct write-through of only the elements requested. + */ + if (IS_H5FD_MPIO(f)) { + H5F_istore_ud1_t udata; + H5O_layout_t l; /* temporary layout */ + + if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to locate raw data chunk"); + }; + + /* + * use default transfer mode as we do not support collective + * transfer mode since each data write could decompose into + * multiple chunk writes and we are not doing the calculation yet. + */ + l.type = H5D_CONTIGUOUS; + l.ndims = layout->ndims; + for (u=l.ndims; u-- > 0; /*void*/) + l.dim[u] = layout->dim[u]; + l.addr = udata.addr; + if (H5F_arr_read(f, H5P_DEFAULT, &l, pline, fill, NULL/*no efl*/, + sub_size, size_m, sub_offset_m, offset_wrt_chunk, buf)<0) { + HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, + "unable to read raw data from file"); + } + } else { #endif #ifdef AKC - printf("Locking chunk( "); - for (i=0; i<layout->ndims; i++){ - printf("%ld ", chunk_offset[i]); - } - printf(")\n"); + printf("Locking chunk( "); + for (u=0; u<layout->ndims; u++){ + printf("%ld ", chunk_offset[u]); + } + printf(")\n"); #endif - /* - * Lock the chunk, transfer data to the application, then unlock - * the chunk. - */ - if (NULL==(chunk=H5F_istore_lock(f, dxpl_id, layout, pline, fill, - chunk_offset, FALSE, - &idx_hint))) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "unable to read raw data chunk"); - } - H5V_hyper_copy(layout->ndims, sub_size, size_m, sub_offset_m, - (void*)buf, layout->dim, offset_wrt_chunk, chunk); - if (H5F_istore_unlock(f, dxpl_id, layout, pline, FALSE, - chunk_offset, &idx_hint, chunk, - naccessed)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "unable to unlock raw data chunk"); - } + /* + * Lock the chunk, transfer data to the application, then unlock + * the chunk. + */ + if (NULL==(chunk=H5F_istore_lock(f, dxpl_id, layout, pline, fill, + chunk_offset, FALSE, &idx_hint))) { + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + "unable to read raw data chunk"); + } + H5V_hyper_copy(layout->ndims, sub_size, size_m, sub_offset_m, + (void*)buf, layout->dim, offset_wrt_chunk, chunk); + if (H5F_istore_unlock(f, dxpl_id, layout, pline, FALSE, + chunk_offset, &idx_hint, chunk, + naccessed)<0) { + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + "unable to unlock raw data chunk"); + } #ifdef H5_HAVE_PARALLEL - } + } #endif - /* Increment indices */ - for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) { - if (++idx_cur[i]>=idx_max[i]) idx_cur[i] = idx_min[i]; - else carry = 0; - } - if (carry) break; + /* Increment indices */ + for (i=(intn)(layout->ndims-1), carry=1; i>=0 && carry; --i) { + if (++idx_cur[i]>=idx_max[i]) + idx_cur[i] = idx_min[i]; + else + carry = 0; + } + if (carry) + break; } FUNC_LEAVE(SUCCEED); } @@ -1869,16 +1874,17 @@ H5F_istore_write(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, const hssize_t offset_f[], const hsize_t size[], const void *buf) { - hssize_t offset_m[H5O_LAYOUT_NDIMS]; + hssize_t offset_m[H5O_LAYOUT_NDIMS]; hsize_t size_m[H5O_LAYOUT_NDIMS]; intn i, carry; + uintn u; hsize_t idx_cur[H5O_LAYOUT_NDIMS]; hsize_t idx_min[H5O_LAYOUT_NDIMS]; hsize_t idx_max[H5O_LAYOUT_NDIMS]; hsize_t sub_size[H5O_LAYOUT_NDIMS]; - hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; - hssize_t offset_wrt_chunk[H5O_LAYOUT_NDIMS]; - hssize_t sub_offset_m[H5O_LAYOUT_NDIMS]; + hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; + hssize_t offset_wrt_chunk[H5O_LAYOUT_NDIMS]; + hssize_t sub_offset_m[H5O_LAYOUT_NDIMS]; uint8_t *chunk=NULL; intn idx_hint=0; size_t chunk_size, naccessed; @@ -1898,19 +1904,19 @@ H5F_istore_write(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, * For now the source must not be a hyperslab. It must be an entire * memory buffer. */ - for (i=0, chunk_size=1; i<layout->ndims; i++) { - offset_m[i] = 0; - size_m[i] = size[i]; - chunk_size *= layout->dim[i]; + for (u=0, chunk_size=1; u<layout->ndims; u++) { + offset_m[u] = 0; + size_m[u] = size[u]; + chunk_size *= layout->dim[u]; } #ifndef NDEBUG - for (i=0; i<layout->ndims; i++) { - assert(offset_f[i]>=0); /*negative offsets not supported*/ - assert(offset_m[i]>=0); /*negative offsets not supported*/ - assert(size[i]<SIZET_MAX); - assert(offset_m[i]+(hssize_t)size[i]<=(hssize_t)size_m[i]); - assert(layout->dim[i]>0); + for (u=0; u<layout->ndims; u++) { + assert(offset_f[u]>=0); /*negative offsets not supported*/ + assert(offset_m[u]>=0); /*negative offsets not supported*/ + assert(size[u]<SIZET_MAX); + assert(offset_m[u]+(hssize_t)size[u]<=(hssize_t)size_m[u]); + assert(layout->dim[u]>0); } #endif @@ -1919,103 +1925,105 @@ H5F_istore_write(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, * loop through the chunks copying each chunk from the application to the * chunk cache. */ - for (i=0; i<layout->ndims; i++) { - idx_min[i] = offset_f[i] / layout->dim[i]; - idx_max[i] = (offset_f[i]+size[i]-1) / layout->dim[i] + 1; - idx_cur[i] = idx_min[i]; + for (u=0; u<layout->ndims; u++) { + idx_min[u] = offset_f[u] / layout->dim[u]; + idx_max[u] = (offset_f[u]+size[u]-1) / layout->dim[u] + 1; + idx_cur[u] = idx_min[u]; } /* Loop over all chunks */ while (1) { - - for (i=0, naccessed=1; i<layout->ndims; i++) { - /* The location and size of the chunk being accessed */ - assert(layout->dim[i] < HSSIZET_MAX); - chunk_offset[i] = idx_cur[i] * (hssize_t)(layout->dim[i]); - - /* The offset and size wrt the chunk */ - offset_wrt_chunk[i] = MAX(offset_f[i], chunk_offset[i]) - - chunk_offset[i]; - sub_size[i] = MIN((idx_cur[i]+1)*layout->dim[i], - offset_f[i]+size[i]) - - (chunk_offset[i] + offset_wrt_chunk[i]); - naccessed *= sub_size[i]; - - /* Offset into mem buffer */ - sub_offset_m[i] = chunk_offset[i] + offset_wrt_chunk[i] + - offset_m[i] - offset_f[i]; - } + for (u=0, naccessed=1; u<layout->ndims; u++) { + /* The location and size of the chunk being accessed */ + assert(layout->dim[u] < HSSIZET_MAX); + chunk_offset[u] = idx_cur[u] * (hssize_t)(layout->dim[u]); + + /* The offset and size wrt the chunk */ + offset_wrt_chunk[u] = MAX(offset_f[u], chunk_offset[u]) - + chunk_offset[u]; + sub_size[u] = MIN((idx_cur[u]+1)*layout->dim[u], + offset_f[u]+size[u]) - + (chunk_offset[u] + offset_wrt_chunk[u]); + naccessed *= sub_size[u]; + + /* Offset into mem buffer */ + sub_offset_m[u] = chunk_offset[u] + offset_wrt_chunk[u] + + offset_m[u] - offset_f[u]; + } #ifdef H5_HAVE_PARALLEL - /* - * If MPIO is used, must bypass the chunk-cache scheme because other - * MPI processes could be writing to other elements in the same chunk. - * Do a direct write-through of only the elements requested. - */ - if (IS_H5FD_MPIO(f)) { - H5F_istore_ud1_t udata; - H5O_layout_t l; /* temporary layout */ - if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to locate raw data chunk"); - }; - - /* - * use default transfer mode as we do not support collective - * transfer mode since each data write could decompose into - * multiple chunk writes and we are not doing the calculation yet. - */ - l.type = H5D_CONTIGUOUS; - l.ndims = layout->ndims; - for (i=l.ndims; i-- > 0; /*void*/) l.dim[i] = layout->dim[i]; - l.addr = udata.addr; - if (H5F_arr_write(f, H5P_DEFAULT, &l, pline, fill, NULL/*no efl*/, - sub_size, size_m, sub_offset_m, offset_wrt_chunk, - buf)<0){ - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to write raw data to file"); - } - } else { + /* + * If MPIO is used, must bypass the chunk-cache scheme because other + * MPI processes could be writing to other elements in the same chunk. + * Do a direct write-through of only the elements requested. + */ + if (IS_H5FD_MPIO(f)) { + H5F_istore_ud1_t udata; + H5O_layout_t l; /* temporary layout */ + + if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to locate raw data chunk"); + }; + + /* + * use default transfer mode as we do not support collective + * transfer mode since each data write could decompose into + * multiple chunk writes and we are not doing the calculation yet. + */ + l.type = H5D_CONTIGUOUS; + l.ndims = layout->ndims; + for (u=l.ndims; u-- > 0; /*void*/) + l.dim[u] = layout->dim[u]; + l.addr = udata.addr; + if (H5F_arr_write(f, H5P_DEFAULT, &l, pline, fill, NULL/*no efl*/, + sub_size, size_m, sub_offset_m, offset_wrt_chunk, buf)<0) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to write raw data to file"); + } + } else { #endif #ifdef AKC - printf("Locking chunk( "); - for (i=0; i<layout->ndims; i++){ - printf("%ld ", chunk_offset[i]); - } - printf(")\n"); + printf("Locking chunk( "); + for (u=0; u<layout->ndims; u++){ + printf("%ld ", chunk_offset[u]); + } + printf(")\n"); #endif - /* - * Lock the chunk, copy from application to chunk, then unlock the - * chunk. - */ - if (NULL==(chunk=H5F_istore_lock(f, dxpl_id, layout, pline, fill, - chunk_offset, - naccessed==chunk_size, - &idx_hint))) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to read raw data chunk"); - } - H5V_hyper_copy(layout->ndims, sub_size, - layout->dim, offset_wrt_chunk, chunk, - size_m, sub_offset_m, buf); - if (H5F_istore_unlock(f, dxpl_id, layout, pline, TRUE, - chunk_offset, &idx_hint, chunk, - naccessed)<0) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "uanble to unlock raw data chunk"); - } + /* + * Lock the chunk, copy from application to chunk, then unlock the + * chunk. + */ + if (NULL==(chunk=H5F_istore_lock(f, dxpl_id, layout, pline, fill, + chunk_offset, + (hbool_t)(naccessed==chunk_size), + &idx_hint))) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to read raw data chunk"); + } + H5V_hyper_copy(layout->ndims, sub_size, + layout->dim, offset_wrt_chunk, chunk, size_m, sub_offset_m, buf); + if (H5F_istore_unlock(f, dxpl_id, layout, pline, TRUE, + chunk_offset, &idx_hint, chunk, + naccessed)<0) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "uanble to unlock raw data chunk"); + } #ifdef H5_HAVE_PARALLEL - } + } #endif - - /* Increment indices */ - for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) { - if (++idx_cur[i]>=idx_max[i]) idx_cur[i] = idx_min[i]; - else carry = 0; - } - if (carry) break; + + /* Increment indices */ + for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) { + if (++idx_cur[i]>=idx_max[i]) + idx_cur[i] = idx_min[i]; + else + carry = 0; + } + if (carry) + break; } FUNC_LEAVE(SUCCEED); @@ -2047,7 +2055,7 @@ H5F_istore_create(H5F_t *f, H5O_layout_t *layout /*out */ ) { H5F_istore_ud1_t udata; #ifndef NDEBUG - int i; + uintn u; #endif FUNC_ENTER(H5F_istore_create, FAIL); @@ -2057,8 +2065,8 @@ H5F_istore_create(H5F_t *f, H5O_layout_t *layout /*out */ ) assert(layout && H5D_CHUNKED == layout->type); assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS); #ifndef NDEBUG - for (i = 0; i < layout->ndims; i++) { - assert(layout->dim[i] > 0); + for (u = 0; u < layout->ndims; u++) { + assert(layout->dim[u] > 0); } #endif @@ -2091,15 +2099,16 @@ H5F_istore_create(H5F_t *f, H5O_layout_t *layout /*out */ ) *------------------------------------------------------------------------- */ hsize_t -H5F_istore_allocated(H5F_t *f, int ndims, haddr_t addr) +H5F_istore_allocated(H5F_t *f, uintn ndims, haddr_t addr) { H5F_istore_ud1_t udata; FUNC_ENTER(H5F_istore_nchunks, 0); + HDmemset(&udata, 0, sizeof udata); udata.mesg.ndims = ndims; if (H5B_iterate(f, H5B_ISTORE, addr, &udata)<0) { - HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0, + HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree"); } FUNC_LEAVE(udata.total_storage); @@ -2125,16 +2134,17 @@ H5F_istore_allocated(H5F_t *f, int ndims, haddr_t addr) *------------------------------------------------------------------------- */ herr_t -H5F_istore_dump_btree(H5F_t *f, FILE *stream, int ndims, haddr_t addr) +H5F_istore_dump_btree(H5F_t *f, FILE *stream, uintn ndims, haddr_t addr) { H5F_istore_ud1_t udata; FUNC_ENTER(H5F_istore_dump_btree, FAIL); + HDmemset(&udata, 0, sizeof udata); udata.mesg.ndims = ndims; udata.stream = stream; if (H5B_iterate(f, H5B_ISTORE, addr, &udata)<0) { - HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0, + HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree"); } FUNC_LEAVE(SUCCEED); @@ -2168,12 +2178,12 @@ H5F_istore_stats (H5F_t *f, hbool_t headers) if (!H5DEBUG(AC)) HRETURN(SUCCEED); if (headers) { - fprintf(H5DEBUG(AC), "H5F: raw data cache statistics for file %s\n", - f->name); - fprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s+%-8s\n", - "Layer", "Hits", "Misses", "MissRate", "Inits", "Flushes"); - fprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s-%-8s\n", - "-----", "----", "------", "--------", "-----", "-------"); + fprintf(H5DEBUG(AC), "H5F: raw data cache statistics for file %s\n", + f->name); + fprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s+%-8s\n", + "Layer", "Hits", "Misses", "MissRate", "Inits", "Flushes"); + fprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s-%-8s\n", + "-----", "----", "------", "--------", "-----", "-------"); } #ifdef H5AC_DEBUG @@ -2181,21 +2191,21 @@ H5F_istore_stats (H5F_t *f, hbool_t headers) #endif if (headers) { - if (rdcc->nhits>0 || rdcc->nmisses>0) { - miss_rate = 100.0 * rdcc->nmisses / - (rdcc->nhits + rdcc->nmisses); - } else { - miss_rate = 0.0; - } - if (miss_rate > 100) { - sprintf(ascii, "%7d%%", (int) (miss_rate + 0.5)); - } else { - sprintf(ascii, "%7.2f%%", miss_rate); - } - - fprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", - "raw data chunks", rdcc->nhits, rdcc->nmisses, ascii, - rdcc->ninits, (long)(rdcc->nflushes)-(long)(rdcc->ninits)); + if (rdcc->nhits>0 || rdcc->nmisses>0) { + miss_rate = 100.0 * rdcc->nmisses / + (rdcc->nhits + rdcc->nmisses); + } else { + miss_rate = 0.0; + } + if (miss_rate > 100) { + sprintf(ascii, "%7d%%", (int) (miss_rate + 0.5)); + } else { + sprintf(ascii, "%7.2f%%", miss_rate); + } + + fprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", + "raw data chunks", rdcc->nhits, rdcc->nmisses, ascii, + rdcc->ninits, (long)(rdcc->nflushes)-(long)(rdcc->ninits)); } FUNC_LEAVE (SUCCEED); @@ -2320,6 +2330,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, { intn i, carry; + uintn u; hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; uint8_t *chunk=NULL; intn idx_hint=0; @@ -2345,9 +2356,9 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, * Setup indice to go through all chunks. (Future improvement * should allocate only chunks that have no file space assigned yet. */ - for (i=0, chunk_size=1; i<layout->ndims; i++) { - chunk_offset[i]=0; - chunk_size *= layout->dim[i]; + for (u=0, chunk_size=1; u<layout->ndims; u++) { + chunk_offset[u]=0; + chunk_size *= layout->dim[u]; } /* Loop over all chunks */ @@ -2355,73 +2366,70 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, #ifdef AKC printf("Checking allocation for chunk( "); - for (i=0; i<layout->ndims; i++){ - printf("%ld ", chunk_offset[i]); + for (u=0; u<layout->ndims; u++){ + printf("%ld ", chunk_offset[u]); } printf(")\n"); #endif #ifdef NO - if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ + if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0) { #endif - /* No file space assigned yet. Allocate it. */ - /* The following needs improvement like calling the */ - /* allocation directly rather than indirectly using the */ - /* allocation effect in the unlock process. */ + /* No file space assigned yet. Allocate it. */ + /* The following needs improvement like calling the */ + /* allocation directly rather than indirectly using the */ + /* allocation effect in the unlock process. */ #ifdef AKC - printf("need allocation\n"); + printf("need allocation\n"); #endif - /* - * Lock the chunk, copy from application to chunk, then unlock the - * chunk. - */ + /* + * Lock the chunk, copy from application to chunk, then unlock the + * chunk. + */ #ifdef H5_HAVE_PARALLEL - /* rky 981207 Serialize access to this critical region. */ - if (SUCCEED!= - H5FD_mpio_wait_for_left_neighbor(f->shared->lf)) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to lock the data chunk"); - } + /* rky 981207 Serialize access to this critical region. */ + if (SUCCEED!= H5FD_mpio_wait_for_left_neighbor(f->shared->lf)) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to lock the data chunk"); + } #endif - if (NULL==(chunk=H5F_istore_lock(f, dxpl_id, layout, pline, - fill, chunk_offset, FALSE, - &idx_hint))) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to read raw data chunk"); - } - if (H5F_istore_unlock(f, dxpl_id, layout, pline, TRUE, - chunk_offset, &idx_hint, chunk, - chunk_size)<0) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "uanble to unlock raw data chunk"); - } + if (NULL==(chunk=H5F_istore_lock(f, dxpl_id, layout, pline, + fill, chunk_offset, FALSE, &idx_hint))) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to read raw data chunk"); + } + if (H5F_istore_unlock(f, dxpl_id, layout, pline, TRUE, + chunk_offset, &idx_hint, chunk, chunk_size)<0) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "uanble to unlock raw data chunk"); + } #ifdef H5_HAVE_PARALLEL - if (SUCCEED!= - H5FD_mpio_signal_right_neighbor(f->shared->lf)) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to unlock the data chunk"); - } + if (SUCCEED!= H5FD_mpio_signal_right_neighbor(f->shared->lf)) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to unlock the data chunk"); + } #endif #ifdef NO - } else { + } else { #ifdef AKC - printf("NO need for allocation\n"); - HDfprintf(stdout, "udata.addr=%a\n", udata.addr); + printf("NO need for allocation\n"); + HDfprintf(stdout, "udata.addr=%a\n", udata.addr); #endif - } + } #endif - /* Increment indices */ - for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) { - chunk_offset[i] += layout->dim[i]; - if (chunk_offset[i] >= (hssize_t)(space_dim[i])) { - chunk_offset[i] = 0; - } else { - carry = 0; - } - } - if (carry) break; + /* Increment indices */ + for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) { + chunk_offset[i] += layout->dim[i]; + if (chunk_offset[i] >= (hssize_t)(space_dim[i])) { + chunk_offset[i] = 0; + } else { + carry = 0; + } + } + if (carry) + break; } #ifdef H5_HAVE_PARALLEL @@ -2436,7 +2444,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, * to allocate space, instead of calling H5F_istore_unlock. */ if (MPI_Barrier(H5FD_mpio_communicator(f->shared->lf))) { - HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Barrier failed"); + HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Barrier failed"); } #endif diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 5efe8e6..7bcb1ae 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -53,16 +53,16 @@ typedef struct H5D_create_t { /* Data transfer property list */ typedef struct H5D_xfer_t { - size_t buf_size; /*max temp buffer size */ + hsize_t buf_size; /*max temp buffer size */ void *tconv_buf; /*type conversion buffer or null */ void *bkg_buf; /*background buffer or null */ - H5T_bkg_t need_bkg; /*type of background buffer needed */ + H5T_bkg_t need_bkg; /*type of background buffer needed */ double split_ratios[3];/*B-tree node splitting ratios */ - uintn cache_hyper; /*cache hyperslab blocks during I/O? */ - uintn block_limit; /*largest hyperslab block to cache */ + uintn cache_hyper; /*cache hyperslab blocks during I/O? */ + uintn block_limit; /*largest hyperslab block to cache */ H5MM_allocate_t vlen_alloc; /*VL datatype allocation function */ void *alloc_info; /*VL datatype allocation information */ - H5MM_free_t vlen_free; /*VL datatype free function */ + H5MM_free_t vlen_free; /*VL datatype free function */ void *free_info; /*VL datatype free information */ hid_t driver_id; /*File driver ID */ void *driver_info; /*File driver specific information */ diff --git a/src/H5Dseq.c b/src/H5Dseq.c index 209821a..01d484d 100644 --- a/src/H5Dseq.c +++ b/src/H5Dseq.c @@ -59,7 +59,7 @@ herr_t H5F_seq_read(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const H5O_fill_t *fill, const struct H5O_efl_t *efl, const H5S_t *file_space, size_t elmt_size, - hsize_t seq_len, hssize_t file_offset, void *buf/*out*/) + hsize_t seq_len, hsize_t file_offset, void *buf/*out*/) { hsize_t dset_dims[H5O_LAYOUT_NDIMS]; /* dataspace dimensions */ hssize_t coords[H5O_LAYOUT_NDIMS]; /* offset of hyperslab in dataspace */ @@ -285,7 +285,7 @@ herr_t H5F_seq_write(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const H5O_fill_t *fill, const struct H5O_efl_t *efl, const H5S_t *file_space, size_t elmt_size, - hsize_t seq_len, hssize_t file_offset, const void *buf) + hsize_t seq_len, hsize_t file_offset, const void *buf) { hsize_t dset_dims[H5O_LAYOUT_NDIMS]; /* dataspace dimensions */ hssize_t coords[H5O_LAYOUT_NDIMS]; /* offset of hyperslab in dataspace */ @@ -1519,7 +1519,8 @@ H5FD_realloc(H5FD_t *file, H5FD_mem_t type, haddr_t old_addr, hsize_t old_size, HRETURN_ERROR(H5E_FILE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed"); } - if (old_size>sizeof(_buf) && NULL==(buf=H5MM_malloc(old_size))) { + assert(old_size==(hsize_t)((size_t)old_size)); /*check for overflow*/ + if (old_size>sizeof(_buf) && NULL==(buf=H5MM_malloc((size_t)old_size))) { H5FDfree(file, type, new_addr, new_size); HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed"); @@ -1914,7 +1915,8 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t si amount_read=MIN((file->accum_size-read_off),size); /* Copy the data out of the buffer */ - HDmemcpy(read_buf,file->meta_accum+read_off,amount_read); + assert(amount_read==(hsize_t)((size_t)amount_read)); /*check for overflow*/ + HDmemcpy(read_buf,file->meta_accum+read_off,(size_t)amount_read); /* Adjust the buffer, address & size */ read_buf+=amount_read; @@ -2021,7 +2023,7 @@ herr_t H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size, const void *buf) { - size_t new_size; /* New size of the accumulator buffer */ + hsize_t new_size; /* New size of the accumulator buffer */ size_t old_offset; /* Offset of old data within the accumulator buffer */ FUNC_ENTER(H5FD_write, FAIL); @@ -2059,10 +2061,12 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t s } /* end if */ /* Move the existing metadata to the proper location */ - HDmemmove(file->meta_accum+size,file->meta_accum,file->accum_size); + assert(file->accum_size==(hsize_t)((size_t)file->accum_size)); /*check for overflow*/ + HDmemmove(file->meta_accum+size,file->meta_accum,(size_t)file->accum_size); /* Copy the new metadata at the front */ - HDmemcpy(file->meta_accum,buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(file->meta_accum,buf,(size_t)size); /* Set the new size & location of the metadata accumulator */ file->accum_loc=addr; @@ -2084,7 +2088,8 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t s } /* end if */ /* Copy the new metadata to the end */ - HDmemcpy(file->meta_accum+file->accum_size,buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(file->meta_accum+file->accum_size,buf,(size_t)size); /* Set the new size of the metadata accumulator */ file->accum_size=file->accum_size+size; @@ -2095,7 +2100,8 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t s /* Check if the new metadata is entirely within the current accumulator */ else if(addr>=file->accum_loc && (addr+size)<=(file->accum_loc+file->accum_size)) { /* Copy the new metadata to the proper location within the accumulator */ - HDmemcpy(file->meta_accum+(addr-file->accum_loc),buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(file->meta_accum+(addr-file->accum_loc),buf,(size_t)size); /* Mark it as written to */ file->accum_dirty=TRUE; @@ -2119,10 +2125,12 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t s old_offset=(addr+size)-file->accum_loc; /* Move the existing metadata to the proper location */ - HDmemmove(file->meta_accum+size,file->meta_accum+old_offset,file->accum_size-old_offset); + assert((file->accum_size-old_offset)==(hsize_t)((size_t)(file->accum_size-old_offset))); /*check for overflow*/ + HDmemmove(file->meta_accum+size,file->meta_accum+old_offset,(size_t)(file->accum_size-old_offset)); /* Copy the new metadata at the front */ - HDmemcpy(file->meta_accum,buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(file->meta_accum,buf,(size_t)size); /* Set the new size & location of the metadata accumulator */ file->accum_loc=addr; @@ -2147,7 +2155,8 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t s } /* end if */ /* Copy the new metadata to the end */ - HDmemcpy(file->meta_accum+(addr-file->accum_loc),buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(file->meta_accum+(addr-file->accum_loc),buf,(size_t)size); /* Set the new size & location of the metadata accumulator */ file->accum_loc=addr; @@ -2181,7 +2190,8 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t s file->accum_loc=addr; file->accum_size=size; file->accum_dirty=TRUE; - HDmemcpy(file->meta_accum,buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(file->meta_accum,buf,(size_t)size); } /* end else */ } /* end if */ /* No metadata in the accumulator, grab this piece and keep it */ @@ -2200,7 +2210,8 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t s file->accum_loc=addr; file->accum_size=size; file->accum_dirty=TRUE; - HDmemcpy(file->meta_accum,buf,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(file->meta_accum,buf,(size_t)size); } /* end else */ } /* end if */ else { diff --git a/src/H5FDcore.c b/src/H5FDcore.c index ac20921..ae70cbe 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -303,7 +303,7 @@ H5FD_core_open(const char *name, unsigned UNUSED flags, hid_t fapl_id, /* Open backing store */ if (fa && fa->backing_store && name && - (fd=open(name, O_CREAT|O_TRUNC|O_RDWR, 0666))<0) { + (fd=HDopen(name, O_CREAT|O_TRUNC|O_RDWR, 0666))<0) { HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open backing store"); } @@ -358,12 +358,15 @@ H5FD_core_flush(H5FD_t *_file) haddr_t size = file->eof; unsigned char *ptr = file->mem; - if (0!=lseek(file->fd, 0, SEEK_SET)) + if (0!=HDlseek(file->fd, (off_t)0, SEEK_SET)) HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "error seeking in backing store"); while (size) { - ssize_t n = write(file->fd, ptr, size); + ssize_t n; + + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + n = HDwrite(file->fd, ptr, (size_t)size); if (n<0 && EINTR==errno) continue; if (n<0) HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, @@ -408,10 +411,10 @@ H5FD_core_close(H5FD_t *_file) HRETURN_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file"); /* Release resources */ - if (file->fd>=0) close(file->fd); + if (file->fd>=0) HDclose(file->fd); if (file->name) H5MM_xfree(file->name); if (file->mem) H5MM_xfree(file->mem); - memset(file, 0, sizeof(H5FD_core_t)); + HDmemset(file, 0, sizeof(H5FD_core_t)); H5MM_xfree(file); FUNC_LEAVE(0); } @@ -595,15 +598,18 @@ H5FD_core_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd if (addr < file->eof) { hsize_t nbytes = MIN(size, file->eof-addr); - memcpy(buf, file->mem + addr, nbytes); + assert(nbytes==(hsize_t)((size_t)nbytes)); /*check for overflow*/ + HDmemcpy(buf, file->mem + addr, (size_t)nbytes); size -= nbytes; addr += nbytes; buf = (char *)buf + nbytes; } /* Read zeros for the part which is after the EOF markers */ - if (size > 0) - memset(buf, 0, size); + if (size > 0) { + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemset(buf, 0, (size_t)size); + } FUNC_LEAVE(SUCCEED); } @@ -665,7 +671,8 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had } /* Write from BUF to memory */ - memcpy(file->mem+addr, buf, size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemcpy(file->mem+addr, buf, (size_t)size); file->dirty = TRUE; FUNC_LEAVE(SUCCEED); diff --git a/src/H5FDlog.c b/src/H5FDlog.c index d56755b..4799b17 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -404,7 +404,7 @@ static H5FD_t * H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { - unsigned o_flags; + int o_flags; int fd; struct stat sb; H5FD_log_t *file=NULL; @@ -434,8 +434,8 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, /* Open the file */ if ((fd=HDopen(name, o_flags, 0666))<0) HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file"); - if (fstat(fd, &sb)<0) { - close(fd); + if (HDfstat(fd, &sb)<0) { + HDclose(fd); HRETURN_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file"); } @@ -471,7 +471,7 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, file->nwrite=H5MM_calloc(file->iosize); file->flavor=H5MM_calloc(file->iosize); if(fa->logfile) - file->logfp=fopen(fa->logfile,"w"); + file->logfp=HDfopen(fa->logfile,"w"); else file->logfp=stderr; } /* end if */ @@ -689,7 +689,8 @@ printf("%s: flavor=%s, size=%lu\n",FUNC,flavors[type],(unsigned long)size); /* Retain the (first) flavor of the information written to the file */ if(file->fa.verbosity>=0) { assert(addr<file->iosize); - HDmemset(&file->flavor[addr],type,size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemset(&file->flavor[addr],type,(size_t)size); if(file->fa.verbosity>1) HDfprintf(file->logfp,"%10a-%10a (%10lu bytes) Allocated, flavor=%s\n",addr,addr+size-1,(unsigned long)size,flavors[file->flavor[addr]]); @@ -856,9 +857,10 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr * and the end of the file. */ while (size>0) { - do - nbytes = read(file->fd, buf, size); - while (-1==nbytes && EINTR==errno); + do { + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + nbytes = HDread(file->fd, buf, (size_t)size); + } while (-1==nbytes && EINTR==errno); if (-1==nbytes) { /* error */ file->pos = HADDR_UNDEF; @@ -867,7 +869,8 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr } if (0==nbytes) { /* end of file but not end of format address space */ - memset(buf, 0, size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemset(buf, 0, (size_t)size); size = 0; } assert(nbytes>=0); @@ -903,7 +906,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr *------------------------------------------------------------------------- */ static herr_t -H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t addr, +H5FD_log_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr_t addr, hsize_t size, const void *buf) { H5FD_log_t *file = (H5FD_log_t*)_file; @@ -957,9 +960,10 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add * results */ while (size>0) { - do - nbytes = write(file->fd, buf, size); - while (-1==nbytes && EINTR==errno); + do { + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + nbytes = HDwrite(file->fd, buf, (size_t)size); + } while (-1==nbytes && EINTR==errno); if (-1==nbytes) { /* error */ file->pos = HADDR_UNDEF; diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index a26d7e1..fd7dfbb 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -469,8 +469,10 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/, if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1); - if (H5FD_MULTI!=H5P_get_driver(fapl_id)) +#ifndef WANT_H5_V1_2_COMPAT + if (H5FD_MULTI!=H5Pget_driver(fapl_id)) H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "incorrect VFL driver", -1); +#endif /* WANT_H5_V1_2_COMPAT */ if (NULL==(fa=H5Pget_driver_info(fapl_id))) H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "bad VFL driver info", -1); @@ -586,8 +588,10 @@ H5Pget_dxpl_multi(hid_t dxpl_id, hid_t *memb_dxpl/*out*/) if (H5P_FILE_ACCESS!=H5Pget_class(dxpl_id)) H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1); - if (H5FD_MULTI!=H5P_get_driver(dxpl_id)) +#ifndef WANT_H5_V1_2_COMPAT + if (H5FD_MULTI!=H5Pget_driver(dxpl_id)) H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "incorrect VFL driver", -1); +#endif /* WANT_H5_V1_2_COMPAT */ if (NULL==(dx=H5Pget_driver_info(dxpl_id))) H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "bad VFL driver info", -1); @@ -642,8 +646,8 @@ H5FD_multi_sb_size(H5FD_t *_file) /* Name templates */ UNIQUE_MEMBERS(file->fa.memb_map, mt) { - size_t n = strlen(file->fa.memb_name[mt])+1; - nbytes += (n+7) & ~0x0007; + size_t n = strlen(file->fa.memb_name[mt])+1; + nbytes += (n+7) & ~((size_t)0x0007); } END_MEMBERS; return nbytes; @@ -682,7 +686,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, H5FD_multi_t *file = (H5FD_multi_t*)_file; haddr_t memb_eoa; unsigned char *p; - int nseen; + hsize_t nseen; size_t i; H5FD_mem_t m; static const char *func="H5FD_multi_sb_encode"; /* Function Name for error reporting */ @@ -695,7 +699,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, assert(7==H5FD_MEM_NTYPES); for (m=H5FD_MEM_SUPER; m<H5FD_MEM_NTYPES; m++) { - buf[m-1] = file->fa.memb_map[m]; + buf[m-1] = file->fa.memb_map[m]; } buf[7] = 0; buf[8] = 0; @@ -710,12 +714,12 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, p = buf+8; assert(sizeof(haddr_t)<=8); UNIQUE_MEMBERS(file->fa.memb_map, mt) { - memb_eoa = H5FDget_eoa(file->memb[mt]); - memcpy(p, &(file->fa.memb_addr[mt]), sizeof(haddr_t)); - p += sizeof(haddr_t); - memcpy(p, &memb_eoa, sizeof(haddr_t)); - p += sizeof(haddr_t); - nseen++; + memb_eoa = H5FDget_eoa(file->memb[mt]); + memcpy(p, &(file->fa.memb_addr[mt]), sizeof(haddr_t)); + p += sizeof(haddr_t); + memcpy(p, &memb_eoa, sizeof(haddr_t)); + p += sizeof(haddr_t); + nseen++; } END_MEMBERS; if (H5Tconvert(H5T_NATIVE_HADDR, H5T_STD_U64LE, nseen*2, buf+8, NULL, H5P_DEFAULT)<0) { @@ -725,10 +729,10 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/, /* Encode all name templates */ p = buf + 8 + nseen*2*8; UNIQUE_MEMBERS(file->fa.memb_map, mt) { - size_t n = strlen(file->fa.memb_name[mt]) + 1; - strcpy((char *)p, file->fa.memb_name[mt]); - p += n; - for (i=n; i%8; i++) *p++ = '\0'; + size_t n = strlen(file->fa.memb_name[mt]) + 1; + strcpy((char *)p, file->fa.memb_name[mt]); + p += n; + for (i=n; i%8; i++) *p++ = '\0'; } END_MEMBERS; return 0; @@ -763,7 +767,8 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) H5FD_multi_t *file = (H5FD_multi_t*)_file; char x[2*H5FD_MEM_NTYPES*8]; H5FD_mem_t map[H5FD_MEM_NTYPES]; - int nseen=0, i; + int i; + hsize_t nseen=0; hbool_t map_changed=FALSE; hbool_t in_use[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; @@ -781,9 +786,9 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) /* Set default values */ ALL_MEMBERS(mt) { - memb_addr[mt] = HADDR_UNDEF; - memb_eoa[mt] = HADDR_UNDEF; - memb_name[mt] = NULL; + memb_addr[mt] = HADDR_UNDEF; + memb_eoa[mt] = HADDR_UNDEF; + memb_name[mt] = NULL; } END_MEMBERS; /* @@ -792,31 +797,32 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) memset(map, 0, sizeof map); for (i=0; i<6; i++) { map[i+1] = (H5FD_mem_t)buf[i]; - if (file->fa.memb_map[i+1]!=map[i+1]) map_changed=TRUE; + if (file->fa.memb_map[i+1]!=map[i+1]) + map_changed=TRUE; } UNIQUE_MEMBERS(map, mt) { - nseen++; + nseen++; } END_MEMBERS; buf += 8; /* Decode Address and EOA values */ assert(sizeof(haddr_t)<=8); - memcpy(x, buf, nseen*2*8); + assert((nseen*2*8)==(hsize_t)((size_t)(nseen*2*8))); /*check for overflow*/ + memcpy(x, buf, (size_t)(nseen*2*8)); buf += nseen*2*8; - if (H5Tconvert(H5T_STD_U64LE, H5T_NATIVE_HADDR, nseen*2, x, NULL, - H5P_DEFAULT)<0) + if (H5Tconvert(H5T_STD_U64LE, H5T_NATIVE_HADDR, nseen*2, x, NULL, H5P_DEFAULT)<0) H5Epush_ret(func, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1); ap = (haddr_t*)x; UNIQUE_MEMBERS(map, mt) { - memb_addr[_unmapped] = *ap++; - memb_eoa[_unmapped] = *ap++; + memb_addr[_unmapped] = *ap++; + memb_eoa[_unmapped] = *ap++; } END_MEMBERS; /* Decode name templates */ UNIQUE_MEMBERS(map, mt) { - size_t n = strlen((const char *)buf)+1; - memb_name[_unmapped] = (const char *)buf; - buf += (n+7) & ~0x0007; + size_t n = strlen((const char *)buf)+1; + memb_name[_unmapped] = (const char *)buf; + buf += (n+7) & ~((unsigned)0x0007); } END_MEMBERS; /* @@ -827,50 +833,50 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) */ if (map_changed) { #ifdef H5FD_MULTI_DEBUG - if (file->flags & H5F_ACC_DEBUG) { - fprintf(stderr, "H5FD_MULTI: member map override\n"); - fprintf(stderr, " old value: "); - ALL_MEMBERS(mt) { - fprintf(stderr, "%s%d", mt?", ":"", - (int)(file->fa.memb_map[mt])); - } END_MEMBERS; - fprintf(stderr, "\n new value: "); - ALL_MEMBERS(mt) { - fprintf(stderr, "%s%d", mt?", ":"", (int)(map[mt])); - } END_MEMBERS; - } + if (file->flags & H5F_ACC_DEBUG) { + fprintf(stderr, "H5FD_MULTI: member map override\n"); + fprintf(stderr, " old value: "); + ALL_MEMBERS(mt) { + fprintf(stderr, "%s%d", mt?", ":"", (int)(file->fa.memb_map[mt])); + } END_MEMBERS; + fprintf(stderr, "\n new value: "); + ALL_MEMBERS(mt) { + fprintf(stderr, "%s%d", mt?", ":"", (int)(map[mt])); + } END_MEMBERS; + } #endif - /* Commit map */ - ALL_MEMBERS(mt) { - file->fa.memb_map[mt] = map[mt]; - } END_MEMBERS; - - /* Close files which are unused now */ - memset(in_use, 0, sizeof in_use); - UNIQUE_MEMBERS(map, mt) { - in_use[mt] = TRUE; - } END_MEMBERS; - ALL_MEMBERS(mt) { - if (!in_use[mt] && file->memb[mt]) { + /* Commit map */ + ALL_MEMBERS(mt) { + file->fa.memb_map[mt] = map[mt]; + } END_MEMBERS; + + /* Close files which are unused now */ + memset(in_use, 0, sizeof in_use); + UNIQUE_MEMBERS(map, mt) { + in_use[mt] = TRUE; + } END_MEMBERS; + ALL_MEMBERS(mt) { + if (!in_use[mt] && file->memb[mt]) { #ifdef H5FD_MULTI_DEBUG - if (file->flags & H5F_ACC_DEBUG) { - fprintf(stderr, "H5FD_MULTI: close member %d\n", (int)mt); - } + if (file->flags & H5F_ACC_DEBUG) { + fprintf(stderr, "H5FD_MULTI: close member %d\n", (int)mt); + } #endif - H5FDclose(file->memb[mt]); - file->memb[mt] = NULL; - } - file->fa.memb_map[mt] = map[mt]; - } END_MEMBERS; + H5FDclose(file->memb[mt]); + file->memb[mt] = NULL; + } + file->fa.memb_map[mt] = map[mt]; + } END_MEMBERS; } /* Commit member starting addresses and name templates */ ALL_MEMBERS(mt) { - file->fa.memb_addr[mt] = memb_addr[mt]; - if (memb_name[mt]) { - if (file->fa.memb_name[mt]) free(file->fa.memb_name[mt]); - file->fa.memb_name[mt] = my_strdup(memb_name[mt]); - } + file->fa.memb_addr[mt] = memb_addr[mt]; + if (memb_name[mt]) { + if (file->fa.memb_name[mt]) + free(file->fa.memb_name[mt]); + file->fa.memb_name[mt] = my_strdup(memb_name[mt]); + } } END_MEMBERS; if (compute_next(file)<0) H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", -1); @@ -881,9 +887,9 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf) /* Set the EOA marker for all open files */ UNIQUE_MEMBERS(file->fa.memb_map, mt) { - if (file->memb[mt]) { - H5FDset_eoa(file->memb[mt], memb_eoa[mt]); - } + if (file->memb[mt]) { + H5FDset_eoa(file->memb[mt], memb_eoa[mt]); + } } END_MEMBERS; return 0; @@ -1134,7 +1140,7 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id, */ if (NULL==(file=calloc(1, sizeof(H5FD_multi_t)))) H5Epush_ret(func, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL); - if (H5P_DEFAULT==fapl_id || H5FD_MULTI!=H5P_get_driver(fapl_id)) { + if (H5P_DEFAULT==fapl_id || H5FD_MULTI!=H5Pget_driver(fapl_id)) { close_fapl = fapl_id = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE); } @@ -1579,7 +1585,7 @@ H5FD_multi_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsi H5Eclear(); /* Get the data transfer properties */ - if (H5P_DEFAULT!=dxpl_id && H5FD_MULTI==H5P_get_driver(dxpl_id)) { + if (H5P_DEFAULT!=dxpl_id && H5FD_MULTI==H5Pget_driver(dxpl_id)) { dx = H5Pget_driver_info(dxpl_id); } @@ -1634,7 +1640,7 @@ H5FD_multi_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hs H5Eclear(); /* Get the data transfer properties */ - if (H5P_DEFAULT!=dxpl_id && H5FD_MULTI==H5P_get_driver(dxpl_id)) { + if (H5P_DEFAULT!=dxpl_id && H5FD_MULTI==H5Pget_driver(dxpl_id)) { dx = H5Pget_driver_info(dxpl_id); } diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index bc21fd4..2d29c0c 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -264,7 +264,7 @@ static H5FD_t * H5FD_sec2_open(const char *name, unsigned flags, hid_t UNUSED fapl_id, haddr_t maxaddr) { - unsigned o_flags; + int o_flags; int fd; struct stat sb; H5FD_sec2_t *file=NULL; @@ -579,9 +579,10 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd * and the end of the file. */ while (size>0) { - do - nbytes = read(file->fd, buf, size); - while (-1==nbytes && EINTR==errno); + do { + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + nbytes = HDread(file->fd, buf, (size_t)size); + } while (-1==nbytes && EINTR==errno); if (-1==nbytes) { /* error */ file->pos = HADDR_UNDEF; @@ -590,7 +591,8 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd } if (0==nbytes) { /* end of file but not end of format address space */ - memset(buf, 0, size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemset(buf, 0, (size_t)size); size = 0; } assert(nbytes>=0); @@ -659,9 +661,10 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had * results */ while (size>0) { - do - nbytes = write(file->fd, buf, size); - while (-1==nbytes && EINTR==errno); + do { + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + nbytes = HDwrite(file->fd, buf, (size_t)size); + } while (-1==nbytes && EINTR==errno); if (-1==nbytes) { /* error */ file->pos = HADDR_UNDEF; diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 0319561..571e1a4 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -608,7 +608,8 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsi if (0 == size) return(0); if ((haddr_t)addr >= file->eof) { - memset(buf, 0, size); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + memset(buf, 0, (size_t)size); return(0); } @@ -649,13 +650,15 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsi * will advance the file position by N. If N is negative or an error * occurs then the file position is undefined. */ - n = fread(buf, 1, size, file->fp); + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + n = fread(buf, 1, (size_t)size, file->fp); if (n <= 0 && ferror(file->fp)) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(func, H5E_IO, H5E_READERROR, "fread failed", -1); } else if (n < size) { - memset((unsigned char *)buf + n, 0, size - n); + assert((size-n)==(hsize_t)((size_t)(size-n))); /*check for overflow*/ + memset((unsigned char *)buf + n, 0, (size_t)(size - n)); } /* @@ -740,7 +743,8 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, * advanced by the number of bytes read. Otherwise nobody knows where it * is. */ - if (size != fwrite(buf, 1, size, file->fp)) { + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + if (size != fwrite(buf, 1, (size_t)size, file->fp)) { file->op = H5FD_STDIO_OP_UNKNOWN; file->pos = HADDR_UNDEF; H5Epush_ret(func, H5E_IO, H5E_WRITEERROR, "fwrite failed", -1); diff --git a/src/H5FDstream.c b/src/H5FDstream.c index 786eaa1..79d9b5c 100644 --- a/src/H5FDstream.c +++ b/src/H5FDstream.c @@ -374,7 +374,7 @@ static void *H5FD_stream_fapl_get (H5FD_t *_stream) static H5FD_STREAM_SOCKET_TYPE H5FDstream_open_socket (const char *filename, int o_flags, - unsigned int backlog, + int backlog, const char **errormsg, H5E_major_t *major, H5E_minor_t *minor) { @@ -419,7 +419,7 @@ H5FDstream_open_socket (const char *filename, int o_flags, return (sock); } - hostname = (char *) H5MM_malloc (separator - filename + 1); + hostname = (char *) H5MM_malloc ((size_t)(separator - filename + 1)); /* Return if out of memory */ if (hostname == NULL) @@ -429,11 +429,11 @@ H5FDstream_open_socket (const char *filename, int o_flags, return (sock); } - strncpy (hostname, filename, separator - filename); + HDstrncpy (hostname, filename, (size_t)(separator - filename)); hostname[separator - filename] = 0; port = atoi (separator + 1); - memset (&server, 0, sizeof (server)); + HDmemset (&server, 0, sizeof (server)); server.sin_family = AF_INET; server.sin_port = htons (port); @@ -450,7 +450,7 @@ H5FDstream_open_socket (const char *filename, int o_flags, { if (O_RDONLY == o_flags) { - memcpy (&server.sin_addr, he->h_addr, he->h_length); + HDmemcpy (&server.sin_addr, he->h_addr, (size_t)he->h_length); #ifdef DEBUG fprintf (stderr, "Stream VFD: connecting to host '%s' port %d\n", hostname, port); @@ -545,7 +545,7 @@ static void H5FDstream_read_from_socket (H5FD_stream_t *stream, } /* now receive the next chunk of data */ - size = recv (stream->socket, ptr, (int) max_size, 0); + size = recv (stream->socket, ptr, max_size, 0); if (size < 0 && (EINTR == errno || EAGAIN == errno || EWOULDBLOCK)) { @@ -657,7 +657,7 @@ static H5FD_t *H5FD_stream_open (const char *filename, } /* zero out file structure and set file access property list */ - memset (&_stream, 0, sizeof (_stream)); + HDmemset (&_stream, 0, sizeof (_stream)); _stream.fapl = *fapl; errormsg = NULL; @@ -781,8 +781,8 @@ static H5FD_t *H5FD_stream_open (const char *filename, static herr_t H5FD_stream_flush (H5FD_t *_stream) { H5FD_stream_t *stream = (H5FD_stream_t *) _stream; - int size; - int bytes_send; + size_t size; + ssize_t bytes_send; int on = 1; unsigned char *ptr; struct sockaddr from; @@ -808,7 +808,7 @@ static herr_t H5FD_stream_flush (H5FD_t *_stream) continue; /* continue the loop for other clients' requests */ } - size = (int) stream->eof; + size = stream->eof; ptr = stream->mem; while (size) @@ -878,7 +878,7 @@ static herr_t H5FD_stream_close (H5FD_t *_stream) { H5MM_xfree (stream->mem); } - memset (stream, 0, sizeof (H5FD_stream_t)); + HDmemset (stream, 0, sizeof (H5FD_stream_t)); H5MM_xfree (stream); FUNC_LEAVE (0); @@ -1006,7 +1006,6 @@ static haddr_t H5FD_stream_get_eof (H5FD_t *_stream) { H5FD_stream_t *stream = (H5FD_stream_t *) _stream; - FUNC_ENTER (H5FD_stream_get_eof, HADDR_UNDEF); FUNC_LEAVE (MAX (stream->eof, stream->eoa)); @@ -1042,7 +1041,6 @@ static herr_t H5FD_stream_read (H5FD_t *_stream, H5FD_stream_t *stream = (H5FD_stream_t *) _stream; ssize_t nbytes; - FUNC_ENTER (H5FD_stream_read, FAIL); assert (stream && stream->pub.cls); @@ -1066,7 +1064,7 @@ static herr_t H5FD_stream_read (H5FD_t *_stream, if (addr < stream->eof) { nbytes = (ssize_t) MIN (size, stream->eof - addr); - memcpy (buf, stream->mem + addr, (size_t) nbytes); + HDmemcpy (buf, stream->mem + addr, (size_t) nbytes); size -= nbytes; addr += nbytes; buf = (char *) buf + nbytes; @@ -1075,7 +1073,7 @@ static herr_t H5FD_stream_read (H5FD_t *_stream, /* Read zeros for the part which is after the EOF markers */ if (size > 0) { - memset (buf, 0, (size_t) size); + HDmemset (buf, 0, (size_t) size); } FUNC_LEAVE (SUCCEED); @@ -1159,7 +1157,7 @@ static herr_t H5FD_stream_write (H5FD_t *_stream, } /* Write from BUF to memory */ - memcpy (stream->mem + addr, buf, (size_t) size); + HDmemcpy (stream->mem + addr, buf, (size_t) size); stream->dirty = TRUE; FUNC_LEAVE (SUCCEED); diff --git a/src/H5FDstream.h b/src/H5FDstream.h index aa0f339..6ea2e7e 100644 --- a/src/H5FDstream.h +++ b/src/H5FDstream.h @@ -62,7 +62,7 @@ typedef struct H5FD_stream_fapl_t size_t increment; /* how much to grow memory in reallocs */ H5FD_STREAM_SOCKET_TYPE socket; /* external socket descriptor */ hbool_t do_socket_io; /* do I/O on socket */ - unsigned int backlog; /* backlog argument for listen call */ + int backlog; /* backlog argument for listen call */ H5FD_stream_broadcast_t broadcast_fn; /* READ broadcast callback */ void *broadcast_arg; /* READ broadcast callback user argument*/ } H5FD_stream_fapl_t; @@ -123,19 +123,20 @@ H5FL_DEFINE(H5FL_blk_node_t); *------------------------------------------------------------------------- */ static void * -H5FL_malloc(size_t mem_size) +H5FL_malloc(hsize_t mem_size) { void *ret_value=NULL; /* return value*/ FUNC_ENTER (H5FL_malloc, NULL); /* Attempt to allocate the memory requested */ - if(NULL==(ret_value=H5MM_malloc(mem_size))) { + assert(mem_size==(hsize_t)((size_t)mem_size)); /*check for overflow*/ + if(NULL==(ret_value=H5MM_malloc((size_t)mem_size))) { /* If we can't allocate the memory now, try garbage collecting first */ H5FL_garbage_coll(); /* Now try allocating the memory again */ - if(NULL==(ret_value=H5MM_malloc(mem_size))) + if(NULL==(ret_value=H5MM_malloc((size_t)mem_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk"); } /* end if */ @@ -331,8 +332,10 @@ H5FL_reg_alloc(H5FL_reg_head_t *head, uintn clear) } /* end else */ /* Clear to zeros, if asked */ - if(clear) - HDmemset(ret_value,0,head->size); + if(clear) { + assert(head->size==(hsize_t)((size_t)head->size)); /*check for overflow*/ + HDmemset(ret_value,0,(size_t)head->size); + } /* end if */ #endif /* NO_REG_FREE_LISTS */ FUNC_LEAVE (ret_value); @@ -531,7 +534,7 @@ H5FL_reg_term(void) *------------------------------------------------------------------------- */ static H5FL_blk_node_t * -H5FL_blk_find_list(H5FL_blk_node_t **head, size_t size) +H5FL_blk_find_list(H5FL_blk_node_t **head, hsize_t size) { H5FL_blk_node_t *temp; /* Temp. pointer to node in the native list */ H5FL_blk_node_t *ret_value=NULL; @@ -585,7 +588,7 @@ H5FL_blk_find_list(H5FL_blk_node_t **head, size_t size) *------------------------------------------------------------------------- */ static H5FL_blk_node_t * -H5FL_blk_create_list(H5FL_blk_node_t **head, size_t size) +H5FL_blk_create_list(H5FL_blk_node_t **head, hsize_t size) { H5FL_blk_node_t *temp; /* Temp. pointer to node in the list */ H5FL_blk_node_t *ret_value=NULL; @@ -734,8 +737,10 @@ H5FL_blk_alloc(H5FL_blk_head_t *head, hsize_t size, uintn clear) } /* end else */ /* Clear the block to zeros, if requested */ - if(clear) - HDmemset(ret_value,0,size); + if(clear) { + assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ + HDmemset(ret_value,0,(size_t)size); + } /* end if */ #endif /* NO_BLK_FREE_LISTS */ done: @@ -841,7 +846,8 @@ printf("%s: head->name=%s, garbage collecting all block lists\n",FUNC,head->name void * H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, hsize_t new_size) { - H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */ + hsize_t blk_size; /* Temporary block size */ + H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */ void *ret_value=NULL; /* Return value */ FUNC_ENTER(H5FL_blk_realloc, NULL); @@ -861,7 +867,9 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, hsize_t new_size) if(new_size!=temp->size) { if((ret_value=H5FL_blk_alloc(head,new_size,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block"); - HDmemcpy(ret_value,block,MIN(new_size,temp->size)); + blk_size=MIN(new_size,temp->size); + assert(blk_size==(hsize_t)((size_t)blk_size)); /*check for overflow*/ + HDmemcpy(ret_value,block,(size_t)blk_size); H5FL_blk_free(head,block); } /* end if */ else @@ -1196,7 +1204,7 @@ H5FL_arr_alloc(H5FL_arr_head_t *head, hsize_t elem, uintn clear) { H5FL_arr_node_t *new_obj; /* Pointer to the new free list node allocated */ void *ret_value; /* Pointer to object to return */ - size_t mem_size; /* Size of memory block being recycled */ + hsize_t mem_size; /* Size of memory block being recycled */ FUNC_ENTER (H5FL_arr_alloc, NULL); @@ -1251,8 +1259,10 @@ H5FL_arr_alloc(H5FL_arr_head_t *head, hsize_t elem, uintn clear) } /* end else */ /* Clear to zeros, if asked */ - if(clear) - HDmemset(ret_value,0,mem_size); + if(clear) { + assert(mem_size==(hsize_t)((size_t)mem_size)); /*check for overflow*/ + HDmemset(ret_value,0,(size_t)mem_size); + } /* end if */ } /* end if */ /* No fixed number of elements, use PQ routine */ else { @@ -1282,6 +1292,7 @@ H5FL_arr_alloc(H5FL_arr_head_t *head, hsize_t elem, uintn clear) void * H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, hsize_t new_elem) { + hsize_t blk_size; /* Size of block */ H5FL_arr_node_t *temp; /* Temp. ptr to the new free list node allocated */ void *ret_value; /* Pointer to object to return */ @@ -1309,7 +1320,9 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, hsize_t new_elem) ret_value=H5FL_arr_alloc(head,new_elem,0); /* Copy the appropriate amount of elements */ - HDmemcpy(ret_value,obj,head->size*MIN(temp->nelem,new_elem)); + blk_size=head->size*MIN(temp->nelem,new_elem); + assert(blk_size==(hsize_t)((size_t)blk_size)); /*check for overflow*/ + HDmemcpy(ret_value,obj,(size_t)blk_size); /* Free the old block */ H5FL_arr_free(head,obj); diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h index 472bcca..50315ed 100644 --- a/src/H5FLprivate.h +++ b/src/H5FLprivate.h @@ -47,7 +47,7 @@ typedef struct H5FL_reg_head_t { uintn onlist; /* Number of blocks on free list */ size_t list_mem; /* Amount of memory on free list */ const char *name; /* Name of the type */ - size_t size; /* Size of the blocks in the list */ + hsize_t size; /* Size of the blocks in the list */ H5FL_reg_node_t *list; /* List of free blocks */ } H5FL_reg_head_t; @@ -75,7 +75,7 @@ typedef struct H5FL_reg_head_t { /* Data structure to store each block in free list */ typedef struct H5FL_blk_list_t { - size_t size; /* Size of the page */ + hsize_t size; /* Size of the page */ struct H5FL_blk_list_t *next; /* Pointer to next block in free list */ union { double unused1; /* Unused normally, just here for aligment */ @@ -85,7 +85,7 @@ typedef struct H5FL_blk_list_t { /* Data structure for priority queue node of block free lists */ typedef struct H5FL_blk_node_t { - size_t size; /* Size of the blocks in the list */ + hsize_t size; /* Size of the blocks in the list */ H5FL_blk_list_t *list; /* List of free blocks */ struct H5FL_blk_node_t *next; /* Pointer to next free list in queue */ struct H5FL_blk_node_t *prev; /* Pointer to previous free list in queue */ @@ -96,7 +96,7 @@ typedef struct H5FL_blk_head_t { uintn init; /* Whether the free list has been initialized */ uintn allocated; /* Number of blocks allocated */ uintn onlist; /* Number of blocks on free list */ - size_t list_mem; /* Amount of memory in block on free list */ + hsize_t list_mem; /* Amount of memory in block on free list */ const char *name; /* Name of the type */ H5FL_blk_node_t *head; /* Pointer to first free list in queue */ } H5FL_blk_head_t; @@ -125,7 +125,7 @@ typedef struct H5FL_blk_head_t { /* Data structure to store each array in free list */ typedef struct H5FL_arr_node_t { struct H5FL_arr_node_t *next; /* Pointer to next block in free list */ - size_t nelem; /* Number of elements in this array */ + hsize_t nelem; /* Number of elements in this array */ union { double unused1; /* Unused normally, just here for aligment */ haddr_t unused2; /* Unused normally, just here for aligment */ @@ -137,10 +137,10 @@ typedef struct H5FL_arr_head_t { uintn init; /* Whether the free list has been initialized */ uintn allocated; /* Number of blocks allocated */ uintn *onlist; /* Number of blocks on free list */ - size_t list_mem; /* Amount of memory in block on free list */ + hsize_t list_mem; /* Amount of memory in block on free list */ const char *name; /* Name of the type */ intn maxelem; /* Maximum number of elements in an array */ - size_t size; /* Size of the array elements in the list */ + hsize_t size; /* Size of the array elements in the list */ union { H5FL_arr_node_t **list_arr; /* Array of lists of free blocks */ H5FL_blk_head_t queue; /* Priority queue of array blocks */ diff --git a/src/H5Farray.c b/src/H5Farray.c index 2c2a6c9..2c7c9d8 100644 --- a/src/H5Farray.c +++ b/src/H5Farray.c @@ -53,7 +53,7 @@ static intn interface_initialize_g = 0; herr_t H5F_arr_create (H5F_t *f, struct H5O_layout_t *layout/*in,out*/) { - intn i; + uintn u; hsize_t nbytes; FUNC_ENTER (H5F_arr_create, FAIL); @@ -64,28 +64,29 @@ H5F_arr_create (H5F_t *f, struct H5O_layout_t *layout/*in,out*/) layout->addr = HADDR_UNDEF; /*just in case we fail*/ switch (layout->type) { - case H5D_CONTIGUOUS: - /* Reserve space in the file for the entire array */ - for (i=0, nbytes=1; i<layout->ndims; i++) nbytes *= layout->dim[i]; - assert (nbytes>0); - if (HADDR_UNDEF==(layout->addr=H5MF_alloc(f, H5FD_MEM_DRAW, nbytes))) { - HRETURN_ERROR (H5E_IO, H5E_NOSPACE, FAIL, - "unable to reserve file space"); - } - break; + case H5D_CONTIGUOUS: + /* Reserve space in the file for the entire array */ + for (u=0, nbytes=1; u<layout->ndims; u++) + nbytes *= layout->dim[u]; + assert (nbytes>0); + if (HADDR_UNDEF==(layout->addr=H5MF_alloc(f, H5FD_MEM_DRAW, nbytes))) { + HRETURN_ERROR (H5E_IO, H5E_NOSPACE, FAIL, + "unable to reserve file space"); + } + break; - case H5D_CHUNKED: - /* Create the root of the B-tree that describes chunked storage */ - if (H5F_istore_create (f, layout/*out*/)<0) { - HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL, - "unable to initialize chunked storage"); - } - break; + case H5D_CHUNKED: + /* Create the root of the B-tree that describes chunked storage */ + if (H5F_istore_create (f, layout/*out*/)<0) { + HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL, + "unable to initialize chunked storage"); + } + break; - default: - assert ("not implemented yet" && 0); - HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, - "unsupported storage layout"); + default: + assert ("not implemented yet" && 0); + HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, + "unsupported storage layout"); } FUNC_LEAVE (SUCCEED); @@ -141,9 +142,10 @@ H5F_arr_read(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, hsize_t file_start; /*byte offset to start */ hsize_t elmt_size = 1; /*bytes per element */ size_t nelmts, z; /*number of elements */ - intn ndims; /*stride dimensionality */ + uintn ndims; /*stride dimensionality */ haddr_t addr; /*address in file */ - intn i, j; /*counters */ + intn j; /*counters */ + uintn u; /*counters */ hbool_t carray; /*carry for subtraction */ #ifdef H5_HAVE_PARALLEL H5FD_mpio_xfer_t xfer_mode=H5FD_MPIO_INDEPENDENT; @@ -193,166 +195,168 @@ H5F_arr_read(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, if(qak_debug) { printf("%s: layout->ndims=%d\n",FUNC,(int)layout->ndims); - for(i=0; i<layout->ndims; i++) - printf("%s: %d: hslab_size=%d, mem_size=%d, mem_offset=%d, file_offset=%d\n",FUNC,i,(int)_hslab_size[i],(int)mem_size[i],(int)mem_offset[i],(int)file_offset[i]); + for(u=0; u<layout->ndims; u++) + printf("%s: %u: hslab_size=%d, mem_size=%d, mem_offset=%d, file_offset=%d\n",FUNC,u,(int)_hslab_size[u],(int)mem_size[u],(int)mem_offset[u],(int)file_offset[u]); printf("%s: *buf=%d, *(buf+1)=%d\n", FUNC,(int)*(const uint16_t *)buf,(int)*((const uint16 *)buf+1)); } } #endif /* QAK */ switch (layout->type) { - case H5D_CONTIGUOUS: - ndims = layout->ndims; - /* - * Offsets must not be negative for this type of storage. - */ - for (i=0; i<ndims; i++) { - if (mem_offset[i]<0 || file_offset[i]<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "negative offsets are not valid"); - } - } + case H5D_CONTIGUOUS: + ndims = layout->ndims; + /* + * Offsets must not be negative for this type of storage. + */ + for (u=0; u<ndims; u++) { + if (mem_offset[u]<0 || file_offset[u]<0) { + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + "negative offsets are not valid"); + } + } - /* - * Filters cannot be used for contiguous data. - */ - if (pline && pline->nfilters>0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "filters are not allowed for contiguous data"); - } - - /* - * Calculate the strides needed to walk through the array on disk - * and memory. Optimize the strides to result in the fewest number of - * I/O requests. - */ - mem_start = H5V_hyper_stride(ndims, hslab_size, mem_size, - mem_offset, mem_stride/*out*/); - file_start = H5V_hyper_stride(ndims, hslab_size, layout->dim, - file_offset, file_stride/*out*/); - H5V_stride_optimize2(&ndims, &elmt_size, hslab_size, - mem_stride, file_stride); - - /* - * Initialize loop variables. The loop is a multi-dimensional loop - * that counts from SIZE down to zero and IDX is the counter. Each - * element of IDX is treated as a digit with IDX[0] being the least - * significant digit. - */ - H5V_vector_cpy(ndims, idx, hslab_size); - nelmts = H5V_vector_reduce_product(ndims, hslab_size); - if (efl && efl->nused>0) { - addr = 0; - } else { - addr = layout->addr; - } - addr += file_start; - buf += mem_start; + /* + * Filters cannot be used for contiguous data. + */ + if (pline && pline->nfilters>0) { + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + "filters are not allowed for contiguous data"); + } + + /* + * Calculate the strides needed to walk through the array on disk + * and memory. Optimize the strides to result in the fewest number of + * I/O requests. + */ + mem_start = H5V_hyper_stride(ndims, hslab_size, mem_size, + mem_offset, mem_stride/*out*/); + file_start = H5V_hyper_stride(ndims, hslab_size, layout->dim, + file_offset, file_stride/*out*/); + H5V_stride_optimize2(&ndims, &elmt_size, hslab_size, + mem_stride, file_stride); + + /* + * Initialize loop variables. The loop is a multi-dimensional loop + * that counts from SIZE down to zero and IDX is the counter. Each + * element of IDX is treated as a digit with IDX[0] being the least + * significant digit. + */ + H5V_vector_cpy(ndims, idx, hslab_size); + nelmts = H5V_vector_reduce_product(ndims, hslab_size); + if (efl && efl->nused>0) { + addr = 0; + } else { + addr = layout->addr; + } + addr += file_start; + buf += mem_start; - /* - * Now begin to walk through the array, copying data from disk to - * memory. - */ + /* + * Now begin to walk through the array, copying data from disk to + * memory. + */ #ifdef H5_HAVE_PARALLEL - if (H5FD_MPIO_COLLECTIVE==xfer_mode){ - /* - * Currently supports same number of collective access. Need to - * be changed LATER to combine all reads into one collective MPIO - * call. - */ - unsigned long max, min, temp; - - temp = nelmts; - assert(temp==nelmts); /* verify no overflow */ - MPI_Allreduce(&temp, &max, 1, MPI_UNSIGNED_LONG, MPI_MAX, - H5FD_mpio_communicator(f->shared->lf)); - MPI_Allreduce(&temp, &min, 1, MPI_UNSIGNED_LONG, MPI_MIN, - H5FD_mpio_communicator(f->shared->lf)); + if (H5FD_MPIO_COLLECTIVE==xfer_mode){ + /* + * Currently supports same number of collective access. Need to + * be changed LATER to combine all reads into one collective MPIO + * call. + */ + unsigned long max, min, temp; + + temp = nelmts; + assert(temp==nelmts); /* verify no overflow */ + MPI_Allreduce(&temp, &max, 1, MPI_UNSIGNED_LONG, MPI_MAX, + H5FD_mpio_communicator(f->shared->lf)); + MPI_Allreduce(&temp, &min, 1, MPI_UNSIGNED_LONG, MPI_MIN, + H5FD_mpio_communicator(f->shared->lf)); #ifdef AKC - printf("nelmts=%lu, min=%lu, max=%lu\n", temp, min, max); + printf("nelmts=%lu, min=%lu, max=%lu\n", temp, min, max); #endif - if (max != min) - HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL, - "collective access with unequal number of " - "blocks not supported yet"); - } + if (max != min) + HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL, + "collective access with unequal number of " + "blocks not supported yet"); + } #endif #ifdef COALESCE_READS - /* Get the dataset transfer property list */ - if (H5P_DEFAULT == dxpl_id) { - xfer_parms = &H5D_xfer_dflt; - } else if (H5P_DATASET_XFER != H5P_get_class (dxpl_id) || - NULL == (xfer_parms = H5I_object (dxpl_id))) { - HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); - } - - for (z=0, xfer_parms->gather_reads = nelmts - 1; - z<nelmts; - z++, xfer_parms->gather_reads--) { + /* Get the dataset transfer property list */ + if (H5P_DEFAULT == dxpl_id) { + xfer_parms = &H5D_xfer_dflt; + } else if (H5P_DATASET_XFER != H5P_get_class (dxpl_id) || + NULL == (xfer_parms = H5I_object (dxpl_id))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); + } + + for (z=0, xfer_parms->gather_reads = nelmts - 1; + z<nelmts; + z++, xfer_parms->gather_reads--) { #else #ifdef QAK -printf("%s: nelmts=%d, addr=%lu, elmt_size=%lu\n",FUNC,(int)nelmts,(unsigned long)addr,(unsigned long)elmt_size); -printf("%s: sieve_buf=%p, sieve_loc=%lu, sieve_size=%lu, sieve_buf_size=%lu, sieve_dirty=%u\n",FUNC,f->shared->sieve_buf,(unsigned long)f->shared->sieve_loc,(unsigned long)f->shared->sieve_size,(unsigned long)f->shared->sieve_buf_size,(unsigned)f->shared->sieve_dirty); -printf("%s: feature_flags=%lx\n",FUNC,(unsigned long)f->shared->lf->feature_flags); + printf("%s: nelmts=%d, addr=%lu, elmt_size=%lu\n",FUNC,(int)nelmts,(unsigned long)addr,(unsigned long)elmt_size); + printf("%s: sieve_buf=%p, sieve_loc=%lu, sieve_size=%lu, sieve_buf_size=%lu, sieve_dirty=%u\n",FUNC,f->shared->sieve_buf,(unsigned long)f->shared->sieve_loc,(unsigned long)f->shared->sieve_size,(unsigned long)f->shared->sieve_buf_size,(unsigned)f->shared->sieve_dirty); + printf("%s: feature_flags=%lx\n",FUNC,(unsigned long)f->shared->lf->feature_flags); #endif /* QAK */ - for (z=0; z<nelmts; z++) { + for (z=0; z<nelmts; z++) { #endif - /* Read directly from file if the dataset is in an external file */ - /* Note: We can't use data sieve buffers for datasets in external files - * because the 'addr' of all external files is set to 0 (above) and - * all datasets in external files would alias to the same set of - * file offsets, totally mixing up the data sieve buffer information. -QAK - */ - if (efl && efl->nused>0) { - if (H5O_efl_read(f, efl, addr, elmt_size, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "external data read failed"); + /* Read directly from file if the dataset is in an external file */ + /* Note: We can't use data sieve buffers for datasets in external files + * because the 'addr' of all external files is set to 0 (above) and + * all datasets in external files would alias to the same set of + * file offsets, totally mixing up the data sieve buffer information. -QAK + */ + if (efl && efl->nused>0) { + if (H5O_efl_read(f, efl, addr, elmt_size, buf)<0) { + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + "external data read failed"); + } + } else { + if (H5F_contig_read(f, H5FD_MEM_DRAW, addr, elmt_size, dxpl_id, buf)<0) { + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + "block read failed"); + } + } /* end else */ + + /* Decrement indices and advance pointers */ + for (j=ndims-1, carray=TRUE; j>=0 && carray; --j) { + addr += file_stride[j]; + buf += mem_stride[j]; + + if (--idx[j]) + carray = FALSE; + else + idx[j] = hslab_size[j]; + } } - } else { - if (H5F_contig_read(f, H5FD_MEM_DRAW, addr, elmt_size, dxpl_id, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "block read failed"); + break; + + case H5D_CHUNKED: + /* + * This method is unable to access external raw data files or to copy + * into a proper hyperslab. + */ + if (efl && efl->nused>0) { + HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, + "chunking and external files are mutually exclusive"); } - } /* end else */ - - /* Decrement indices and advance pointers */ - for (j=ndims-1, carray=TRUE; j>=0 && carray; --j) { - addr += file_stride[j]; - buf += mem_stride[j]; - - if (--idx[j]) carray = FALSE; - else idx[j] = hslab_size[j]; - } - } - break; - - case H5D_CHUNKED: - /* - * This method is unable to access external raw data files or to copy - * into a proper hyperslab. - */ - if (efl && efl->nused>0) { - HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, - "chunking and external files are mutually exclusive"); - } - for (i=0; i<layout->ndims; i++) { - if (0!=mem_offset[i] || hslab_size[i]!=mem_size[i]) { - HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, - "unable to copy into a proper hyperslab"); - } - } - if (H5F_istore_read(f, dxpl_id, layout, pline, fill, file_offset, - hslab_size, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "chunked read failed"); - } - break; + for (u=0; u<layout->ndims; u++) { + if (0!=mem_offset[u] || hslab_size[u]!=mem_size[u]) { + HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, + "unable to copy into a proper hyperslab"); + } + } + if (H5F_istore_read(f, dxpl_id, layout, pline, fill, file_offset, + hslab_size, buf)<0) { + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "chunked read failed"); + } + break; - default: - assert("not implemented yet" && 0); - HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, - "unsupported storage layout"); + default: + assert("not implemented yet" && 0); + HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, + "unsupported storage layout"); } FUNC_LEAVE(SUCCEED); @@ -409,9 +413,10 @@ H5F_arr_write(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, hsize_t file_start; /*byte offset to start */ hsize_t elmt_size = 1; /*bytes per element */ size_t nelmts, z; /*number of elements */ - intn ndims; /*dimensionality */ + uintn ndims; /*dimensionality */ haddr_t addr; /*address in file */ - intn i, j; /*counters */ + intn j; /*counters */ + uintn u; /*counters */ hbool_t carray; /*carry for subtraction */ #ifdef H5_HAVE_PARALLEL H5FD_mpio_xfer_t xfer_mode=H5FD_MPIO_INDEPENDENT; @@ -469,138 +474,140 @@ H5F_arr_write(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, #endif /* QAK */ switch (layout->type) { - case H5D_CONTIGUOUS: - ndims = layout->ndims; - /* - * Offsets must not be negative for this type of storage. - */ - for (i=0; i<ndims; i++) { - if (mem_offset[i]<0 || file_offset[i]<0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "negative offsets are not valid"); - } - } + case H5D_CONTIGUOUS: + ndims = layout->ndims; + /* + * Offsets must not be negative for this type of storage. + */ + for (u=0; u<ndims; u++) { + if (mem_offset[u]<0 || file_offset[u]<0) { + HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "negative offsets are not valid"); + } + } - /* - * Filters cannot be used for contiguous data - */ - if (pline && pline->nfilters>0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "filters are not allowed for contiguous data"); - } - - /* - * Calculate the strides needed to walk through the array on disk. - * Optimize the strides to result in the fewest number of I/O - * requests. - */ - mem_start = H5V_hyper_stride(ndims, hslab_size, mem_size, - mem_offset, mem_stride/*out*/); - file_start = H5V_hyper_stride(ndims, hslab_size, layout->dim, - file_offset, file_stride/*out*/); - H5V_stride_optimize2(&ndims, &elmt_size, hslab_size, - mem_stride, file_stride); - - /* - * Initialize loop variables. The loop is a multi-dimensional loop - * that counts from SIZE down to zero and IDX is the counter. Each - * element of IDX is treated as a digit with IDX[0] being the least - * significant digit. - */ - H5V_vector_cpy(ndims, idx, hslab_size); - nelmts = H5V_vector_reduce_product(ndims, hslab_size); - if (efl && efl->nused>0) { - addr = 0; - } else { - addr = layout->addr; - } - addr += file_start; - buf += mem_start; + /* + * Filters cannot be used for contiguous data + */ + if (pline && pline->nfilters>0) { + HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "filters are not allowed for contiguous data"); + } + + /* + * Calculate the strides needed to walk through the array on disk. + * Optimize the strides to result in the fewest number of I/O + * requests. + */ + mem_start = H5V_hyper_stride(ndims, hslab_size, mem_size, + mem_offset, mem_stride/*out*/); + file_start = H5V_hyper_stride(ndims, hslab_size, layout->dim, + file_offset, file_stride/*out*/); + H5V_stride_optimize2(&ndims, &elmt_size, hslab_size, + mem_stride, file_stride); + + /* + * Initialize loop variables. The loop is a multi-dimensional loop + * that counts from SIZE down to zero and IDX is the counter. Each + * element of IDX is treated as a digit with IDX[0] being the least + * significant digit. + */ + H5V_vector_cpy(ndims, idx, hslab_size); + nelmts = H5V_vector_reduce_product(ndims, hslab_size); + if (efl && efl->nused>0) { + addr = 0; + } else { + addr = layout->addr; + } + addr += file_start; + buf += mem_start; - /* - * Now begin to walk through the array, copying data from memory to - * disk. - */ + /* + * Now begin to walk through the array, copying data from memory to + * disk. + */ #ifdef H5_HAVE_PARALLEL - if (H5FD_MPIO_COLLECTIVE==xfer_mode){ - /* - * Currently supports same number of collective access. Need to - * be changed LATER to combine all writes into one collective - * MPIO call. - */ - unsigned long max, min, temp; - - temp = nelmts; - assert(temp==nelmts); /* verify no overflow */ - MPI_Allreduce(&temp, &max, 1, MPI_UNSIGNED_LONG, MPI_MAX, - H5FD_mpio_communicator(f->shared->lf)); - MPI_Allreduce(&temp, &min, 1, MPI_UNSIGNED_LONG, MPI_MIN, - H5FD_mpio_communicator(f->shared->lf)); + if (H5FD_MPIO_COLLECTIVE==xfer_mode){ + /* + * Currently supports same number of collective access. Need to + * be changed LATER to combine all writes into one collective + * MPIO call. + */ + unsigned long max, min, temp; + + temp = nelmts; + assert(temp==nelmts); /* verify no overflow */ + MPI_Allreduce(&temp, &max, 1, MPI_UNSIGNED_LONG, MPI_MAX, + H5FD_mpio_communicator(f->shared->lf)); + MPI_Allreduce(&temp, &min, 1, MPI_UNSIGNED_LONG, MPI_MIN, + H5FD_mpio_communicator(f->shared->lf)); #ifdef AKC - printf("nelmts=%lu, min=%lu, max=%lu\n", temp, min, max); + printf("nelmts=%lu, min=%lu, max=%lu\n", temp, min, max); #endif - if (max != min) { - HRETURN_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, - "collective access with unequal number of " - "blocks not supported yet"); - } - } + if (max != min) { + HRETURN_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, + "collective access with unequal number of " + "blocks not supported yet"); + } + } #endif - for (z=0; z<nelmts; z++) { + for (z=0; z<nelmts; z++) { + + /* Write to file */ + if (efl && efl->nused>0) { + if (H5O_efl_write(f, efl, addr, elmt_size, buf)<0) { + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + "external data write failed"); + } + } else { + if (H5F_contig_write(f, H5FD_MEM_DRAW, addr, elmt_size, dxpl_id, buf)<0) { + HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "block write failed"); + } + } /* end else */ + + /* Decrement indices and advance pointers */ + for (j=ndims-1, carray=TRUE; j>=0 && carray; --j) { + addr += file_stride[j]; + buf += mem_stride[j]; + + if (--idx[j]) + carray = FALSE; + else + idx[j] = hslab_size[j]; + } - /* Write to file */ - if (efl && efl->nused>0) { - if (H5O_efl_write(f, efl, addr, elmt_size, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "external data write failed"); } - } else { - if (H5F_contig_write(f, H5FD_MEM_DRAW, addr, elmt_size, dxpl_id, buf)<0) { + break; + + case H5D_CHUNKED: + /* + * This method is unable to access external raw data files or to copy + * from a proper hyperslab. + */ + if (efl && efl->nused>0) { + HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, + "chunking and external files are mutually " + "exclusive"); + } + for (u=0; u<layout->ndims; u++) { + if (0!=mem_offset[u] || hslab_size[u]!=mem_size[u]) { + HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, + "unable to copy from a proper hyperslab"); + } + } + if (H5F_istore_write(f, dxpl_id, layout, pline, fill, file_offset, + hslab_size, buf)<0) { HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "block write failed"); + "chunked write failed"); } - } /* end else */ - - /* Decrement indices and advance pointers */ - for (j=ndims-1, carray=TRUE; j>=0 && carray; --j) { - addr += file_stride[j]; - buf += mem_stride[j]; - - if (--idx[j]) carray = FALSE; - else idx[j] = hslab_size[j]; - } - - } - break; - - case H5D_CHUNKED: - /* - * This method is unable to access external raw data files or to copy - * from a proper hyperslab. - */ - if (efl && efl->nused>0) { - HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, - "chunking and external files are mutually " - "exclusive"); - } - for (i=0; i<layout->ndims; i++) { - if (0!=mem_offset[i] || hslab_size[i]!=mem_size[i]) { - HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, - "unable to copy from a proper hyperslab"); - } - } - if (H5F_istore_write(f, dxpl_id, layout, pline, fill, file_offset, - hslab_size, buf)<0) { - HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "chunked write failed"); - } - break; + break; - default: - assert("not implemented yet" && 0); - HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, - "unsupported storage layout"); + default: + assert("not implemented yet" && 0); + HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, + "unsupported storage layout"); } FUNC_LEAVE (SUCCEED); diff --git a/src/H5Fcontig.c b/src/H5Fcontig.c index 14fdda7..b1dad47 100644 --- a/src/H5Fcontig.c +++ b/src/H5Fcontig.c @@ -151,7 +151,8 @@ H5F_contig_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hid_t dxp } /* end if */ else { /* Allocate room for the data sieve buffer */ - if (NULL==(f->shared->sieve_buf=H5MM_malloc(f->shared->sieve_buf_size))) { + assert(f->shared->sieve_buf_size==(hsize_t)((size_t)f->shared->sieve_buf_size)); /*check for overflow*/ + if (NULL==(f->shared->sieve_buf=H5MM_malloc((size_t)f->shared->sieve_buf_size))) { HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } @@ -325,7 +326,8 @@ H5F_contig_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, } /* end if */ else { /* Allocate room for the data sieve buffer */ - if (NULL==(f->shared->sieve_buf=H5MM_malloc(f->shared->sieve_buf_size))) { + assert(f->shared->sieve_buf_size==(hsize_t)((size_t)f->shared->sieve_buf_size)); /*check for overflow*/ + if (NULL==(f->shared->sieve_buf=H5MM_malloc((size_t)f->shared->sieve_buf_size))) { HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } diff --git a/src/H5Fistore.c b/src/H5Fistore.c index 8c4d816..8b98743 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -153,10 +153,10 @@ typedef struct H5F_istore_key_t { } H5F_istore_key_t; typedef struct H5F_istore_ud1_t { - H5F_istore_key_t key; /*key values */ + H5F_istore_key_t key; /*key values */ haddr_t addr; /*file address of chunk */ - H5O_layout_t mesg; /*layout message */ - hsize_t total_storage; /*output from iterator */ + H5O_layout_t mesg; /*layout message */ + hsize_t total_storage; /*output from iterator */ FILE *stream; /*debug output stream */ } H5F_istore_ud1_t; @@ -220,7 +220,7 @@ H5F_istore_chunk_alloc(size_t chunk_size) FUNC_ENTER(H5F_istore_chunk_alloc, NULL); - ret_value=H5FL_BLK_ALLOC(istore_chunk,chunk_size,0); + ret_value=H5FL_BLK_ALLOC(istore_chunk,(hsize_t)chunk_size,0); FUNC_LEAVE(ret_value); } /* end H5F_istore_chunk_alloc() */ @@ -280,7 +280,7 @@ H5F_istore_chunk_realloc(void *chunk, size_t new_size) FUNC_ENTER(H5F_istore_chunk_realloc, NULL); - ret_value=H5FL_BLK_REALLOC(istore_chunk,chunk,new_size); + ret_value=H5FL_BLK_REALLOC(istore_chunk,chunk,(hsize_t)new_size); FUNC_LEAVE(ret_value); } /* end H5F_istore_chunk_realloc() */ @@ -424,7 +424,7 @@ H5F_istore_debug_key (FILE *stream, intn indent, intn fwidth, { const H5F_istore_key_t *key = (const H5F_istore_key_t *)_key; const H5F_istore_ud1_t *udata = (const H5F_istore_ud1_t *)_udata; - int i; + uintn u; FUNC_ENTER (H5F_istore_debug_key, FAIL); assert (key); @@ -435,8 +435,8 @@ H5F_istore_debug_key (FILE *stream, intn indent, intn fwidth, "Filter mask:", key->filter_mask); HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Logical offset:"); - for (i=0; i<udata->mesg.ndims; i++) { - HDfprintf (stream, "%s%Hd", i?", ":"", key->offset[i]); + for (u=0; u<udata->mesg.ndims; u++) { + HDfprintf (stream, "%s%Hd", u?", ":"", key->offset[u]); } HDfputs ("}\n", stream); @@ -572,7 +572,7 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op, H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key; H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key; H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata; - intn i; + uintn u; FUNC_ENTER(H5F_istore_new_node, FAIL); #ifdef AKC @@ -591,9 +591,8 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op, #ifdef AKC printf("calling H5MF_alloc for new chunk\n"); #endif - if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_DRAW, - udata->key.nbytes))) { - HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL, + if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)udata->key.nbytes))) { + HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "couldn't allocate new file storage"); } udata->addr = *addr_p; @@ -604,8 +603,8 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op, */ lt_key->nbytes = udata->key.nbytes; lt_key->filter_mask = udata->key.filter_mask; - for (i=0; i<udata->mesg.ndims; i++) { - lt_key->offset[i] = udata->key.offset[i]; + for (u=0; u<udata->mesg.ndims; u++) { + lt_key->offset[u] = udata->key.offset[u]; } /* @@ -613,15 +612,15 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op, * chunk. */ if (H5B_INS_LEFT != op) { - rt_key->nbytes = 0; - rt_key->filter_mask = 0; - for (i=0; i<udata->mesg.ndims; i++) { - assert (udata->mesg.dim[i] < HSSIZET_MAX); - assert (udata->key.offset[i]+(hssize_t)(udata->mesg.dim[i]) > - udata->key.offset[i]); - rt_key->offset[i] = udata->key.offset[i] + - (hssize_t)(udata->mesg.dim[i]); - } + rt_key->nbytes = 0; + rt_key->filter_mask = 0; + for (u=0; u<udata->mesg.ndims; u++) { + assert (udata->mesg.dim[u] < HSSIZET_MAX); + assert (udata->key.offset[u]+(hssize_t)(udata->mesg.dim[u]) > + udata->key.offset[u]); + rt_key->offset[u] = udata->key.offset[u] + + (hssize_t)(udata->mesg.dim[u]); + } } FUNC_LEAVE(SUCCEED); @@ -661,7 +660,7 @@ H5F_istore_found(H5F_t UNUSED *f, haddr_t addr, const void *_lt_key, { H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata; const H5F_istore_key_t *lt_key = (const H5F_istore_key_t *) _lt_key; - int i; + uintn u; FUNC_ENTER(H5F_istore_found, FAIL); @@ -672,11 +671,10 @@ H5F_istore_found(H5F_t UNUSED *f, haddr_t addr, const void *_lt_key, assert(lt_key); /* Is this *really* the requested chunk? */ - for (i=0; i<udata->mesg.ndims; i++) { - if (udata->key.offset[i] >= - lt_key->offset[i]+(hssize_t)(udata->mesg.dim[i])) { - HRETURN(FAIL); - } + for (u=0; u<udata->mesg.ndims; u++) { + if (udata->key.offset[u] >= lt_key->offset[u]+(hssize_t)(udata->mesg.dim[u])) { + HRETURN(FAIL); + } } /* Initialize return values */ @@ -684,8 +682,8 @@ H5F_istore_found(H5F_t UNUSED *f, haddr_t addr, const void *_lt_key, udata->key.nbytes = lt_key->nbytes; udata->key.filter_mask = lt_key->filter_mask; assert (lt_key->nbytes>0); - for (i = 0; i < udata->mesg.ndims; i++) { - udata->key.offset[i] = lt_key->offset[i]; + for (u = 0; u < udata->mesg.ndims; u++) { + udata->key.offset[u] = lt_key->offset[u]; } FUNC_LEAVE(SUCCEED); @@ -735,7 +733,8 @@ H5F_istore_insert(H5F_t *f, haddr_t addr, void *_lt_key, H5F_istore_key_t *md_key = (H5F_istore_key_t *) _md_key; H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key; H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata; - intn i, cmp; + intn cmp; + uintn u; H5B_ins_t ret_value = H5B_INS_ERROR; FUNC_ENTER(H5F_istore_insert, H5B_INS_ERROR); @@ -758,72 +757,72 @@ H5F_istore_insert(H5F_t *f, haddr_t addr, void *_lt_key, assert(cmp <= 0); if (cmp < 0) { - /* Negative indices not supported yet */ - assert("HDF5 INTERNAL ERROR -- see rpm" && 0); - HRETURN_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, + /* Negative indices not supported yet */ + assert("HDF5 INTERNAL ERROR -- see rpm" && 0); + HRETURN_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error"); } else if (H5V_vector_eq_s (udata->mesg.ndims, udata->key.offset, lt_key->offset) && lt_key->nbytes>0) { - /* - * Already exists. If the new size is not the same as the old size - * then we should reallocate storage. - */ - if (lt_key->nbytes != udata->key.nbytes) { + /* + * Already exists. If the new size is not the same as the old size + * then we should reallocate storage. + */ + if (lt_key->nbytes != udata->key.nbytes) { #ifdef AKC - printf("calling H5MF_realloc for new chunk\n"); + printf("calling H5MF_realloc for new chunk\n"); #endif - if (HADDR_UNDEF==(*new_node_p=H5MF_realloc(f, H5FD_MEM_DRAW, addr, - lt_key->nbytes, - udata->key.nbytes))) { - HRETURN_ERROR (H5E_STORAGE, H5E_WRITEERROR, H5B_INS_ERROR, - "unable to reallocate chunk storage"); - } - lt_key->nbytes = udata->key.nbytes; - lt_key->filter_mask = udata->key.filter_mask; - *lt_key_changed = TRUE; - udata->addr = *new_node_p; - ret_value = H5B_INS_CHANGE; - } else { - udata->addr = addr; - ret_value = H5B_INS_NOOP; - } + if (HADDR_UNDEF==(*new_node_p=H5MF_realloc(f, H5FD_MEM_DRAW, addr, + (hsize_t)lt_key->nbytes, + (hsize_t)udata->key.nbytes))) { + HRETURN_ERROR (H5E_STORAGE, H5E_WRITEERROR, H5B_INS_ERROR, + "unable to reallocate chunk storage"); + } + lt_key->nbytes = udata->key.nbytes; + lt_key->filter_mask = udata->key.filter_mask; + *lt_key_changed = TRUE; + udata->addr = *new_node_p; + ret_value = H5B_INS_CHANGE; + } else { + udata->addr = addr; + ret_value = H5B_INS_NOOP; + } } else if (H5V_hyper_disjointp(udata->mesg.ndims, lt_key->offset, udata->mesg.dim, udata->key.offset, udata->mesg.dim)) { - assert(H5V_hyper_disjointp(udata->mesg.ndims, + assert(H5V_hyper_disjointp(udata->mesg.ndims, rt_key->offset, udata->mesg.dim, udata->key.offset, udata->mesg.dim)); - /* - * Split this node, inserting the new new node to the right of the - * current node. The MD_KEY is where the split occurs. - */ - md_key->nbytes = udata->key.nbytes; - md_key->filter_mask = udata->key.filter_mask; - for (i=0; i<udata->mesg.ndims; i++) { - assert(0 == udata->key.offset[i] % udata->mesg.dim[i]); - md_key->offset[i] = udata->key.offset[i]; - } - - /* - * Allocate storage for the new chunk - */ + /* + * Split this node, inserting the new new node to the right of the + * current node. The MD_KEY is where the split occurs. + */ + md_key->nbytes = udata->key.nbytes; + md_key->filter_mask = udata->key.filter_mask; + for (u=0; u<udata->mesg.ndims; u++) { + assert(0 == udata->key.offset[u] % udata->mesg.dim[u]); + md_key->offset[u] = udata->key.offset[u]; + } + + /* + * Allocate storage for the new chunk + */ #ifdef AKC - printf("calling H5MF_alloc for new chunk\n"); + printf("calling H5MF_alloc for new chunk\n"); #endif - if (HADDR_UNDEF==(*new_node_p=H5MF_alloc(f, H5FD_MEM_DRAW, - udata->key.nbytes))) { - HRETURN_ERROR(H5E_IO, H5E_CANTINIT, H5B_INS_ERROR, - "file allocation failed"); - } - udata->addr = *new_node_p; - ret_value = H5B_INS_RIGHT; + if (HADDR_UNDEF==(*new_node_p=H5MF_alloc(f, H5FD_MEM_DRAW, + (hsize_t)udata->key.nbytes))) { + HRETURN_ERROR(H5E_IO, H5E_CANTINIT, H5B_INS_ERROR, + "file allocation failed"); + } + udata->addr = *new_node_p; + ret_value = H5B_INS_RIGHT; } else { - assert("HDF5 INTERNAL ERROR -- see rpm" && 0); - HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR, + assert("HDF5 INTERNAL ERROR -- see rpm" && 0); + HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error"); } @@ -856,25 +855,25 @@ H5F_istore_iterate (H5F_t UNUSED *f, void *_lt_key, haddr_t UNUSED addr, { H5F_istore_ud1_t *bt_udata = (H5F_istore_ud1_t *)_udata; H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key; - int i; + uintn u; FUNC_ENTER(H5F_istore_iterate, FAIL); if (bt_udata->stream) { - if (0==bt_udata->total_storage) { - fprintf(bt_udata->stream, " Address:\n"); - fprintf(bt_udata->stream, - " Flags Bytes Address Logical Offset\n"); - fprintf(bt_udata->stream, - " ========== ======== ========== " - "==============================\n"); - } - HDfprintf(bt_udata->stream, " 0x%08x %8Zu %10a [", - lt_key->filter_mask, lt_key->nbytes, addr); - for (i=0; i<bt_udata->mesg.ndims; i++) { - HDfprintf(bt_udata->stream, "%s%Hd", i?", ":"", lt_key->offset[i]); - } - fputs("]\n", bt_udata->stream); + if (0==bt_udata->total_storage) { + fprintf(bt_udata->stream, " Address:\n"); + fprintf(bt_udata->stream, + " Flags Bytes Address Logical Offset\n"); + fprintf(bt_udata->stream, + " ========== ======== ========== " + "==============================\n"); + } + HDfprintf(bt_udata->stream, " 0x%08x %8Zu %10a [", + lt_key->filter_mask, lt_key->nbytes, addr); + for (u=0; u<bt_udata->mesg.ndims; u++) { + HDfprintf(bt_udata->stream, "%s%Hd", u?", ":"", lt_key->offset[u]); + } + fputs("]\n", bt_udata->stream); } bt_udata->total_storage += lt_key->nbytes; @@ -907,7 +906,8 @@ H5F_istore_init (H5F_t *f) HDmemset (rdcc, 0, sizeof(H5F_rdcc_t)); if (f->shared->rdcc_nbytes>0 && f->shared->rdcc_nelmts>0) { rdcc->nslots = f->shared->rdcc_nelmts; - rdcc->slot = H5FL_ARR_ALLOC (H5F_rdcc_ent_ptr_t,rdcc->nslots,1); + assert(rdcc->nslots>=0); + rdcc->slot = H5FL_ARR_ALLOC (H5F_rdcc_ent_ptr_t,(hsize_t)rdcc->nslots,1); if (NULL==rdcc->slot) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); @@ -940,7 +940,7 @@ H5F_istore_flush_entry(H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t reset) { herr_t ret_value=FAIL; /*return value */ H5F_istore_ud1_t udata; /*pass through B-tree */ - intn i; /*counters */ + uintn u; /*counters */ void *buf=NULL; /*temporary buffer */ size_t alloc; /*bytes allocated for BUF */ hbool_t point_of_no_return = FALSE; @@ -952,82 +952,83 @@ H5F_istore_flush_entry(H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t reset) buf = ent->chunk; if (ent->dirty) { - udata.mesg = *(ent->layout); - udata.key.filter_mask = 0; - udata.addr = HADDR_UNDEF; - udata.key.nbytes = ent->chunk_size; - for (i=0; i<ent->layout->ndims; i++) { - udata.key.offset[i] = ent->offset[i]; - } - alloc = ent->alloc_size; - - /* Should the chunk be filtered before writing it to disk? */ - if (ent->pline && ent->pline->nfilters) { - if (!reset) { - /* - * Copy the chunk to a new buffer before running it through - * the pipeline because we'll want to save the original buffer - * for later. - */ - alloc = ent->chunk_size; - if (NULL==(buf = H5F_istore_chunk_alloc(alloc))) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for pipeline"); - } - HDmemcpy(buf, ent->chunk, ent->chunk_size); - } else { - /* - * If we are reseting and something goes wrong after this - * point then it's too late to recover because we may have - * destroyed the original data by calling H5Z_pipeline(). - * The only safe option is to continue with the reset - * even if we can't write the data to disk. - */ - point_of_no_return = TRUE; - ent->chunk = NULL; - } - if (H5Z_pipeline(f, ent->pline, 0, &(udata.key.filter_mask), - &(udata.key.nbytes), &alloc, &buf)<0) { - HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, - "output pipeline failed"); - } - } - - /* - * Create the chunk it if it doesn't exist, or reallocate the chunk if - * its size changed. Then write the data into the file. - */ - if (H5B_insert(f, H5B_ISTORE, ent->layout->addr, ent->split_ratios, - &udata)<0) { - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "unable to allocate chunk"); - } - if (H5F_block_write(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, H5P_DEFAULT, - buf)<0) { - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, - "unable to write raw data to file"); - } - - /* Mark cache entry as clean */ - ent->dirty = FALSE; - f->shared->rdcc.nflushes++; + udata.mesg = *(ent->layout); + udata.key.filter_mask = 0; + udata.addr = HADDR_UNDEF; + udata.key.nbytes = ent->chunk_size; + for (u=0; u<ent->layout->ndims; u++) { + udata.key.offset[u] = ent->offset[u]; + } + alloc = ent->alloc_size; + + /* Should the chunk be filtered before writing it to disk? */ + if (ent->pline && ent->pline->nfilters) { + if (!reset) { + /* + * Copy the chunk to a new buffer before running it through + * the pipeline because we'll want to save the original buffer + * for later. + */ + alloc = ent->chunk_size; + if (NULL==(buf = H5F_istore_chunk_alloc(alloc))) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for pipeline"); + } + HDmemcpy(buf, ent->chunk, ent->chunk_size); + } else { + /* + * If we are reseting and something goes wrong after this + * point then it's too late to recover because we may have + * destroyed the original data by calling H5Z_pipeline(). + * The only safe option is to continue with the reset + * even if we can't write the data to disk. + */ + point_of_no_return = TRUE; + ent->chunk = NULL; + } + if (H5Z_pipeline(f, ent->pline, 0, &(udata.key.filter_mask), + &(udata.key.nbytes), &alloc, &buf)<0) { + HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, + "output pipeline failed"); + } + } + + /* + * Create the chunk it if it doesn't exist, or reallocate the chunk if + * its size changed. Then write the data into the file. + */ + if (H5B_insert(f, H5B_ISTORE, ent->layout->addr, ent->split_ratios, + &udata)<0) { + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "unable to allocate chunk"); + } + if (H5F_block_write(f, H5FD_MEM_DRAW, udata.addr, (hsize_t)udata.key.nbytes, H5P_DEFAULT, + buf)<0) { + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, + "unable to write raw data to file"); + } + + /* Mark cache entry as clean */ + ent->dirty = FALSE; + f->shared->rdcc.nflushes++; } /* Reset, but do not free or removed from list */ if (reset) { - point_of_no_return = FALSE; - ent->layout = H5O_free(H5O_LAYOUT, ent->layout); - ent->pline = H5O_free(H5O_PLINE, ent->pline); - if (buf==ent->chunk) buf = NULL; - if(ent->chunk!=NULL) - ent->chunk = H5F_istore_chunk_free(ent->chunk); + point_of_no_return = FALSE; + ent->layout = H5O_free(H5O_LAYOUT, ent->layout); + ent->pline = H5O_free(H5O_PLINE, ent->pline); + if (buf==ent->chunk) buf = NULL; + if(ent->chunk!=NULL) + ent->chunk = H5F_istore_chunk_free(ent->chunk); } ret_value = SUCCEED; - done: +done: /* Free the temp buffer only if it's different than the entry chunk */ - if (buf!=ent->chunk) H5F_istore_chunk_free(buf); + if (buf!=ent->chunk) + H5F_istore_chunk_free(buf); /* * If we reached the point of no return then we have no choice but to @@ -1036,10 +1037,10 @@ H5F_istore_flush_entry(H5F_t *f, H5F_rdcc_ent_t *ent, hbool_t reset) * list. */ if (ret_value<0 && point_of_no_return) { - ent->layout = H5O_free(H5O_LAYOUT, ent->layout); - ent->pline = H5O_free(H5O_PLINE, ent->pline); - if(ent->chunk) - ent->chunk = H5F_istore_chunk_free(ent->chunk); + ent->layout = H5O_free(H5O_LAYOUT, ent->layout); + ent->pline = H5O_free(H5O_PLINE, ent->pline); + if(ent->chunk) + ent->chunk = H5F_istore_chunk_free(ent->chunk); } FUNC_LEAVE(ret_value); } @@ -1336,11 +1337,12 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, const hssize_t offset[], hbool_t relax, intn *idx_hint/*in,out*/) { - uintn idx=0; /*hash index number */ + intn idx=0; /*hash index number */ + uintn temp_idx=0; /* temporary index number */ hbool_t found = FALSE; /*already in cache? */ H5F_rdcc_t *rdcc = &(f->shared->rdcc);/*raw data chunk cache*/ H5F_rdcc_ent_t *ent = NULL; /*cache entry */ - intn i; /*counters */ + uintn u; /*counters */ H5F_istore_ud1_t udata; /*B-tree pass-through */ size_t chunk_size=0; /*size of a chunk */ size_t chunk_alloc=0; /*allocated chunk size */ @@ -1351,230 +1353,228 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, FUNC_ENTER (H5F_istore_lock, NULL); if (rdcc->nslots>0) { - /* We don't care about loss of precision in the following statement. */ - for (i=0, idx=0; i<layout->ndims; i++) { - idx *= layout->dim[i]; - idx += offset[i]; - } - idx += (uintn)(layout->addr); - idx=H5F_HASH(f,idx); - ent = rdcc->slot[idx]; - - if (ent && - layout->ndims==ent->layout->ndims && - H5F_addr_eq(layout->addr, ent->layout->addr)) { - for (i=0, found=TRUE; i<ent->layout->ndims; i++) { - if (offset[i]!=ent->offset[i]) { - found = FALSE; - break; - } - } - } + /* We don't care about loss of precision in the following statement. */ + for (u=0, temp_idx=0; u<layout->ndims; u++) { + temp_idx *= layout->dim[u]; + temp_idx += offset[u]; + } + temp_idx += (uintn)(layout->addr); + idx=H5F_HASH(f,temp_idx); + ent = rdcc->slot[idx]; + + if (ent && layout->ndims==ent->layout->ndims && + H5F_addr_eq(layout->addr, ent->layout->addr)) { + for (u=0, found=TRUE; u<ent->layout->ndims; u++) { + if (offset[u]!=ent->offset[u]) { + found = FALSE; + break; + } + } + } } if (found) { - /* - * Already in the cache. Count a hit. - */ - rdcc->nhits++; + /* + * Already in the cache. Count a hit. + */ + rdcc->nhits++; } else if (!found && relax) { - /* - * Not in the cache, but we're about to overwrite the whole thing - * anyway, so just allocate a buffer for it but don't initialize that - * buffer with the file contents. Count this as a hit instead of a - * miss because we saved ourselves lots of work. - */ + /* + * Not in the cache, but we're about to overwrite the whole thing + * anyway, so just allocate a buffer for it but don't initialize that + * buffer with the file contents. Count this as a hit instead of a + * miss because we saved ourselves lots of work. + */ #ifdef H5F_ISTORE_DEBUG - putc('w', stderr); - fflush(stderr); + putc('w', stderr); + fflush(stderr); #endif - rdcc->nhits++; - for (i=0, chunk_size=1; i<layout->ndims; i++) { - chunk_size *= layout->dim[i]; - } - chunk_alloc = chunk_size; - if (NULL==(chunk=H5F_istore_chunk_alloc (chunk_alloc))) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed for raw data chunk"); - } - + rdcc->nhits++; + for (u=0, chunk_size=1; u<layout->ndims; u++) { + chunk_size *= layout->dim[u]; + } + chunk_alloc = chunk_size; + if (NULL==(chunk=H5F_istore_chunk_alloc (chunk_alloc))) { + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk"); + } + } else { - /* - * Not in the cache. Read it from the file and count this as a miss - * if it's in the file or an init if it isn't. - */ - for (i=0, chunk_size=1; i<layout->ndims; i++) { - udata.key.offset[i] = offset[i]; - chunk_size *= layout->dim[i]; - } - chunk_alloc = chunk_size; - udata.mesg = *layout; - udata.addr = HADDR_UNDEF; - status = H5B_find (f, H5B_ISTORE, layout->addr, &udata); - H5E_clear (); - if (NULL==(chunk = H5F_istore_chunk_alloc (chunk_alloc))) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed for raw data chunk"); - } - if (status>=0 && H5F_addr_defined(udata.addr)) { - /* - * The chunk exists on disk. - */ - if (H5F_block_read(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, H5P_DEFAULT, - chunk)<0) { - HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL, - "unable to read raw data chunk"); - } - if (H5Z_pipeline(f, pline, H5Z_FLAG_REVERSE, - &(udata.key.filter_mask), &(udata.key.nbytes), - &chunk_alloc, &chunk)<0 || - udata.key.nbytes!=chunk_size) { - HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL, - "data pipeline read failed"); - } - rdcc->nmisses++; - } else if (fill && fill->buf) { - /* - * The chunk doesn't exist in the file. Replicate the fill - * value throughout the chunk. - */ - assert(0==chunk_size % fill->size); - H5V_array_fill(chunk, fill->buf, fill->size, - chunk_size/fill->size); - rdcc->ninits++; - - } else { - /* - * The chunk doesn't exist in the file and no fill value was - * specified. Assume all zeros. - */ - HDmemset (chunk, 0, chunk_size); - rdcc->ninits++; - } + /* + * Not in the cache. Read it from the file and count this as a miss + * if it's in the file or an init if it isn't. + */ + for (u=0, chunk_size=1; u<layout->ndims; u++) { + udata.key.offset[u] = offset[u]; + chunk_size *= layout->dim[u]; + } + chunk_alloc = chunk_size; + udata.mesg = *layout; + udata.addr = HADDR_UNDEF; + status = H5B_find (f, H5B_ISTORE, layout->addr, &udata); + H5E_clear (); + if (NULL==(chunk = H5F_istore_chunk_alloc (chunk_alloc))) { + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed for raw data chunk"); + } + if (status>=0 && H5F_addr_defined(udata.addr)) { + /* + * The chunk exists on disk. + */ + if (H5F_block_read(f, H5FD_MEM_DRAW, udata.addr, (hsize_t)udata.key.nbytes, H5P_DEFAULT, + chunk)<0) { + HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL, + "unable to read raw data chunk"); + } + if (H5Z_pipeline(f, pline, H5Z_FLAG_REVERSE, + &(udata.key.filter_mask), &(udata.key.nbytes), + &chunk_alloc, &chunk)<0 || udata.key.nbytes!=chunk_size) { + HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL, + "data pipeline read failed"); + } + rdcc->nmisses++; + } else if (fill && fill->buf) { + /* + * The chunk doesn't exist in the file. Replicate the fill + * value throughout the chunk. + */ + assert(0==chunk_size % fill->size); + H5V_array_fill(chunk, fill->buf, fill->size, chunk_size/fill->size); + rdcc->ninits++; + } else { + /* + * The chunk doesn't exist in the file and no fill value was + * specified. Assume all zeros. + */ + HDmemset (chunk, 0, chunk_size); + rdcc->ninits++; + } } assert (found || chunk_size>0); if (!found && rdcc->nslots>0 && chunk_size<=f->shared->rdcc_nbytes && - (!ent || !ent->locked)) { - /* - * Add the chunk to the cache only if the slot is not already locked. - * Preempt enough things from the cache to make room. - */ - if (ent) { + (!ent || !ent->locked)) { + /* + * Add the chunk to the cache only if the slot is not already locked. + * Preempt enough things from the cache to make room. + */ + if (ent) { #ifdef H5F_ISTORE_DEBUG - putc('#', stderr); - fflush(stderr); + putc('#', stderr); + fflush(stderr); #endif #if 0 - HDfprintf(stderr, "\ncollision %3d %10a {", - idx, ent->layout->addr); - for (i=0; i<layout->ndims; i++) { - HDfprintf(stderr, "%s%Zu", i?",":"", ent->offset[i]); - } - HDfprintf(stderr, "}\n %10a {", layout->addr); - for (i=0; i<layout->ndims; i++) { - HDfprintf(stderr, "%s%Zu", i?",":"", offset[i]); - } - fprintf(stderr, "}\n"); + HDfprintf(stderr, "\ncollision %3d %10a {", + idx, ent->layout->addr); + for (u=0; u<layout->ndims; u++) { + HDfprintf(stderr, "%s%Zu", u?",":"", ent->offset[u]); + } + HDfprintf(stderr, "}\n %10a {", layout->addr); + for (u=0; u<layout->ndims; u++) { + HDfprintf(stderr, "%s%Zu", u?",":"", offset[u]); + } + fprintf(stderr, "}\n"); #endif - if (H5F_istore_preempt(f, ent)<0) { - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, - "unable to preempt chunk from cache"); - } - } - if (H5F_istore_prune(f, chunk_size)<0) { - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, - "unable to preempt chunk(s) from cache"); - } - - /* Create a new entry */ - ent = H5FL_ALLOC(H5F_rdcc_ent_t,0); - ent->locked = 0; - ent->dirty = FALSE; - ent->chunk_size = chunk_size; - ent->alloc_size = chunk_size; - ent->layout = H5O_copy(H5O_LAYOUT, layout, NULL); - ent->pline = H5O_copy(H5O_PLINE, pline, NULL); - for (i=0; i<layout->ndims; i++) { - ent->offset[i] = offset[i]; - } - ent->rd_count = chunk_size; - ent->wr_count = chunk_size; - ent->chunk = chunk; - - { - H5D_xfer_t *dxpl; - dxpl = (H5P_DEFAULT==dxpl_id) ? &H5D_xfer_dflt : (H5D_xfer_t *)H5I_object(dxpl_id); - ent->split_ratios[0] = dxpl->split_ratios[0]; - ent->split_ratios[1] = dxpl->split_ratios[1]; - ent->split_ratios[2] = dxpl->split_ratios[2]; - } - - /* Add it to the cache */ - assert(NULL==rdcc->slot[idx]); - rdcc->slot[idx] = ent; - ent->idx = idx; - rdcc->nbytes += chunk_size; - rdcc->nused++; - - /* Add it to the linked list */ - ent->next = NULL; - if (rdcc->tail) { - rdcc->tail->next = ent; - ent->prev = rdcc->tail; - rdcc->tail = ent; - } else { - rdcc->head = rdcc->tail = ent; - ent->prev = NULL; - } - found = TRUE; - + if (H5F_istore_preempt(f, ent)<0) { + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, + "unable to preempt chunk from cache"); + } + } + if (H5F_istore_prune(f, chunk_size)<0) { + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, + "unable to preempt chunk(s) from cache"); + } + + /* Create a new entry */ + ent = H5FL_ALLOC(H5F_rdcc_ent_t,0); + ent->locked = 0; + ent->dirty = FALSE; + ent->chunk_size = chunk_size; + ent->alloc_size = chunk_size; + ent->layout = H5O_copy(H5O_LAYOUT, layout, NULL); + ent->pline = H5O_copy(H5O_PLINE, pline, NULL); + for (u=0; u<layout->ndims; u++) { + ent->offset[u] = offset[u]; + } + ent->rd_count = chunk_size; + ent->wr_count = chunk_size; + ent->chunk = chunk; + + { + H5D_xfer_t *dxpl; + dxpl = (H5P_DEFAULT==dxpl_id) ? &H5D_xfer_dflt : (H5D_xfer_t *)H5I_object(dxpl_id); + ent->split_ratios[0] = dxpl->split_ratios[0]; + ent->split_ratios[1] = dxpl->split_ratios[1]; + ent->split_ratios[2] = dxpl->split_ratios[2]; + } + + /* Add it to the cache */ + assert(NULL==rdcc->slot[idx]); + rdcc->slot[idx] = ent; + ent->idx = idx; + rdcc->nbytes += chunk_size; + rdcc->nused++; + + /* Add it to the linked list */ + ent->next = NULL; + if (rdcc->tail) { + rdcc->tail->next = ent; + ent->prev = rdcc->tail; + rdcc->tail = ent; + } else { + rdcc->head = rdcc->tail = ent; + ent->prev = NULL; + } + found = TRUE; + } else if (!found) { - /* - * The chunk is larger than the entire cache so we don't cache it. - * This is the reason all those arguments have to be repeated for the - * unlock function. - */ - ent = NULL; - idx = -999; + /* + * The chunk is larger than the entire cache so we don't cache it. + * This is the reason all those arguments have to be repeated for the + * unlock function. + */ + ent = NULL; + idx = INT_MIN; } else if (found) { - /* - * The chunk is not at the beginning of the cache; move it backward - * by one slot. This is how we implement the LRU preemption - * algorithm. - */ - if (ent->next) { - if (ent->next->next) { - ent->next->next->prev = ent; - } else { - rdcc->tail = ent; - } - ent->next->prev = ent->prev; - if (ent->prev) { - ent->prev->next = ent->next; - } else { - rdcc->head = ent->next; - } - ent->prev = ent->next; - ent->next = ent->next->next; - ent->prev->next = ent; - } + /* + * The chunk is not at the beginning of the cache; move it backward + * by one slot. This is how we implement the LRU preemption + * algorithm. + */ + if (ent->next) { + if (ent->next->next) { + ent->next->next->prev = ent; + } else { + rdcc->tail = ent; + } + ent->next->prev = ent->prev; + if (ent->prev) { + ent->prev->next = ent->next; + } else { + rdcc->head = ent->next; + } + ent->prev = ent->next; + ent->next = ent->next->next; + ent->prev->next = ent; + } } /* Lock the chunk into the cache */ if (ent) { - assert (!ent->locked); - ent->locked = TRUE; - chunk = ent->chunk; + assert (!ent->locked); + ent->locked = TRUE; + chunk = ent->chunk; } - if (idx_hint) *idx_hint = idx; + if (idx_hint) + *idx_hint = idx; ret_value = chunk; done: - if (!ret_value) H5F_istore_chunk_free (chunk); + if (!ret_value) + H5F_istore_chunk_free (chunk); FUNC_LEAVE (ret_value); } @@ -1613,11 +1613,12 @@ H5F_istore_unlock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, { H5F_rdcc_t *rdcc = &(f->shared->rdcc); H5F_rdcc_ent_t *ent = NULL; - intn i, found = -1; + intn found = -1; + uintn u; FUNC_ENTER (H5F_istore_unlock, FAIL); - if (-999==*idx_hint) { + if (INT_MIN==*idx_hint) { /*not in cache*/ } else { assert(*idx_hint>=0 && *idx_hint<rdcc->nslots); @@ -1627,50 +1628,51 @@ H5F_istore_unlock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, } if (found<0) { - /* - * It's not in the cache, probably because it's too big. If it's - * dirty then flush it to disk. In any case, free the chunk. - * Note: we have to copy the layout and filter messages so we - * don't discard the `const' qualifier. - */ - if (dirty) { - H5F_rdcc_ent_t x; - HDmemset (&x, 0, sizeof x); - x.dirty = TRUE; - x.layout = H5O_copy (H5O_LAYOUT, layout, NULL); - x.pline = H5O_copy (H5O_PLINE, pline, NULL); - for (i=0, x.chunk_size=1; i<layout->ndims; i++) { - x.offset[i] = offset[i]; - x.chunk_size *= layout->dim[i]; - } - x.alloc_size = x.chunk_size; - x.chunk = chunk; - { - H5D_xfer_t *dxpl; - dxpl = (H5P_DEFAULT==dxpl_id) ? &H5D_xfer_dflt : (H5D_xfer_t *)H5I_object(dxpl_id); - x.split_ratios[0] = dxpl->split_ratios[0]; - x.split_ratios[1] = dxpl->split_ratios[1]; - x.split_ratios[2] = dxpl->split_ratios[2]; - } - - H5F_istore_flush_entry (f, &x, TRUE); - } else { - if(chunk) - H5F_istore_chunk_free (chunk); - } + /* + * It's not in the cache, probably because it's too big. If it's + * dirty then flush it to disk. In any case, free the chunk. + * Note: we have to copy the layout and filter messages so we + * don't discard the `const' qualifier. + */ + if (dirty) { + H5F_rdcc_ent_t x; + + HDmemset (&x, 0, sizeof x); + x.dirty = TRUE; + x.layout = H5O_copy (H5O_LAYOUT, layout, NULL); + x.pline = H5O_copy (H5O_PLINE, pline, NULL); + for (u=0, x.chunk_size=1; u<layout->ndims; u++) { + x.offset[u] = offset[u]; + x.chunk_size *= layout->dim[u]; + } + x.alloc_size = x.chunk_size; + x.chunk = chunk; + { + H5D_xfer_t *dxpl; + dxpl = (H5P_DEFAULT==dxpl_id) ? &H5D_xfer_dflt : (H5D_xfer_t *)H5I_object(dxpl_id); + x.split_ratios[0] = dxpl->split_ratios[0]; + x.split_ratios[1] = dxpl->split_ratios[1]; + x.split_ratios[2] = dxpl->split_ratios[2]; + } + + H5F_istore_flush_entry (f, &x, TRUE); + } else { + if(chunk) + H5F_istore_chunk_free (chunk); + } } else { - /* - * It's in the cache so unlock it. - */ - ent = rdcc->slot[found]; - assert (ent->locked); - if (dirty) { - ent->dirty = TRUE; - ent->wr_count -= MIN (ent->wr_count, naccessed); - } else { - ent->rd_count -= MIN (ent->rd_count, naccessed); - } - ent->locked = FALSE; + /* + * It's in the cache so unlock it. + */ + ent = rdcc->slot[found]; + assert (ent->locked); + if (dirty) { + ent->dirty = TRUE; + ent->wr_count -= MIN (ent->wr_count, naccessed); + } else { + ent->rd_count -= MIN (ent->rd_count, naccessed); + } + ent->locked = FALSE; } FUNC_LEAVE (SUCCEED); @@ -1709,6 +1711,7 @@ H5F_istore_read(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, hssize_t sub_offset_m[H5O_LAYOUT_NDIMS]; hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; intn i, carry; + uintn u; size_t naccessed; /*bytes accessed in chnk*/ uint8_t *chunk=NULL; /*ptr to a chunk buffer */ intn idx_hint=0; /*cache index hint */ @@ -1728,18 +1731,18 @@ H5F_istore_read(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, * For now, a hyperslab of the file must be read into an array in * memory.We do not yet support reading into a hyperslab of memory. */ - for (i=0; i<layout->ndims; i++) { - offset_m[i] = 0; - size_m[i] = size[i]; + for (u=0; u<layout->ndims; u++) { + offset_m[u] = 0; + size_m[u] = size[u]; } #ifndef NDEBUG - for (i=0; i<layout->ndims; i++) { - assert(offset_f[i]>=0); /*negative offsets not supported*/ - assert(offset_m[i]>=0); /*negative offsets not supported*/ - assert(size[i]<SIZET_MAX); - assert(offset_m[i]+(hssize_t)size[i]<=(hssize_t)size_m[i]); - assert(layout->dim[i]>0); + for (u=0; u<layout->ndims; u++) { + assert(offset_f[u]>=0); /*negative offsets not supported*/ + assert(offset_m[u]>=0); /*negative offsets not supported*/ + assert(size[u]<SIZET_MAX); + assert(offset_m[u]+(hssize_t)size[u]<=(hssize_t)size_m[u]); + assert(layout->dim[u]>0); } #endif @@ -1748,99 +1751,101 @@ H5F_istore_read(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, * loop through the chunks copying each to its final destination in the * application buffer. */ - for (i=0; i<layout->ndims; i++) { - idx_min[i] = offset_f[i] / layout->dim[i]; - idx_max[i] = (offset_f[i]+size[i]-1) / layout->dim[i] + 1; - idx_cur[i] = idx_min[i]; + for (u=0; u<layout->ndims; u++) { + idx_min[u] = offset_f[u] / layout->dim[u]; + idx_max[u] = (offset_f[u]+size[u]-1) / layout->dim[u] + 1; + idx_cur[u] = idx_min[u]; } /* Loop over all chunks */ while (1) { - for (i=0, naccessed=1; i<layout->ndims; i++) { - /* The location and size of the chunk being accessed */ - assert(layout->dim[i] < HSSIZET_MAX); - chunk_offset[i] = idx_cur[i] * (hssize_t)(layout->dim[i]); - - /* The offset and size wrt the chunk */ - offset_wrt_chunk[i] = MAX(offset_f[i], chunk_offset[i]) - - chunk_offset[i]; - sub_size[i] = MIN((idx_cur[i]+1)*layout->dim[i], - offset_f[i]+size[i]) - - (chunk_offset[i] + offset_wrt_chunk[i]); - naccessed *= sub_size[i]; - - /* Offset into mem buffer */ - sub_offset_m[i] = chunk_offset[i] + offset_wrt_chunk[i] + - offset_m[i] - offset_f[i]; - } + for (u=0, naccessed=1; u<layout->ndims; u++) { + /* The location and size of the chunk being accessed */ + assert(layout->dim[u] < HSSIZET_MAX); + chunk_offset[u] = idx_cur[u] * (hssize_t)(layout->dim[u]); + + /* The offset and size wrt the chunk */ + offset_wrt_chunk[u] = MAX(offset_f[u], chunk_offset[u]) - + chunk_offset[u]; + sub_size[u] = MIN((idx_cur[u]+1)*layout->dim[u], + offset_f[u]+size[u]) - + (chunk_offset[u] + offset_wrt_chunk[u]); + naccessed *= sub_size[u]; + + /* Offset into mem buffer */ + sub_offset_m[u] = chunk_offset[u] + offset_wrt_chunk[u] + + offset_m[u] - offset_f[u]; + } #ifdef H5_HAVE_PARALLEL - /* - * If MPIO is used, must bypass the chunk-cache scheme because other - * MPI processes could be writing to other elements in the same chunk. - * Do a direct write-through of only the elements requested. - */ - if (IS_H5FD_MPIO(f)) { - H5F_istore_ud1_t udata; - H5O_layout_t l; /* temporary layout */ - - if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to locate raw data chunk"); - }; - - /* - * use default transfer mode as we do not support collective - * transfer mode since each data write could decompose into - * multiple chunk writes and we are not doing the calculation yet. - */ - l.type = H5D_CONTIGUOUS; - l.ndims = layout->ndims; - for (i=l.ndims; i-- > 0; /*void*/) l.dim[i] = layout->dim[i]; - l.addr = udata.addr; - if (H5F_arr_read(f, H5P_DEFAULT, &l, pline, fill, NULL/*no efl*/, - sub_size, size_m, sub_offset_m, offset_wrt_chunk, - buf)<0){ - HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, - "unable to read raw data from file"); - } - } else { + /* + * If MPIO is used, must bypass the chunk-cache scheme because other + * MPI processes could be writing to other elements in the same chunk. + * Do a direct write-through of only the elements requested. + */ + if (IS_H5FD_MPIO(f)) { + H5F_istore_ud1_t udata; + H5O_layout_t l; /* temporary layout */ + + if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to locate raw data chunk"); + }; + + /* + * use default transfer mode as we do not support collective + * transfer mode since each data write could decompose into + * multiple chunk writes and we are not doing the calculation yet. + */ + l.type = H5D_CONTIGUOUS; + l.ndims = layout->ndims; + for (u=l.ndims; u-- > 0; /*void*/) + l.dim[u] = layout->dim[u]; + l.addr = udata.addr; + if (H5F_arr_read(f, H5P_DEFAULT, &l, pline, fill, NULL/*no efl*/, + sub_size, size_m, sub_offset_m, offset_wrt_chunk, buf)<0) { + HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, + "unable to read raw data from file"); + } + } else { #endif #ifdef AKC - printf("Locking chunk( "); - for (i=0; i<layout->ndims; i++){ - printf("%ld ", chunk_offset[i]); - } - printf(")\n"); + printf("Locking chunk( "); + for (u=0; u<layout->ndims; u++){ + printf("%ld ", chunk_offset[u]); + } + printf(")\n"); #endif - /* - * Lock the chunk, transfer data to the application, then unlock - * the chunk. - */ - if (NULL==(chunk=H5F_istore_lock(f, dxpl_id, layout, pline, fill, - chunk_offset, FALSE, - &idx_hint))) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "unable to read raw data chunk"); - } - H5V_hyper_copy(layout->ndims, sub_size, size_m, sub_offset_m, - (void*)buf, layout->dim, offset_wrt_chunk, chunk); - if (H5F_istore_unlock(f, dxpl_id, layout, pline, FALSE, - chunk_offset, &idx_hint, chunk, - naccessed)<0) { - HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, - "unable to unlock raw data chunk"); - } + /* + * Lock the chunk, transfer data to the application, then unlock + * the chunk. + */ + if (NULL==(chunk=H5F_istore_lock(f, dxpl_id, layout, pline, fill, + chunk_offset, FALSE, &idx_hint))) { + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + "unable to read raw data chunk"); + } + H5V_hyper_copy(layout->ndims, sub_size, size_m, sub_offset_m, + (void*)buf, layout->dim, offset_wrt_chunk, chunk); + if (H5F_istore_unlock(f, dxpl_id, layout, pline, FALSE, + chunk_offset, &idx_hint, chunk, + naccessed)<0) { + HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, + "unable to unlock raw data chunk"); + } #ifdef H5_HAVE_PARALLEL - } + } #endif - /* Increment indices */ - for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) { - if (++idx_cur[i]>=idx_max[i]) idx_cur[i] = idx_min[i]; - else carry = 0; - } - if (carry) break; + /* Increment indices */ + for (i=(intn)(layout->ndims-1), carry=1; i>=0 && carry; --i) { + if (++idx_cur[i]>=idx_max[i]) + idx_cur[i] = idx_min[i]; + else + carry = 0; + } + if (carry) + break; } FUNC_LEAVE(SUCCEED); } @@ -1869,16 +1874,17 @@ H5F_istore_write(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, const hssize_t offset_f[], const hsize_t size[], const void *buf) { - hssize_t offset_m[H5O_LAYOUT_NDIMS]; + hssize_t offset_m[H5O_LAYOUT_NDIMS]; hsize_t size_m[H5O_LAYOUT_NDIMS]; intn i, carry; + uintn u; hsize_t idx_cur[H5O_LAYOUT_NDIMS]; hsize_t idx_min[H5O_LAYOUT_NDIMS]; hsize_t idx_max[H5O_LAYOUT_NDIMS]; hsize_t sub_size[H5O_LAYOUT_NDIMS]; - hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; - hssize_t offset_wrt_chunk[H5O_LAYOUT_NDIMS]; - hssize_t sub_offset_m[H5O_LAYOUT_NDIMS]; + hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; + hssize_t offset_wrt_chunk[H5O_LAYOUT_NDIMS]; + hssize_t sub_offset_m[H5O_LAYOUT_NDIMS]; uint8_t *chunk=NULL; intn idx_hint=0; size_t chunk_size, naccessed; @@ -1898,19 +1904,19 @@ H5F_istore_write(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, * For now the source must not be a hyperslab. It must be an entire * memory buffer. */ - for (i=0, chunk_size=1; i<layout->ndims; i++) { - offset_m[i] = 0; - size_m[i] = size[i]; - chunk_size *= layout->dim[i]; + for (u=0, chunk_size=1; u<layout->ndims; u++) { + offset_m[u] = 0; + size_m[u] = size[u]; + chunk_size *= layout->dim[u]; } #ifndef NDEBUG - for (i=0; i<layout->ndims; i++) { - assert(offset_f[i]>=0); /*negative offsets not supported*/ - assert(offset_m[i]>=0); /*negative offsets not supported*/ - assert(size[i]<SIZET_MAX); - assert(offset_m[i]+(hssize_t)size[i]<=(hssize_t)size_m[i]); - assert(layout->dim[i]>0); + for (u=0; u<layout->ndims; u++) { + assert(offset_f[u]>=0); /*negative offsets not supported*/ + assert(offset_m[u]>=0); /*negative offsets not supported*/ + assert(size[u]<SIZET_MAX); + assert(offset_m[u]+(hssize_t)size[u]<=(hssize_t)size_m[u]); + assert(layout->dim[u]>0); } #endif @@ -1919,103 +1925,105 @@ H5F_istore_write(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, * loop through the chunks copying each chunk from the application to the * chunk cache. */ - for (i=0; i<layout->ndims; i++) { - idx_min[i] = offset_f[i] / layout->dim[i]; - idx_max[i] = (offset_f[i]+size[i]-1) / layout->dim[i] + 1; - idx_cur[i] = idx_min[i]; + for (u=0; u<layout->ndims; u++) { + idx_min[u] = offset_f[u] / layout->dim[u]; + idx_max[u] = (offset_f[u]+size[u]-1) / layout->dim[u] + 1; + idx_cur[u] = idx_min[u]; } /* Loop over all chunks */ while (1) { - - for (i=0, naccessed=1; i<layout->ndims; i++) { - /* The location and size of the chunk being accessed */ - assert(layout->dim[i] < HSSIZET_MAX); - chunk_offset[i] = idx_cur[i] * (hssize_t)(layout->dim[i]); - - /* The offset and size wrt the chunk */ - offset_wrt_chunk[i] = MAX(offset_f[i], chunk_offset[i]) - - chunk_offset[i]; - sub_size[i] = MIN((idx_cur[i]+1)*layout->dim[i], - offset_f[i]+size[i]) - - (chunk_offset[i] + offset_wrt_chunk[i]); - naccessed *= sub_size[i]; - - /* Offset into mem buffer */ - sub_offset_m[i] = chunk_offset[i] + offset_wrt_chunk[i] + - offset_m[i] - offset_f[i]; - } + for (u=0, naccessed=1; u<layout->ndims; u++) { + /* The location and size of the chunk being accessed */ + assert(layout->dim[u] < HSSIZET_MAX); + chunk_offset[u] = idx_cur[u] * (hssize_t)(layout->dim[u]); + + /* The offset and size wrt the chunk */ + offset_wrt_chunk[u] = MAX(offset_f[u], chunk_offset[u]) - + chunk_offset[u]; + sub_size[u] = MIN((idx_cur[u]+1)*layout->dim[u], + offset_f[u]+size[u]) - + (chunk_offset[u] + offset_wrt_chunk[u]); + naccessed *= sub_size[u]; + + /* Offset into mem buffer */ + sub_offset_m[u] = chunk_offset[u] + offset_wrt_chunk[u] + + offset_m[u] - offset_f[u]; + } #ifdef H5_HAVE_PARALLEL - /* - * If MPIO is used, must bypass the chunk-cache scheme because other - * MPI processes could be writing to other elements in the same chunk. - * Do a direct write-through of only the elements requested. - */ - if (IS_H5FD_MPIO(f)) { - H5F_istore_ud1_t udata; - H5O_layout_t l; /* temporary layout */ - if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to locate raw data chunk"); - }; - - /* - * use default transfer mode as we do not support collective - * transfer mode since each data write could decompose into - * multiple chunk writes and we are not doing the calculation yet. - */ - l.type = H5D_CONTIGUOUS; - l.ndims = layout->ndims; - for (i=l.ndims; i-- > 0; /*void*/) l.dim[i] = layout->dim[i]; - l.addr = udata.addr; - if (H5F_arr_write(f, H5P_DEFAULT, &l, pline, fill, NULL/*no efl*/, - sub_size, size_m, sub_offset_m, offset_wrt_chunk, - buf)<0){ - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to write raw data to file"); - } - } else { + /* + * If MPIO is used, must bypass the chunk-cache scheme because other + * MPI processes could be writing to other elements in the same chunk. + * Do a direct write-through of only the elements requested. + */ + if (IS_H5FD_MPIO(f)) { + H5F_istore_ud1_t udata; + H5O_layout_t l; /* temporary layout */ + + if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to locate raw data chunk"); + }; + + /* + * use default transfer mode as we do not support collective + * transfer mode since each data write could decompose into + * multiple chunk writes and we are not doing the calculation yet. + */ + l.type = H5D_CONTIGUOUS; + l.ndims = layout->ndims; + for (u=l.ndims; u-- > 0; /*void*/) + l.dim[u] = layout->dim[u]; + l.addr = udata.addr; + if (H5F_arr_write(f, H5P_DEFAULT, &l, pline, fill, NULL/*no efl*/, + sub_size, size_m, sub_offset_m, offset_wrt_chunk, buf)<0) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to write raw data to file"); + } + } else { #endif #ifdef AKC - printf("Locking chunk( "); - for (i=0; i<layout->ndims; i++){ - printf("%ld ", chunk_offset[i]); - } - printf(")\n"); + printf("Locking chunk( "); + for (u=0; u<layout->ndims; u++){ + printf("%ld ", chunk_offset[u]); + } + printf(")\n"); #endif - /* - * Lock the chunk, copy from application to chunk, then unlock the - * chunk. - */ - if (NULL==(chunk=H5F_istore_lock(f, dxpl_id, layout, pline, fill, - chunk_offset, - naccessed==chunk_size, - &idx_hint))) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to read raw data chunk"); - } - H5V_hyper_copy(layout->ndims, sub_size, - layout->dim, offset_wrt_chunk, chunk, - size_m, sub_offset_m, buf); - if (H5F_istore_unlock(f, dxpl_id, layout, pline, TRUE, - chunk_offset, &idx_hint, chunk, - naccessed)<0) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "uanble to unlock raw data chunk"); - } + /* + * Lock the chunk, copy from application to chunk, then unlock the + * chunk. + */ + if (NULL==(chunk=H5F_istore_lock(f, dxpl_id, layout, pline, fill, + chunk_offset, + (hbool_t)(naccessed==chunk_size), + &idx_hint))) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to read raw data chunk"); + } + H5V_hyper_copy(layout->ndims, sub_size, + layout->dim, offset_wrt_chunk, chunk, size_m, sub_offset_m, buf); + if (H5F_istore_unlock(f, dxpl_id, layout, pline, TRUE, + chunk_offset, &idx_hint, chunk, + naccessed)<0) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "uanble to unlock raw data chunk"); + } #ifdef H5_HAVE_PARALLEL - } + } #endif - - /* Increment indices */ - for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) { - if (++idx_cur[i]>=idx_max[i]) idx_cur[i] = idx_min[i]; - else carry = 0; - } - if (carry) break; + + /* Increment indices */ + for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) { + if (++idx_cur[i]>=idx_max[i]) + idx_cur[i] = idx_min[i]; + else + carry = 0; + } + if (carry) + break; } FUNC_LEAVE(SUCCEED); @@ -2047,7 +2055,7 @@ H5F_istore_create(H5F_t *f, H5O_layout_t *layout /*out */ ) { H5F_istore_ud1_t udata; #ifndef NDEBUG - int i; + uintn u; #endif FUNC_ENTER(H5F_istore_create, FAIL); @@ -2057,8 +2065,8 @@ H5F_istore_create(H5F_t *f, H5O_layout_t *layout /*out */ ) assert(layout && H5D_CHUNKED == layout->type); assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS); #ifndef NDEBUG - for (i = 0; i < layout->ndims; i++) { - assert(layout->dim[i] > 0); + for (u = 0; u < layout->ndims; u++) { + assert(layout->dim[u] > 0); } #endif @@ -2091,15 +2099,16 @@ H5F_istore_create(H5F_t *f, H5O_layout_t *layout /*out */ ) *------------------------------------------------------------------------- */ hsize_t -H5F_istore_allocated(H5F_t *f, int ndims, haddr_t addr) +H5F_istore_allocated(H5F_t *f, uintn ndims, haddr_t addr) { H5F_istore_ud1_t udata; FUNC_ENTER(H5F_istore_nchunks, 0); + HDmemset(&udata, 0, sizeof udata); udata.mesg.ndims = ndims; if (H5B_iterate(f, H5B_ISTORE, addr, &udata)<0) { - HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0, + HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree"); } FUNC_LEAVE(udata.total_storage); @@ -2125,16 +2134,17 @@ H5F_istore_allocated(H5F_t *f, int ndims, haddr_t addr) *------------------------------------------------------------------------- */ herr_t -H5F_istore_dump_btree(H5F_t *f, FILE *stream, int ndims, haddr_t addr) +H5F_istore_dump_btree(H5F_t *f, FILE *stream, uintn ndims, haddr_t addr) { H5F_istore_ud1_t udata; FUNC_ENTER(H5F_istore_dump_btree, FAIL); + HDmemset(&udata, 0, sizeof udata); udata.mesg.ndims = ndims; udata.stream = stream; if (H5B_iterate(f, H5B_ISTORE, addr, &udata)<0) { - HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0, + HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree"); } FUNC_LEAVE(SUCCEED); @@ -2168,12 +2178,12 @@ H5F_istore_stats (H5F_t *f, hbool_t headers) if (!H5DEBUG(AC)) HRETURN(SUCCEED); if (headers) { - fprintf(H5DEBUG(AC), "H5F: raw data cache statistics for file %s\n", - f->name); - fprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s+%-8s\n", - "Layer", "Hits", "Misses", "MissRate", "Inits", "Flushes"); - fprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s-%-8s\n", - "-----", "----", "------", "--------", "-----", "-------"); + fprintf(H5DEBUG(AC), "H5F: raw data cache statistics for file %s\n", + f->name); + fprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s+%-8s\n", + "Layer", "Hits", "Misses", "MissRate", "Inits", "Flushes"); + fprintf(H5DEBUG(AC), " %-18s %8s %8s %8s %8s-%-8s\n", + "-----", "----", "------", "--------", "-----", "-------"); } #ifdef H5AC_DEBUG @@ -2181,21 +2191,21 @@ H5F_istore_stats (H5F_t *f, hbool_t headers) #endif if (headers) { - if (rdcc->nhits>0 || rdcc->nmisses>0) { - miss_rate = 100.0 * rdcc->nmisses / - (rdcc->nhits + rdcc->nmisses); - } else { - miss_rate = 0.0; - } - if (miss_rate > 100) { - sprintf(ascii, "%7d%%", (int) (miss_rate + 0.5)); - } else { - sprintf(ascii, "%7.2f%%", miss_rate); - } - - fprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", - "raw data chunks", rdcc->nhits, rdcc->nmisses, ascii, - rdcc->ninits, (long)(rdcc->nflushes)-(long)(rdcc->ninits)); + if (rdcc->nhits>0 || rdcc->nmisses>0) { + miss_rate = 100.0 * rdcc->nmisses / + (rdcc->nhits + rdcc->nmisses); + } else { + miss_rate = 0.0; + } + if (miss_rate > 100) { + sprintf(ascii, "%7d%%", (int) (miss_rate + 0.5)); + } else { + sprintf(ascii, "%7.2f%%", miss_rate); + } + + fprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", + "raw data chunks", rdcc->nhits, rdcc->nmisses, ascii, + rdcc->ninits, (long)(rdcc->nflushes)-(long)(rdcc->ninits)); } FUNC_LEAVE (SUCCEED); @@ -2320,6 +2330,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, { intn i, carry; + uintn u; hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; uint8_t *chunk=NULL; intn idx_hint=0; @@ -2345,9 +2356,9 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, * Setup indice to go through all chunks. (Future improvement * should allocate only chunks that have no file space assigned yet. */ - for (i=0, chunk_size=1; i<layout->ndims; i++) { - chunk_offset[i]=0; - chunk_size *= layout->dim[i]; + for (u=0, chunk_size=1; u<layout->ndims; u++) { + chunk_offset[u]=0; + chunk_size *= layout->dim[u]; } /* Loop over all chunks */ @@ -2355,73 +2366,70 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, #ifdef AKC printf("Checking allocation for chunk( "); - for (i=0; i<layout->ndims; i++){ - printf("%ld ", chunk_offset[i]); + for (u=0; u<layout->ndims; u++){ + printf("%ld ", chunk_offset[u]); } printf(")\n"); #endif #ifdef NO - if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0){ + if (H5F_istore_get_addr(f, layout, chunk_offset, &udata)<0) { #endif - /* No file space assigned yet. Allocate it. */ - /* The following needs improvement like calling the */ - /* allocation directly rather than indirectly using the */ - /* allocation effect in the unlock process. */ + /* No file space assigned yet. Allocate it. */ + /* The following needs improvement like calling the */ + /* allocation directly rather than indirectly using the */ + /* allocation effect in the unlock process. */ #ifdef AKC - printf("need allocation\n"); + printf("need allocation\n"); #endif - /* - * Lock the chunk, copy from application to chunk, then unlock the - * chunk. - */ + /* + * Lock the chunk, copy from application to chunk, then unlock the + * chunk. + */ #ifdef H5_HAVE_PARALLEL - /* rky 981207 Serialize access to this critical region. */ - if (SUCCEED!= - H5FD_mpio_wait_for_left_neighbor(f->shared->lf)) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to lock the data chunk"); - } + /* rky 981207 Serialize access to this critical region. */ + if (SUCCEED!= H5FD_mpio_wait_for_left_neighbor(f->shared->lf)) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to lock the data chunk"); + } #endif - if (NULL==(chunk=H5F_istore_lock(f, dxpl_id, layout, pline, - fill, chunk_offset, FALSE, - &idx_hint))) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to read raw data chunk"); - } - if (H5F_istore_unlock(f, dxpl_id, layout, pline, TRUE, - chunk_offset, &idx_hint, chunk, - chunk_size)<0) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "uanble to unlock raw data chunk"); - } + if (NULL==(chunk=H5F_istore_lock(f, dxpl_id, layout, pline, + fill, chunk_offset, FALSE, &idx_hint))) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to read raw data chunk"); + } + if (H5F_istore_unlock(f, dxpl_id, layout, pline, TRUE, + chunk_offset, &idx_hint, chunk, chunk_size)<0) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "uanble to unlock raw data chunk"); + } #ifdef H5_HAVE_PARALLEL - if (SUCCEED!= - H5FD_mpio_signal_right_neighbor(f->shared->lf)) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, - "unable to unlock the data chunk"); - } + if (SUCCEED!= H5FD_mpio_signal_right_neighbor(f->shared->lf)) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, + "unable to unlock the data chunk"); + } #endif #ifdef NO - } else { + } else { #ifdef AKC - printf("NO need for allocation\n"); - HDfprintf(stdout, "udata.addr=%a\n", udata.addr); + printf("NO need for allocation\n"); + HDfprintf(stdout, "udata.addr=%a\n", udata.addr); #endif - } + } #endif - /* Increment indices */ - for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) { - chunk_offset[i] += layout->dim[i]; - if (chunk_offset[i] >= (hssize_t)(space_dim[i])) { - chunk_offset[i] = 0; - } else { - carry = 0; - } - } - if (carry) break; + /* Increment indices */ + for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) { + chunk_offset[i] += layout->dim[i]; + if (chunk_offset[i] >= (hssize_t)(space_dim[i])) { + chunk_offset[i] = 0; + } else { + carry = 0; + } + } + if (carry) + break; } #ifdef H5_HAVE_PARALLEL @@ -2436,7 +2444,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, * to allocate space, instead of calling H5F_istore_unlock. */ if (MPI_Barrier(H5FD_mpio_communicator(f->shared->lf))) { - HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Barrier failed"); + HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Barrier failed"); } #endif diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 707b546..d417b76 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -204,9 +204,5 @@ __DLL__ herr_t H5F_contig_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t __DLL__ herr_t H5F_contig_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size, hid_t dxpl_id, const void *buf); -/* Functions for allocation/releasing chunks */ -__DLL__ void * H5F_istore_chunk_alloc(size_t chunk_size); -__DLL__ void * H5F_istore_chunk_realloc(void *chunk, size_t new_size); - #endif diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index c4adb85..09ed4c7 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -342,20 +342,22 @@ __DLL__ herr_t H5F_seq_read(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, const struct H5S_t *file_space, size_t elmt_size, hsize_t seq_len, - hssize_t file_offset, void *_buf/*out*/); + hsize_t file_offset, void *_buf/*out*/); __DLL__ herr_t H5F_seq_write (H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, const struct H5S_t *file_space, size_t elmt_size, hsize_t seq_len, - hssize_t file_offset, const void *_buf); + hsize_t file_offset, const void *_buf); /* Functions that operate on indexed storage */ -__DLL__ hsize_t H5F_istore_allocated(H5F_t *f, int ndims, haddr_t addr); -__DLL__ herr_t H5F_istore_dump_btree(H5F_t *f, FILE *stream, int ndims, +__DLL__ hsize_t H5F_istore_allocated(H5F_t *f, uintn ndims, haddr_t addr); +__DLL__ herr_t H5F_istore_dump_btree(H5F_t *f, FILE *stream, uintn ndims, haddr_t addr); /* Functions for allocation/releasing chunks */ +__DLL__ void * H5F_istore_chunk_alloc(size_t chunk_size); +__DLL__ void * H5F_istore_chunk_realloc(void *chunk, size_t new_size); __DLL__ void * H5F_istore_chunk_free(void *chunk); /* Address-related functions */ diff --git a/src/H5Fseq.c b/src/H5Fseq.c index 209821a..01d484d 100644 --- a/src/H5Fseq.c +++ b/src/H5Fseq.c @@ -59,7 +59,7 @@ herr_t H5F_seq_read(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const H5O_fill_t *fill, const struct H5O_efl_t *efl, const H5S_t *file_space, size_t elmt_size, - hsize_t seq_len, hssize_t file_offset, void *buf/*out*/) + hsize_t seq_len, hsize_t file_offset, void *buf/*out*/) { hsize_t dset_dims[H5O_LAYOUT_NDIMS]; /* dataspace dimensions */ hssize_t coords[H5O_LAYOUT_NDIMS]; /* offset of hyperslab in dataspace */ @@ -285,7 +285,7 @@ herr_t H5F_seq_write(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const H5O_fill_t *fill, const struct H5O_efl_t *efl, const H5S_t *file_space, size_t elmt_size, - hsize_t seq_len, hssize_t file_offset, const void *buf) + hsize_t seq_len, hsize_t file_offset, const void *buf) { hsize_t dset_dims[H5O_LAYOUT_NDIMS]; /* dataspace dimensions */ hssize_t coords[H5O_LAYOUT_NDIMS]; /* offset of hyperslab in dataspace */ @@ -2055,7 +2055,7 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link, /* Find the object's symbol table entry */ if (H5G_namei (loc, name, NULL, &grp_ent/*out*/, &obj_ent/*out*/, - follow_link?H5G_TARGET_NORMAL:H5G_TARGET_SLINK, NULL)<0) { + (uintn)(follow_link?H5G_TARGET_NORMAL:H5G_TARGET_SLINK), NULL)<0) { HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to stat object"); } diff --git a/src/H5Gnode.c b/src/H5Gnode.c index bf9f959..eaf3115 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -272,7 +272,7 @@ H5G_node_create(H5F_t *f, H5B_ins_t UNUSED op, void *_lt_key, "unable to allocate file space"); } sym->dirty = TRUE; - sym->entry = H5FL_ARR_ALLOC(H5G_entry_t,2*H5G_NODE_K(f),1); + sym->entry = H5FL_ARR_ALLOC(H5G_entry_t,(hsize_t)(2*H5G_NODE_K(f)),1); if (NULL==sym->entry) { H5FL_FREE(H5G_node_t,sym); HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, @@ -347,7 +347,7 @@ H5G_node_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5G_node_t *sym) size = H5G_node_size(f); /* Allocate temporary buffer */ - if ((buf=H5FL_BLK_ALLOC(symbol_node,size, 0))==NULL) + if ((buf=H5FL_BLK_ALLOC(symbol_node,(hsize_t)size, 0))==NULL) HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); p=buf; @@ -415,7 +415,7 @@ H5G_node_load(H5F_t *f, haddr_t addr, const void UNUSED *_udata1, void UNUSED *_udata2) { H5G_node_t *sym = NULL; - size_t size = 0; + hsize_t size = 0; uint8_t *buf = NULL; const uint8_t *p = NULL; H5G_node_t *ret_value = NULL; /*for error handling */ @@ -439,11 +439,11 @@ H5G_node_load(H5F_t *f, haddr_t addr, const void UNUSED *_udata1, "memory allocation failed for symbol table node"); p=buf; if (NULL==(sym = H5FL_ALLOC(H5G_node_t,1)) || - NULL==(sym->entry=H5FL_ARR_ALLOC(H5G_entry_t,2*H5G_NODE_K(f),1))) { + NULL==(sym->entry=H5FL_ARR_ALLOC(H5G_entry_t,(hsize_t)(2*H5G_NODE_K(f)),1))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } - if (H5F_block_read(f, H5FD_MEM_BTREE, addr, (hsize_t)size, H5P_DEFAULT, buf) < 0) { + if (H5F_block_read(f, H5FD_MEM_BTREE, addr, size, H5P_DEFAULT, buf) < 0) { HGOTO_ERROR(H5E_SYM, H5E_READERROR, NULL, "unabel to read symbol table node"); } @@ -989,7 +989,7 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/, sn->dirty = TRUE; if (H5AC_unprotect(f, H5AC_SNODE, addr, sn)<0 || H5AC_flush(f, H5AC_SNODE, addr, TRUE)<0 || - H5MF_xfree(f, H5FD_MEM_BTREE, addr, H5G_node_size(f))<0) { + H5MF_xfree(f, H5FD_MEM_BTREE, addr, (hsize_t)H5G_node_size(f))<0) { sn = NULL; HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node"); @@ -52,7 +52,7 @@ struct H5HG_heap_t { size_t size; /*total size of collection */ uint8_t *chunk; /*the collection, incl. header */ intn nalloc; /*numb object slots allocated */ - H5HG_obj_t *obj; /*array of object descriptions */ + H5HG_obj_t *obj; /*array of object descriptions */ }; /* PRIVATE PROTOTYPES */ @@ -118,7 +118,8 @@ H5HG_create (H5F_t *f, size_t size) /* Check args */ assert (f); - if (size<H5HG_MINSIZE) size = H5HG_MINSIZE; + if (size<H5HG_MINSIZE) + size = H5HG_MINSIZE; size = H5HG_ALIGN(size); #ifdef QAK printf("%s: size=%d\n",FUNC,(int)size); @@ -136,12 +137,12 @@ printf("%s: size=%d\n",FUNC,(int)size); heap->addr = addr; heap->size = size; heap->dirty = TRUE; - if (NULL==(heap->chunk = H5FL_BLK_ALLOC (heap_chunk,size,0))) { + if (NULL==(heap->chunk = H5FL_BLK_ALLOC (heap_chunk,(hsize_t)size,0))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } heap->nalloc = H5HG_NOBJS (f, size); - if (NULL==(heap->obj = H5FL_ARR_ALLOC (H5HG_obj_t,heap->nalloc,1))) { + if (NULL==(heap->obj = H5FL_ARR_ALLOC (H5HG_obj_t,(hsize_t)heap->nalloc,1))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } @@ -252,7 +253,7 @@ H5HG_load (H5F_t *f, haddr_t addr, const void UNUSED *udata1, "memory allocation failed"); } heap->addr = addr; - if (NULL==(heap->chunk = H5FL_BLK_ALLOC (heap_chunk,H5HG_MINSIZE,0))) { + if (NULL==(heap->chunk = H5FL_BLK_ALLOC (heap_chunk,(hsize_t)H5HG_MINSIZE,0))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } @@ -288,7 +289,7 @@ H5HG_load (H5F_t *f, haddr_t addr, const void UNUSED *udata1, */ if (heap->size > H5HG_MINSIZE) { haddr_t next_addr = addr + (hsize_t)H5HG_MINSIZE; - if (NULL==(heap->chunk = H5FL_BLK_REALLOC (heap_chunk, heap->chunk, heap->size))) { + if (NULL==(heap->chunk = H5FL_BLK_REALLOC (heap_chunk, heap->chunk, (hsize_t)heap->size))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } @@ -302,7 +303,7 @@ H5HG_load (H5F_t *f, haddr_t addr, const void UNUSED *udata1, /* Decode each object */ p = heap->chunk + H5HG_SIZEOF_HDR (f); nalloc = H5HG_NOBJS (f, heap->size); - if (NULL==(heap->obj = H5FL_ARR_ALLOC (H5HG_obj_t,nalloc,1))) { + if (NULL==(heap->obj = H5FL_ARR_ALLOC (H5HG_obj_t,(hsize_t)nalloc,1))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } @@ -851,75 +852,74 @@ H5HG_remove (H5F_t *f, H5HG_t *hobj) assert (f); assert (hobj); if (0==(f->intent & H5F_ACC_RDWR)) { - HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, + HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file"); } /* Load the heap */ if (NULL==(heap=H5AC_find (f, H5AC_GHEAP, hobj->addr, NULL, NULL))) { - HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); + HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap"); } assert (hobj->idx>0 && hobj->idx<heap->nalloc); assert (heap->obj[hobj->idx].begin); obj_start = heap->obj[hobj->idx].begin; - need = H5HG_ALIGN(heap->obj[hobj->idx].size); /* - * should this include the + need = H5HG_ALIGN(heap->obj[hobj->idx].size); /* should this include the * object header size? -rpm */ /* Move the new free space to the end of the heap */ for (i=0; i<heap->nalloc; i++) { - if (heap->obj[i].begin > heap->obj[hobj->idx].begin) { - heap->obj[i].begin -= need; - } + if (heap->obj[i].begin > heap->obj[hobj->idx].begin) { + heap->obj[i].begin -= need; + } } if (NULL==heap->obj[0].begin) { - heap->obj[0].begin = heap->chunk + (heap->size-need); - heap->obj[0].size = need; - heap->obj[0].nrefs = 0; + heap->obj[0].begin = heap->chunk + (heap->size-need); + heap->obj[0].size = need; + heap->obj[0].nrefs = 0; } else { - heap->obj[0].size += need; + heap->obj[0].size += need; } HDmemmove (obj_start, obj_start+need, heap->size-((obj_start+need)-heap->chunk)); if (heap->obj[0].size>=H5HG_SIZEOF_OBJHDR (f)) { - p = heap->obj[0].begin; - UINT16ENCODE(p, 0); /*id*/ - UINT16ENCODE(p, 0); /*nrefs*/ - UINT32ENCODE(p, 0); /*reserved*/ - H5F_ENCODE_LENGTH (f, p, need); + p = heap->obj[0].begin; + UINT16ENCODE(p, 0); /*id*/ + UINT16ENCODE(p, 0); /*nrefs*/ + UINT32ENCODE(p, 0); /*reserved*/ + H5F_ENCODE_LENGTH (f, p, need); } HDmemset (heap->obj+hobj->idx, 0, sizeof(H5HG_obj_t)); heap->dirty = 1; if (heap->obj[0].size+H5HG_SIZEOF_HDR(f)==heap->size) { - /* - * The collection is empty. Remove it from the CWFS list and return it - * to the file free list. - */ - heap->dirty = FALSE; - H5MF_xfree(f, H5FD_MEM_GHEAP, heap->addr, heap->size); - H5AC_flush (f, H5AC_GHEAP, heap->addr, TRUE); - heap = NULL; + /* + * The collection is empty. Remove it from the CWFS list and return it + * to the file free list. + */ + heap->dirty = FALSE; + H5MF_xfree(f, H5FD_MEM_GHEAP, heap->addr, (hsize_t)heap->size); + H5AC_flush (f, H5AC_GHEAP, heap->addr, TRUE); + heap = NULL; } else { - /* - * If the heap is in the CWFS list then advance it one position. The - * H5AC_find() might have done that too, but that's okay. If the - * heap isn't on the CWFS list then add it to the end. - */ - for (i=0; i<f->shared->ncwfs; i++) { - if (f->shared->cwfs[i]==heap) { - if (i) { - f->shared->cwfs[i] = f->shared->cwfs[i-1]; - f->shared->cwfs[i-1] = heap; - } - break; - } - } - if (i>=f->shared->ncwfs) { - f->shared->ncwfs = MIN (f->shared->ncwfs+1, H5HG_NCWFS); - f->shared->cwfs[f->shared->ncwfs-1] = heap; - } + /* + * If the heap is in the CWFS list then advance it one position. The + * H5AC_find() might have done that too, but that's okay. If the + * heap isn't on the CWFS list then add it to the end. + */ + for (i=0; i<f->shared->ncwfs; i++) { + if (f->shared->cwfs[i]==heap) { + if (i) { + f->shared->cwfs[i] = f->shared->cwfs[i-1]; + f->shared->cwfs[i-1] = heap; + } + break; + } + } + if (i>=f->shared->ncwfs) { + f->shared->ncwfs = MIN (f->shared->ncwfs+1, H5HG_NCWFS); + f->shared->cwfs[f->shared->ncwfs-1] = heap; + } } FUNC_LEAVE (SUCCEED); @@ -112,7 +112,7 @@ herr_t H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr_p/*out*/) { H5HL_t *heap = NULL; - size_t total_size; /*total heap size on disk */ + hsize_t total_size; /*total heap size on disk */ herr_t ret_value = FAIL; FUNC_ENTER(H5HL_create, FAIL); @@ -141,7 +141,7 @@ H5HL_create(H5F_t *f, size_t size_hint, haddr_t *addr_p/*out*/) heap->addr = *addr_p + (hsize_t)H5HL_SIZEOF_HDR(f); heap->disk_alloc = size_hint; heap->mem_alloc = size_hint; - if (NULL==(heap->chunk = H5FL_BLK_ALLOC(heap_chunk,H5HL_SIZEOF_HDR(f) + size_hint,1))) { + if (NULL==(heap->chunk = H5FL_BLK_ALLOC(heap_chunk,(hsize_t)(H5HL_SIZEOF_HDR(f) + size_hint),1))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } @@ -253,7 +253,7 @@ H5HL_load(H5F_t *f, haddr_t addr, const void UNUSED *udata1, /* data */ H5F_addr_decode(f, &p, &(heap->addr)); - heap->chunk = H5FL_BLK_ALLOC(heap_chunk,H5HL_SIZEOF_HDR(f) + heap->mem_alloc,1); + heap->chunk = H5FL_BLK_ALLOC(heap_chunk,(hsize_t)(H5HL_SIZEOF_HDR(f) + heap->mem_alloc),1); if (NULL==heap->chunk) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); @@ -350,12 +350,12 @@ H5HL_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5HL_t *heap) if (heap->mem_alloc > heap->disk_alloc) { haddr_t old_addr = heap->addr, new_addr; if (HADDR_UNDEF==(new_addr=H5MF_alloc(f, H5FD_MEM_LHEAP, - heap->mem_alloc))) { + (hsize_t)heap->mem_alloc))) { HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space for heap"); } heap->addr = new_addr; - H5MF_xfree(f, H5FD_MEM_LHEAP, old_addr, heap->disk_alloc); + H5MF_xfree(f, H5FD_MEM_LHEAP, old_addr, (hsize_t)heap->disk_alloc); H5E_clear(); /*don't really care if the free failed */ heap->disk_alloc = heap->mem_alloc; } @@ -722,7 +722,7 @@ H5HL_insert(H5F_t *f, haddr_t addr, size_t buf_size, const void *buf) old_size = heap->mem_alloc; heap->mem_alloc += need_more; heap->chunk = H5FL_BLK_REALLOC(heap_chunk,heap->chunk, - H5HL_SIZEOF_HDR(f) + heap->mem_alloc); + (hsize_t)(H5HL_SIZEOF_HDR(f) + heap->mem_alloc)); if (NULL==heap->chunk) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "memory allocation failed"); @@ -1103,7 +1103,7 @@ H5I_find_id(hid_t id) * *------------------------------------------------------------------------- */ -#ifdef H5I_DEBUG +#ifdef H5I_DEBUG_OUTPUT static herr_t H5I_debug(H5I_type_t grp) { @@ -1150,5 +1150,5 @@ H5I_debug(H5I_type_t grp) FUNC_LEAVE(SUCCEED); } -#endif /* H5I_DEBUG */ +#endif /* H5I_DEBUG_OUTPUT */ @@ -69,12 +69,12 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t type, hsize_t size) /* Fail if we don't have write access */ if (0==(f->intent & H5F_ACC_RDWR)) { - HRETURN_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "file is read-only"); + HRETURN_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "file is read-only"); } /* Allocate space from the virtual file layer */ if (HADDR_UNDEF==(ret_value=H5FD_alloc(f->shared->lf, type, size))) { - HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed"); } @@ -186,7 +186,7 @@ H5MF_realloc(H5F_t *f, H5FD_mem_t type, haddr_t old_addr, hsize_t old_size, ret_value = H5FD_realloc(f->shared->lf, type, old_addr, old_size, new_size); if (HADDR_UNDEF==ret_value) { - HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "unable to allocate new file memory"); } @@ -157,7 +157,7 @@ H5O_init_interface(void) herr_t H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/) { - size_t size; /*total size of object header */ + hsize_t size; /*total size of object header */ H5O_t *oh = NULL; haddr_t tmp_addr; @@ -189,7 +189,7 @@ H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/) /* create the chunk list and initialize the first chunk */ oh->nchunks = 1; oh->alloc_nchunks = H5O_NCHUNKS; - if (NULL==(oh->chunk=H5FL_ARR_ALLOC(H5O_chunk_t,oh->alloc_nchunks,0))) { + if (NULL==(oh->chunk=H5FL_ARR_ALLOC(H5O_chunk_t,(hsize_t)oh->alloc_nchunks,0))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } @@ -197,7 +197,7 @@ H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/) oh->chunk[0].dirty = TRUE; oh->chunk[0].addr = tmp_addr; oh->chunk[0].size = size_hint; - if (NULL==(oh->chunk[0].image = H5FL_BLK_ALLOC(chunk_image,size_hint,1))) { + if (NULL==(oh->chunk[0].image = H5FL_BLK_ALLOC(chunk_image,(hsize_t)size_hint,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } @@ -205,7 +205,7 @@ H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/) /* create the message list and initialize the first message */ oh->nmesgs = 1; oh->alloc_nmesgs = H5O_NMESGS; - if (NULL==(oh->mesg=H5FL_ARR_ALLOC(H5O_mesg_t,oh->alloc_nmesgs,1))) { + if (NULL==(oh->mesg=H5FL_ARR_ALLOC(H5O_mesg_t,(hsize_t)oh->alloc_nmesgs,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } @@ -352,7 +352,8 @@ H5O_load(H5F_t *f, haddr_t addr, const void UNUSED *_udata1, H5O_t *oh = NULL; H5O_t *ret_value = NULL; uint8_t buf[16], *p; - size_t hdr_size, mesg_size; + size_t mesg_size; + hsize_t hdr_size; uintn id; intn mesgno, chunkno, curmesg = 0, nmesgs; haddr_t chunk_addr; @@ -404,7 +405,7 @@ H5O_load(H5F_t *f, haddr_t addr, const void UNUSED *_udata1, /* build the message array */ oh->alloc_nmesgs = MAX(H5O_NMESGS, nmesgs); - if (NULL==(oh->mesg=H5FL_ARR_ALLOC(H5O_mesg_t,oh->alloc_nmesgs,1))) { + if (NULL==(oh->mesg=H5FL_ARR_ALLOC(H5O_mesg_t,(hsize_t)oh->alloc_nmesgs,1))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } @@ -414,10 +415,10 @@ H5O_load(H5F_t *f, haddr_t addr, const void UNUSED *_udata1, /* increase chunk array size */ if (oh->nchunks >= oh->alloc_nchunks) { - size_t na = oh->alloc_nchunks + H5O_NCHUNKS; + hsize_t na = oh->alloc_nchunks + H5O_NCHUNKS; H5O_chunk_t *x = H5FL_ARR_REALLOC (H5O_chunk_t, oh->chunk, na); if (!x) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } oh->alloc_nchunks = (intn)na; @@ -429,11 +430,11 @@ H5O_load(H5F_t *f, haddr_t addr, const void UNUSED *_udata1, oh->chunk[chunkno].dirty = FALSE; oh->chunk[chunkno].addr = chunk_addr; oh->chunk[chunkno].size = chunk_size; - if (NULL==(oh->chunk[chunkno].image = H5FL_BLK_ALLOC(chunk_image,chunk_size,0))) { + if (NULL==(oh->chunk[chunkno].image = H5FL_BLK_ALLOC(chunk_image,(hsize_t)chunk_size,0))) { HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } - if (H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, chunk_size, H5P_DEFAULT, + if (H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, (hsize_t)chunk_size, H5P_DEFAULT, oh->chunk[chunkno].image) < 0) { HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header data"); @@ -595,63 +596,60 @@ H5O_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5O_t *oh) /* encode messages */ for (i = 0; i < oh->nmesgs; i++) { if (oh->mesg[i].dirty) { - p = oh->mesg[i].raw - H5O_SIZEOF_MSGHDR(f); - - id = oh->mesg[i].type->id; - UINT16ENCODE(p, id); - assert (oh->mesg[i].raw_size<65536); - UINT16ENCODE(p, oh->mesg[i].raw_size); - *p++ = oh->mesg[i].flags; - *p++ = 0; /*reserved*/ - *p++ = 0; /*reserved*/ - *p++ = 0; /*reserved*/ - - if (oh->mesg[i].native) { - assert(oh->mesg[i].type->encode); - - /* allocate file space for chunks that have none yet */ - if (H5O_CONT_ID == oh->mesg[i].type->id && - !H5F_addr_defined(((H5O_cont_t *)(oh->mesg[i].native)) - ->addr)) { - cont = (H5O_cont_t *) (oh->mesg[i].native); - assert(cont->chunkno >= 0); - assert(cont->chunkno < oh->nchunks); - assert(!H5F_addr_defined(oh->chunk[cont->chunkno].addr)); - cont->size = oh->chunk[cont->chunkno].size; - if (HADDR_UNDEF==(cont->addr=H5MF_alloc(f, - H5FD_MEM_OHDR, - cont->size))) { - HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "unable to allocate space for " - "object header data"); - } - oh->chunk[cont->chunkno].addr = cont->addr; - } - - /* - * Encode the message. If the message is shared then we - * encode a Shared Object message instead of the object - * which is being shared. - */ - assert(oh->mesg[i].raw >= - oh->chunk[oh->mesg[i].chunkno].image); - assert (oh->mesg[i].raw_size == - H5O_ALIGN (oh->mesg[i].raw_size)); - assert(oh->mesg[i].raw + oh->mesg[i].raw_size <= - oh->chunk[oh->mesg[i].chunkno].image + - oh->chunk[oh->mesg[i].chunkno].size); - if (oh->mesg[i].flags & H5O_FLAG_SHARED) { - encode = H5O_SHARED->encode; - } else { - encode = oh->mesg[i].type->encode; - } - if ((encode)(f, oh->mesg[i].raw, oh->mesg[i].native)<0) { - HRETURN_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, - "unable to encode object header message"); - } - } - oh->mesg[i].dirty = FALSE; - oh->chunk[oh->mesg[i].chunkno].dirty = TRUE; + p = oh->mesg[i].raw - H5O_SIZEOF_MSGHDR(f); + + id = oh->mesg[i].type->id; + UINT16ENCODE(p, id); + assert (oh->mesg[i].raw_size<65536); + UINT16ENCODE(p, oh->mesg[i].raw_size); + *p++ = oh->mesg[i].flags; + *p++ = 0; /*reserved*/ + *p++ = 0; /*reserved*/ + *p++ = 0; /*reserved*/ + + if (oh->mesg[i].native) { + assert(oh->mesg[i].type->encode); + + /* allocate file space for chunks that have none yet */ + if (H5O_CONT_ID == oh->mesg[i].type->id && + !H5F_addr_defined(((H5O_cont_t *)(oh->mesg[i].native))->addr)) { + cont = (H5O_cont_t *) (oh->mesg[i].native); + assert(cont->chunkno >= 0); + assert(cont->chunkno < oh->nchunks); + assert(!H5F_addr_defined(oh->chunk[cont->chunkno].addr)); + cont->size = oh->chunk[cont->chunkno].size; + if (HADDR_UNDEF==(cont->addr=H5MF_alloc(f, + H5FD_MEM_OHDR, (hsize_t)cont->size))) { + HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "unable to allocate space for object header data"); + } + oh->chunk[cont->chunkno].addr = cont->addr; + } + + /* + * Encode the message. If the message is shared then we + * encode a Shared Object message instead of the object + * which is being shared. + */ + assert(oh->mesg[i].raw >= + oh->chunk[oh->mesg[i].chunkno].image); + assert (oh->mesg[i].raw_size == + H5O_ALIGN (oh->mesg[i].raw_size)); + assert(oh->mesg[i].raw + oh->mesg[i].raw_size <= + oh->chunk[oh->mesg[i].chunkno].image + + oh->chunk[oh->mesg[i].chunkno].size); + if (oh->mesg[i].flags & H5O_FLAG_SHARED) { + encode = H5O_SHARED->encode; + } else { + encode = oh->mesg[i].type->encode; + } + if ((encode)(f, oh->mesg[i].raw, oh->mesg[i].native)<0) { + HRETURN_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, + "unable to encode object header message"); + } + } + oh->mesg[i].dirty = FALSE; + oh->chunk[oh->mesg[i].chunkno].dirty = TRUE; } } @@ -661,7 +659,7 @@ H5O_flush(H5F_t *f, hbool_t destroy, haddr_t addr, H5O_t *oh) assert(H5F_addr_defined(oh->chunk[i].addr)); if(i==0 && combine) { /* Allocate space for the combined prefix and first chunk */ - if((p=H5FL_BLK_ALLOC(chunk_image,H5O_SIZEOF_HDR(f)+oh->chunk[i].size,0))==NULL) + if((p=H5FL_BLK_ALLOC(chunk_image,(hsize_t)(H5O_SIZEOF_HDR(f)+oh->chunk[i].size),0))==NULL) HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); /* Copy in the prefix */ @@ -1682,7 +1680,7 @@ H5O_alloc_extend_chunk(H5O_t *oh, intn chunkno, size_t size) /* Be careful not to indroduce garbage */ oh->chunk[chunkno].image = H5FL_BLK_REALLOC(chunk_image,old_addr, - (oh->chunk[chunkno].size + delta)); + (hsize_t)(oh->chunk[chunkno].size + delta)); if (NULL==oh->chunk[chunkno].image) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); @@ -1706,14 +1704,14 @@ H5O_alloc_extend_chunk(H5O_t *oh, intn chunkno, size_t size) /* create a new null message */ if (oh->nmesgs >= oh->alloc_nmesgs) { - size_t na = oh->alloc_nmesgs + H5O_NMESGS; - H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na); - if (NULL==x) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed"); - } - oh->alloc_nmesgs = (intn)na; - oh->mesg = x; + hsize_t na = oh->alloc_nmesgs + H5O_NMESGS; + H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na); + if (NULL==x) { + HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed"); + } + oh->alloc_nmesgs = (intn)na; + oh->mesg = x; } delta = MAX(H5O_MIN_SIZE, aligned_size+H5O_SIZEOF_MSGHDR(f)); delta = H5O_ALIGN(delta); @@ -1731,7 +1729,7 @@ H5O_alloc_extend_chunk(H5O_t *oh, intn chunkno, size_t size) old_size = oh->chunk[chunkno].size; oh->chunk[chunkno].size += delta; oh->chunk[chunkno].image = H5FL_BLK_REALLOC(chunk_image,old_addr, - oh->chunk[chunkno].size); + (hsize_t)oh->chunk[chunkno].size); if (NULL==oh->chunk[chunkno].image) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); @@ -1845,20 +1843,20 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size) * Create the new chunk without giving it a file address. */ if (oh->nchunks >= oh->alloc_nchunks) { - size_t na = oh->alloc_nchunks + H5O_NCHUNKS; - H5O_chunk_t *x = H5FL_ARR_REALLOC (H5O_chunk_t, oh->chunk, na); - if (!x) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed"); - } - oh->alloc_nchunks = (intn)na; - oh->chunk = x; + hsize_t na = oh->alloc_nchunks + H5O_NCHUNKS; + H5O_chunk_t *x = H5FL_ARR_REALLOC (H5O_chunk_t, oh->chunk, na); + if (!x) { + HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed"); + } + oh->alloc_nchunks = (intn)na; + oh->chunk = x; } chunkno = oh->nchunks++; oh->chunk[chunkno].dirty = TRUE; oh->chunk[chunkno].addr = HADDR_UNDEF; oh->chunk[chunkno].size = size; - if (NULL==(oh->chunk[chunkno].image = p = H5FL_BLK_ALLOC(chunk_image,size,1))) { + if (NULL==(oh->chunk[chunkno].image = p = H5FL_BLK_ALLOC(chunk_image,(hsize_t)size,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } @@ -1869,12 +1867,12 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size) */ if (oh->nmesgs + 3 > oh->alloc_nmesgs) { int old_alloc=oh->alloc_nmesgs; - size_t na = oh->alloc_nmesgs + MAX (H5O_NMESGS, 3); - H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na); - if (!x) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed"); - } + hsize_t na = oh->alloc_nmesgs + MAX (H5O_NMESGS, 3); + H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na); + if (!x) { + HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed"); + } oh->alloc_nmesgs = (intn)na; oh->mesg = x; @@ -2026,10 +2024,10 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size) if (oh->nmesgs >= oh->alloc_nmesgs) { int old_alloc=oh->alloc_nmesgs; - size_t na = oh->alloc_nmesgs + H5O_NMESGS; + hsize_t na = oh->alloc_nmesgs + H5O_NMESGS; H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na); if (!x) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, + HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } oh->alloc_nmesgs = (intn)na; diff --git a/src/H5Ofill.c b/src/H5Ofill.c index 7178575..251801c 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -361,7 +361,7 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type) } /* Do the conversion */ - if (H5T_convert(tpath, src_id, dst_id, 1, 0, 0, buf, bkg, H5P_DEFAULT)<0) { + if (H5T_convert(tpath, src_id, dst_id, (hsize_t)1, 0, 0, buf, bkg, H5P_DEFAULT)<0) { HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed"); } diff --git a/src/H5Olayout.c b/src/H5Olayout.c index b494ea1..83d7a6b 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -73,7 +73,8 @@ static void * H5O_layout_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5O_layout_t *mesg = NULL; - intn i, version; + intn version; + uintn u; FUNC_ENTER(H5O_layout_decode, NULL); @@ -84,14 +85,14 @@ H5O_layout_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh) /* decode */ if (NULL==(mesg = H5FL_ALLOC(H5O_layout_t,1))) { - HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, + HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } /* Version */ version = *p++; if (version!=H5O_LAYOUT_VERSION) { - HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for layout message"); } @@ -114,8 +115,8 @@ H5O_layout_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh) H5F_addr_decode(f, &p, &(mesg->addr)); /* Read the size */ - for (i = 0; i < mesg->ndims; i++) { - UINT32DECODE(p, mesg->dim[i]); + for (u = 0; u < mesg->ndims; u++) { + UINT32DECODE(p, mesg->dim[u]); } FUNC_LEAVE(mesg); @@ -141,7 +142,7 @@ static herr_t H5O_layout_encode(H5F_t *f, uint8_t *p, const void *_mesg) { const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; - int i; + uintn u; FUNC_ENTER(H5O_layout_encode, FAIL); @@ -161,14 +162,15 @@ H5O_layout_encode(H5F_t *f, uint8_t *p, const void *_mesg) *p++ = mesg->type; /* reserved bytes should be zero */ - for (i=0; i<5; i++) *p++ = 0; + for (u=0; u<5; u++) + *p++ = 0; /* data or B-tree address */ H5F_addr_encode(f, &p, mesg->addr); /* dimension size */ - for (i = 0; i < mesg->ndims; i++) { - UINT32ENCODE(p, mesg->dim[i]); + for (u = 0; u < mesg->ndims; u++) { + UINT32ENCODE(p, mesg->dim[u]); } FUNC_LEAVE(SUCCEED); @@ -299,7 +301,7 @@ H5O_layout_debug(H5F_t UNUSED *f, const void *_mesg, FILE * stream, intn indent, intn fwidth) { const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg; - intn i; + uintn u; FUNC_ENTER(H5O_layout_debug, FAIL); @@ -320,9 +322,9 @@ H5O_layout_debug(H5F_t UNUSED *f, const void *_mesg, FILE * stream, /* Size */ HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Size:"); - for (i = 0; i < mesg->ndims; i++) { - HDfprintf(stream, "%s%lu", i ? ", " : "", - (unsigned long) (mesg->dim[i])); + for (u = 0; u < mesg->ndims; u++) { + HDfprintf(stream, "%s%lu", u ? ", " : "", + (unsigned long) (mesg->dim[u])); } HDfprintf(stream, "}\n"); diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index b7b85a4..c0cc93c 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -78,7 +78,7 @@ typedef struct H5O_class_t { herr_t (*reset)(void *); /*free nested data structs */ herr_t (*free)(void *); /*free main data struct */ herr_t (*get_share)(H5F_t*, const void*, struct H5O_shared_t*); - herr_t (*set_share)(H5F_t*, void*, const struct H5O_shared_t*); + herr_t (*set_share)(H5F_t*, void*, const struct H5O_shared_t*); herr_t (*debug)(H5F_t*, const void*, FILE*, intn, intn); } H5O_class_t; @@ -106,11 +106,11 @@ typedef struct H5O_t { intn version; /*version number */ intn nlink; /*link count */ intn nmesgs; /*number of messages */ - intn alloc_nmesgs; /*number of message slots */ - H5O_mesg_t *mesg; /*array of messages */ + intn alloc_nmesgs; /*number of message slots */ + H5O_mesg_t *mesg; /*array of messages */ intn nchunks; /*number of chunks */ - intn alloc_nchunks; /*chunks allocated */ - H5O_chunk_t *chunk; /*array of chunks */ + intn alloc_nchunks; /*chunks allocated */ + H5O_chunk_t *chunk; /*array of chunks */ } H5O_t; /* @@ -157,7 +157,7 @@ typedef struct H5O_fill_t { __DLLVAR__ const H5O_class_t H5O_EFL[1];/*external file list class */ typedef struct H5O_efl_entry_t { - size_t name_offset; /*offset of name within heap */ + size_t name_offset; /*offset of name within heap */ char *name; /*malloc'd name */ off_t offset; /*offset of data within file */ hsize_t size; /*size allocated within file */ @@ -167,7 +167,7 @@ typedef struct H5O_efl_t { haddr_t heap_addr; /*address of name heap */ intn nalloc; /*number of slots allocated */ intn nused; /*number of slots used */ - H5O_efl_entry_t *slot; /*array of external file entries */ + H5O_efl_entry_t *slot; /*array of external file entries */ } H5O_efl_t; /* @@ -180,7 +180,7 @@ __DLLVAR__ const H5O_class_t H5O_LAYOUT[1]; typedef struct H5O_layout_t { int type; /*type of layout, H5D_layout_t */ haddr_t addr; /*file address of data or B-tree */ - intn ndims; /*num dimensions in stored data */ + uintn ndims; /*num dimensions in stored data */ hsize_t dim[H5O_LAYOUT_NDIMS]; /*size of data or chunk */ } H5O_layout_t; @@ -194,11 +194,11 @@ typedef struct H5O_pline_t { size_t nfilters; /*num filters defined */ size_t nalloc; /*num elements in `filter' array */ struct { - H5Z_filter_t id; /*filter identification number */ - uintn flags; /*defn and invocation flags */ - char *name; /*optional filter name */ - size_t cd_nelmts; /*number of elements in cd_values[] */ - uintn *cd_values; /*client data values */ + H5Z_filter_t id; /*filter identification number */ + uintn flags; /*defn and invocation flags */ + char *name; /*optional filter name */ + size_t cd_nelmts; /*number of elements in cd_values[] */ + uintn *cd_values; /*client data values */ } *filter; /*array of filters */ } H5O_pline_t; diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index ae156c4..a2829ef 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -97,7 +97,7 @@ H5O_sdspace_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5S_simple_t *sdim = NULL;/* New simple dimensionality structure */ void *ret_value = NULL; - intn u; /* local counting variable */ + uintn u; /* local counting variable */ uintn flags, version; FUNC_ENTER(H5O_sdspace_decode, NULL); @@ -109,47 +109,47 @@ H5O_sdspace_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh) /* decode */ if ((sdim = H5FL_ALLOC(H5S_simple_t,1)) != NULL) { - version = *p++; - if (version!=H5O_SDSPACE_VERSION) { - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, - "wrong version number in data space message"); - } - sdim->rank = *p++; - if (sdim->rank>H5S_MAX_RANK) { - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, - "simple data space dimensionality is too large"); - } - flags = *p++; - p += 5; /*reserved*/ - - if (sdim->rank > 0) { - if (NULL==(sdim->size=H5FL_ARR_ALLOC(hsize_t,sdim->rank,0))) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); - } - for (u = 0; u < sdim->rank; u++) { - H5F_DECODE_LENGTH (f, p, sdim->size[u]); - } - if (flags & H5S_VALID_MAX) { - if (NULL==(sdim->max=H5FL_ARR_ALLOC(hsize_t,sdim->rank,0))) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); - } - for (u = 0; u < sdim->rank; u++) { - H5F_DECODE_LENGTH (f, p, sdim->max[u]); - } - } + version = *p++; + if (version!=H5O_SDSPACE_VERSION) { + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, + "wrong version number in data space message"); + } + sdim->rank = *p++; + if (sdim->rank>H5S_MAX_RANK) { + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, + "simple data space dimensionality is too large"); + } + flags = *p++; + p += 5; /*reserved*/ + + if (sdim->rank > 0) { + if (NULL==(sdim->size=H5FL_ARR_ALLOC(hsize_t,(hsize_t)sdim->rank,0))) { + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed"); + } + for (u = 0; u < sdim->rank; u++) { + H5F_DECODE_LENGTH (f, p, sdim->size[u]); + } + if (flags & H5S_VALID_MAX) { + if (NULL==(sdim->max=H5FL_ARR_ALLOC(hsize_t,(hsize_t)sdim->rank,0))) { + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed"); + } + for (u = 0; u < sdim->rank; u++) { + H5F_DECODE_LENGTH (f, p, sdim->max[u]); + } + } #ifdef LATER - if (flags & H5S_VALID_PERM) { - if (NULL==(sdim->perm=H5FL_ARR_ALLOC(hsize_t,sdim->rank,0))) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, - "memory allocation failed"); - } - for (u = 0; u < sdim->rank; u++) - UINT32DECODE(p, sdim->perm[u]); - } + if (flags & H5S_VALID_PERM) { + if (NULL==(sdim->perm=H5FL_ARR_ALLOC(hsize_t,sdim->rank,0))) { + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, + "memory allocation failed"); + } + for (u = 0; u < sdim->rank; u++) + UINT32DECODE(p, sdim->perm[u]); + } #endif - } + } } ret_value = (void*)sdim; /*success*/ @@ -187,7 +187,7 @@ static herr_t H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *mesg) { const H5S_simple_t *sdim = (const H5S_simple_t *) mesg; - intn u; /* Local counting variable */ + uintn u; /* Local counting variable */ uintn flags = 0; FUNC_ENTER(H5O_sdspace_encode, FAIL); @@ -198,9 +198,11 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *mesg) assert(sdim); /* set flags */ - if (sdim->max) flags |= H5S_VALID_MAX; + if (sdim->max) + flags |= H5S_VALID_MAX; #ifdef LATER - if (sdim->perm) flags |= H5S_VALID_PERM; + if (sdim->perm) + flags |= H5S_VALID_PERM; #endif /* encode */ @@ -214,19 +216,17 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *mesg) *p++ = 0; /*reserved*/ if (sdim->rank > 0) { - for (u = 0; u < sdim->rank; u++) { - H5F_ENCODE_LENGTH (f, p, sdim->size[u]); - } - if (flags & H5S_VALID_MAX) { - for (u = 0; u < sdim->rank; u++) { - H5F_ENCODE_LENGTH (f, p, sdim->max[u]); - } - } + for (u = 0; u < sdim->rank; u++) + H5F_ENCODE_LENGTH (f, p, sdim->size[u]); + if (flags & H5S_VALID_MAX) { + for (u = 0; u < sdim->rank; u++) + H5F_ENCODE_LENGTH (f, p, sdim->max[u]); + } #ifdef LATER - if (flags & H5S_VALID_PERM) { - for (u = 0; u < sdim->rank; u++) - UINT32ENCODE(p, sdim->perm[u]); - } + if (flags & H5S_VALID_PERM) { + for (u = 0; u < sdim->rank; u++) + UINT32ENCODE(p, sdim->perm[u]); + } #endif } FUNC_LEAVE(SUCCEED); @@ -266,14 +266,14 @@ H5O_sdspace_copy(const void *mesg, void *dest) HDmemcpy(dst, src, sizeof(H5S_simple_t)); if (src->size) { - if (NULL==(dst->size = H5FL_ARR_ALLOC(hsize_t,src->rank,0))) { + if (NULL==(dst->size = H5FL_ARR_ALLOC(hsize_t,(hsize_t)src->rank,0))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } HDmemcpy (dst->size, src->size, src->rank*sizeof(src->size[0])); } if (src->max) { - if (NULL==(dst->max=H5FL_ARR_ALLOC(hsize_t,src->rank,0))) { + if (NULL==(dst->max=H5FL_ARR_ALLOC(hsize_t,(hsize_t)src->rank,0))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } @@ -417,7 +417,7 @@ H5O_sdspace_debug(H5F_t UNUSED *f, const void *mesg, FILE * stream, intn indent, intn fwidth) { const H5S_simple_t *sdim = (const H5S_simple_t *) mesg; - intn u; /* local counting variable */ + uintn u; /* local counting variable */ FUNC_ENTER(H5O_sdspace_debug, FAIL); @@ -434,32 +434,32 @@ H5O_sdspace_debug(H5F_t UNUSED *f, const void *mesg, HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:"); for (u = 0; u < sdim->rank; u++) { - HDfprintf (stream, "%s%Hu", u?", ":"", sdim->size[u]); + HDfprintf (stream, "%s%Hu", u?", ":"", sdim->size[u]); } HDfprintf (stream, "}\n"); HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Dim Max:"); if (sdim->max) { - HDfprintf (stream, "{"); - for (u = 0; u < sdim->rank; u++) { - if (H5S_UNLIMITED==sdim->max[u]) { - HDfprintf (stream, "%sINF", u?", ":""); - } else { - HDfprintf (stream, "%s%Hu", u?", ":"", sdim->max[u]); - } - } - HDfprintf (stream, "}\n"); + HDfprintf (stream, "{"); + for (u = 0; u < sdim->rank; u++) { + if (H5S_UNLIMITED==sdim->max[u]) { + HDfprintf (stream, "%sINF", u?", ":""); + } else { + HDfprintf (stream, "%s%Hu", u?", ":"", sdim->max[u]); + } + } + HDfprintf (stream, "}\n"); } else { - HDfprintf (stream, "CONSTANT\n"); + HDfprintf (stream, "CONSTANT\n"); } #ifdef LATER if (sdim->perm) { - HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Perm:"); - for (u = 0; u < sdim->rank; u++) { - HDfprintf (stream, "%s%lu", u?", ":"", - (unsigned long) (sdim->perm[u])); - } + HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Perm:"); + for (u = 0; u < sdim->rank; u++) { + HDfprintf (stream, "%s%lu", u?", ":"", + (unsigned long) (sdim->perm[u])); + } } #endif @@ -2805,7 +2805,7 @@ H5Pget_cache(hid_t plist_id, int *mdc_nelmts, *------------------------------------------------------------------------- */ herr_t -H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, void *bkg) +H5Pset_buffer(hid_t plist_id, hsize_t size, void *tconv, void *bkg) { H5D_xfer_t *plist = NULL; @@ -2848,7 +2848,7 @@ H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, void *bkg) * *------------------------------------------------------------------------- */ -size_t +hsize_t H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/) { H5D_xfer_t *plist = NULL; @@ -3093,7 +3093,7 @@ H5Pset_filter(hid_t plist_id, H5Z_filter_t filter, unsigned int flags, HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identifier"); } - if (flags & ~H5Z_FLAG_DEFMASK) { + if (flags & ~((unsigned)H5Z_FLAG_DEFMASK)) { HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags"); } @@ -3564,7 +3564,7 @@ H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/) HDmemcpy(buf, plist->fill.buf, H5T_get_size(plist->fill.type)); /* Do the conversion */ - if (H5T_convert(tpath, src_id, type_id, 1, 0, 0, buf, bkg, H5P_DEFAULT)<0) { + if (H5T_convert(tpath, src_id, type_id, (hsize_t)1, 0, 0, buf, bkg, H5P_DEFAULT)<0) { HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed"); } @@ -4699,7 +4699,7 @@ done: hid_t H5Pcreate_list(hid_t cls_id) { H5P_genclass_t *pclass; /* Property list class to modify */ - H5P_genplist_t *plist; /* Property list created */ + H5P_genplist_t *plist=NULL; /* Property list created */ hid_t plist_id=FAIL; /* Property list ID */ hid_t ret_value=FAIL; /* return value */ @@ -4871,7 +4871,7 @@ static herr_t H5P_register(H5P_genclass_t *pclass, const char *name, size_t size */ if(pclass->plists>0 || pclass->classes>0) { if((new_class=H5P_create_class(pclass->parent,pclass->name,pclass->hashsize, - pclass->internal,pclass->create_func,pclass->create_data, + (uintn)pclass->internal,pclass->create_func,pclass->create_data, pclass->close_func,pclass->close_data))==NULL) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy class"); @@ -7255,7 +7255,7 @@ done: PURPOSE Internal routine to close a property list class. USAGE - herr_t H5P_create_class(class) + herr_t H5P_close_class(class) H5P_genclass_t *class; IN: Property list class to close RETURNS Returns non-negative on success, negative on failure. diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 82d96fc..e03d1bf 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -172,9 +172,9 @@ __DLL__ herr_t H5Pget_xfer(hid_t plist_id, H5D_transfer_t *data_xfer_mode); __DLL__ hid_t H5Pget_driver(hid_t plist_id); #endif /* WANT_H5_V1_2_COMPAT */ __DLL__ void *H5Pget_driver_info(hid_t plist_id); -__DLL__ herr_t H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, +__DLL__ herr_t H5Pset_buffer(hid_t plist_id, hsize_t size, void *tconv, void *bkg); -__DLL__ size_t H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, +__DLL__ hsize_t H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/); __DLL__ herr_t H5Pset_preserve(hid_t plist_id, hbool_t status); __DLL__ int H5Pget_preserve(hid_t plist_id); @@ -204,7 +204,8 @@ H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type, buf_size+=sizeof(haddr_t); /* Allocate the space to store the serialized information */ - if (NULL==(buf = H5MM_malloc(buf_size))) { + assert(buf_size==(hssize_t)((size_t)buf_size)); /*check for overflow*/ + if (NULL==(buf = H5MM_malloc((size_t)buf_size))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } @@ -220,7 +221,8 @@ H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type, "Unable to serialize selection"); /* Save the serialized buffer for later */ - if(H5HG_insert(loc->file,buf_size,buf,&hobjid)<0) + assert(buf_size==(hssize_t)((size_t)buf_size)); /*check for overflow*/ + if(H5HG_insert(loc->file,(size_t)buf_size,buf,&hobjid)<0) HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to serialize selection"); @@ -730,7 +730,8 @@ H5RA_write(H5RA_t *ra, hssize_t start_row, hsize_t nrows, H5T_t *type, HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, "unable to set meta data selection"); } - if (NULL==(meta=H5MM_malloc(nrows*sizeof(H5RA_meta_t)))) { + assert((nrows*sizeof(H5RA_meta_t))==(hsize_t)((size_t)(nrows*sizeof(H5RA_meta_t)))); /*check for overflow*/ + if (NULL==(meta=H5MM_malloc((size_t)(nrows*sizeof(H5RA_meta_t))))) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for meta data"); } @@ -739,8 +740,9 @@ H5RA_write(H5RA_t *ra, hssize_t start_row, hsize_t nrows, H5T_t *type, HGOTO_ERROR(H5E_RAGGED, H5E_READERROR, FAIL, "unable to read meta data"); } + assert(((nrows-meta_read_size)*sizeof(H5RA_meta_t))==(hsize_t)((size_t)((nrows-meta_read_size)*sizeof(H5RA_meta_t)))); /*check for overflow*/ HDmemset(meta+meta_read_size, 0, - (nrows-meta_read_size)*sizeof(H5RA_meta_t)); + (size_t)((nrows-meta_read_size)*sizeof(H5RA_meta_t))); /* Write the part of the data that will fit in the raw dataset */ if (NULL==(rf_space=H5D_get_space(ra->raw)) || @@ -748,15 +750,17 @@ H5RA_write(H5RA_t *ra, hssize_t start_row, hsize_t nrows, H5T_t *type, HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, "unable to determine current raw data extents"); } - if (NULL==(raw_buf=H5MM_malloc(nrows*raw_cur_size[1]*type_size))) { + assert((nrows*raw_cur_size[1]*type_size)==(hsize_t)((size_t)(nrows*raw_cur_size[1]*type_size))); /*check for overflow*/ + if (NULL==(raw_buf=H5MM_malloc((size_t)(nrows*raw_cur_size[1]*type_size)))) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate buffer for raw data"); } for (i=0; i<nrows; i++) { size_t nbytes = MIN(size[i], raw_cur_size[1])*type_size; HDmemcpy(raw_buf+i*raw_cur_size[1]*type_size, buf[i], nbytes); + assert((raw_cur_size[1]*type_size-nbytes)==(hsize_t)((size_t)(raw_cur_size[1]*type_size-nbytes))); /*check for overflow*/ HDmemset(raw_buf+i*raw_cur_size[1]*type_size+nbytes, 0, - raw_cur_size[1]*type_size-nbytes); + (size_t)(raw_cur_size[1]*type_size-nbytes)); } if ((hsize_t)start_row+nrows>raw_cur_size[0]) { raw_cur_size[0] = (hsize_t)start_row + nrows; @@ -1105,7 +1109,8 @@ H5RA_read(H5RA_t *ra, hssize_t start_row, hsize_t nrows, H5T_t *type, * this because if we return failure we want `buf' to have the original * values. */ - if (NULL==(buf_out=H5MM_calloc(nrows*sizeof(void*)))) { + assert((nrows*sizeof(void*))==(hsize_t)((size_t)(nrows*sizeof(void*)))); /*check for overflow*/ + if (NULL==(buf_out=H5MM_calloc((size_t)(nrows*sizeof(void*))))) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for BUF output values"); } @@ -1132,7 +1137,8 @@ H5RA_read(H5RA_t *ra, hssize_t start_row, hsize_t nrows, H5T_t *type, HGOTO_ERROR(H5E_RAGGED, H5E_CANTINIT, FAIL, "unable to set raw dataset selection"); } - if (NULL==(raw_buf=H5MM_malloc(nrows*raw_read_size[1]*type_size))) { + assert((nrows*raw_read_size[1]*type_size)==(hsize_t)((size_t)(nrows*raw_read_size[1]*type_size))); /*check for overflow*/ + if (NULL==(raw_buf=H5MM_malloc((size_t)(nrows*raw_read_size[1]*type_size)))) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw dataset"); } @@ -1141,11 +1147,13 @@ H5RA_read(H5RA_t *ra, hssize_t start_row, hsize_t nrows, H5T_t *type, HGOTO_ERROR(H5E_RAGGED, H5E_READERROR, FAIL, "unable to read raw dataset"); } + assert(((nrows-raw_read_size[0])*raw_read_size[1]*type_size)==(hsize_t)((size_t)((nrows-raw_read_size[0])*raw_read_size[1]*type_size))); /*check for overflow*/ HDmemset(raw_buf+raw_read_size[0]*raw_read_size[1]*type_size, 0, - (nrows-raw_read_size[0])*raw_read_size[1]*type_size); + (size_t)((nrows-raw_read_size[0])*raw_read_size[1]*type_size)); /* Get the meta data */ - if (NULL==(meta=H5MM_malloc(nrows*sizeof(H5RA_meta_t)))) { + assert((nrows*sizeof(H5RA_meta_t))==(hsize_t)((size_t)(nrows*sizeof(H5RA_meta_t)))); /*check for overflow*/ + if (NULL==(meta=H5MM_malloc((size_t)(nrows*sizeof(H5RA_meta_t))))) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for meta data"); } @@ -1171,8 +1179,9 @@ H5RA_read(H5RA_t *ra, hssize_t start_row, hsize_t nrows, H5T_t *type, HGOTO_ERROR(H5E_RAGGED, H5E_READERROR, FAIL, "unable to read meta data"); } + assert(((nrows-meta_read_size)*sizeof(H5RA_meta_t))==(hsize_t)((size_t)((nrows-meta_read_size)*sizeof(H5RA_meta_t)))); /*check for overflow*/ HDmemset(meta+meta_read_size, 0, - (nrows-meta_read_size)*sizeof(H5RA_meta_t)); + (size_t)((nrows-meta_read_size)*sizeof(H5RA_meta_t))); /* Copy data into output buffers */ for (i=0; i<nrows; i++) { @@ -1182,8 +1191,9 @@ H5RA_read(H5RA_t *ra, hssize_t start_row, hsize_t nrows, H5T_t *type, * size and request the entire row. */ if (NULL==(buf_out[i]=buf[i])) { + assert((meta[i].nelmts*type_size)==(hsize_t)((size_t)(meta[i].nelmts*type_size))); /*check for overflow*/ if (meta[i].nelmts>0 && - NULL==(buf_out[i]=H5MM_malloc(meta[i].nelmts*type_size))) { + NULL==(buf_out[i]=H5MM_malloc((size_t)(meta[i].nelmts*type_size)))) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for result"); } @@ -654,7 +654,7 @@ H5Sextent_copy(hid_t dst_id,hid_t src_id) herr_t H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src) { - int i; + uint u; FUNC_ENTER(H5S_extent_copy, FAIL); @@ -668,15 +668,15 @@ H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src) case H5S_SIMPLE: if (src->u.simple.size) { - dst->u.simple.size = H5FL_ARR_ALLOC(hsize_t,src->u.simple.rank,0); - for (i = 0; i < src->u.simple.rank; i++) { - dst->u.simple.size[i] = src->u.simple.size[i]; + dst->u.simple.size = H5FL_ARR_ALLOC(hsize_t,(hsize_t)src->u.simple.rank,0); + for (u = 0; u < src->u.simple.rank; u++) { + dst->u.simple.size[u] = src->u.simple.size[u]; } } if (src->u.simple.max) { - dst->u.simple.max = H5FL_ARR_ALLOC(hsize_t,src->u.simple.rank,0); - for (i = 0; i < src->u.simple.rank; i++) { - dst->u.simple.max[i] = src->u.simple.max[i]; + dst->u.simple.max = H5FL_ARR_ALLOC(hsize_t,(hsize_t)src->u.simple.rank,0); + for (u = 0; u < src->u.simple.rank; u++) { + dst->u.simple.max[u] = src->u.simple.max[u]; } } break; @@ -754,8 +754,8 @@ H5S_copy(const H5S_t *src) hssize_t H5S_get_simple_extent_npoints(const H5S_t *ds) { - hssize_t ret_value = -1; - intn i; + hssize_t ret_value = -1; + uintn u; FUNC_ENTER(H5S_get_simple_extent_npoints, -1); @@ -768,8 +768,8 @@ H5S_get_simple_extent_npoints(const H5S_t *ds) break; case H5S_SIMPLE: - for (ret_value=1, i=0; i<ds->extent.u.simple.rank; i++) { - ret_value *= ds->extent.u.simple.size[i]; + for (ret_value=1, u=0; u<ds->extent.u.simple.rank; u++) { + ret_value *= ds->extent.u.simple.size[u]; } break; @@ -846,8 +846,8 @@ H5Sget_simple_extent_npoints(hid_t space_id) hsize_t H5S_get_npoints_max(const H5S_t *ds) { - hsize_t ret_value = 0; - intn i; + hsize_t ret_value = 0; + uintn u; FUNC_ENTER(H5S_get_npoints_max, 0); @@ -861,17 +861,17 @@ H5S_get_npoints_max(const H5S_t *ds) case H5S_SIMPLE: if (ds->extent.u.simple.max) { - for (ret_value=1, i=0; i<ds->extent.u.simple.rank; i++) { - if (H5S_UNLIMITED==ds->extent.u.simple.max[i]) { + for (ret_value=1, u=0; u<ds->extent.u.simple.rank; u++) { + if (H5S_UNLIMITED==ds->extent.u.simple.max[u]) { ret_value = HSIZET_MAX; break; } else { - ret_value *= ds->extent.u.simple.max[i]; + ret_value *= ds->extent.u.simple.max[u]; } } } else { - for (ret_value=1, i=0; i<ds->extent.u.simple.rank; i++) { - ret_value *= ds->extent.u.simple.size[i]; + for (ret_value=1, u=0; u<ds->extent.u.simple.rank; u++) { + ret_value *= ds->extent.u.simple.size[u]; } } break; @@ -1164,7 +1164,7 @@ H5S_read(H5G_entry_t *ent) ds->select.type=H5S_SEL_ALL; /* Allocate space for the offset and set it to zeros */ - if (NULL==(ds->select.offset = H5FL_ARR_ALLOC(hssize_t,ds->extent.u.simple.rank,1))) { + if (NULL==(ds->select.offset = H5FL_ARR_ALLOC(hssize_t,(hsize_t)ds->extent.u.simple.rank,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } @@ -1193,7 +1193,7 @@ H5S_read(H5G_entry_t *ent) intn H5S_cmp(const H5S_t *ds1, const H5S_t *ds2) { - intn i; + uintn u; FUNC_ENTER(H5S_cmp, 0); @@ -1214,22 +1214,22 @@ H5S_cmp(const H5S_t *ds1, const H5S_t *ds2) if (ds1->extent.u.simple.rank > ds2->extent.u.simple.rank) HRETURN(1); - for (i = 0; i < ds1->extent.u.simple.rank; i++) { - if (ds1->extent.u.simple.size[i] < ds2->extent.u.simple.size[i]) + for (u = 0; u < ds1->extent.u.simple.rank; u++) { + if (ds1->extent.u.simple.size[u] < ds2->extent.u.simple.size[u]) HRETURN(-1); - if (ds1->extent.u.simple.size[i] > ds2->extent.u.simple.size[i]) + if (ds1->extent.u.simple.size[u] > ds2->extent.u.simple.size[u]) HRETURN(1); } /* don't compare max dimensions */ #ifdef LATER - for (i = 0; i < ds1->extent.u.simple.rank; i++) { - if ((ds1->extent.u.simple.perm ? ds1->extent.u.simple.perm[i] : i) < - (ds2->extent.u.simple.perm ? ds2->extent.u.simple.perm[i] : i)) + for (u = 0; u < ds1->extent.u.simple.rank; u++) { + if ((ds1->extent.u.simple.perm ? ds1->extent.u.simple.perm[u] : u) < + (ds2->extent.u.simple.perm ? ds2->extent.u.simple.perm[u] : i)) HRETURN(-1); - if ((ds1->extent.u.simple.perm ? ds2->extent.u.simple.perm[i] : i) > - (ds2->extent.u.simple.perm ? ds2->extent.u.simple.perm[i] : i)) + if ((ds1->extent.u.simple.perm ? ds2->extent.u.simple.perm[u] : u) > + (ds2->extent.u.simple.perm ? ds2->extent.u.simple.perm[u] : i)) HRETURN(1); } #endif @@ -1415,7 +1415,7 @@ H5S_set_extent_simple (H5S_t *space, int rank, const hsize_t *dims, space->select.offset=H5FL_ARR_FREE(hssize_t,space->select.offset); /* Allocate space for the offset and set it to zeros */ - if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,rank,1))) { + if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,(hsize_t)rank,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } @@ -1450,12 +1450,12 @@ H5S_set_extent_simple (H5S_t *space, int rank, const hsize_t *dims, /* Set the rank and copy the dims */ space->extent.u.simple.rank = rank; - space->extent.u.simple.size = H5FL_ARR_ALLOC(hsize_t,rank,0); + space->extent.u.simple.size = H5FL_ARR_ALLOC(hsize_t,(hsize_t)rank,0); HDmemcpy(space->extent.u.simple.size, dims, sizeof(hsize_t) * rank); /* Copy the maximum dimensions if specified */ if(max!=NULL) { - space->extent.u.simple.max = H5FL_ARR_ALLOC(hsize_t,rank,0); + space->extent.u.simple.max = H5FL_ARR_ALLOC(hsize_t,(hsize_t)rank,0); HDmemcpy(space->extent.u.simple.max, max, sizeof(hsize_t) * rank); } /* end if */ } @@ -1538,8 +1538,10 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space) H5S_conv_g[i]->read = H5S_all_read; H5S_conv_g[i]->write = H5S_all_write; } - else - H5S_conv_g[i]->read = H5S_conv_g[i]->write = NULL; + else { + H5S_conv_g[i]->read = NULL; + H5S_conv_g[i]->write = NULL; + } HRETURN(H5S_conv_g[i]); } @@ -1620,7 +1622,8 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space) intn H5S_extend (H5S_t *space, const hsize_t *size) { - intn i, ret_value=0; + intn ret_value=0; + uintn u; FUNC_ENTER (H5S_extend, FAIL); @@ -1628,11 +1631,11 @@ H5S_extend (H5S_t *space, const hsize_t *size) assert (space && H5S_SIMPLE==space->extent.type); assert (size); - for (i=0; i<space->extent.u.simple.rank; i++) { - if (space->extent.u.simple.size[i]<size[i]) { + for (u=0; u<space->extent.u.simple.rank; u++) { + if (space->extent.u.simple.size[u]<size[u]) { if (space->extent.u.simple.max && - H5S_UNLIMITED!=space->extent.u.simple.max[i] && - space->extent.u.simple.max[i]<size[i]) { + H5S_UNLIMITED!=space->extent.u.simple.max[u] && + space->extent.u.simple.max[u]<size[u]) { HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "dimension cannot be increased"); } @@ -1642,9 +1645,9 @@ H5S_extend (H5S_t *space, const hsize_t *size) /* Update */ if (ret_value) { - for (i=0; i<space->extent.u.simple.rank; i++) { - if (space->extent.u.simple.size[i]<size[i]) { - space->extent.u.simple.size[i] = size[i]; + for (u=0; u<space->extent.u.simple.rank; u++) { + if (space->extent.u.simple.size[u]<size[u]) { + space->extent.u.simple.size[u] = size[u]; } } } @@ -1884,7 +1887,7 @@ H5Soffset_simple(hid_t space_id, const hssize_t *offset) /* Allocate space for new offset */ if(space->select.offset==NULL) { - if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,space->extent.u.simple.rank,0))) { + if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,(hsize_t)space->extent.u.simple.rank,0))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } diff --git a/src/H5Sall.c b/src/H5Sall.c index f56e480..8e15b7d 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -24,28 +24,28 @@ static intn interface_initialize_g = 0; static herr_t H5S_all_init (const struct H5O_layout_t *layout, const H5S_t *space, H5S_sel_iter_t *iter, size_t *min_elem_out); -static size_t H5S_all_favail (const H5S_t *space, const H5S_sel_iter_t *iter, - size_t max); -static size_t H5S_all_fgath (H5F_t *f, const struct H5O_layout_t *layout, +static hsize_t H5S_all_favail (const H5S_t *space, const H5S_sel_iter_t *iter, + hsize_t max); +static hsize_t H5S_all_fgath (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, - H5S_sel_iter_t *file_iter, size_t nelmts, + H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id, void *buf/*out*/); static herr_t H5S_all_fscat (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, - H5S_sel_iter_t *file_iter, size_t nelmts, + H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id, const void *buf); -static size_t H5S_all_mgath (const void *_buf, size_t elmt_size, +static hsize_t H5S_all_mgath (const void *_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *_tconv_buf/*out*/); + hsize_t nelmts, void *_tconv_buf/*out*/); static herr_t H5S_all_mscat (const void *_tconv_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *_buf/*out*/); + hsize_t nelmts, void *_buf/*out*/); static herr_t H5S_select_all(H5S_t *space); const H5S_fconv_t H5S_ALL_FCONV[1] = {{ @@ -123,7 +123,7 @@ H5S_all_init (const struct H5O_layout_t UNUSED *layout, * Purpose: Figure out the optimal number of elements to transfer to/from * the file. * - * Return: non-negative number of elements on success, negative on + * Return: non-negative number of elements on success, zero on * failure. * * Programmer: Quincey Koziol @@ -133,8 +133,8 @@ H5S_all_init (const struct H5O_layout_t UNUSED *layout, * *------------------------------------------------------------------------- */ -static size_t -H5S_all_favail (const H5S_t *space, const H5S_sel_iter_t *sel_iter, size_t max) +static hsize_t +H5S_all_favail (const H5S_t *space, const H5S_sel_iter_t *sel_iter, hsize_t max) { hsize_t nelmts; int m_ndims; /* file dimensionality */ @@ -142,7 +142,7 @@ H5S_all_favail (const H5S_t *space, const H5S_sel_iter_t *sel_iter, size_t max) hsize_t acc; int i; - FUNC_ENTER (H5S_all_favail, FAIL); + FUNC_ENTER (H5S_all_favail, 0); /* Check args */ assert (space && H5S_SEL_ALL==space->select.type); @@ -158,7 +158,7 @@ H5S_all_favail (const H5S_t *space, const H5S_sel_iter_t *sel_iter, size_t max) acc *= size[i]; nelmts = (max/acc) * acc; if (nelmts<=0) { - HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, + HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, 0, "strip mine buffer is too small"); } @@ -191,12 +191,12 @@ H5S_all_favail (const H5S_t *space, const H5S_sel_iter_t *sel_iter, size_t max) * what the virtual file layer needs. *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_all_fgath (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, - H5S_sel_iter_t *file_iter, size_t nelmts, hid_t dxpl_id, + H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id, void *_buf/*out*/) { hssize_t file_offset[H5O_LAYOUT_NDIMS]; /*offset of slab in file*/ @@ -252,11 +252,11 @@ H5S_all_fgath (H5F_t *f, const struct H5O_layout_t *layout, */ if (H5F_arr_read(f, dxpl_id, layout, pline, fill, efl, hsize, hsize, zero, file_offset, buf/*out*/)<0) { - HRETURN_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error"); + HRETURN_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error"); } /* Advance iterator */ - file_iter->all.elmt_left--; + file_iter->all.elmt_left-=nelmts; file_iter->all.offset+=nelmts; FUNC_LEAVE (nelmts); @@ -287,7 +287,7 @@ H5S_all_fscat (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, H5S_sel_iter_t *file_iter, - size_t nelmts, hid_t dxpl_id, const void *_buf) + hsize_t nelmts, hid_t dxpl_id, const void *_buf) { hssize_t file_offset[H5O_LAYOUT_NDIMS]; /*offset of hyperslab */ hsize_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */ @@ -342,7 +342,7 @@ H5S_all_fscat (H5F_t *f, const struct H5O_layout_t *layout, } /* Advance iterator */ - file_iter->all.elmt_left--; + file_iter->all.elmt_left-=nelmts; file_iter->all.offset+=nelmts; FUNC_LEAVE (SUCCEED); @@ -368,10 +368,10 @@ H5S_all_fscat (H5F_t *f, const struct H5O_layout_t *layout, * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_all_mgath (const void *_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *_tconv_buf/*out*/) + hsize_t nelmts, void *_tconv_buf/*out*/) { hssize_t mem_offset[H5O_LAYOUT_NDIMS]; /*slab offset in app buf*/ hsize_t mem_size[H5O_LAYOUT_NDIMS]; /*total size of app buf */ @@ -426,14 +426,15 @@ H5S_all_mgath (const void *_buf, size_t elmt_size, /* * Scatter from conversion buffer to application memory. */ - if (H5V_hyper_copy (space_ndims+1, hsize, hsize, zero, tconv_buf, + H5_CHECK_OVERFLOW(space_ndims+1,intn,uintn); + if (H5V_hyper_copy ((uintn)(space_ndims+1), hsize, hsize, zero, tconv_buf, mem_size, mem_offset, buf)<0) { HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0, "unable to scatter data to memory"); } /* Advance iterator */ - mem_iter->all.elmt_left--; + mem_iter->all.elmt_left-=nelmts; mem_iter->all.offset+=nelmts; FUNC_LEAVE (nelmts); @@ -459,7 +460,7 @@ H5S_all_mgath (const void *_buf, size_t elmt_size, static herr_t H5S_all_mscat (const void *_tconv_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *_buf/*out*/) + hsize_t nelmts, void *_buf/*out*/) { hssize_t mem_offset[H5O_LAYOUT_NDIMS]; /*slab offset in app buf*/ hsize_t mem_size[H5O_LAYOUT_NDIMS]; /*total size of app buf */ @@ -516,14 +517,15 @@ H5S_all_mscat (const void *_tconv_buf, size_t elmt_size, /* * Scatter from conversion buffer to application memory. */ - if (H5V_hyper_copy (space_ndims+1, hsize, mem_size, mem_offset, buf, + H5_CHECK_OVERFLOW(space_ndims+1,intn,uintn); + if (H5V_hyper_copy ((uintn)(space_ndims+1), hsize, mem_size, mem_offset, buf, hsize, zero, tconv_buf)<0) { HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to scatter data to memory"); } /* Advance iterator */ - mem_iter->all.elmt_left--; + mem_iter->all.elmt_left-=nelmts; mem_iter->all.offset+=nelmts; FUNC_LEAVE (SUCCEED); @@ -567,7 +569,7 @@ H5S_all_read(H5F_t *f, const H5O_layout_t *layout, const H5O_pline_t *pline, hsize_t size[H5O_LAYOUT_NDIMS]; hssize_t file_offset[H5O_LAYOUT_NDIMS]; hssize_t mem_offset[H5O_LAYOUT_NDIMS]; - int i; + uintn u; FUNC_ENTER(H5S_all_read, FAIL); *must_convert = TRUE; @@ -588,8 +590,8 @@ printf("%s: check 1.0\n",FUNC); /* Check for a "regular" hyperslab selection */ if(mem_space->select.sel_info.hslab.diminfo != NULL) { /* Check each dimension */ - for(count=1,i=0; i<mem_space->extent.u.simple.rank; i++) - count*=mem_space->select.sel_info.hslab.diminfo[i].count; + for(count=1,u=0; u<mem_space->extent.u.simple.rank; u++) + count*=mem_space->select.sel_info.hslab.diminfo[u].count; /* If the regular hyperslab definition creates more than one hyperslab, fall through */ if(count>1) goto fall_through; @@ -609,8 +611,8 @@ printf("%s: check 1.0\n",FUNC); /* Check for a "regular" hyperslab selection */ if(file_space->select.sel_info.hslab.diminfo != NULL) { /* Check each dimension */ - for(count=1,i=0; i<file_space->extent.u.simple.rank; i++) - count*=file_space->select.sel_info.hslab.diminfo[i].count; + for(count=1,u=0; u<file_space->extent.u.simple.rank; u++) + count*=file_space->select.sel_info.hslab.diminfo[u].count; /* If the regular hyperslab definition creates more than one hyperslab, fall through */ if(count>1) goto fall_through; @@ -626,56 +628,56 @@ printf("%s: check 1.0\n",FUNC); goto fall_through; /* Get information about memory and file */ - for (i=0; i<mem_space->extent.u.simple.rank; i++) { + for (u=0; u<mem_space->extent.u.simple.rank; u++) { if (mem_space->extent.u.simple.max && - mem_space->extent.u.simple.size[i]!=mem_space->extent.u.simple.max[i]) + mem_space->extent.u.simple.size[u]!=mem_space->extent.u.simple.max[u]) goto fall_through; if (file_space->extent.u.simple.max && - file_space->extent.u.simple.size[i]!=file_space->extent.u.simple.max[i]) + file_space->extent.u.simple.size[u]!=file_space->extent.u.simple.max[u]) goto fall_through; if(mem_space->select.type==H5S_SEL_HYPERSLABS) { /* Check for a "regular" hyperslab selection */ if(mem_space->select.sel_info.hslab.diminfo != NULL) { - mem_size=mem_space->select.sel_info.hslab.diminfo[i].block; - mem_off=mem_space->select.sel_info.hslab.diminfo[i].start; + mem_size=mem_space->select.sel_info.hslab.diminfo[u].block; + mem_off=mem_space->select.sel_info.hslab.diminfo[u].start; } /* end if */ else { - mem_size=(mem_node->end[i]-mem_node->start[i])+1; - mem_off=mem_node->start[i]; + mem_size=(mem_node->end[u]-mem_node->start[u])+1; + mem_off=mem_node->start[u]; } /* end else */ } /* end if */ else { - mem_size=mem_space->extent.u.simple.size[i]; + mem_size=mem_space->extent.u.simple.size[u]; mem_off=0; } /* end else */ if(file_space->select.type==H5S_SEL_HYPERSLABS) { /* Check for a "regular" hyperslab selection */ if(file_space->select.sel_info.hslab.diminfo != NULL) { - file_size=file_space->select.sel_info.hslab.diminfo[i].block; - file_off=file_space->select.sel_info.hslab.diminfo[i].start; + file_size=file_space->select.sel_info.hslab.diminfo[u].block; + file_off=file_space->select.sel_info.hslab.diminfo[u].start; } /* end if */ else { - file_size=(file_node->end[i]-file_node->start[i])+1; - file_off=file_node->start[i]; + file_size=(file_node->end[u]-file_node->start[u])+1; + file_off=file_node->start[u]; } /* end else */ } /* end if */ else { - file_size=file_space->extent.u.simple.size[i]; + file_size=file_space->extent.u.simple.size[u]; file_off=0; } /* end else */ if (mem_size!=file_size) goto fall_through; - size[i] = file_size; - file_offset[i] = file_off; - mem_offset[i] = mem_off; + size[u] = file_size; + file_offset[u] = file_off; + mem_offset[u] = mem_off; } - size[i] = elmt_size; - file_offset[i] = 0; - mem_offset[i] = 0; + size[u] = elmt_size; + file_offset[u] = 0; + mem_offset[u] = 0; #ifdef QAK printf("%s: check 2.0\n",FUNC); @@ -731,7 +733,7 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, hsize_t size[H5O_LAYOUT_NDIMS]; hssize_t file_offset[H5O_LAYOUT_NDIMS]; hssize_t mem_offset[H5O_LAYOUT_NDIMS]; - int i; + uintn u; FUNC_ENTER(H5S_all_write, FAIL); *must_convert = TRUE; @@ -749,8 +751,8 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, /* Check for a "regular" hyperslab selection */ if(mem_space->select.sel_info.hslab.diminfo != NULL) { /* Check each dimension */ - for(count=1,i=0; i<mem_space->extent.u.simple.rank; i++) - count*=mem_space->select.sel_info.hslab.diminfo[i].count; + for(count=1,u=0; u<mem_space->extent.u.simple.rank; u++) + count*=mem_space->select.sel_info.hslab.diminfo[u].count; /* If the regular hyperslab definition creates more than one hyperslab, fall through */ if(count>1) goto fall_through; @@ -770,8 +772,8 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, /* Check for a "regular" hyperslab selection */ if(file_space->select.sel_info.hslab.diminfo != NULL) { /* Check each dimension */ - for(count=1,i=0; i<file_space->extent.u.simple.rank; i++) - count*=file_space->select.sel_info.hslab.diminfo[i].count; + for(count=1,u=0; u<file_space->extent.u.simple.rank; u++) + count*=file_space->select.sel_info.hslab.diminfo[u].count; /* If the regular hyperslab definition creates more than one hyperslab, fall through */ if(count>1) goto fall_through; @@ -787,56 +789,56 @@ H5S_all_write(H5F_t *f, const struct H5O_layout_t *layout, goto fall_through; /* Get information about memory and file */ - for (i=0; i<mem_space->extent.u.simple.rank; i++) { + for (u=0; u<mem_space->extent.u.simple.rank; u++) { if (mem_space->extent.u.simple.max && - mem_space->extent.u.simple.size[i]!=mem_space->extent.u.simple.max[i]) + mem_space->extent.u.simple.size[u]!=mem_space->extent.u.simple.max[u]) goto fall_through; if (file_space->extent.u.simple.max && - file_space->extent.u.simple.size[i]!=file_space->extent.u.simple.max[i]) + file_space->extent.u.simple.size[u]!=file_space->extent.u.simple.max[u]) goto fall_through; if(mem_space->select.type==H5S_SEL_HYPERSLABS) { /* Check for a "regular" hyperslab selection */ if(mem_space->select.sel_info.hslab.diminfo != NULL) { - mem_size=mem_space->select.sel_info.hslab.diminfo[i].block; - mem_off=mem_space->select.sel_info.hslab.diminfo[i].start; + mem_size=mem_space->select.sel_info.hslab.diminfo[u].block; + mem_off=mem_space->select.sel_info.hslab.diminfo[u].start; } /* end if */ else { - mem_size=(mem_node->end[i]-mem_node->start[i])+1; - mem_off=mem_node->start[i]; + mem_size=(mem_node->end[u]-mem_node->start[u])+1; + mem_off=mem_node->start[u]; } /* end else */ } /* end if */ else { - mem_size=mem_space->extent.u.simple.size[i]; + mem_size=mem_space->extent.u.simple.size[u]; mem_off=0; } /* end else */ if(file_space->select.type==H5S_SEL_HYPERSLABS) { /* Check for a "regular" hyperslab selection */ if(file_space->select.sel_info.hslab.diminfo != NULL) { - file_size=file_space->select.sel_info.hslab.diminfo[i].block; - file_off=file_space->select.sel_info.hslab.diminfo[i].start; + file_size=file_space->select.sel_info.hslab.diminfo[u].block; + file_off=file_space->select.sel_info.hslab.diminfo[u].start; } /* end if */ else { - file_size=(file_node->end[i]-file_node->start[i])+1; - file_off=file_node->start[i]; + file_size=(file_node->end[u]-file_node->start[u])+1; + file_off=file_node->start[u]; } /* end else */ } /* end if */ else { - file_size=file_space->extent.u.simple.size[i]; + file_size=file_space->extent.u.simple.size[u]; file_off=0; } /* end else */ if (mem_size!=file_size) goto fall_through; - size[i] = file_size; - file_offset[i] = file_off; - mem_offset[i] = mem_off; + size[u] = file_size; + file_offset[u] = file_off; + mem_offset[u] = mem_off; } - size[i] = elmt_size; - file_offset[i] = 0; - mem_offset[i] = 0; + size[u] = elmt_size; + file_offset[u] = 0; + mem_offset[u] = 0; /* Write data to the file */ if (H5F_arr_write(f, dxpl_id, layout, pline, NULL, efl, size, @@ -879,6 +881,7 @@ H5S_all_release (H5S_t UNUSED *space) FUNC_LEAVE (SUCCEED); } /* H5S_all_release() */ + /*-------------------------------------------------------------------------- NAME @@ -901,7 +904,7 @@ H5S_all_release (H5S_t UNUSED *space) hsize_t H5S_all_npoints (const H5S_t *space) { - intn i; /* Counters */ + uintn u; /* Counters */ hsize_t ret_value; FUNC_ENTER (H5S_all_npoints, 0); @@ -909,11 +912,12 @@ H5S_all_npoints (const H5S_t *space) /* Check args */ assert (space); - for(i=0, ret_value=1; i<space->extent.u.simple.rank; i++) - ret_value*=space->extent.u.simple.size[i]; + for(u=0, ret_value=1; u<space->extent.u.simple.rank; u++) + ret_value*=space->extent.u.simple.size[u]; FUNC_LEAVE (ret_value); } /* H5S_all_npoints() */ + /*-------------------------------------------------------------------------- NAME @@ -954,6 +958,7 @@ H5S_all_select_serialize (const H5S_t *space, uint8_t *buf) FUNC_LEAVE (ret_value); } /* H5S_all_select_serialize() */ + /*-------------------------------------------------------------------------- NAME @@ -991,6 +996,7 @@ H5S_all_select_deserialize (H5S_t *space, const uint8_t UNUSED *buf) done: FUNC_LEAVE (ret_value); } /* H5S_all_select_deserialize() */ + /*-------------------------------------------------------------------------- NAME @@ -1163,7 +1169,7 @@ H5S_all_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t op hsize_t offset; /* offset of region in buffer */ hsize_t nelemts; /* Number of elements to iterate through */ void *tmp_buf; /* temporary location of the element in the buffer */ - intn rank; /* Dataspace rank */ + uintn rank; /* Dataspace rank */ intn indx; /* Index to increment */ herr_t ret_value=0; /* return value */ @@ -1193,7 +1199,7 @@ H5S_all_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t op offset=H5V_array_offset(rank+1,mem_size,(const hssize_t *)mem_offset); tmp_buf=((char *)buf+offset); - ret_value=(*op)(tmp_buf,type_id,rank,(hssize_t *)mem_offset,operator_data); + ret_value=(*op)(tmp_buf,type_id,(hsize_t)rank,(hssize_t *)mem_offset,operator_data); /* Decrement the number of elements to iterate through */ nelemts--; diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 0934bd2..08cad89 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -37,7 +37,7 @@ typedef struct { size_t elmt_size; const H5S_t *space; H5S_sel_iter_t *iter; - size_t nelmts; + hsize_t nelmts; hid_t dxpl_id; const void *src; void *dst; @@ -63,52 +63,52 @@ typedef struct { static H5S_hyper_region_t * H5S_hyper_get_regions (size_t *num_regions, uintn rank, uintn dim, size_t bound_count, H5S_hyper_bound_t **lo_bounds, hssize_t *pos, hssize_t *offset); -static size_t H5S_hyper_fread (intn dim, H5S_hyper_io_info_t *io_info); -static size_t H5S_hyper_fread_opt (H5F_t *f, const struct H5O_layout_t *layout, +static hsize_t H5S_hyper_fread (intn dim, H5S_hyper_io_info_t *io_info); +static hsize_t H5S_hyper_fread_opt (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, H5S_sel_iter_t *file_iter, - size_t nelmts, hid_t dxpl_id, void *_buf/*out*/); -static size_t H5S_hyper_fwrite (intn dim, + hsize_t nelmts, hid_t dxpl_id, void *_buf/*out*/); +static hsize_t H5S_hyper_fwrite (intn dim, H5S_hyper_io_info_t *io_info); -static size_t H5S_hyper_fwrite_opt (H5F_t *f, const struct H5O_layout_t *layout, +static hsize_t H5S_hyper_fwrite_opt (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, H5S_sel_iter_t *file_iter, - size_t nelmts, hid_t dxpl_id, const void *_buf); + hsize_t nelmts, hid_t dxpl_id, const void *_buf); static herr_t H5S_hyper_init (const struct H5O_layout_t *layout, const H5S_t *space, H5S_sel_iter_t *iter, size_t *min_elem_out); -static size_t H5S_hyper_favail (const H5S_t *space, const H5S_sel_iter_t *iter, - size_t max); -static size_t H5S_hyper_fgath (H5F_t *f, const struct H5O_layout_t *layout, +static hsize_t H5S_hyper_favail (const H5S_t *space, const H5S_sel_iter_t *iter, + hsize_t max); +static hsize_t H5S_hyper_fgath (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, - H5S_sel_iter_t *file_iter, size_t nelmts, + H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id, void *buf/*out*/); static herr_t H5S_hyper_fscat (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, - H5S_sel_iter_t *file_iter, size_t nelmts, + H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id, const void *buf); -static size_t H5S_hyper_mread (intn dim, H5S_hyper_io_info_t *io_info); -static size_t H5S_hyper_mread_opt (const void *_buf, size_t elmt_size, +static hsize_t H5S_hyper_mread (intn dim, H5S_hyper_io_info_t *io_info); +static hsize_t H5S_hyper_mread_opt (const void *_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *_tconv_buf/*out*/); -static size_t H5S_hyper_mgath (const void *_buf, size_t elmt_size, + hsize_t nelmts, void *_tconv_buf/*out*/); +static hsize_t H5S_hyper_mgath (const void *_buf, size_t elmt_size, const H5S_t *mem_space, - H5S_sel_iter_t *mem_iter, size_t nelmts, + H5S_sel_iter_t *mem_iter, hsize_t nelmts, void *_tconv_buf/*out*/); static size_t H5S_hyper_mwrite (intn dim, H5S_hyper_io_info_t *io_info); -static size_t H5S_hyper_mwrite_opt (const void *_tconv_buf, size_t elmt_size, +static hsize_t H5S_hyper_mwrite_opt (const void *_tconv_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *_buf/*out*/); + hsize_t nelmts, void *_buf/*out*/); static herr_t H5S_hyper_mscat (const void *_tconv_buf, size_t elmt_size, const H5S_t *mem_space, - H5S_sel_iter_t *mem_iter, size_t nelmts, + H5S_sel_iter_t *mem_iter, hsize_t nelmts, void *_buf/*out*/); const H5S_fconv_t H5S_HYPER_FCONV[1] = {{ @@ -186,7 +186,7 @@ H5S_hyper_init (const struct H5O_layout_t UNUSED *layout, sel_iter->hyp.elmt_left=space->select.num_elem; /* Allocate the position & initialize to invalid location */ - sel_iter->hyp.pos = H5FL_ARR_ALLOC(hsize_t,space->extent.u.simple.rank,0); + sel_iter->hyp.pos = H5FL_ARR_ALLOC(hsize_t,(hsize_t)space->extent.u.simple.rank,0); sel_iter->hyp.pos[0]=(-1); H5V_array_fill(sel_iter->hyp.pos, sel_iter->hyp.pos, sizeof(hssize_t), space->extent.u.simple.rank); @@ -199,7 +199,7 @@ H5S_hyper_init (const struct H5O_layout_t UNUSED *layout, * * Purpose: Figure out the optimal number of elements to transfer to/from the file * - * Return: non-negative number of elements on success, negative on failure + * Return: non-negative number of elements on success, zero on failure * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 @@ -208,11 +208,11 @@ H5S_hyper_init (const struct H5O_layout_t UNUSED *layout, * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_hyper_favail (const H5S_t UNUSED *space, - const H5S_sel_iter_t *sel_iter, size_t max) + const H5S_sel_iter_t *sel_iter, hsize_t max) { - FUNC_ENTER (H5S_hyper_favail, FAIL); + FUNC_ENTER (H5S_hyper_favail, 0); /* Check args */ assert (space && H5S_SEL_HYPERSLABS==space->select.type); @@ -332,7 +332,7 @@ printf("%s: check 1.3, i=%d, temp_dim=%d\n",FUNC,(int)i,(int)temp_dim); /* Check if we've allocated the array yet */ if(num_reg==0) { /* Allocate temporary buffer, big enough for worst case size */ - reg=H5FL_ARR_ALLOC(H5S_hyper_region_t,bound_count,0); + reg=H5FL_ARR_ALLOC(H5S_hyper_region_t,(hsize_t)bound_count,0); /* Initialize with first region */ reg[num_reg].start=MAX(node->start[dim],pos[dim])+offset[dim]; @@ -401,7 +401,7 @@ H5S_hyper_block_cache (H5S_hyper_node_t *node, { hssize_t file_offset[H5O_LAYOUT_NDIMS]; /*offset of slab in file*/ hsize_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */ - intn i; /* Counters */ + uintn u; /* Counters */ FUNC_ENTER (H5S_hyper_block_cache, SUCCEED); @@ -409,7 +409,7 @@ H5S_hyper_block_cache (H5S_hyper_node_t *node, assert(io_info); /* Allocate temporary buffer of proper size */ - if((node->cinfo.block=H5FL_BLK_ALLOC(hyper_block,node->cinfo.size*io_info->elmt_size,0))==NULL) + if((node->cinfo.block=H5FL_BLK_ALLOC(hyper_block,(hsize_t)(node->cinfo.size*io_info->elmt_size),0))==NULL) HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab cache block"); @@ -420,8 +420,8 @@ H5S_hyper_block_cache (H5S_hyper_node_t *node, file_offset[io_info->space->extent.u.simple.rank]=0; /* Set the hyperslab size to read */ - for(i=0; i<io_info->space->extent.u.simple.rank; i++) - hsize[i]=(node->end[i]-node->start[i])+1; + for(u=0; u<io_info->space->extent.u.simple.rank; u++) + hsize[u]=(node->end[u]-node->start[u])+1; hsize[io_info->space->extent.u.simple.rank]=io_info->elmt_size; if (H5F_arr_read(io_info->f, io_info->dxpl_id, @@ -513,7 +513,7 @@ H5S_hyper_block_write (H5S_hyper_node_t *node, { hssize_t file_offset[H5O_LAYOUT_NDIMS]; /*offset of slab in file*/ hsize_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */ - intn i; /* Counters */ + uintn u; /* Counters */ FUNC_ENTER (H5S_hyper_block_write, SUCCEED); @@ -541,8 +541,8 @@ H5S_hyper_block_write (H5S_hyper_node_t *node, file_offset[io_info->space->extent.u.simple.rank]=0; /* Set the hyperslab size to write */ - for(i=0; i<io_info->space->extent.u.simple.rank; i++) - hsize[i]=(node->end[i]-node->start[i])+1; + for(u=0; u<io_info->space->extent.u.simple.rank; u++) + hsize[u]=(node->end[u]-node->start[u])+1; hsize[io_info->space->extent.u.simple.rank]=io_info->elmt_size; if (H5F_arr_write(io_info->f, io_info->dxpl_id, io_info->layout, @@ -579,7 +579,7 @@ H5S_hyper_block_write (H5S_hyper_node_t *node, * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_hyper_fread (intn dim, H5S_hyper_io_info_t *io_info) { hsize_t region_size; /* Size of lowest region */ @@ -588,7 +588,7 @@ H5S_hyper_fread (intn dim, H5S_hyper_io_info_t *io_info) size_t num_regions; /* number of regions overlapped */ size_t i; /* Counters */ intn j; - size_t num_read=0; /* Number of elements read */ + hsize_t num_read=0; /* Number of elements read */ const H5D_xfer_t *xfer_parms;/* Data transfer property list */ FUNC_ENTER (H5S_hyper_fread, 0); @@ -608,7 +608,7 @@ H5S_hyper_fread (intn dim, H5S_hyper_io_info_t *io_info) /* Get a sorted list (in the next dimension down) of the regions which */ /* overlap the current index in this dim */ if((regions=H5S_hyper_get_regions(&num_regions,io_info->space->extent.u.simple.rank, - dim+1, + (uintn)(dim+1), io_info->space->select.sel_info.hslab.hyper_lst->count, io_info->space->select.sel_info.hslab.hyper_lst->lo_bounds, io_info->iter->hyp.pos,io_info->space->select.offset))!=NULL) { @@ -637,15 +637,15 @@ H5S_hyper_fread (intn dim, H5S_hyper_io_info_t *io_info) printf("%s: check 2.1, region #%d: start=%d, end=%d\n", FUNC,i,(int)regions[i].start,(int)regions[i].end); #endif /* QAK */ - if((dim+2)==io_info->space->extent.u.simple.rank) { + if((uintn)(dim+2)==io_info->space->extent.u.simple.rank) { #ifdef QAK printf("%s: check 2.1.1, num_regions=%d\n",FUNC,(int)num_regions); #endif /* QAK */ /* perform I/O on data from regions */ for(i=0; i<num_regions && io_info->nelmts>0; i++) { /* Compute the size of the region to read */ - region_size=MIN(io_info->nelmts, - (regions[i].end-regions[i].start)+1); + H5_CHECK_OVERFLOW(io_info->nelmts,hsize_t,hssize_t); + region_size=MIN((hssize_t)io_info->nelmts, (regions[i].end-regions[i].start)+1); #ifdef QAK printf("%s: check 2.1.2, region=%d, region_size=%d\n",FUNC,(int)i,(int)region_size); @@ -716,8 +716,7 @@ H5S_hyper_fread (intn dim, H5S_hyper_io_info_t *io_info) #endif /* QAK */ /* Advance the pointer in the buffer */ - io_info->dst = ((uint8_t *)io_info->dst) + - region_size*io_info->elmt_size; + io_info->dst = ((uint8_t *)io_info->dst) + region_size*io_info->elmt_size; /* Increment the number of elements read */ num_read+=region_size; @@ -930,13 +929,13 @@ H5S_hyper_iter_next (const H5S_t *file_space, H5S_sel_iter_t *file_iter) * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_hyper_fread_opt (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, H5S_sel_iter_t *file_iter, - size_t nelmts, hid_t dxpl_id, void *_buf/*out*/) + hsize_t nelmts, hid_t dxpl_id, void *_buf/*out*/) { hssize_t offset[H5O_LAYOUT_NDIMS]; /* Offset on disk */ hsize_t slab[H5O_LAYOUT_NDIMS]; /* Hyperslab size */ @@ -953,14 +952,15 @@ H5S_hyper_fread_opt (H5F_t *f, const struct H5O_layout_t *layout, intn fast_dim; /* Rank of the fastest changing dimension for the dataspace */ intn temp_dim; /* Temporary rank holder */ hsize_t acc; /* Accumulator */ - hssize_t buf_off; /* Current buffer offset for copying memory */ - hssize_t last_buf_off; /* Last buffer offset for copying memory */ - size_t buf_size; /* Current size of the buffer to write */ + hsize_t buf_off; /* Current buffer offset for copying memory */ + hsize_t last_buf_off; /* Last buffer offset for copying memory */ + hsize_t buf_size; /* Current size of the buffer to write */ intn i; /* Counters */ + uintn u; /* Counters */ intn ndims; /* Number of dimensions of dataset */ - size_t actual_read; /* The actual number of elements to read in */ - size_t actual_bytes; /* The actual number of bytes to copy */ - size_t num_read=0; /* Number of elements read */ + hsize_t actual_read; /* The actual number of elements to read in */ + hsize_t actual_bytes; /* The actual number of bytes to copy */ + hsize_t num_read=0; /* Number of elements read */ FUNC_ENTER (H5S_hyper_fread_opt, 0); @@ -969,8 +969,8 @@ printf("%s: Called!\n",FUNC); #endif /* QAK */ /* Check if this is the first element read in from the hyperslab */ if(file_iter->hyp.pos[0]==(-1)) { - for(i=0; i<file_space->extent.u.simple.rank; i++) - file_iter->hyp.pos[i]=file_space->select.sel_info.hslab.diminfo[i].start; + for(u=0; u<file_space->extent.u.simple.rank; u++) + file_iter->hyp.pos[u]=file_space->select.sel_info.hslab.diminfo[u].start; } /* end if */ #ifdef QAK @@ -996,7 +996,7 @@ for(i=0; i<file_space->extent.u.simple.rank; i++) /* Check if we stopped in the middle of a sequence of elements */ if((file_iter->hyp.pos[fast_dim]-file_space->select.sel_info.hslab.diminfo[fast_dim].start)%file_space->select.sel_info.hslab.diminfo[fast_dim].stride!=0 || ((file_iter->hyp.pos[fast_dim]!=file_space->select.sel_info.hslab.diminfo[fast_dim].start) && file_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 */ #ifdef QAK printf("%s: Check 1.0\n",FUNC); @@ -1114,7 +1114,7 @@ for(i=0; i<file_space->extent.u.simple.rank; i++) #endif /* QAK */ /* Set the last location & length to invalid numbers */ - last_buf_off=-1; + last_buf_off=(hsize_t)-1; buf_size=0; /* Set the local copy of the diminfo pointer */ @@ -1143,7 +1143,7 @@ for(i=0; i<file_space->extent.u.simple.rank; i++) #endif /* QAK */ /* check for the first read */ - if(last_buf_off<0) { + if(last_buf_off==(hsize_t)-1) { last_buf_off=buf_off; buf_size=actual_bytes; } /* end if */ @@ -1242,7 +1242,7 @@ for(i=0; i<file_space->extent.u.simple.rank; i++) } /* end while */ /* check for the last read */ - if(last_buf_off>=0) { + if(last_buf_off!=(hsize_t)-1) { /* Read in the sequence */ if (H5F_seq_read(f, dxpl_id, layout, pline, fill, efl, file_space, elmt_size, buf_size, last_buf_off, buf/*out*/)<0) { @@ -1286,16 +1286,16 @@ for(i=0; i<file_space->extent.u.simple.rank; i++) * what the virtual file layer needs. *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_hyper_fgath (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, H5S_sel_iter_t *file_iter, - size_t nelmts, hid_t dxpl_id, void *_buf/*out*/) + hsize_t nelmts, hid_t dxpl_id, void *_buf/*out*/) { H5S_hyper_io_info_t io_info; /* Block of parameters to pass into recursive calls */ - size_t num_read=0; /* number of elements read into buffer */ + hsize_t num_read=0; /* number of elements read into buffer */ herr_t ret_value=SUCCEED; FUNC_ENTER (H5S_hyper_fgath, 0); @@ -1368,7 +1368,7 @@ H5S_hyper_fgath (H5F_t *f, const struct H5O_layout_t *layout, * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_hyper_fwrite (intn dim, H5S_hyper_io_info_t *io_info) { hsize_t region_size; /* Size of lowest region */ @@ -1377,17 +1377,17 @@ H5S_hyper_fwrite (intn dim, H5S_hyper_io_info_t *io_info) size_t num_regions; /* number of regions overlapped */ size_t i; /* Counters */ intn j; - size_t num_written=0; /* Number of elements read */ + hsize_t num_written=0; /* Number of elements read */ const H5D_xfer_t *xfer_parms; /* Data transfer properties */ FUNC_ENTER (H5S_hyper_fwrite, 0); assert(io_info); if (H5P_DEFAULT==io_info->dxpl_id) { - xfer_parms = &H5D_xfer_dflt; + xfer_parms = &H5D_xfer_dflt; } else { - xfer_parms = H5I_object(io_info->dxpl_id); - assert(xfer_parms); + xfer_parms = H5I_object(io_info->dxpl_id); + assert(xfer_parms); } #ifdef QAK @@ -1396,7 +1396,7 @@ H5S_hyper_fwrite (intn dim, H5S_hyper_io_info_t *io_info) /* Get a sorted list (in the next dimension down) of the regions which */ /* overlap the current index in this dim */ if((regions=H5S_hyper_get_regions(&num_regions,io_info->space->extent.u.simple.rank, - dim+1, + (uintn)(dim+1), io_info->space->select.sel_info.hslab.hyper_lst->count, io_info->space->select.sel_info.hslab.hyper_lst->lo_bounds, io_info->iter->hyp.pos,io_info->space->select.offset))!=NULL) { @@ -1413,12 +1413,13 @@ H5S_hyper_fwrite (intn dim, H5S_hyper_io_info_t *io_info) /* Check if this is the second to last dimension in dataset */ /* (Which means that we've got a list of the regions in the fastest */ /* changing dimension and should input those regions) */ - if((dim+2)==io_info->space->extent.u.simple.rank) { + if((uintn)(dim+2)==io_info->space->extent.u.simple.rank) { /* perform I/O on data from regions */ for(i=0; i<num_regions && io_info->nelmts>0; i++) { /* Compute the size of the region to read */ - region_size=MIN(io_info->nelmts, (regions[i].end-regions[i].start)+1); + H5_CHECK_OVERFLOW(io_info->nelmts,hsize_t,hssize_t); + region_size=MIN((hssize_t)io_info->nelmts, (regions[i].end-regions[i].start)+1); /* Check if this hyperslab block is cached or could be cached */ if(!regions[i].node->cinfo.cached && (xfer_parms->cache_hyper && (xfer_parms->block_limit==0 || xfer_parms->block_limit>=(regions[i].node->cinfo.size*io_info->elmt_size)))) { @@ -1531,13 +1532,13 @@ H5S_hyper_fwrite (intn dim, H5S_hyper_io_info_t *io_info) * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_hyper_fwrite_opt (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, H5S_sel_iter_t *file_iter, - size_t nelmts, hid_t dxpl_id, const void *_buf) + hsize_t nelmts, hid_t dxpl_id, const void *_buf) { hssize_t offset[H5O_LAYOUT_NDIMS]; /* Offset on disk */ hsize_t slab[H5O_LAYOUT_NDIMS]; /* Hyperslab size */ @@ -1554,14 +1555,15 @@ H5S_hyper_fwrite_opt (H5F_t *f, const struct H5O_layout_t *layout, intn fast_dim; /* Rank of the fastest changing dimension for the dataspace */ intn temp_dim; /* Temporary rank holder */ hsize_t acc; /* Accumulator */ - hssize_t buf_off; /* Buffer offset for copying memory */ - hssize_t last_buf_off; /* Last buffer offset for copying memory */ - size_t buf_size; /* Current size of the buffer to write */ + hsize_t buf_off; /* Buffer offset for copying memory */ + hsize_t last_buf_off; /* Last buffer offset for copying memory */ + hsize_t buf_size; /* Current size of the buffer to write */ intn i; /* Counters */ + uintn u; /* Counters */ intn ndims; /* Number of dimensions of dataset */ - size_t actual_write; /* The actual number of elements to read in */ - size_t actual_bytes; /* The actual number of bytes to copy */ - size_t num_write=0; /* Number of elements read */ + hsize_t actual_write; /* The actual number of elements to read in */ + hsize_t actual_bytes; /* The actual number of bytes to copy */ + hsize_t num_write=0; /* Number of elements read */ FUNC_ENTER (H5S_hyper_fwrite_opt, 0); @@ -1570,8 +1572,8 @@ printf("%s: Called!\n",FUNC); #endif /* QAK */ /* Check if this is the first element read in from the hyperslab */ if(file_iter->hyp.pos[0]==(-1)) { - for(i=0; i<file_space->extent.u.simple.rank; i++) - file_iter->hyp.pos[i]=file_space->select.sel_info.hslab.diminfo[i].start; + for(u=0; u<file_space->extent.u.simple.rank; u++) + file_iter->hyp.pos[u]=file_space->select.sel_info.hslab.diminfo[u].start; } /* end if */ #ifdef QAK @@ -1592,7 +1594,7 @@ for(i=0; i<file_space->extent.u.simple.rank; i++) /* Check if we stopped in the middle of a sequence of elements */ if((file_iter->hyp.pos[fast_dim]-file_space->select.sel_info.hslab.diminfo[fast_dim].start)%file_space->select.sel_info.hslab.diminfo[fast_dim].stride!=0 || ((file_iter->hyp.pos[fast_dim]!=file_space->select.sel_info.hslab.diminfo[fast_dim].start) && file_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 */ #ifdef QAK printf("%s: Check 1.0\n",FUNC); @@ -1690,7 +1692,7 @@ for(i=0; i<file_space->extent.u.simple.rank; i++) #endif /* QAK */ /* Set the last location & length to invalid numbers */ - last_buf_off=-1; + last_buf_off=(hsize_t)-1; buf_size=0; /* Set the local copy of the diminfo pointer */ @@ -1719,7 +1721,7 @@ for(i=0; i<file_space->extent.u.simple.rank; i++) #endif /* QAK */ /* check for the first write */ - if(last_buf_off<0) { + if(last_buf_off==(hsize_t)-1) { last_buf_off=buf_off; buf_size=actual_bytes; } /* end if */ @@ -1818,7 +1820,7 @@ for(i=0; i<file_space->extent.u.simple.rank; i++) } /* end while */ /* check for the last write */ - if(last_buf_off>=0) { + if(last_buf_off!=(hsize_t)-1) { /* Write out the sequence */ if (H5F_seq_write(f, dxpl_id, layout, pline, fill, efl, file_space, elmt_size, buf_size, last_buf_off, buf)<0) { @@ -1863,10 +1865,10 @@ H5S_hyper_fscat (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, H5S_sel_iter_t *file_iter, - size_t nelmts, hid_t dxpl_id, const void *_buf) + hsize_t nelmts, hid_t dxpl_id, const void *_buf) { H5S_hyper_io_info_t io_info; /* Block of parameters to pass into recursive calls */ - size_t num_written=0; /* number of elements read into buffer */ + hsize_t num_written=0; /* number of elements read into buffer */ herr_t ret_value=SUCCEED; FUNC_ENTER (H5S_hyper_fscat, 0); @@ -1938,7 +1940,7 @@ H5S_hyper_fscat (H5F_t *f, const struct H5O_layout_t *layout, * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_hyper_mread (intn dim, H5S_hyper_io_info_t *io_info) { hsize_t region_size; /* Size of lowest region */ @@ -1946,7 +1948,7 @@ H5S_hyper_mread (intn dim, H5S_hyper_io_info_t *io_info) size_t num_regions; /* number of regions overlapped */ size_t i; /* Counters */ intn j; - size_t num_read=0; /* Number of elements read */ + hsize_t num_read=0; /* Number of elements read */ FUNC_ENTER (H5S_hyper_mread, 0); @@ -1959,7 +1961,7 @@ H5S_hyper_mread (intn dim, H5S_hyper_io_info_t *io_info) /* Get a sorted list (in the next dimension down) of the regions which */ /* overlap the current index in this dim */ if((regions=H5S_hyper_get_regions(&num_regions,io_info->space->extent.u.simple.rank, - dim+1, + (uintn)(dim+1), io_info->space->select.sel_info.hslab.hyper_lst->count, io_info->space->select.sel_info.hslab.hyper_lst->lo_bounds, io_info->iter->hyp.pos,io_info->space->select.offset))!=NULL) { @@ -1976,7 +1978,7 @@ H5S_hyper_mread (intn dim, H5S_hyper_io_info_t *io_info) FUNC,i,(int)regions[i].start,(int)regions[i].end); #endif /* QAK */ - if((dim+2)==io_info->space->extent.u.simple.rank) { + if((uintn)(dim+2)==io_info->space->extent.u.simple.rank) { /* Set up hyperslab I/O parameters which apply to all regions */ @@ -1986,7 +1988,8 @@ H5S_hyper_mread (intn dim, H5S_hyper_io_info_t *io_info) /* perform I/O on data from regions */ for(i=0; i<num_regions && io_info->nelmts>0; i++) { - region_size=MIN(io_info->nelmts,(regions[i].end-regions[i].start)+1); + H5_CHECK_OVERFLOW(io_info->nelmts,hsize_t,hssize_t); + region_size=MIN((hssize_t)io_info->nelmts,(regions[i].end-regions[i].start)+1); io_info->hsize[io_info->space->extent.u.simple.rank-1]=region_size; io_info->offset[io_info->space->extent.u.simple.rank-1]=regions[i].start; #ifdef QAK @@ -2081,10 +2084,10 @@ H5S_hyper_mread (intn dim, H5S_hyper_io_info_t *io_info) * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_hyper_mread_opt (const void *_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *_tconv_buf/*out*/) + hsize_t nelmts, void *_tconv_buf/*out*/) { hsize_t mem_size[H5O_LAYOUT_NDIMS]; /* Size of the source buffer */ hssize_t offset[H5O_LAYOUT_NDIMS]; /* Offset on disk */ @@ -2105,10 +2108,11 @@ H5S_hyper_mread_opt (const void *_buf, size_t elmt_size, hsize_t acc; /* Accumulator */ size_t buf_off; /* Buffer offset for copying memory */ intn i; /* Counters */ + uintn u; /* Counters */ intn ndims; /* Number of dimensions of dataset */ - size_t actual_read; /* The actual number of elements to read in */ - size_t actual_bytes; /* The actual number of bytes to copy */ - size_t num_read=0; /* Number of elements read */ + hsize_t actual_read; /* The actual number of elements to read in */ + hsize_t actual_bytes; /* The actual number of bytes to copy */ + hsize_t num_read=0; /* Number of elements read */ FUNC_ENTER (H5S_hyper_mread_opt, 0); @@ -2117,13 +2121,13 @@ printf("%s: Called!\n",FUNC); #endif /* QAK */ /* Check if this is the first element read in from the hyperslab */ if(mem_iter->hyp.pos[0]==(-1)) { - for(i=0; i<mem_space->extent.u.simple.rank; i++) - mem_iter->hyp.pos[i]=mem_space->select.sel_info.hslab.diminfo[i].start; + for(u=0; u<mem_space->extent.u.simple.rank; u++) + mem_iter->hyp.pos[u]=mem_space->select.sel_info.hslab.diminfo[u].start; } /* end if */ #ifdef QAK -for(i=0; i<mem_space->extent.u.simple.rank; i++) - printf("%s: mem_file->hyp.pos[%d]=%d\n",FUNC,(int)i,(int)mem_iter->hyp.pos[i]); +for(u=0; u<mem_space->extent.u.simple.rank; u++) + printf("%s: mem_file->hyp.pos[%u]=%d\n",FUNC,(unsigned)u,(int)mem_iter->hyp.pos[u]); #endif /* QAK */ /* Set the aliases for dimension information */ @@ -2174,7 +2178,8 @@ printf("%s: Check 1.0\n",FUNC); for(i=0,buf_off=0; i<ndims; i++) buf_off+=offset[i]*slab[i]; - HDmemcpy(dst,src+buf_off,actual_bytes); + assert(actual_bytes==(hsize_t)((size_t)actual_bytes)); /*check for overflow*/ + HDmemcpy(dst,src+buf_off,(size_t)actual_bytes); /* Increment the offset of the buffer */ dst+=actual_bytes; @@ -2270,7 +2275,8 @@ for(i=0; i<mem_space->extent.u.simple.rank; i++) #endif /* QAK */ /* Scatter out the rest of the sequence */ - HDmemcpy(dst,src+buf_off,actual_bytes); + assert(actual_bytes==(hsize_t)((size_t)actual_bytes)); /*check for overflow*/ + HDmemcpy(dst,src+buf_off,(size_t)actual_bytes); /* Increment the offset of the buffer */ dst+=actual_bytes; @@ -2373,13 +2379,13 @@ for(i=0; i<mem_space->extent.u.simple.rank; i++) * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_hyper_mgath (const void *_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *_tconv_buf/*out*/) + hsize_t nelmts, void *_tconv_buf/*out*/) { H5S_hyper_io_info_t io_info; /* Block of parameters to pass into recursive calls */ - size_t num_read; /* number of elements read into buffer */ + hsize_t num_read; /* number of elements read into buffer */ FUNC_ENTER (H5S_hyper_mgath, 0); @@ -2453,12 +2459,12 @@ H5S_hyper_mgath (const void *_buf, size_t elmt_size, static size_t H5S_hyper_mwrite (intn dim, H5S_hyper_io_info_t *io_info) { - hsize_t region_size; /* Size of lowest region */ + hsize_t region_size; /* Size of lowest region */ H5S_hyper_region_t *regions; /* Pointer to array of hyperslab nodes overlapped */ size_t num_regions; /* number of regions overlapped */ size_t i; /* Counters */ intn j; - size_t num_read=0; /* Number of elements read */ + hsize_t num_write=0; /* Number of elements written */ FUNC_ENTER (H5S_hyper_mwrite, 0); @@ -2470,7 +2476,7 @@ H5S_hyper_mwrite (intn dim, H5S_hyper_io_info_t *io_info) /* Get a sorted list (in the next dimension down) of the regions which */ /* overlap the current index in this dim */ if((regions=H5S_hyper_get_regions(&num_regions,io_info->space->extent.u.simple.rank, - dim+1, + (uintn)(dim+1), io_info->space->select.sel_info.hslab.hyper_lst->count, io_info->space->select.sel_info.hslab.hyper_lst->lo_bounds, io_info->iter->hyp.pos,io_info->space->select.offset))!=NULL) { @@ -2485,7 +2491,7 @@ H5S_hyper_mwrite (intn dim, H5S_hyper_io_info_t *io_info) /* Check if this is the second to last dimension in dataset */ /* (Which means that we've got a list of the regions in the fastest */ /* changing dimension and should input those regions) */ - if((dim+2)==io_info->space->extent.u.simple.rank) { + if((uintn)(dim+2)==io_info->space->extent.u.simple.rank) { /* Set up hyperslab I/O parameters which apply to all regions */ @@ -2498,7 +2504,8 @@ H5S_hyper_mwrite (intn dim, H5S_hyper_io_info_t *io_info) #endif /* QAK */ /* perform I/O on data from regions */ for(i=0; i<num_regions && io_info->nelmts>0; i++) { - region_size=MIN(io_info->nelmts, (regions[i].end-regions[i].start)+1); + H5_CHECK_OVERFLOW(io_info->nelmts,hsize_t,hssize_t); + region_size=MIN((hssize_t)io_info->nelmts, (regions[i].end-regions[i].start)+1); io_info->hsize[io_info->space->extent.u.simple.rank-1]=region_size; io_info->offset[io_info->space->extent.u.simple.rank-1]=regions[i].start; @@ -2517,7 +2524,7 @@ H5S_hyper_mwrite (intn dim, H5S_hyper_io_info_t *io_info) region_size*io_info->elmt_size; /* Increment the number of elements read */ - num_read+=region_size; + num_write+=region_size; /* Decrement the buffer left */ io_info->nelmts-=region_size; @@ -2555,7 +2562,7 @@ H5S_hyper_mwrite (intn dim, H5S_hyper_io_info_t *io_info) io_info->iter->hyp.pos[dim]=j; /* Go get the regions in the next lower dimension */ - num_read+=H5S_hyper_mwrite(dim, io_info); + num_write+=H5S_hyper_mwrite(dim, io_info); /* Advance to the next row if we got the whole region */ if(io_info->iter->hyp.pos[dim+1]==(-1)) @@ -2571,7 +2578,7 @@ H5S_hyper_mwrite (intn dim, H5S_hyper_io_info_t *io_info) H5FL_ARR_FREE(H5S_hyper_region_t,regions); } /* end if */ - FUNC_LEAVE (num_read); + FUNC_LEAVE (num_write); } /* H5S_hyper_mwrite() */ @@ -2592,10 +2599,10 @@ H5S_hyper_mwrite (intn dim, H5S_hyper_io_info_t *io_info) * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_hyper_mwrite_opt (const void *_tconv_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *_buf/*out*/) + hsize_t nelmts, void *_buf/*out*/) { hsize_t mem_size[H5O_LAYOUT_NDIMS]; /* Size of the source buffer */ hsize_t slab[H5O_LAYOUT_NDIMS]; /* Hyperslab size */ @@ -2616,10 +2623,11 @@ H5S_hyper_mwrite_opt (const void *_tconv_buf, size_t elmt_size, hsize_t acc; /* Accumulator */ size_t buf_off; /* Buffer offset for copying memory */ intn i; /* Counters */ + uintn u; /* Counters */ intn ndims; /* Number of dimensions of dataset */ - size_t actual_write; /* The actual number of elements to read in */ - size_t actual_bytes; /* The actual number of bytes to copy */ - size_t num_write=0; /* Number of elements read */ + hsize_t actual_write; /* The actual number of elements to read in */ + hsize_t actual_bytes; /* The actual number of bytes to copy */ + hsize_t num_write=0; /* Number of elements read */ FUNC_ENTER (H5S_hyper_fwrite_opt, 0); @@ -2628,13 +2636,13 @@ printf("%s: Called!, elmt_size=%d\n",FUNC,(int)elmt_size); #endif /* QAK */ /* Check if this is the first element read in from the hyperslab */ if(mem_iter->hyp.pos[0]==(-1)) { - for(i=0; i<mem_space->extent.u.simple.rank; i++) - mem_iter->hyp.pos[i]=mem_space->select.sel_info.hslab.diminfo[i].start; + for(u=0; u<mem_space->extent.u.simple.rank; u++) + mem_iter->hyp.pos[u]=mem_space->select.sel_info.hslab.diminfo[u].start; } /* end if */ #ifdef QAK -for(i=0; i<mem_space->extent.u.simple.rank; i++) - printf("%s: mem_file->hyp.pos[%d]=%d\n",FUNC,(int)i,(int)mem_iter->hyp.pos[i]); +for(u=0; u<mem_space->extent.u.simple.rank; u++) + printf("%s: mem_file->hyp.pos[%u]=%d\n",FUNC,(unsigned)u,(int)mem_iter->hyp.pos[u]); #endif /* QAK */ /* Set the aliases for a few important dimension ranks */ @@ -2686,7 +2694,8 @@ printf("%s: Check 1.0\n",FUNC); buf_off+=offset[i]*slab[i]; /* Scatter out the rest of the sequence */ - HDmemcpy(dst+buf_off,src,actual_bytes); + assert(actual_bytes==(hsize_t)((size_t)actual_bytes)); /*check for overflow*/ + HDmemcpy(dst+buf_off,src,(size_t)actual_bytes); /* Increment the offset of the buffer */ src+=actual_bytes; @@ -2782,7 +2791,8 @@ for(i=0; i<mem_space->extent.u.simple.rank; i++) #endif /* QAK */ /* Scatter out the rest of the sequence */ - HDmemcpy(dst+buf_off,src,actual_bytes); + assert(actual_bytes==(hsize_t)((size_t)actual_bytes)); /*check for overflow*/ + HDmemcpy(dst+buf_off,src,(size_t)actual_bytes); #ifdef QAK printf("%s: buf_off=%u, actual_bytes=%u\n",FUNC,(unsigned)buf_off,(int)actual_bytes); @@ -2889,10 +2899,10 @@ printf("%s: buf_off=%u, actual_bytes=%u\n",FUNC,(unsigned)buf_off,(int)actual_by static herr_t H5S_hyper_mscat (const void *_tconv_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *_buf/*out*/) + hsize_t nelmts, void *_buf/*out*/) { H5S_hyper_io_info_t io_info; /* Block of parameters to pass into recursive calls */ - size_t num_written; /* number of elements written into buffer */ + hsize_t num_written; /* number of elements written into buffer */ FUNC_ENTER (H5S_hyper_mscat, 0); @@ -2996,7 +3006,7 @@ H5S_hyper_bound_comp(const void *_b1, const void *_b2) herr_t H5S_hyper_node_add(head, start, size) H5S_hyper_node_t *head; IN: Pointer to head of hyperslab list intn endflag; IN: "size" array actually contains "end" array - intn rank; IN: # of dimensions of the node + uintn rank; IN: # of dimensions of the node const hssize_t *start; IN: Offset of block const hsize_t *size; IN: Size of block RETURNS @@ -3009,10 +3019,10 @@ H5S_hyper_bound_comp(const void *_b1, const void *_b2) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_hyper_node_add (H5S_hyper_node_t **head, intn endflag, intn rank, const hssize_t *start, const hsize_t *size) +H5S_hyper_node_add (H5S_hyper_node_t **head, intn endflag, uintn rank, const hssize_t *start, const hsize_t *size) { H5S_hyper_node_t *slab; /* New hyperslab node to add */ - intn i; /* Counters */ + uintn u; /* Counters */ herr_t ret_value=SUCCEED; FUNC_ENTER (H5S_hyper_node_add, FAIL); @@ -3023,26 +3033,26 @@ H5S_hyper_node_add (H5S_hyper_node_t **head, intn endflag, intn rank, const hssi assert (size); #ifdef QAK - printf("%s: check 1.0, head=%p, *head=%p, rank=%d, endflag=%d\n",FUNC,head,*head,rank,endflag); + printf("%s: check 1.0, head=%p, *head=%p, rank=%u, endflag=%d\n",FUNC,head,*head,rank,endflag); #endif /* QAK */ /* Create new hyperslab node to insert */ if((slab = H5FL_ALLOC(H5S_hyper_node_t,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab node"); - if((slab->start = H5FL_ARR_ALLOC(hsize_t,rank,0))==NULL) + if((slab->start = H5FL_ARR_ALLOC(hsize_t,(hsize_t)rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab start boundary"); - if((slab->end = H5FL_ARR_ALLOC(hsize_t,rank,0))==NULL) + if((slab->end = H5FL_ARR_ALLOC(hsize_t,(hsize_t)rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab end boundary"); #ifdef QAK printf("%s: check 2.0, slab=%p, slab->start=%p, slab->end=%p\n",FUNC,slab,slab->start,slab->end); #endif /* QAK */ /* Set boundary on new node */ - for(i=0; i<rank; i++) { - slab->start[i]=start[i]; + for(u=0; u<rank; u++) { + slab->start[u]=start[u]; if(endflag) - slab->end[i]=size[i]; + slab->end[u]=size[u]; else - slab->end[i]=start[i]+size[i]-1; + slab->end[u]=start[u]+size[u]-1; } /* end for */ /* Prepend on list of hyperslabs for this selection */ @@ -3153,7 +3163,7 @@ H5S_hyper_add (H5S_t *space, H5S_hyper_node_t *piece_lst) H5S_hyper_bound_t *tmp; /* Temporary pointer to an hyperslab bound array */ size_t elem_count; /* Number of elements in hyperslab selection */ uintn piece_count; /* Number of hyperslab pieces being added */ - intn i; /* Counters */ + uintn u; /* Counters */ herr_t ret_value=SUCCEED; FUNC_ENTER (H5S_hyper_add, FAIL); @@ -3174,13 +3184,13 @@ H5S_hyper_add (H5S_t *space, H5S_hyper_node_t *piece_lst) FUNC, (unsigned)piece_count,space->select.sel_info.hslab.hyper_lst->lo_bounds); #endif /* QAK */ /* Increase size of boundary arrays for dataspace's selection by piece_count */ - for(i=0; i<space->extent.u.simple.rank; i++) { - tmp=space->select.sel_info.hslab.hyper_lst->lo_bounds[i]; + for(u=0; u<space->extent.u.simple.rank; u++) { + tmp=space->select.sel_info.hslab.hyper_lst->lo_bounds[u]; #ifdef QAK - printf("%s: check 1.1, i=%d, space->sel_info.count=%d, tmp=%p\n",FUNC,(int)i, space->select.sel_info.hslab.hyper_lst->count,tmp); + printf("%s: check 1.1, u=%u, space->sel_info.count=%d, tmp=%p\n",FUNC,(unsigned)u, space->select.sel_info.hslab.hyper_lst->count,tmp); #endif /* QAK */ - if((space->select.sel_info.hslab.hyper_lst->lo_bounds[i]=H5FL_ARR_REALLOC(H5S_hyper_bound_t,tmp,(space->select.sel_info.hslab.hyper_lst->count+piece_count)))==NULL) { - space->select.sel_info.hslab.hyper_lst->lo_bounds[i]=tmp; + if((space->select.sel_info.hslab.hyper_lst->lo_bounds[u]=H5FL_ARR_REALLOC(H5S_hyper_bound_t,tmp,(hsize_t)(space->select.sel_info.hslab.hyper_lst->count+piece_count)))==NULL) { + space->select.sel_info.hslab.hyper_lst->lo_bounds[u]=tmp; HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab lo boundary array"); } /* end if */ @@ -3200,12 +3210,12 @@ H5S_hyper_add (H5S_t *space, H5S_hyper_node_t *piece_lst) printf("%s: check 3.0\n",FUNC); #endif /* QAK */ /* Set boundary on new node */ - for(i=0,elem_count=1; i<space->extent.u.simple.rank; i++) { + for(u=0,elem_count=1; u<space->extent.u.simple.rank; u++) { #ifdef QAK - printf("%s: check 3.1, %d: start=%d, end=%d, elem_count=%d\n", - FUNC,(int)i,(int)start[i],(int)end[i],(int)elem_count); + printf("%s: check 3.1, %u: start=%d, end=%d, elem_count=%d\n", + FUNC,(unsigned)u,(int)start[u],(int)end[u],(int)elem_count); #endif /* QAK */ - elem_count*=(slab->end[i]-slab->start[i])+1; + elem_count*=(slab->end[u]-slab->start[u])+1; } /* end for */ /* Initialize caching parameters */ @@ -3217,27 +3227,27 @@ H5S_hyper_add (H5S_t *space, H5S_hyper_node_t *piece_lst) #ifdef QAK printf("%s: check 4.0\n",FUNC); { - intn j; + uintn v; - for(i=0; i<space->extent.u.simple.rank; i++) { - for(j=0; j<(int)space->select.sel_info.hslab.hyper_lst->count; j++) { - printf("%s: lo_bound[%d][%d]=%d(%p)\n", FUNC, - i,j,(int)space->select.sel_info.hslab.hyper_lst->lo_bounds[i][j].bound, - space->select.sel_info.hslab.hyper_lst->lo_bounds[i][j].node); + for(u=0; u<space->extent.u.simple.rank; u++) { + for(v=0; v<space->select.sel_info.hslab.hyper_lst->count; v++) { + printf("%s: lo_bound[%u][%u]=%d(%p)\n", FUNC, + u,v,(int)space->select.sel_info.hslab.hyper_lst->lo_bounds[u][v].bound, + space->select.sel_info.hslab.hyper_lst->lo_bounds[u][v].node); } } } #endif /* QAK */ /* Insert each boundary of the hyperslab into the sorted lists of bounds */ - for(i=0; i<space->extent.u.simple.rank; i++) { + for(u=0; u<space->extent.u.simple.rank; u++) { #ifdef QAK - printf("%s: check 4.1, start[%d]=%d, end[%d]=%d\n", - FUNC, i, (int)slab->start[i],i,(int)slab->end[i]); - printf("%s: check 4.1,.hslab.hyper_lst->count=%d\n", - FUNC,(int)space->select.sel_info.hslab.hyper_lst->count); + printf("%s: check 4.1, start[%u]=%d, end[%u]=%d\n", + FUNC, u, (int)slab->start[u],u,(int)slab->end[u]); + printf("%s: check 4.1,.hslab.hyper_lst->count=%d\n", + FUNC,(int)space->select.sel_info.hslab.hyper_lst->count); #endif /* QAK */ - space->select.sel_info.hslab.hyper_lst->lo_bounds[i][space->select.sel_info.hslab.hyper_lst->count].bound=slab->start[i]; - space->select.sel_info.hslab.hyper_lst->lo_bounds[i][space->select.sel_info.hslab.hyper_lst->count].node=slab; + space->select.sel_info.hslab.hyper_lst->lo_bounds[u][space->select.sel_info.hslab.hyper_lst->count].bound=slab->start[u]; + space->select.sel_info.hslab.hyper_lst->lo_bounds[u][space->select.sel_info.hslab.hyper_lst->count].node=slab; } /* end for */ /* Increment the number of bounds in the array */ @@ -3255,13 +3265,13 @@ H5S_hyper_add (H5S_t *space, H5S_hyper_node_t *piece_lst) #ifdef QAK printf("%s: check 6.0, elem_count=%d\n",FUNC,(int)elem_count); { - intn j; + uintn v; - for(i=0; i<space->extent.u.simple.rank; i++) { - for(j=0; j<(int)space->select.sel_info.hslab.hyper_lst->count; j++) { - printf("%s: lo_bound[%d][%d]=%d(%p)\n", FUNC, - i,j,(int)space->select.sel_info.hslab.hyper_lst->lo_bounds[i][j].bound, - space->select.sel_info.hslab.hyper_lst->lo_bounds[i][j].node); + for(u=0; u<space->extent.u.simple.rank; u++) { + for(v=0; v<space->select.sel_info.hslab.hyper_lst->count; v++) { + printf("%s: lo_bound[%u][%u]=%d(%p)\n", FUNC, + u,v,(int)space->select.sel_info.hslab.hyper_lst->lo_bounds[u][v].bound, + space->select.sel_info.hslab.hyper_lst->lo_bounds[u][v].node); } } } @@ -3269,8 +3279,8 @@ H5S_hyper_add (H5S_t *space, H5S_hyper_node_t *piece_lst) } /* end while */ /* Sort each dimension's array of bounds, now that they are all in the array */ - for(i=0; i<space->extent.u.simple.rank; i++) - HDqsort(space->select.sel_info.hslab.hyper_lst->lo_bounds[i],space->select.sel_info.hslab.hyper_lst->count,sizeof(H5S_hyper_bound_t),H5S_hyper_bound_comp); + for(u=0; u<space->extent.u.simple.rank; u++) + HDqsort(space->select.sel_info.hslab.hyper_lst->lo_bounds[u],space->select.sel_info.hslab.hyper_lst->count,sizeof(H5S_hyper_bound_t),H5S_hyper_bound_comp); done: FUNC_LEAVE (ret_value); @@ -3364,10 +3374,10 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, *new_nodes=NULL; /* List of new nodes added */ hssize_t *start=NULL; /* Temporary arrays of start & sizes (for splitting nodes) */ hsize_t *end=NULL; /* Temporary arrays of start & sizes (for splitting nodes) */ - intn rank; /* Cached copy of the rank of the dataspace */ + uintn rank; /* Cached copy of the rank of the dataspace */ intn overlapped; /* Flag for overlapping nodes */ intn non_intersect; /* Flag for non-intersecting nodes */ - intn i; /* Counters */ + uintn u; /* Counters */ enum /* Cases for edge overlaps */ {OVERLAP_BOTH,OVERLAP_LOWER,OVERLAP_UPPER,WITHIN,NO_OVERLAP} clip_case; herr_t ret_value=SUCCEED; @@ -3380,9 +3390,9 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, assert (uniq || overlap); /* Allocate space for the temporary starts & sizes */ - if((start = H5FL_ARR_ALLOC(hsize_t,space->extent.u.simple.rank,0))==NULL) + if((start = H5FL_ARR_ALLOC(hsize_t,(hsize_t)space->extent.u.simple.rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab start array"); - if((end = H5FL_ARR_ALLOC(hsize_t,space->extent.u.simple.rank,0))==NULL) + if((end = H5FL_ARR_ALLOC(hsize_t,(hsize_t)space->extent.u.simple.rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab size array"); /* Set up local variables */ @@ -3406,16 +3416,16 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, #ifdef QAK printf("%s: check 2.1, node=%p, next_node=%p\n",FUNC,node,next_node); printf("node->start={",FUNC); - for(i=0; i<rank; i++) { - printf("%d",(int)node->start[i]); - if(i<rank-1) + for(u=0; u<rank; u++) { + printf("%d",(int)node->start[u]); + if(u<rank-1) printf(", "); } /* end for */ printf("}\n"); printf("node->end={",FUNC); - for(i=0; i<rank; i++) { - printf("%d",(int)node->end[i]); - if(i<rank-1) + for(u=0; u<rank; u++) { + printf("%d",(int)node->end[u]); + if(u<rank-1) printf(", "); } /* end for */ printf("}\n"); @@ -3423,16 +3433,16 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, while(region!=NULL) { printf("new_nodes=%p, new_nodes->next=%p\n",region,region->next); printf("\tstart={",FUNC); - for(i=0; i<rank; i++) { - printf("%d",(int)region->start[i]); - if(i<rank-1) + for(u=0; u<rank; u++) { + printf("%d",(int)region->start[u]); + if(u<rank-1) printf(", "); } /* end for */ printf("}\n"); printf("\tend={",FUNC); - for(i=0; i<rank; i++) { - printf("%d",(int)region->end[i]); - if(i<rank-1) + for(u=0; u<rank; u++) { + printf("%d",(int)region->end[u]); + if(u<rank-1) printf(", "); } /* end for */ printf("}\n"); @@ -3443,16 +3453,16 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, while(region!=NULL) { printf("region=%p, region->next=%p\n",region,region->next); printf("\tstart={",FUNC); - for(i=0; i<rank; i++) { - printf("%d",(int)region->start[i]); - if(i<rank-1) + for(u=0; u<rank; u++) { + printf("%d",(int)region->start[u]); + if(u<rank-1) printf(", "); } /* end for */ printf("}\n"); printf("\tend={",FUNC); - for(i=0; i<rank; i++) { - printf("%d",(int)region->end[i]); - if(i<rank-1) + for(u=0; u<rank; u++) { + printf("%d",(int)region->end[u]); + if(u<rank-1) printf(", "); } /* end for */ printf("}\n"); @@ -3466,23 +3476,23 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, #ifdef QAK printf("%s: check 3.0, new_nodes=%p, region=%p, head=%p, overlapped=%d\n",FUNC,new_nodes,region,space->select.sel_info.hslab.hyper_lst->head,overlapped); printf("region->start={",FUNC); - for(i=0; i<rank; i++) { - printf("%d",(int)region->start[i]); - if(i<rank-1) + for(u=0; u<rank; u++) { + printf("%d",(int)region->start[u]); + if(u<rank-1) printf(", "); } /* end for */ printf("}\n"); printf("region->end={",FUNC); - for(i=0; i<rank; i++) { - printf("%d",(int)region->end[i]); - if(i<rank-1) + for(u=0; u<rank; u++) { + printf("%d",(int)region->end[u]); + if(u<rank-1) printf(", "); } /* end for */ printf("}\n"); #endif /* QAK */ /* Check for intersection */ - for(i=0, non_intersect=0; i<rank && non_intersect==0; i++) { - if(node->end[i]<region->start[i] || node->start[i]>region->end[i]) + for(u=0, non_intersect=0; u<rank && non_intersect==0; u++) { + if(node->end[u]<region->start[u] || node->start[u]>region->end[u]) non_intersect=1; } /* end for */ @@ -3492,17 +3502,17 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, /* Only compare node with regions that actually intersect */ if(non_intersect==0) { /* Compare the boundaries of the two objects in each dimension */ - for(i=0; i<rank && overlapped==0; i++) { + for(u=0; u<rank && overlapped==0; u++) { /* Find overlap case we are in */ /* True if case 1, 4 or 2b */ - if(node->start[i]<region->start[i]) { + if(node->start[u]<region->start[u]) { #ifdef QAK printf("%s: check 3.1, overlapped=%d\n",FUNC,overlapped); #endif /* QAK */ /* Test for case 4 */ /* NO_OVERLAP cases could be taken out, but are left in for clarity */ - if(node->end[i]<region->start[i]) { + if(node->end[u]<region->start[u]) { #ifdef QAK printf("%s: check 3.1.1, overlapped=%d\n",FUNC,overlapped); #endif /* QAK */ @@ -3514,7 +3524,7 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, printf("%s: check 3.1.2, overlapped=%d\n",FUNC,overlapped); #endif /* QAK */ /* Test for case 2b */ - if(node->end[i]<=region->end[i]) { + if(node->end[u]<=region->end[u]) { #ifdef QAK printf("%s: check 3.1.2.1, overlapped=%d\n",FUNC,overlapped); #endif /* QAK */ @@ -3535,7 +3545,7 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, printf("%s: check 3.2, overlapped=%d\n",FUNC,overlapped); #endif /* QAK */ /* Test for case 4 */ - if(node->start[i]>region->end[i]) { + if(node->start[u]>region->end[u]) { #ifdef QAK printf("%s: check 3.2.1, overlapped=%d\n",FUNC,overlapped); #endif /* QAK */ @@ -3548,7 +3558,7 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, printf("%s: check 3.2.2, overlapped=%d\n",FUNC,overlapped); #endif /* QAK */ /* Test for case 2a */ - if(node->end[i]>region->end[i]) { + if(node->end[u]>region->end[u]) { #ifdef QAK printf("%s: check 3.2.2.1, overlapped=%d\n",FUNC,overlapped); #endif /* QAK */ @@ -3579,9 +3589,9 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, printf("%s: check 3.4, new_nodes=%p\n",FUNC,new_nodes); #endif /* QAK */ /* Modify the end point in the current dimension of the overlap */ - end[i]=region->start[i]-1; + end[u]=region->start[u]-1; /* Clip the existing non-overlapped portion off the current node */ - node->start[i]=region->start[i]; + node->start[u]=region->start[u]; /* Add the non-overlapping portion to the list of new nodes */ if(H5S_hyper_node_add(&new_nodes,1,rank,(const hssize_t *)start,(const hsize_t *)end)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't insert hyperslab"); @@ -3590,22 +3600,22 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, #ifdef QAK { H5S_hyper_node_t *tmp_reg; /* Temp. hyperslab selection region pointer */ - intn k; + uintn v; tmp_reg=space->select.sel_info.hslab.hyper_lst->head; while(tmp_reg!=NULL) { printf("tmp_reg=%p\n",tmp_reg); printf("\tstart={",FUNC); - for(k=0; k<rank; k++) { - printf("%d",(int)tmp_reg->start[k]); - if(k<rank-1) + for(v=0; v<rank; v++) { + printf("%d",(int)tmp_reg->start[v]); + if(v<rank-1) printf(", "); } /* end for */ printf("}\n"); printf("\tend={",FUNC); - for(k=0; k<rank; k++) { - printf("%d",(int)tmp_reg->end[k]); - if(k<rank-1) + for(v=0; v<rank; v++) { + printf("%d",(int)tmp_reg->end[v]); + if(v<rank-1) printf(", "); } /* end for */ printf("}\n"); @@ -3622,10 +3632,10 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, /* Work on lower overlapping block */ if(clip_case==OVERLAP_BOTH || clip_case==OVERLAP_UPPER) { /* Modify the start & end point in the current dimension of the overlap */ - start[i]=region->end[i]+1; - end[i]=node->end[i]; + start[u]=region->end[u]+1; + end[u]=node->end[u]; /* Clip the existing non-overlapped portion off the current node */ - node->end[i]=region->end[i]; + node->end[u]=region->end[u]; /* Add the non-overlapping portion to the list of new nodes */ #ifdef QAK printf("%s: check 3.5, &new_nodes=%p, new_nodes=%p\n",FUNC,&new_nodes,new_nodes); @@ -3637,22 +3647,22 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, #ifdef QAK { H5S_hyper_node_t *tmp_reg; /* Temp. hyperslab selection region pointer */ - intn k; + uintn v; tmp_reg=space->select.sel_info.hslab.hyper_lst->head; while(tmp_reg!=NULL) { printf("tmp_reg=%p\n",tmp_reg); printf("\tstart={",FUNC); - for(k=0; k<rank; k++) { - printf("%d",(int)tmp_reg->start[k]); - if(k<rank-1) + for(v=0; v<rank; v++) { + printf("%d",(int)tmp_reg->start[v]); + if(v<rank-1) printf(", "); } /* end for */ printf("}\n"); printf("\tend={",FUNC); - for(k=0; k<rank; k++) { - printf("%d",(int)tmp_reg->end[k]); - if(k<rank-1) + for(v=0; v<rank; v++) { + printf("%d",(int)tmp_reg->end[v]); + if(v<rank-1) printf(", "); } /* end for */ printf("}\n"); @@ -3669,7 +3679,7 @@ H5S_hyper_clip (H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, /* Check if this is the last dimension */ /* Add the block to the "overlapped" list, if so */ /* Allow the algorithm to proceed to the next dimension otherwise */ - if(i==(rank-1)) { + if(u==(rank-1)) { #ifdef QAK printf("%s: check 3.6, overlapped=%d\n",FUNC,overlapped); #endif /* QAK */ @@ -3755,7 +3765,7 @@ herr_t H5S_hyper_release (H5S_t *space) { H5S_hyper_node_t *curr,*next; /* Pointer to hyperslab nodes */ - intn i; /* Counters */ + uintn u; /* Counters */ FUNC_ENTER (H5S_hyper_release, FAIL); @@ -3780,9 +3790,9 @@ H5S_hyper_release (H5S_t *space) if(space->select.sel_info.hslab.hyper_lst!=NULL) { /* Release hi and lo boundary information */ if(space->select.sel_info.hslab.hyper_lst->lo_bounds!=NULL) { - for(i=0; i<space->extent.u.simple.rank; i++) { - H5FL_ARR_FREE(H5S_hyper_bound_t,space->select.sel_info.hslab.hyper_lst->lo_bounds[i]); - space->select.sel_info.hslab.hyper_lst->lo_bounds[i] = NULL; + for(u=0; u<space->extent.u.simple.rank; u++) { + H5FL_ARR_FREE(H5S_hyper_bound_t,space->select.sel_info.hslab.hyper_lst->lo_bounds[u]); + space->select.sel_info.hslab.hyper_lst->lo_bounds[u] = NULL; } /* end for */ H5FL_ARR_FREE(H5S_hyper_bound_ptr_t,space->select.sel_info.hslab.hyper_lst->lo_bounds); space->select.sel_info.hslab.hyper_lst->lo_bounds = NULL; @@ -3921,8 +3931,8 @@ H5S_hyper_copy (H5S_t *dst, const H5S_t *src) H5S_hyper_list_t *new_hyper=NULL; /* New hyperslab selection */ H5S_hyper_node_t *curr, *new, *new_head; /* Hyperslab information nodes */ H5S_hyper_dim_t *new_diminfo=NULL; /* New per-dimension info array[rank] */ - intn i; /* Counters */ - size_t u; /* Counters */ + uintn u; /* Counters */ + size_t v; /* Counters */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER (H5S_hyper_copy, FAIL); @@ -3936,28 +3946,28 @@ H5S_hyper_copy (H5S_t *dst, const H5S_t *src) /* Check if there is regular hyperslab information to copy */ if(src->select.sel_info.hslab.diminfo!=NULL) { /* Create the per-dimension selection info */ - if((new_diminfo = H5FL_ARR_ALLOC(H5S_hyper_dim_t,src->extent.u.simple.rank,0))==NULL) + if((new_diminfo = H5FL_ARR_ALLOC(H5S_hyper_dim_t,(hsize_t)src->extent.u.simple.rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate per-dimension array"); /* Copy the per-dimension selection info */ - for(i=0; i<src->extent.u.simple.rank; i++) { - new_diminfo[i].start = src->select.sel_info.hslab.diminfo[i].start; - new_diminfo[i].stride = src->select.sel_info.hslab.diminfo[i].stride; - new_diminfo[i].count = src->select.sel_info.hslab.diminfo[i].count; - new_diminfo[i].block = src->select.sel_info.hslab.diminfo[i].block; + for(u=0; u<src->extent.u.simple.rank; u++) { + new_diminfo[u].start = src->select.sel_info.hslab.diminfo[u].start; + new_diminfo[u].stride = src->select.sel_info.hslab.diminfo[u].stride; + new_diminfo[u].count = src->select.sel_info.hslab.diminfo[u].count; + new_diminfo[u].block = src->select.sel_info.hslab.diminfo[u].block; } /* end for */ dst->select.sel_info.hslab.diminfo = new_diminfo; /* Create the per-dimension selection info */ - if((new_diminfo = H5FL_ARR_ALLOC(H5S_hyper_dim_t,src->extent.u.simple.rank,0))==NULL) + if((new_diminfo = H5FL_ARR_ALLOC(H5S_hyper_dim_t,(hsize_t)src->extent.u.simple.rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate per-dimension array"); /* Copy the per-dimension selection info */ - for(i=0; i<src->extent.u.simple.rank; i++) { - new_diminfo[i].start = src->select.sel_info.hslab.app_diminfo[i].start; - new_diminfo[i].stride = src->select.sel_info.hslab.app_diminfo[i].stride; - new_diminfo[i].count = src->select.sel_info.hslab.app_diminfo[i].count; - new_diminfo[i].block = src->select.sel_info.hslab.app_diminfo[i].block; + for(u=0; u<src->extent.u.simple.rank; u++) { + new_diminfo[u].start = src->select.sel_info.hslab.app_diminfo[u].start; + new_diminfo[u].stride = src->select.sel_info.hslab.app_diminfo[u].stride; + new_diminfo[u].count = src->select.sel_info.hslab.app_diminfo[u].count; + new_diminfo[u].block = src->select.sel_info.hslab.app_diminfo[u].block; } /* end for */ dst->select.sel_info.hslab.app_diminfo = new_diminfo; } /* end if */ @@ -3980,11 +3990,11 @@ H5S_hyper_copy (H5S_t *dst, const H5S_t *src) printf("%s: check 4.0\n", FUNC); #endif /* QAK */ /* Allocate space for the low & high bound arrays */ - if((new_hyper->lo_bounds = H5FL_ARR_ALLOC(H5S_hyper_bound_ptr_t,src->extent.u.simple.rank,0))==NULL) + if((new_hyper->lo_bounds = H5FL_ARR_ALLOC(H5S_hyper_bound_ptr_t,(hsize_t)src->extent.u.simple.rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate boundary node"); - for(i=0; i<src->extent.u.simple.rank; i++) { - if((new_hyper->lo_bounds[i] = H5FL_ARR_ALLOC(H5S_hyper_bound_t,src->select.sel_info.hslab.hyper_lst->count,0))==NULL) + for(u=0; u<src->extent.u.simple.rank; u++) { + if((new_hyper->lo_bounds[u] = H5FL_ARR_ALLOC(H5S_hyper_bound_t,(hsize_t)src->select.sel_info.hslab.hyper_lst->count,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate boundary list"); } /* end for */ @@ -3995,7 +4005,7 @@ H5S_hyper_copy (H5S_t *dst, const H5S_t *src) /* Copy the hyperslab selection nodes, adding them to the lo & hi bound arrays also */ curr=src->select.sel_info.hslab.hyper_lst->head; new_head=NULL; - u=0; + v=0; while(curr!=NULL) { #ifdef QAK printf("%s: check 5.1\n", FUNC); @@ -4005,10 +4015,10 @@ H5S_hyper_copy (H5S_t *dst, const H5S_t *src) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node"); HDmemcpy(new,curr,sizeof(H5S_hyper_node_t)); /* copy caching information */ - if((new->start = H5FL_ARR_ALLOC(hsize_t,src->extent.u.simple.rank,0))==NULL) + if((new->start = H5FL_ARR_ALLOC(hsize_t,(hsize_t)src->extent.u.simple.rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information"); - if((new->end = H5FL_ARR_ALLOC(hsize_t,src->extent.u.simple.rank,0))==NULL) + if((new->end = H5FL_ARR_ALLOC(hsize_t,(hsize_t)src->extent.u.simple.rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information"); HDmemcpy(new->start,curr->start,(src->extent.u.simple.rank*sizeof(hssize_t))); @@ -4016,11 +4026,11 @@ H5S_hyper_copy (H5S_t *dst, const H5S_t *src) new->next=NULL; /* Insert into low & high bound arrays */ - for(i=0; i<src->extent.u.simple.rank; i++) { - new_hyper->lo_bounds[i][u].bound=new->start[i]; - new_hyper->lo_bounds[i][u].node=new; + for(u=0; u<src->extent.u.simple.rank; u++) { + new_hyper->lo_bounds[u][v].bound=new->start[u]; + new_hyper->lo_bounds[u][v].node=new; } /* end for */ - u++; /* Increment the location of the next node in the boundary arrays */ + v++; /* Increment the location of the next node in the boundary arrays */ /* Keep the order the same when copying */ if(new_head==NULL) @@ -4037,8 +4047,8 @@ H5S_hyper_copy (H5S_t *dst, const H5S_t *src) #endif /* QAK */ /* Sort the boundary array */ - for(i=0; i<src->extent.u.simple.rank; i++) - HDqsort(new_hyper->lo_bounds[i], new_hyper->count, sizeof(H5S_hyper_bound_t), H5S_hyper_compare_bounds); + for(u=0; u<src->extent.u.simple.rank; u++) + HDqsort(new_hyper->lo_bounds[u], new_hyper->count, sizeof(H5S_hyper_bound_t), H5S_hyper_compare_bounds); #ifdef QAK printf("%s: check 7.0\n", FUNC); #endif /* QAK */ @@ -4076,8 +4086,8 @@ htri_t H5S_hyper_select_valid (const H5S_t *space) { H5S_hyper_node_t *curr; /* Hyperslab information nodes */ - intn i; /* Counter */ - htri_t ret_value=TRUE; /* return value */ + uintn u; /* Counter */ + htri_t ret_value=TRUE; /* return value */ FUNC_ENTER (H5S_hyper_select_valid, FAIL); @@ -4089,26 +4099,26 @@ H5S_hyper_select_valid (const H5S_t *space) hssize_t end; /* The high bound of a region in a dimension */ /* Check each dimension */ - for(i=0; i<space->extent.u.simple.rank; i++) { - /* if block or count is zero, then can skip the test since */ - /* no data point is chosen */ - if (diminfo[i].count*diminfo[i].block != 0){ - /* Bounds check the start point in this dimension */ - if((diminfo[i].start+space->select.offset[i])<0 || - (diminfo[i].start+space->select.offset[i])>=(hssize_t)space->extent.u.simple.size[i]) { - ret_value=FALSE; - break; - } /* end if */ - - /* Compute the largest location in this dimension */ - end=diminfo[i].start+diminfo[i].stride*(diminfo[i].count-1)+(diminfo[i].block-1)+space->select.offset[i]; - - /* Bounds check the end point in this dimension */ - if(end<0 || end>=(hssize_t)space->extent.u.simple.size[i]) { - ret_value=FALSE; - break; - } /* end if */ - } + for(u=0; u<space->extent.u.simple.rank; u++) { + /* if block or count is zero, then can skip the test since */ + /* no data point is chosen */ + if (diminfo[u].count*diminfo[u].block != 0) { + /* Bounds check the start point in this dimension */ + if((diminfo[u].start+space->select.offset[u])<0 || + (diminfo[u].start+space->select.offset[u])>=(hssize_t)space->extent.u.simple.size[u]) { + ret_value=FALSE; + break; + } /* end if */ + + /* Compute the largest location in this dimension */ + end=diminfo[u].start+diminfo[u].stride*(diminfo[u].count-1)+(diminfo[u].block-1)+space->select.offset[u]; + + /* Bounds check the end point in this dimension */ + if(end<0 || end>=(hssize_t)space->extent.u.simple.size[u]) { + ret_value=FALSE; + break; + } /* end if */ + } } /* end for */ } /* end if */ else { @@ -4116,13 +4126,13 @@ H5S_hyper_select_valid (const H5S_t *space) curr=space->select.sel_info.hslab.hyper_lst->head; while(curr!=NULL && ret_value==TRUE) { /* Check each dimension */ - for(i=0; i<space->extent.u.simple.rank; i++) { + for(u=0; u<space->extent.u.simple.rank; u++) { /* Check if an offset has been defined */ /* Bounds check the selected point + offset against the extent */ - if(((curr->start[i]+space->select.offset[i])>(hssize_t)space->extent.u.simple.size[i]) - || ((curr->start[i]+space->select.offset[i])<0) - || ((curr->end[i]+space->select.offset[i])>(hssize_t)space->extent.u.simple.size[i]) - || ((curr->end[i]+space->select.offset[i])<0)) { + if(((curr->start[u]+space->select.offset[u])>(hssize_t)space->extent.u.simple.size[u]) + || ((curr->start[u]+space->select.offset[u])<0) + || ((curr->end[u]+space->select.offset[u])>(hssize_t)space->extent.u.simple.size[u]) + || ((curr->end[u]+space->select.offset[u])<0)) { ret_value=FALSE; break; } /* end if */ @@ -4158,7 +4168,7 @@ hssize_t H5S_hyper_select_serial_size (const H5S_t *space) { H5S_hyper_node_t *curr; /* Hyperslab information nodes */ - intn i; /* Counter */ + uintn u; /* Counter */ hssize_t block_count; /* block counter for regular hyperslabs */ hssize_t ret_value=FAIL; /* return value */ @@ -4175,8 +4185,8 @@ H5S_hyper_select_serial_size (const H5S_t *space) /* Check for a "regular" hyperslab selection */ if(space->select.sel_info.hslab.diminfo != NULL) { /* Check each dimension */ - for(block_count=1,i=0; i<space->extent.u.simple.rank; i++) - block_count*=space->select.sel_info.hslab.diminfo[i].count; + for(block_count=1,u=0; u<space->extent.u.simple.rank; u++) + block_count*=space->select.sel_info.hslab.diminfo[u].count; ret_value+=8*block_count*space->extent.u.simple.rank; } /* end if */ else { @@ -4222,6 +4232,7 @@ H5S_hyper_select_serialize (const H5S_t *space, uint8_t *buf) uint8_t *lenp; /* pointer to length location for later storage */ uint32_t len=0; /* number of bytes used */ intn i; /* local counting variable */ + uintn u; /* local counting variable */ hssize_t block_count; /* block counter for regular hyperslabs */ intn fast_dim; /* Rank of the fastest changing dimension for the dataspace */ intn temp_dim; /* Temporary rank holder */ @@ -4355,12 +4366,12 @@ for(i=0; i<ndims; i++) len+=8*space->extent.u.simple.rank; /* Encode starting point */ - for(i=0; i<space->extent.u.simple.rank; i++) - UINT32ENCODE(buf, (uint32_t)curr->start[i]); + for(u=0; u<space->extent.u.simple.rank; u++) + UINT32ENCODE(buf, (uint32_t)curr->start[u]); /* Encode ending point */ - for(i=0; i<space->extent.u.simple.rank; i++) - UINT32ENCODE(buf, (uint32_t)curr->end[i]); + for(u=0; u<space->extent.u.simple.rank; u++) + UINT32ENCODE(buf, (uint32_t)curr->end[u]); curr=curr->next; } /* end while */ @@ -4397,7 +4408,7 @@ for(i=0; i<ndims; i++) herr_t H5S_hyper_select_deserialize (H5S_t *space, const uint8_t *buf) { - int32_t rank; /* rank of points */ + uint32_t rank; /* rank of points */ size_t num_elem=0; /* number of elements in selection */ hssize_t *start=NULL; /* hyperslab start information */ hssize_t *end=NULL; /* hyperslab end information */ @@ -4418,33 +4429,33 @@ H5S_hyper_select_deserialize (H5S_t *space, const uint8_t *buf) /* Deserialize slabs to select */ buf+=16; /* Skip over selection header */ - INT32DECODE(buf,rank); /* decode the rank of the point selection */ + UINT32DECODE(buf,rank); /* decode the rank of the point selection */ if(rank!=space->extent.u.simple.rank) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of pointer does not match dataspace"); UINT32DECODE(buf,num_elem); /* decode the number of points */ /* Allocate space for the coordinates */ - if((start = H5FL_ARR_ALLOC(hsize_t,rank,0))==NULL) + if((start = H5FL_ARR_ALLOC(hsize_t,(hsize_t)rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab information"); - if((end = H5FL_ARR_ALLOC(hsize_t,rank,0))==NULL) + if((end = H5FL_ARR_ALLOC(hsize_t,(hsize_t)rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab information"); - if((block = H5FL_ARR_ALLOC(hsize_t,rank,0))==NULL) + if((block = H5FL_ARR_ALLOC(hsize_t,(hsize_t)rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab information"); - if((count = H5FL_ARR_ALLOC(hsize_t,rank,0))==NULL) + if((count = H5FL_ARR_ALLOC(hsize_t,(hsize_t)rank,0))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab information"); /* Set the count for all blocks */ - for(tcount=count,j=0; j<(unsigned)rank; j++,tcount++) + for(tcount=count,j=0; j<rank; j++,tcount++) *tcount=1; /* Retrieve the coordinates from the buffer */ for(i=0; i<num_elem; i++) { /* Decode the starting points */ - for(tstart=start,j=0; j<(unsigned)rank; j++,tstart++) + for(tstart=start,j=0; j<rank; j++,tstart++) UINT32DECODE(buf, *tstart); /* Decode the ending points */ - for(tend=end,j=0; j<(unsigned)rank; j++,tend++) + for(tend=end,j=0; j<rank; j++,tend++) UINT32DECODE(buf, *tend); /* Change the ending points into blocks */ @@ -4564,8 +4575,8 @@ H5S_hyper_select_contiguous(const H5S_t *space) { htri_t ret_value=FAIL; /* return value */ H5S_hyper_node_t *node; /* Hyperslab node */ - intn rank; /* Dataspace rank */ - intn i; /* index variable */ + uintn rank; /* Dataspace rank */ + uintn u; /* index variable */ FUNC_ENTER (H5S_hyper_select_contiguous, FAIL); @@ -4580,8 +4591,8 @@ H5S_hyper_select_contiguous(const H5S_t *space) * dimension. */ ret_value=TRUE; /* assume true and reset if the dimensions don't match */ - for(i=1; i<space->extent.u.simple.rank; i++) { - if(space->select.sel_info.hslab.diminfo[i].block>1 || space->select.sel_info.hslab.diminfo[i].block!=space->extent.u.simple.size[i]) { + for(u=1; u<space->extent.u.simple.rank; u++) { + if(space->select.sel_info.hslab.diminfo[u].block>1 || space->select.sel_info.hslab.diminfo[u].block!=space->extent.u.simple.size[u]) { ret_value=FALSE; break; } /* end if */ @@ -4603,8 +4614,8 @@ H5S_hyper_select_contiguous(const H5S_t *space) * dataspace extent's in all but the slowest changing dimension */ ret_value=TRUE; /* assume true and reset if the dimensions don't match */ - for(i=1; i<rank; i++) { - if(((node->end[i]-node->start[i])+1)!=(hssize_t)space->extent.u.simple.size[i]) { + for(u=1; u<rank; u++) { + if(((node->end[u]-node->start[u])+1)!=(hssize_t)space->extent.u.simple.size[u]) { ret_value=FALSE; break; } /* end if */ @@ -4642,7 +4653,8 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, *uniq=NULL; /* List of unique hyperslab nodes */ uintn acc; /* Accumulator for building slices */ uintn contig; /* whether selection is contiguous or not */ - int i,j; /* Counters */ + intn i; /* Counters */ + uintn u,v; /* Counters */ herr_t ret_value=FAIL; /* return value */ FUNC_ENTER (H5S_generate_hyperslab, FAIL); @@ -4658,9 +4670,9 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, /* Determine if selection is contiguous */ /* assume hyperslab is contiguous, until proven otherwise */ contig=1; - for(i=0; i<space->extent.u.simple.rank; i++) { + for(u=0; u<space->extent.u.simple.rank; u++) { /* contiguous hyperslabs have the block size equal to the stride */ - if(stride[i]!=block[i]) { + if(stride[u]!=block[u]) { contig=0; /* hyperslab isn't contiguous */ break; /* no use looking further */ } /* end if */ @@ -4681,7 +4693,7 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, /* Set the fields for the hyperslab list */ space->select.sel_info.hslab.hyper_lst->count=0; space->select.sel_info.hslab.hyper_lst->head=NULL; - if((space->select.sel_info.hslab.hyper_lst->lo_bounds = H5FL_ARR_ALLOC(H5S_hyper_bound_ptr_t,space->extent.u.simple.rank,1))==NULL) + if((space->select.sel_info.hslab.hyper_lst->lo_bounds = H5FL_ARR_ALLOC(H5S_hyper_bound_ptr_t,(hsize_t)space->extent.u.simple.rank,1))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab lo bound information"); } /* end if */ @@ -4703,8 +4715,8 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, /* Account for strides & blocks being equal, but larger than one */ /* (Why someone would torture us this way, I don't know... -QAK :-) */ - for(i=0; i<space->extent.u.simple.rank; i++) - slab[i]=count[i]*stride[i]; + for(u=0; u<space->extent.u.simple.rank; u++) + slab[u]=count[u]*stride[u]; /* Add the contiguous hyperslab to the selection */ if(H5S_hyper_node_add(&add,0,space->extent.u.simple.rank,start,(const hsize_t *)slab)<0) { @@ -4715,9 +4727,9 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, printf("%s: check 4.3\n",FUNC); #endif /* QAK */ /* Build the slice sizes for each dimension */ - for(i=0, acc=1; i<space->extent.u.simple.rank; i++) { - slice[i]=acc; - acc*=count[i]; + for(u=0, acc=1; u<space->extent.u.simple.rank; u++) { + slice[u]=acc; + acc*=count[u]; } /* end for */ /* Step through all the blocks to add */ @@ -4725,8 +4737,8 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, /* Adding the blocks in reverse order reduces the time spent moving memory around in H5S_hyper_add() */ for(i=(int)acc-1; i>=0; i--) { /* Build the location of the block */ - for(j=0; j<space->extent.u.simple.rank; j++) - slab[j]=start[j]+((i/slice[j])%count[j])*stride[j]; + for(v=0; v<space->extent.u.simple.rank; v++) + slab[v]=start[v]+((i/slice[v])%count[v])*stride[v]; /* Add the block to the list of hyperslab selections */ if(H5S_hyper_node_add(&add,0,space->extent.u.simple.rank,(const hssize_t *)slab, (const hsize_t *)block)<0) { @@ -4798,9 +4810,9 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, const hsize_t count[/*space_id*/], const hsize_t block[/*space_id*/]) { - hsize_t *_stride=NULL; /* Stride array */ - hsize_t *_block=NULL; /* Block size array */ - int i; /* Counters */ + hsize_t *_stride=NULL; /* Stride array */ + hsize_t *_block=NULL; /* Block size array */ + uintn u; /* Counters */ H5S_hyper_dim_t *diminfo; /* per-dimension info for the selection */ herr_t ret_value=FAIL; /* return value */ @@ -4817,7 +4829,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, hssize_t fill=1; /* Allocate temporary buffer */ - if ((_stride=H5FL_ARR_ALLOC(hsize_t,space->extent.u.simple.rank,0))==NULL) + if ((_stride=H5FL_ARR_ALLOC(hsize_t,(hsize_t)space->extent.u.simple.rank,0))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for stride buffer"); H5V_array_fill(_stride,&fill,sizeof(hssize_t),space->extent.u.simple.rank); @@ -4829,7 +4841,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, hssize_t fill=1; /* Allocate temporary buffer */ - if ((_block=H5FL_ARR_ALLOC(hsize_t,space->extent.u.simple.rank,0))==NULL) + if ((_block=H5FL_ARR_ALLOC(hsize_t,(hsize_t)space->extent.u.simple.rank,0))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for stride buffer"); H5V_array_fill(_block,&fill,sizeof(hssize_t),space->extent.u.simple.rank); @@ -4845,11 +4857,11 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, * (remove when real block-merging algorithm is in place? -QAK). */ #ifdef QAK -for(i=0; i<space->extent.u.simple.rank; i++) - printf("%s: (%d) start=%d, stride=%d, count=%d, block=%d\n",FUNC,i,(int)start[i],(int)stride[i],(int)count[i],(int)block[i]); +for(u=0; u<space->extent.u.simple.rank; u++) + printf("%s: (%u) start=%d, stride=%d, count=%d, block=%d\n",FUNC,u,(int)start[u],(int)stride[u],(int)count[u],(int)block[u]); #endif /* QAK */ - for(i=0; i<space->extent.u.simple.rank; i++) { - if(count[i]>1 && stride[i]<block[i]) { + for(u=0; u<space->extent.u.simple.rank; u++) { + if(count[u]>1 && stride[u]<block[u]) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap"); } /* end if */ @@ -4862,45 +4874,45 @@ for(i=0; i<space->extent.u.simple.rank; i++) } /* end if */ /* Copy all the application per-dimension selection info into the space descriptor */ - if((diminfo = H5FL_ARR_ALLOC(H5S_hyper_dim_t,space->extent.u.simple.rank,0))==NULL) { + if((diminfo = H5FL_ARR_ALLOC(H5S_hyper_dim_t,(hsize_t)space->extent.u.simple.rank,0))==NULL) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate per-dimension vector"); } /* end if */ - for(i=0; i<space->extent.u.simple.rank; i++) { - diminfo[i].start = start[i]; - diminfo[i].stride = stride[i]; - diminfo[i].count = count[i]; - diminfo[i].block = block[i]; + for(u=0; u<space->extent.u.simple.rank; u++) { + diminfo[u].start = start[u]; + diminfo[u].stride = stride[u]; + diminfo[u].count = count[u]; + diminfo[u].block = block[u]; } /* end for */ space->select.sel_info.hslab.app_diminfo = diminfo; /* Allocate room for the optimized per-dimension selection info */ - if((diminfo = H5FL_ARR_ALLOC(H5S_hyper_dim_t,space->extent.u.simple.rank,0))==NULL) { + if((diminfo = H5FL_ARR_ALLOC(H5S_hyper_dim_t,(hsize_t)space->extent.u.simple.rank,0))==NULL) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate per-dimension vector"); } /* end if */ /* Optimize the hyperslab selection to detect contiguously selected block/stride information */ /* Modify the stride, block & count for contiguous hyperslab selections */ - for(i=0; i<space->extent.u.simple.rank; i++) { + for(u=0; u<space->extent.u.simple.rank; u++) { /* Starting location doesn't get optimized */ - diminfo[i].start = start[i]; + diminfo[u].start = start[u]; /* contiguous hyperslabs have the block size equal to the stride */ - if(stride[i]==block[i]) { - diminfo[i].stride=1; - diminfo[i].count=1; - diminfo[i].block=count[i]*block[i]; + if(stride[u]==block[u]) { + diminfo[u].stride=1; + diminfo[u].count=1; + diminfo[u].block=count[u]*block[u]; } /* end if */ else { - diminfo[i].stride=stride[i]; - diminfo[i].count=count[i]; - diminfo[i].block=block[i]; + diminfo[u].stride=stride[u]; + diminfo[u].count=count[u]; + diminfo[u].block=block[u]; } /* end else */ } /* end for */ space->select.sel_info.hslab.diminfo = diminfo; /* Set the number of elements in the hyperslab selection */ - for(space->select.num_elem=1,i=0; i<space->extent.u.simple.rank; i++) - space->select.num_elem*=block[i]*count[i]; + for(space->select.num_elem=1,u=0; u<space->extent.u.simple.rank; u++) + space->select.num_elem*=block[u]*count[u]; } /* end if */ else if(op==H5S_SELECT_OR) { switch(space->select.type) { @@ -4921,11 +4933,11 @@ for(i=0; i<space->extent.u.simple.rank; i++) /* Generate the hyperslab information for the regular hyperslab */ /* Copy over the 'diminfo' information */ - for(i=0; i<space->extent.u.simple.rank; i++) { - tmp_start[i]=space->select.sel_info.hslab.diminfo[i].start; - tmp_stride[i]=space->select.sel_info.hslab.diminfo[i].stride; - tmp_count[i]=space->select.sel_info.hslab.diminfo[i].count; - tmp_block[i]=space->select.sel_info.hslab.diminfo[i].block; + for(u=0; u<space->extent.u.simple.rank; u++) { + tmp_start[u]=space->select.sel_info.hslab.diminfo[u].start; + tmp_stride[u]=space->select.sel_info.hslab.diminfo[u].stride; + tmp_count[u]=space->select.sel_info.hslab.diminfo[u].count; + tmp_block[u]=space->select.sel_info.hslab.diminfo[u].block; } /* end for */ /* Reset the number of selection elements */ @@ -5071,7 +5083,7 @@ H5S_hyper_select_iterate_mem (intn dim, H5S_hyper_iter_info_t *iter_info) /* Get a sorted list (in the next dimension down) of the regions which */ /* overlap the current index in this dim */ if((regions=H5S_hyper_get_regions(&num_regions,iter_info->space->extent.u.simple.rank, - dim+1, + (uintn)(dim+1), iter_info->space->select.sel_info.hslab.hyper_lst->count, iter_info->space->select.sel_info.hslab.hyper_lst->lo_bounds, iter_info->iter->hyp.pos,iter_info->space->select.offset))!=NULL) { @@ -5079,7 +5091,7 @@ H5S_hyper_select_iterate_mem (intn dim, H5S_hyper_iter_info_t *iter_info) /* Check if this is the second to last dimension in dataset */ /* (Which means that we've got a list of the regions in the fastest */ /* changing dimension and should input those regions) */ - if((dim+2)==iter_info->space->extent.u.simple.rank) { + if((uintn)(dim+2)==iter_info->space->extent.u.simple.rank) { HDmemcpy(iter_info->mem_offset, iter_info->iter->hyp.pos,(iter_info->space->extent.u.simple.rank*sizeof(hssize_t))); iter_info->mem_offset[iter_info->space->extent.u.simple.rank]=0; @@ -5096,7 +5108,7 @@ H5S_hyper_select_iterate_mem (intn dim, H5S_hyper_iter_info_t *iter_info) /* Iterate over each element in the current region */ for(j=regions[i].start; j<=regions[i].end && user_ret==0; j++) { /* Call the user's function */ - user_ret=(*(iter_info->op))(tmp_buf,iter_info->dt,iter_info->space->extent.u.simple.rank,iter_info->mem_offset,iter_info->op_data); + user_ret=(*(iter_info->op))(tmp_buf,iter_info->dt,(hsize_t)iter_info->space->extent.u.simple.rank,iter_info->mem_offset,iter_info->op_data); /* Subtract the element from the selected region (not implemented yet) */ @@ -5194,9 +5206,10 @@ H5S_hyper_select_iterate_mem_opt(H5S_sel_iter_t UNUSED *iter, void *buf, hid_t t hssize_t temp_off; /* Offset in a given dimension */ uint8_t *loc; /* Current element location */ intn i; /* Counter */ + uintn u; /* Counter */ intn fast_dim; /* Rank of the fastest changing dimension for the dataspace */ intn temp_dim; /* Temporary rank holder */ - intn ndims; /* Rank of the dataspace */ + uintn ndims; /* Rank of the dataspace */ herr_t user_ret=0; /* User's return value */ FUNC_ENTER (H5S_hyper_select_iterate_mem_opt, FAIL); @@ -5220,15 +5233,15 @@ H5S_hyper_select_iterate_mem_opt(H5S_sel_iter_t UNUSED *iter, void *buf, hid_t t } /* end if */ /* Build the tables of count & block sizes as well as the initial offset */ - for(i=0; i<ndims; i++) { - tmp_count[i]=diminfo[i].count; - tmp_block[i]=diminfo[i].block; - offset[i]=diminfo[i].start; + for(u=0; u<ndims; u++) { + tmp_count[u]=diminfo[u].count; + tmp_block[u]=diminfo[u].block; + offset[u]=diminfo[u].start; } /* end for */ /* Initialize the starting location */ - for(loc=buf,i=0; i<ndims; i++) - loc+=diminfo[i].start*slab[i]; + for(loc=buf,u=0; u<ndims; u++) + loc+=diminfo[u].start*slab[u]; /* Go iterate over the hyperslabs */ while(user_ret==0) { @@ -5237,7 +5250,7 @@ H5S_hyper_select_iterate_mem_opt(H5S_sel_iter_t UNUSED *iter, void *buf, hid_t t /* Iterate over the elements in the fastest dimension */ while(tmp_block[fast_dim]>0 && user_ret==0) { - user_ret=(*op)(loc,type_id,ndims,offset,op_data); + user_ret=(*op)(loc,type_id,(hsize_t)ndims,offset,op_data); /* Increment the buffer location */ loc+=slab[fast_dim]; @@ -5305,12 +5318,12 @@ H5S_hyper_select_iterate_mem_opt(H5S_sel_iter_t UNUSED *iter, void *buf, hid_t t } /* end if */ /* Re-compute buffer location & offset array */ - for(loc=buf,i=0; i<ndims; i++) { - temp_off=diminfo[i].start - +diminfo[i].stride*(diminfo[i].count-tmp_count[i]) - +(diminfo[i].block-tmp_block[i]); - loc+=temp_off*slab[i]; - offset[i]=temp_off; + for(loc=buf,u=0; u<ndims; u++) { + temp_off=diminfo[u].start + +diminfo[u].stride*(diminfo[u].count-tmp_count[u]) + +(diminfo[u].block-tmp_block[u]); + loc+=temp_off*slab[u]; + offset[u]=temp_off; } /* end for */ } /* end while */ diff --git a/src/H5Snone.c b/src/H5Snone.c index dbfab2e..8ba47e4 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -208,7 +208,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_none_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t op, +H5S_none_select_iterate(void UNUSED *buf, hid_t UNUSED type_id, H5S_t UNUSED *space, H5D_operator_t UNUSED op, void UNUSED *operator_data) { herr_t ret_value=SUCCEED; /* return value */ diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 9fadfb5..784563d 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -23,7 +23,7 @@ */ /* Simple extent container */ typedef struct H5S_simple_t { - intn rank; /* Number of dimensions */ + uintn rank; /* Number of dimensions */ hsize_t *size; /* Current size of the dimensions */ hsize_t *max; /* Maximum size of the dimensions */ #ifdef LATER @@ -185,7 +185,7 @@ __DLL__ herr_t H5S_hyper_copy(H5S_t *dst, const H5S_t *src); __DLL__ htri_t H5S_hyper_select_valid(const H5S_t *space); __DLL__ intn H5S_hyper_bound_comp(const void *_b1, const void *_b2); __DLL__ herr_t H5S_hyper_node_add(H5S_hyper_node_t **head, intn endflag, - intn rank, const hssize_t *start, + uintn rank, const hssize_t *start, const hsize_t *size); __DLL__ herr_t H5S_hyper_clip(H5S_t *space, H5S_hyper_node_t *nodes, H5S_hyper_node_t **uniq, diff --git a/src/H5Spoint.c b/src/H5Spoint.c index d56fe82..0626a42 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -25,29 +25,29 @@ static intn interface_initialize_g = 0; static herr_t H5S_point_init (const struct H5O_layout_t *layout, const H5S_t *space, H5S_sel_iter_t *iter, size_t *min_elem_out); -static size_t H5S_point_favail (const H5S_t *space, const H5S_sel_iter_t *iter, - size_t max); -static size_t H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout, +static hsize_t H5S_point_favail (const H5S_t *space, const H5S_sel_iter_t *iter, + hsize_t max); +static hsize_t H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, - H5S_sel_iter_t *file_iter, size_t nelmts, + H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id, void *buf/*out*/); static herr_t H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, - H5S_sel_iter_t *file_iter, size_t nelmts, + H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id, const void *buf); -static size_t H5S_point_mgath (const void *_buf, size_t elmt_size, +static hsize_t H5S_point_mgath (const void *_buf, size_t elmt_size, const H5S_t *mem_space, - H5S_sel_iter_t *mem_iter, size_t nelmts, + H5S_sel_iter_t *mem_iter, hsize_t nelmts, void *_tconv_buf/*out*/); static herr_t H5S_point_mscat (const void *_tconv_buf, size_t elmt_size, const H5S_t *mem_space, - H5S_sel_iter_t *mem_iter, size_t nelmts, + H5S_sel_iter_t *mem_iter, hsize_t nelmts, void *_buf/*out*/); static herr_t H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hssize_t **coord); @@ -228,7 +228,7 @@ done: * * Purpose: Figure out the optimal number of elements to transfer to/from the file * - * Return: non-negative number of elements on success, negative on failure + * Return: non-negative number of elements on success, zero on failure * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 @@ -237,19 +237,18 @@ done: * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_point_favail (const H5S_t UNUSED *space, - const H5S_sel_iter_t *sel_iter, size_t max) + const H5S_sel_iter_t *sel_iter, hsize_t max) { - FUNC_ENTER (H5S_point_favail, FAIL); + FUNC_ENTER (H5S_point_favail, 0); /* Check args */ assert (space && H5S_SEL_POINTS==space->select.type); assert (sel_iter); #ifdef QAK - printf("%s: check 1.0, ret=%d\n", - FUNC,(int)MIN(sel_iter->pnt.elmt_left,max)); + printf("%s: check 1.0, ret=%d\n", FUNC,(int)MIN(sel_iter->pnt.elmt_left,max)); #endif /* QAK */ FUNC_LEAVE (MIN(sel_iter->pnt.elmt_left,max)); } /* H5S_point_favail() */ @@ -284,12 +283,12 @@ H5S_point_favail (const H5S_t UNUSED *space, * what the virtual file layer needs. *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, - H5S_sel_iter_t *file_iter, size_t nelmts, hid_t dxpl_id, + H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id, void *_buf/*out*/) { hssize_t file_offset[H5O_LAYOUT_NDIMS]; /*offset of slab in file*/ @@ -297,8 +296,8 @@ H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout, hssize_t zero[H5O_LAYOUT_NDIMS]; /*zero */ uint8_t *buf=(uint8_t *)_buf; /* Alias for pointer arithmetic */ uintn ndims; /* Number of dimensions of dataset */ - intn i; /*counters */ - size_t num_read; /* number of elements read into buffer */ + uintn u; /*counters */ + hsize_t num_read; /* number of elements read into buffer */ FUNC_ENTER (H5S_point_fgath, 0); @@ -316,9 +315,9 @@ H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout, #endif /* QAK */ ndims=file_space->extent.u.simple.rank; /* initialize hyperslab size and offset in memory buffer */ - for(i=0; i<(int)(ndims+1); i++) { - hsize[i]=1; /* hyperslab size is 1, except for last element */ - zero[i]=0; /* memory offset is 0 */ + for(u=0; u<ndims+1; u++) { + hsize[u]=1; /* hyperslab size is 1, except for last element */ + zero[u]=0; /* memory offset is 0 */ } /* end for */ hsize[ndims] = elmt_size; @@ -330,31 +329,25 @@ H5S_point_fgath (H5F_t *f, const struct H5O_layout_t *layout, while(num_read<nelmts) { if(file_iter->pnt.elmt_left>0) { /* Copy the location of the point to get */ - HDmemcpy(file_offset, file_iter->pnt.curr->pnt, - ndims*sizeof(hssize_t)); + HDmemcpy(file_offset, file_iter->pnt.curr->pnt, ndims*sizeof(hssize_t)); file_offset[ndims] = 0; /* Add in the offset */ - for(i=0; i<file_space->extent.u.simple.rank; i++) - file_offset[i] += file_space->select.offset[i]; + for(u=0; u<file_space->extent.u.simple.rank; u++) + file_offset[u] += file_space->select.offset[u]; /* Go read the point */ - if (H5F_arr_read(f, dxpl_id, layout, pline, fill, efl, hsize, - hsize, zero, file_offset, buf/*out*/)<0) { + if (H5F_arr_read(f, dxpl_id, layout, pline, fill, efl, hsize, hsize, zero, file_offset, buf/*out*/)<0) { HRETURN_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error"); } #ifdef QAK printf("%s: check 3.0\n",FUNC); - { - for(i=0; i<ndims; i++) { - printf("%s: %d - pnt=%d\n", - FUNC, (int)i, (int)file_iter->pnt.curr->pnt[i]); - printf("%s: %d - file_offset=%d\n", - FUNC, (int)i, (int)file_offset[i]); + for(u=0; u<ndims; u++) { + printf("%s: %u - pnt=%d\n", FUNC, (unsigned)u, (int)file_iter->pnt.curr->pnt[u]); + printf("%s: %u - file_offset=%d\n", FUNC, (unsigned)u, (int)file_offset[u]); } printf("%s: *buf=%u\n",FUNC,(unsigned)*buf); - } #endif /* QAK */ /* Increment the offset of the buffer */ buf+=elmt_size; @@ -398,7 +391,7 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, - H5S_sel_iter_t *file_iter, size_t nelmts, hid_t dxpl_id, + H5S_sel_iter_t *file_iter, hsize_t nelmts, hid_t dxpl_id, const void *_buf) { hssize_t file_offset[H5O_LAYOUT_NDIMS]; /*offset of hyperslab */ @@ -406,8 +399,8 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout, hssize_t zero[H5O_LAYOUT_NDIMS]; /*zero vector */ const uint8_t *buf=(const uint8_t *)_buf; /* Alias for pointer arithmetic */ uintn ndims; /* Number of dimensions of dataset */ - intn i; /*counters */ - size_t num_written; /* number of elements written from buffer */ + uintn u; /*counters */ + hsize_t num_written; /* number of elements written from buffer */ FUNC_ENTER (H5S_point_fscat, FAIL); @@ -425,9 +418,9 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout, #endif /* QAK */ ndims=file_space->extent.u.simple.rank; /* initialize hyperslab size and offset in memory buffer */ - for(i=0; i<(int)(ndims+1); i++) { - hsize[i]=1; /* hyperslab size is 1, except for last element */ - zero[i]=0; /* memory offset is 0 */ + for(u=0; u<ndims+1; u++) { + hsize[u]=1; /* hyperslab size is 1, except for last element */ + zero[u]=0; /* memory offset is 0 */ } /* end for */ hsize[ndims] = elmt_size; @@ -440,9 +433,8 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout, #ifdef QAK printf("%s: check 2.0\n",FUNC); { - for(i=0; i<ndims; i++) { - printf("%s: %d - pnt=%d\n", - FUNC, (int)i, (int)file_iter->pnt.curr->pnt[i]); + for(u=0; u<ndims; u++) { + printf("%s: %u - pnt=%d\n", FUNC, (unsigned)u, (int)file_iter->pnt.curr->pnt[u]); } } #endif /* QAK */ @@ -451,24 +443,19 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout, file_offset[ndims] = 0; /* Add in the offset, if there is one */ - for(i=0; i<file_space->extent.u.simple.rank; i++) - file_offset[i] += file_space->select.offset[i]; + for(u=0; u<file_space->extent.u.simple.rank; u++) + file_offset[u] += file_space->select.offset[u]; #ifdef QAK printf("%s: check 3.0\n",FUNC); - { - for(i=0; i<ndims; i++) { - printf("%s: %d - pnt=%d\n", - FUNC,(int)i,(int)file_iter->pnt.curr->pnt[i]); - printf("%s: %d - file_offset=%d\n", - FUNC,(int)i,(int)file_offset[i]); - } - printf("%s: *buf=%u\n",FUNC,(unsigned)*buf); - } + for(u=0; u<ndims; u++) { + printf("%s: %u - pnt=%d\n", FUNC,(unsigned)u,(int)file_iter->pnt.curr->pnt[u]); + printf("%s: %u - file_offset=%d\n", FUNC,(unsigned)u,(int)file_offset[u]); + } + printf("%s: *buf=%u\n",FUNC,(unsigned)*buf); #endif /* QAK */ /* Go write the point */ - if (H5F_arr_write(f, dxpl_id, layout, pline, fill, efl, hsize, - hsize, zero, file_offset, buf)<0) { + if (H5F_arr_write(f, dxpl_id, layout, pline, fill, efl, hsize, hsize, zero, file_offset, buf)<0) { HRETURN_ERROR(H5E_DATASPACE, H5E_WRITEERROR, 0, "write error"); } @@ -482,8 +469,7 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout, file_iter->pnt.elmt_left--; file_iter->pnt.curr=file_iter->pnt.curr->next; #ifdef QAK - printf("%s: check 5.0, file_iter->pnt.curr=%p\n", - FUNC,file_iter->pnt.curr); + printf("%s: check 5.0, file_iter->pnt.curr=%p\n", FUNC,file_iter->pnt.curr); #endif } /* end while */ @@ -510,10 +496,10 @@ H5S_point_fscat (H5F_t *f, const struct H5O_layout_t *layout, * *------------------------------------------------------------------------- */ -static size_t +static hsize_t H5S_point_mgath (const void *_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *_tconv_buf/*out*/) + hsize_t nelmts, void *_tconv_buf/*out*/) { hsize_t mem_size[H5O_LAYOUT_NDIMS]; /*total size of app buf */ const uint8_t *buf=(const uint8_t *)_buf; /* Get local copies for address arithmetic */ @@ -522,7 +508,7 @@ H5S_point_mgath (const void *_buf, size_t elmt_size, hsize_t off; /* coordinate offset */ intn space_ndims; /*dimensionality of space*/ intn i; /*counters */ - size_t num_gath; /* number of elements gathered */ + hsize_t num_gath; /* number of elements gathered */ FUNC_ENTER (H5S_point_mgath, 0); @@ -589,7 +575,7 @@ H5S_point_mgath (const void *_buf, size_t elmt_size, static herr_t H5S_point_mscat (const void *_tconv_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *_buf/*out*/) + hsize_t nelmts, void *_buf/*out*/) { hsize_t mem_size[H5O_LAYOUT_NDIMS]; /*total size of app buf */ uint8_t *buf=(uint8_t *)_buf; /* Get local copies for address arithmetic */ @@ -598,7 +584,7 @@ H5S_point_mscat (const void *_tconv_buf, size_t elmt_size, hsize_t off; /* coordinate offset */ intn space_ndims; /*dimensionality of space*/ intn i; /*counters */ - size_t num_scat; /* Number of elements scattered */ + hsize_t num_scat; /* Number of elements scattered */ FUNC_ENTER (H5S_point_mscat, FAIL); @@ -826,8 +812,8 @@ done: htri_t H5S_point_select_valid (const H5S_t *space) { - H5S_pnt_node_t *curr; /* Point information nodes */ - intn i; /* Counter */ + H5S_pnt_node_t *curr; /* Point information nodes */ + uintn u; /* Counter */ htri_t ret_value=TRUE; /* return value */ FUNC_ENTER (H5S_point_select_valid, FAIL); @@ -841,17 +827,17 @@ printf("%s: check 1.0\n",FUNC); curr=space->select.sel_info.pnt_lst->head; while(curr!=NULL) { /* Check each dimension */ - for(i=0; i<space->extent.u.simple.rank; i++) { + for(u=0; u<space->extent.u.simple.rank; u++) { #ifdef QAK printf("%s: check 2.0\n",FUNC); -printf("%s: curr->pnt[%d]=%d\n",FUNC,(int)i,(int)curr->pnt[i]); -printf("%s: space->select.offset[%d]=%d\n",FUNC,(int)i,(int)space->select.offset[i]); -printf("%s: space->extent.u.simple.size[%d]=%d\n",FUNC,(int)i,(int)space->extent.u.simple.size[i]); +printf("%s: curr->pnt[%u]=%d\n",FUNC,(unsigned)u,(int)curr->pnt[u]); +printf("%s: space->select.offset[%u]=%d\n",FUNC,(unsigned)u,(int)space->select.offset[u]); +printf("%s: space->extent.u.simple.size[%u]=%d\n",FUNC,(unsigned)u,(int)space->extent.u.simple.size[u]); #endif /* QAK */ /* Check if an offset has been defined */ /* Bounds check the selected point + offset against the extent */ - if(((curr->pnt[i]+space->select.offset[i])>(hssize_t)space->extent.u.simple.size[i]) - || ((curr->pnt[i]+space->select.offset[i])<0)) { + if(((curr->pnt[u]+space->select.offset[u])>(hssize_t)space->extent.u.simple.size[u]) + || ((curr->pnt[u]+space->select.offset[u])<0)) { ret_value=FALSE; break; } /* end if */ @@ -934,10 +920,10 @@ H5S_point_select_serial_size (const H5S_t *space) herr_t H5S_point_select_serialize (const H5S_t *space, uint8_t *buf) { - H5S_pnt_node_t *curr; /* Point information nodes */ - uint8_t *lenp; /* pointer to length location for later storage */ - uint32_t len=0; /* number of bytes used */ - intn i; /* local counting variable */ + H5S_pnt_node_t *curr; /* Point information nodes */ + uint8_t *lenp; /* pointer to length location for later storage */ + uint32_t len=0; /* number of bytes used */ + uintn u; /* local counting variable */ herr_t ret_value=FAIL; /* return value */ FUNC_ENTER (H5S_point_select_serialize, FAIL); @@ -952,7 +938,7 @@ H5S_point_select_serialize (const H5S_t *space, uint8_t *buf) buf+=4; /* skip over space for length */ /* Encode number of dimensions */ - INT32ENCODE(buf, (uint32_t)space->extent.u.simple.rank); + UINT32ENCODE(buf, (uint32_t)space->extent.u.simple.rank); len+=4; /* Encode number of elements */ @@ -966,8 +952,8 @@ H5S_point_select_serialize (const H5S_t *space, uint8_t *buf) len+=4*space->extent.u.simple.rank; /* Encode each point */ - for(i=0; i<space->extent.u.simple.rank; i++) - UINT32ENCODE(buf, (uint32_t)curr->pnt[i]); + for(u=0; u<space->extent.u.simple.rank; u++) + UINT32ENCODE(buf, (uint32_t)curr->pnt[u]); curr=curr->next; } /* end while */ @@ -1004,7 +990,7 @@ herr_t H5S_point_select_deserialize (H5S_t *space, const uint8_t *buf) { H5S_seloper_t op=H5S_SELECT_SET; /* Selection operation */ - int32_t rank; /* Rank of points */ + uint32_t rank; /* Rank of points */ size_t num_elem=0; /* Number of elements in selection */ hssize_t *coord=NULL, *tcoord; /* Pointer to array of elements */ uintn i,j; /* local counting variables */ @@ -1018,7 +1004,7 @@ H5S_point_select_deserialize (H5S_t *space, const uint8_t *buf) /* Deserialize points to select */ buf+=16; /* Skip over selection header */ - INT32DECODE(buf,rank); /* decode the rank of the point selection */ + UINT32DECODE(buf,rank); /* decode the rank of the point selection */ if(rank!=space->extent.u.simple.rank) HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of pointer does not match dataspace"); UINT32DECODE(buf,num_elem); /* decode the number of points */ @@ -1330,7 +1316,7 @@ H5S_point_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t hsize_t offset; /* offset of region in buffer */ void *tmp_buf; /* temporary location of the element in the buffer */ H5S_pnt_node_t *node; /* Point node */ - intn rank; /* Dataspace rank */ + uintn rank; /* Dataspace rank */ herr_t ret_value=0; /* return value */ FUNC_ENTER (H5S_point_select_iterate, 0); @@ -1358,7 +1344,7 @@ H5S_point_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t offset=H5V_array_offset(rank+1,mem_size,(const hssize_t *)mem_offset); tmp_buf=((char *)buf+offset); - ret_value=(*op)(tmp_buf,type_id,rank,node->pnt,operator_data); + ret_value=(*op)(tmp_buf,type_id,(hsize_t)rank,node->pnt,operator_data); node=node->next; } /* end while */ diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 53a6f0a..8dfa6e3 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -85,16 +85,16 @@ typedef struct H5S_fconv_t { H5S_sel_iter_t *iter, size_t *min_elem_out); /* Determine optimal number of elements to transfer */ - size_t (*avail)(const H5S_t *file_space, const H5S_sel_iter_t *file_iter, - size_t max); + hsize_t (*avail)(const H5S_t *file_space, const H5S_sel_iter_t *file_iter, + hsize_t max); /* Gather elements from disk to type conversion buffer */ - size_t (*gath)(H5F_t *f, const struct H5O_layout_t *layout, + hsize_t (*gath)(H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_pline_t *pline, const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, H5S_sel_iter_t *file_iter, - size_t nelmts, hid_t dxpl_id, void *tconv_buf/*out*/); + hsize_t nelmts, hid_t dxpl_id, void *tconv_buf/*out*/); /* Scatter elements from type conversion buffer to disk */ herr_t (*scat)(H5F_t *f, const struct H5O_layout_t *layout, @@ -102,7 +102,7 @@ typedef struct H5S_fconv_t { const struct H5O_fill_t *fill, const struct H5O_efl_t *efl, size_t elmt_size, const H5S_t *file_space, H5S_sel_iter_t *file_iter, - size_t nelmts, hid_t dxpl_id, const void *tconv_buf); + hsize_t nelmts, hid_t dxpl_id, const void *tconv_buf); } H5S_fconv_t; typedef struct H5S_mconv_t { @@ -115,14 +115,14 @@ typedef struct H5S_mconv_t { H5S_sel_iter_t *iter, size_t *min_elem_out); /* Gather elements from app buffer to type conversion buffer */ - size_t (*gath)(const void *buf, size_t elmt_size, + hsize_t (*gath)(const void *buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *tconv_buf/*out*/); + hsize_t nelmts, void *tconv_buf/*out*/); /* Scatter elements from type conversion buffer to application buffer */ herr_t (*scat)(const void *tconv_buf, size_t elmt_size, const H5S_t *mem_space, H5S_sel_iter_t *mem_iter, - size_t nelmts, void *buf/*out*/); + hsize_t nelmts, void *buf/*out*/); } H5S_mconv_t; typedef struct H5S_conv_t { diff --git a/src/H5Sselect.c b/src/H5Sselect.c index c2b2fd2..b99bb53 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -69,7 +69,7 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src) /* Need to copy order information still */ /* Copy offset information */ - if (NULL==(dst->select.offset = H5FL_ARR_ALLOC(hssize_t, src->extent.u.simple.rank,1))) { + if (NULL==(dst->select.offset = H5FL_ARR_ALLOC(hssize_t,(hsize_t)src->extent.u.simple.rank,1))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } @@ -563,8 +563,7 @@ H5S_select_deserialize (H5S_t *space, const uint8_t *buf) ret_value=H5S_none_select_deserialize(space,buf); break; - case H5S_SEL_ERROR: - case H5S_SEL_N: + default: break; } @@ -592,7 +591,7 @@ static hssize_t H5S_get_select_hyper_nblocks(H5S_t *space) { hssize_t ret_value=FAIL; /* return value */ - intn i; /* Counter */ + uintn u; /* Counter */ FUNC_ENTER (H5S_get_select_hyper_nblocks, FAIL); @@ -604,13 +603,13 @@ H5S_get_select_hyper_nblocks(H5S_t *space) #ifdef QAK { H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab.diminfo; -for(i=0; i<space->extent.u.simple.rank; i++) - printf("%s: (%d) start=%d, stride=%d, count=%d, block=%d\n",FUNC,i,(int)diminfo[i].start,(int)diminfo[i].stride,(int)diminfo[i].count,(int)diminfo[i].block); +for(u=0; u<space->extent.u.simple.rank; u++) + printf("%s: (%u) start=%d, stride=%d, count=%d, block=%d\n",FUNC,u,(int)diminfo[u].start,(int)diminfo[u].stride,(int)diminfo[u].count,(int)diminfo[u].block); } #endif /*QAK */ /* Check each dimension */ - for(ret_value=1,i=0; i<space->extent.u.simple.rank; i++) - ret_value*=space->select.sel_info.hslab.app_diminfo[i].count; + for(ret_value=1,u=0; u<space->extent.u.simple.rank; u++) + ret_value*=space->select.sel_info.hslab.app_diminfo[u].count; } /* end if */ else ret_value = (hssize_t)space->select.sel_info.hslab.hyper_lst->count; @@ -1380,7 +1380,7 @@ H5T_term_interface(void) H5T_print_stats(path, &nprint/*in,out*/); path->cdata.command = H5T_CONV_FREE; if ((path->func)(FAIL, FAIL, &(path->cdata), - 0, 0, 0, NULL, NULL,H5P_DEFAULT)<0) { + (hsize_t)0, 0, 0, NULL, NULL,H5P_DEFAULT)<0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { fprintf (H5DEBUG(T), "H5T: conversion function " @@ -4337,7 +4337,7 @@ H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, } HDmemset(&cdata, 0, sizeof cdata); cdata.command = H5T_CONV_INIT; - if ((func)(tmp_sid, tmp_did, &cdata, 0, 0, 0, NULL, NULL, + if ((func)(tmp_sid, tmp_did, &cdata, (hsize_t)0, 0, 0, NULL, NULL, H5P_DEFAULT)<0) { H5I_dec_ref(tmp_sid); H5I_dec_ref(tmp_did); @@ -4370,7 +4370,7 @@ H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_print_stats(old_path, &nprint); old_path->cdata.command = H5T_CONV_FREE; if ((old_path->func)(tmp_sid, tmp_did, &(old_path->cdata), - 0, 0, 0, NULL, NULL, H5P_DEFAULT)<0) { + (hsize_t)0, 0, 0, NULL, NULL, H5P_DEFAULT)<0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { fprintf (H5DEBUG(T), "H5T: conversion function 0x%08lx " @@ -4473,7 +4473,7 @@ H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, /* Shut down path */ H5T_print_stats(path, &nprint); path->cdata.command = H5T_CONV_FREE; - if ((path->func)(FAIL, FAIL, &(path->cdata), 0, 0, 0, NULL, NULL, + if ((path->func)(FAIL, FAIL, &(path->cdata), (hsize_t)0, 0, 0, NULL, NULL, H5P_DEFAULT)<0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { @@ -4619,7 +4619,7 @@ H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) *------------------------------------------------------------------------- */ herr_t -H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, void *buf, +H5Tconvert(hid_t src_id, hid_t dst_id, hsize_t nelmts, void *buf, void *background, hid_t plist_id) { H5T_path_t *tpath=NULL; /*type conversion info */ @@ -6751,7 +6751,7 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, HDstrcpy(H5T_g.path[0]->name, "no-op"); H5T_g.path[0]->func = H5T_conv_noop; H5T_g.path[0]->cdata.command = H5T_CONV_INIT; - if (H5T_conv_noop(FAIL, FAIL, &(H5T_g.path[0]->cdata), 0, 0, 0, + if (H5T_conv_noop(FAIL, FAIL, &(H5T_g.path[0]->cdata), (hsize_t)0, 0, 0, NULL, NULL, H5P_DEFAULT)<0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { @@ -6843,7 +6843,7 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, "query"); } path->cdata.command = H5T_CONV_INIT; - if ((func)(src_id, dst_id, &(path->cdata), 0, 0, 0, NULL, NULL, + if ((func)(src_id, dst_id, &(path->cdata), (hsize_t)0, 0, 0, NULL, NULL, H5P_DEFAULT)<0) { HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function"); @@ -6876,7 +6876,7 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, } path->cdata.command = H5T_CONV_INIT; if ((H5T_g.soft[i].func) (src_id, dst_id, &(path->cdata), - 0, 0, 0, NULL, NULL, H5P_DEFAULT)<0) { + (hsize_t)0, 0, 0, NULL, NULL, H5P_DEFAULT)<0) { HDmemset (&(path->cdata), 0, sizeof(H5T_cdata_t)); H5E_clear(); /*ignore the error*/ } else { @@ -6898,7 +6898,7 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, assert(table==H5T_g.path[md]); H5T_print_stats(table, &nprint/*in,out*/); table->cdata.command = H5T_CONV_FREE; - if ((table->func)(FAIL, FAIL, &(table->cdata), 0, 0, 0, NULL, NULL, + if ((table->func)(FAIL, FAIL, &(table->cdata), (hsize_t)0, 0, 0, NULL, NULL, H5P_DEFAULT)<0) { #ifdef H5T_DEBUG if (H5DEBUG(T)) { @@ -6991,7 +6991,7 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, *------------------------------------------------------------------------- */ herr_t -H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, size_t nelmts, +H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist) { @@ -69,7 +69,7 @@ static char RcsId[] = "@(#)$Revision$"; #include <H5TBprivate.h> /*Threaded, balanced, binary trees */ # define KEYcmp(k1,k2,a) ((NULL!=compar) ? (*compar)( k1, k2, a) \ - : HDmemcmp( k1, k2, 0<(a) ? (a) : (intn)HDstrlen(k1) ) ) + : HDmemcmp( k1, k2, 0<(a) ? (a) : HDstrlen(k1) ) ) /* Return maximum of two scalar values (use arguments w/o side effects): */ #define Max(a,b) ( (a) > (b) ? (a) : (b) ) diff --git a/src/H5Tbit.c b/src/H5Tbit.c index f675794..284270e 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -216,19 +216,19 @@ H5T_bit_set_d (uint8_t *buf, size_t offset, size_t size, hsize_t val) assert (8*sizeof(val)>=size); switch (((H5T_t*)(H5I_object(H5T_NATIVE_INT_g)))->u.atomic.order) { - case H5T_ORDER_LE: - break; - - case H5T_ORDER_BE: - for (i=0, hs=sizeof(val)/2; i<hs; i++) { - uint8_t tmp = ((uint8_t*)&val)[i]; - ((uint8_t*)&val)[i] = ((uint8_t*)&val)[sizeof(val)-(i+1)]; - ((uint8_t*)&val)[sizeof(val)-(i+1)] = tmp; - } - break; - - default: - HDabort (); + case H5T_ORDER_LE: + break; + + case H5T_ORDER_BE: + for (i=0, hs=sizeof(val)/2; i<hs; i++) { + uint8_t tmp = ((uint8_t*)&val)[i]; + ((uint8_t*)&val)[i] = ((uint8_t*)&val)[sizeof(val)-(i+1)]; + ((uint8_t*)&val)[sizeof(val)-(i+1)] = tmp; + } + break; + + default: + HDabort (); } H5T_bit_copy (buf, offset, (uint8_t*)&val, 0, size); diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 9b70ea1..973782a 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -266,7 +266,7 @@ H5FL_BLK_DEFINE_STATIC(vlen_seq); /* The first part of every integer hardware conversion macro */ #define CI_BEGIN(STYPE,DTYPE,ST,DT,STRT) { \ - size_t elmtno; /*element number */ \ + hsize_t elmtno; /*element number */ \ void *src, *s; /*source buffer */ \ void *dst, *d; /*destination buffer */ \ H5T_t *st, *dt; /*data type descriptors */ \ @@ -417,27 +417,27 @@ H5FL_BLK_DEFINE_STATIC(vlen_seq); */ herr_t H5T_conv_noop(hid_t UNUSED src_id, hid_t UNUSED dst_id, H5T_cdata_t *cdata, - size_t UNUSED nelmts, size_t UNUSED buf_stride, + hsize_t UNUSED nelmts, size_t UNUSED buf_stride, size_t UNUSED bkg_stride, void UNUSED *buf, void UNUSED *background, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_noop, FAIL); switch (cdata->command) { - case H5T_CONV_INIT: - cdata->need_bkg = H5T_BKG_NO; - break; + case H5T_CONV_INIT: + cdata->need_bkg = H5T_BKG_NO; + break; - case H5T_CONV_CONV: - /* Nothing to convert */ - break; + case H5T_CONV_CONV: + /* Nothing to convert */ + break; - case H5T_CONV_FREE: - break; - - default: - HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "unknown conversion command"); + case H5T_CONV_FREE: + break; + + default: + HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "unknown conversion command"); } FUNC_LEAVE(SUCCEED); @@ -467,7 +467,7 @@ H5T_conv_noop(hid_t UNUSED src_id, hid_t UNUSED dst_id, H5T_cdata_t *cdata, *------------------------------------------------------------------------- */ herr_t -H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, +H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *_buf, void UNUSED *background, hid_t UNUSED dset_xfer_plist) { @@ -475,7 +475,8 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, uint8_t tmp; H5T_t *src = NULL; H5T_t *dst = NULL; - size_t i, j, md; + hsize_t i; + size_t j, md; FUNC_ENTER(H5T_conv_order, FAIL); @@ -574,15 +575,15 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ herr_t -H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, +H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *_buf, void UNUSED *background, hid_t UNUSED dset_xfer_plist) { uint8_t *buf = (uint8_t*)_buf; H5T_t *src=NULL, *dst=NULL; /*source and dest data types */ intn direction; /*direction of traversal */ - size_t elmtno; /*element number */ - size_t olap; /*num overlapping elements */ + hsize_t elmtno; /*element number */ + hsize_t olap; /*num overlapping elements */ size_t half_size; /*1/2 of total size for swapping*/ uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ uint8_t dbuf[256]; /*temp destination buffer */ @@ -985,7 +986,7 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) *------------------------------------------------------------------------- */ herr_t -H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, +H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *_bkg, hid_t dset_xfer_plist) { @@ -999,7 +1000,7 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */ size_t offset; /*byte offset wrt struct */ size_t src_delta; /*source stride */ - uintn elmtno; + hsize_t elmtno; intn i; /*counters */ H5T_conv_struct_t *priv = (H5T_conv_struct_t *)(cdata->priv); @@ -1097,16 +1098,13 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, dst_memb = dst->u.compnd.memb + src2dst[i]; if (dst_memb->size <= src_memb->size) { - if (H5T_convert(priv->memb_path[i], - priv->src_memb_id[i], + if (H5T_convert(priv->memb_path[i], priv->src_memb_id[i], priv->dst_memb_id[src2dst[i]], - 1, 0, 0, /*no striding (packed array)*/ - xbuf+src_memb->offset, - xbkg+dst_memb->offset, - dset_xfer_plist)<0) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, - "unable to convert compound data type " - "member"); + (hsize_t)1, 0, 0, /*no striding (packed array)*/ + xbuf+src_memb->offset, xbkg+dst_memb->offset, + dset_xfer_plist)<0) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert compound data type member"); } HDmemmove (xbuf+offset, xbuf+src_memb->offset, dst_memb->size); @@ -1133,14 +1131,12 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (dst_memb->size > src_memb->size) { offset -= src_memb->size; if (H5T_convert(priv->memb_path[i], - priv->src_memb_id[i], - priv->dst_memb_id[src2dst[i]], - 1, 0, 0, /*no striding (packed array)*/ + priv->src_memb_id[i], priv->dst_memb_id[src2dst[i]], + (hsize_t)1, 0, 0, /*no striding (packed array)*/ xbuf+offset, xbkg+dst_memb->offset, dset_xfer_plist)<0) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, - "unable to convert compound data type " - "member"); + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to convert compound data type member"); } } else { offset -= dst_memb->size; @@ -1236,8 +1232,8 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ herr_t H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t bkg_stride, - void *_buf, void *_bkg, hid_t dset_xfer_plist) + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, + void *_bkg, hid_t dset_xfer_plist) { uint8_t *buf = (uint8_t *)_buf; /*cast for pointer arithmetic */ uint8_t *bkg = (uint8_t *)_bkg; /*background pointer arithmetic */ @@ -1249,7 +1245,7 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, H5T_cmemb_t *src_memb = NULL; /*source struct member descript.*/ H5T_cmemb_t *dst_memb = NULL; /*destination struct memb desc. */ size_t offset; /*byte offset wrt struct */ - uintn elmtno; /*element counter */ + hsize_t elmtno; /*element counter */ intn i; /*counters */ H5T_conv_struct_t *priv = NULL; /*private data */ @@ -1629,7 +1625,7 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) *------------------------------------------------------------------------- */ herr_t -H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, +H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *_buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -1638,7 +1634,7 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, uint8_t *s=NULL, *d=NULL; /*src and dst BUF pointers */ intn src_delta, dst_delta; /*conversion strides */ intn n; /*src value cast as native int */ - size_t i; /*counters */ + hsize_t i; /*counters */ H5T_enum_struct_t *priv = (H5T_enum_struct_t*)(cdata->priv); FUNC_ENTER(H5T_conv_enum, FAIL); @@ -1809,7 +1805,7 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ herr_t -H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, +H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *_bkg, hid_t dset_xfer_plist) { @@ -1818,7 +1814,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, hid_t tsrc_id = -1, tdst_id = -1;/*temporary type atoms */ H5T_t *src = NULL; /*source data type */ H5T_t *dst = NULL; /*destination data type */ - size_t olap; /*num overlapping elements */ + hsize_t olap; /*num overlapping elements */ uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs */ uint8_t **dptr; /*pointer to correct destination pointer*/ size_t src_delta, dst_delta; /*source & destination stride */ @@ -1829,7 +1825,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, hsize_t conv_buf_size; /*size of conversion buffer in bytes */ uint8_t dbuf[64],*dbuf_ptr=dbuf;/*temp destination buffer */ intn direction; /*direction of traversal */ - uintn elmtno; /*element number counter */ + hsize_t elmtno; /*element number counter */ FUNC_ENTER (H5T_conv_vlen, FAIL); @@ -1843,9 +1839,9 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * conversion path. */ if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + NULL == (src = H5I_object(src_id)) || + H5I_DATATYPE != H5I_get_type(dst_id) || + NULL == (dst = H5I_object(dst_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); } assert (H5T_VLEN==src->type); @@ -1865,9 +1861,9 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Conversion. */ if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + NULL == (src = H5I_object(src_id)) || + H5I_DATATYPE != H5I_get_type(dst_id) || + NULL == (dst = H5I_object(dst_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); } @@ -1933,19 +1929,13 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Set up conversion path for base elements */ tpath = H5T_path_find(src->parent, dst->parent, NULL, NULL); - if (NULL==(tpath=H5T_path_find(src->parent, dst->parent, - NULL, NULL))) { + if (NULL==(tpath=H5T_path_find(src->parent, dst->parent, NULL, NULL))) { HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "unable to convert between src and dest " - "datatypes"); + "unable to convert between src and dest datatypes"); } else if (!H5T_IS_NOOP(tpath)) { - if ((tsrc_id = H5I_register(H5I_DATATYPE, - H5T_copy(src->parent, - H5T_COPY_ALL)))<0 || - (tdst_id = H5I_register(H5I_DATATYPE, - H5T_copy(dst->parent, - H5T_COPY_ALL)))<0) { - HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, + if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->parent, H5T_COPY_ALL)))<0 || + (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->parent, H5T_COPY_ALL)))<0) { + HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); } } @@ -1964,11 +1954,9 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * necessary */ if(conv_buf_size<MAX(src_size,dst_size)) { conv_buf_size=MAX(src_size,dst_size); - if((conv_buf=H5FL_BLK_REALLOC(vlen_seq,conv_buf, - conv_buf_size))==NULL) + if((conv_buf=H5FL_BLK_REALLOC(vlen_seq,conv_buf, conv_buf_size))==NULL) HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for type " - "conversion"); + "memory allocation failed for type conversion"); } /* end if */ /* Read in VL sequence */ @@ -1977,14 +1965,15 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, "can't read VL data"); /* Convert VL sequence */ - if (H5T_convert(tpath, tsrc_id, tdst_id, seq_len, 0, bkg_stride, + H5_CHECK_OVERFLOW(seq_len,hssize_t,hsize_t); + if (H5T_convert(tpath, tsrc_id, tdst_id, (hsize_t)seq_len, 0, bkg_stride, conv_buf, _bkg, dset_xfer_plist)<0) HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed"); /* Write sequence to destination location */ if((*(dst->u.vlen.write))(xfer_parms,dst->u.vlen.f,d,conv_buf, - seq_len,dst_base_size)<0) + (hsize_t)seq_len,(hsize_t)dst_base_size)<0) HRETURN_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data"); @@ -2010,9 +1999,10 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5FL_BLK_FREE(vlen_seq,conv_buf); /* Release the temporary datatype IDs used */ - if (tsrc_id >= 0) H5I_dec_ref(tsrc_id); - if (tdst_id >= 0) H5I_dec_ref(tdst_id); - + if (tsrc_id >= 0) + H5I_dec_ref(tsrc_id); + if (tdst_id >= 0) + H5I_dec_ref(tdst_id); break; default: /* Some other command we don't know about yet.*/ @@ -2040,7 +2030,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ herr_t -H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, +H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *_bkg, hid_t dset_xfer_plist) { @@ -2051,7 +2041,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, uint8_t *sp, *dp; /*source and dest traversal ptrs */ size_t src_delta, dst_delta; /*source & destination stride */ intn direction; /*direction of traversal */ - uintn elmtno; /*element number counter */ + hsize_t elmtno; /*element number counter */ intn i; /* local index variable */ FUNC_ENTER (H5T_conv_array, FAIL); @@ -2153,7 +2143,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, HDmemmove(dp, sp, src->size); /* Convert array */ - if (H5T_convert(tpath, tsrc_id, tdst_id, src->u.array.nelem, 0, bkg_stride, + if (H5T_convert(tpath, tsrc_id, tdst_id, (hsize_t)src->u.array.nelem, 0, bkg_stride, dp, _bkg, dset_xfer_plist)<0) HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed"); @@ -2203,16 +2193,16 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ herr_t -H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, +H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { H5T_t *src = NULL; /*source data type */ H5T_t *dst = NULL; /*destination data type */ intn direction; /*direction of traversal */ - size_t elmtno; /*element number */ + hsize_t elmtno; /*element number */ size_t half_size; /*half the type size */ - size_t olap; /*num overlapping elements */ + hsize_t olap; /*num overlapping elements */ uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ uint8_t dbuf[64]; /*temp destination buffer */ size_t first; @@ -2291,20 +2281,18 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * temporary buffer for the destination. */ if (direction>0) { - s = sp; - d = elmtno<olap ? dbuf : dp; + s = sp; + d = elmtno<olap ? dbuf : dp; } else { - s = sp; - d = elmtno+olap >= nelmts ? dbuf : dp; + s = sp; + d = elmtno+olap >= nelmts ? dbuf : dp; } #ifndef NDEBUG /* I don't quite trust the overlap calculations yet --rpm */ if (d==dbuf) { - assert ((dp>=sp && dp<sp+src->size) || - (sp>=dp && sp<dp+dst->size)); + assert ((dp>=sp && dp<sp+src->size) || (sp>=dp && sp<dp+dst->size)); } else { - assert ((dp<sp && dp+dst->size<=sp) || - (sp<dp && sp+src->size<=dp)); + assert ((dp<sp && dp+dst->size<=sp) || (sp<dp && sp+src->size<=dp)); } #endif @@ -2314,12 +2302,12 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * little endian and then we'll fix the order at the end. */ if (H5T_ORDER_BE==src->u.atomic.order) { - half_size = src->size/2; - for (i=0; i<half_size; i++) { - uint8_t tmp = s[src->size-(i+1)]; - s[src->size-(i+1)] = s[i]; - s[i] = tmp; - } + half_size = src->size/2; + for (i=0; i<half_size; i++) { + uint8_t tmp = s[src->size-(i+1)]; + s[src->size-(i+1)] = s[i]; + s[i] = tmp; + } } /* @@ -2331,183 +2319,148 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, first = (size_t)sfirst; if (sfirst<0) { - /* - * The source has no bits set and must therefore be zero. - * Set the destination to zero. - */ - H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, - FALSE); + /* + * The source has no bits set and must therefore be zero. + * Set the destination to zero. + */ + H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, FALSE); } else if (H5T_SGN_NONE==src->u.atomic.u.i.sign && H5T_SGN_NONE==dst->u.atomic.u.i.sign) { - /* - * Source and destination are both unsigned, but if the - * source has more precision bits than the destination then - * it's possible to overflow. When overflow occurs the - * destination will be set to the maximum possible value. - */ - if (src->u.atomic.prec <= dst->u.atomic.prec) { - H5T_bit_copy (d, dst->u.atomic.offset, - s, src->u.atomic.offset, - src->u.atomic.prec); - H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, - dst->u.atomic.prec-src->u.atomic.prec, FALSE); - } else if (first>=dst->u.atomic.prec) { - /*overflow*/ - if (!H5T_overflow_g || - (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - H5T_bit_set (d, dst->u.atomic.offset, - dst->u.atomic.prec, TRUE); - } - } else { - H5T_bit_copy (d, dst->u.atomic.offset, - s, src->u.atomic.offset, - dst->u.atomic.prec); - } - + /* + * Source and destination are both unsigned, but if the + * source has more precision bits than the destination then + * it's possible to overflow. When overflow occurs the + * destination will be set to the maximum possible value. + */ + if (src->u.atomic.prec <= dst->u.atomic.prec) { + H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, + src->u.atomic.prec); + H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, + dst->u.atomic.prec-src->u.atomic.prec, FALSE); + } else if (first>=dst->u.atomic.prec) { + /*overflow*/ + if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, TRUE); + } + } else { + H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, + dst->u.atomic.prec); + } + } else if (H5T_SGN_2==src->u.atomic.u.i.sign && H5T_SGN_NONE==dst->u.atomic.u.i.sign) { - /* - * If the source is signed and the destination isn't then we - * can have overflow if the source contains more bits than - * the destination (destination is set to the maximum - * possible value) or overflow if the source is negative - * (destination is set to zero). - */ - if (first+1 == src->u.atomic.prec) { - /*overflow*/ - if (!H5T_overflow_g || - (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - H5T_bit_set (d, dst->u.atomic.offset, - dst->u.atomic.prec, FALSE); - } - } else if (src->u.atomic.prec < dst->u.atomic.prec) { - H5T_bit_copy (d, dst->u.atomic.offset, - s, src->u.atomic.offset, - src->u.atomic.prec-1); - H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec-1, - (dst->u.atomic.prec-src->u.atomic.prec)+1, - FALSE); - } else if (first>=dst->u.atomic.prec) { - /*overflow*/ - if (!H5T_overflow_g || - (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - H5T_bit_set (d, dst->u.atomic.offset, - dst->u.atomic.prec, TRUE); - } - } else { - H5T_bit_copy (d, dst->u.atomic.offset, - s, src->u.atomic.offset, - dst->u.atomic.prec); - } - + /* + * If the source is signed and the destination isn't then we + * can have overflow if the source contains more bits than + * the destination (destination is set to the maximum + * possible value) or overflow if the source is negative + * (destination is set to zero). + */ + if (first+1 == src->u.atomic.prec) { + /*overflow*/ + if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, FALSE); + } + } else if (src->u.atomic.prec < dst->u.atomic.prec) { + H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, + src->u.atomic.prec-1); + H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec-1, + (dst->u.atomic.prec-src->u.atomic.prec)+1, FALSE); + } else if (first>=dst->u.atomic.prec) { + /*overflow*/ + if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, TRUE); + } + } else { + H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, + dst->u.atomic.prec); + } + } else if (H5T_SGN_NONE==src->u.atomic.u.i.sign && H5T_SGN_2==dst->u.atomic.u.i.sign) { - /* - * If the source is not signed but the destination is then - * overflow can occur in which case the destination is set to - * the largest possible value (all bits set except the msb). - */ - if (first+1 >= dst->u.atomic.prec) { - /*overflow*/ - if (!H5T_overflow_g || - (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - H5T_bit_set (d, dst->u.atomic.offset, - dst->u.atomic.prec-1, TRUE); - H5T_bit_set (d, (dst->u.atomic.offset + - dst->u.atomic.prec-1), 1, FALSE); - } - } else if (src->u.atomic.prec<dst->u.atomic.prec) { - H5T_bit_copy (d, dst->u.atomic.offset, - s, src->u.atomic.offset, - src->u.atomic.prec); - H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, - dst->u.atomic.prec-src->u.atomic.prec, FALSE); - } else { - H5T_bit_copy (d, dst->u.atomic.offset, - s, src->u.atomic.offset, - dst->u.atomic.prec); - } - + /* + * If the source is not signed but the destination is then + * overflow can occur in which case the destination is set to + * the largest possible value (all bits set except the msb). + */ + if (first+1 >= dst->u.atomic.prec) { + /*overflow*/ + if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, TRUE); + H5T_bit_set (d, (dst->u.atomic.offset + dst->u.atomic.prec-1), 1, FALSE); + } + } else if (src->u.atomic.prec<dst->u.atomic.prec) { + H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, + src->u.atomic.prec); + H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, + dst->u.atomic.prec-src->u.atomic.prec, FALSE); + } else { + H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, + dst->u.atomic.prec); + } + } else if (first+1 == src->u.atomic.prec) { - /* - * Both the source and the destination are signed and the - * source value is negative. We could experience overflow - * if the destination isn't wide enough in which case the - * destination is set to a negative number with the largest - * possible magnitude. - */ - ssize_t sfz = H5T_bit_find (s, src->u.atomic.offset, - src->u.atomic.prec-1, H5T_BIT_MSB, - FALSE); - size_t fz = (size_t)sfz; - - if (sfz>=0 && fz+1>=dst->u.atomic.prec) { - /*overflow*/ - if (!H5T_overflow_g || - (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - H5T_bit_set (d, dst->u.atomic.offset, - dst->u.atomic.prec-1, FALSE); - H5T_bit_set (d, (dst->u.atomic.offset + - dst->u.atomic.prec-1), 1, TRUE); - } - } else if (src->u.atomic.prec<dst->u.atomic.prec) { - H5T_bit_copy (d, dst->u.atomic.offset, - s, src->u.atomic.offset, - src->u.atomic.prec); - H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, - dst->u.atomic.prec-src->u.atomic.prec, TRUE); - } else { - H5T_bit_copy (d, dst->u.atomic.offset, - s, src->u.atomic.offset, - dst->u.atomic.prec); - } - + /* + * Both the source and the destination are signed and the + * source value is negative. We could experience overflow + * if the destination isn't wide enough in which case the + * destination is set to a negative number with the largest + * possible magnitude. + */ + ssize_t sfz = H5T_bit_find (s, src->u.atomic.offset, + src->u.atomic.prec-1, H5T_BIT_MSB, FALSE); + size_t fz = (size_t)sfz; + + if (sfz>=0 && fz+1>=dst->u.atomic.prec) { + /*overflow*/ + if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, FALSE); + H5T_bit_set (d, (dst->u.atomic.offset + dst->u.atomic.prec-1), 1, TRUE); + } + } else if (src->u.atomic.prec<dst->u.atomic.prec) { + H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, src->u.atomic.prec); + H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, dst->u.atomic.prec-src->u.atomic.prec, TRUE); + } else { + H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, dst->u.atomic.prec); + } + } else { - /* - * Source and destination are both signed but the source - * value is positive. We could have an overflow in which - * case the destination is set to the largest possible - * positive value. - */ - if (first+1>=dst->u.atomic.prec) { - /*overflow*/ - if (!H5T_overflow_g || - (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - H5T_bit_set (d, dst->u.atomic.offset, - dst->u.atomic.prec-1, TRUE); - H5T_bit_set (d, (dst->u.atomic.offset + - dst->u.atomic.prec-1), 1, FALSE); - } - } else if (src->u.atomic.prec<dst->u.atomic.prec) { - H5T_bit_copy (d, dst->u.atomic.offset, - s, src->u.atomic.offset, - src->u.atomic.prec); - H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, - dst->u.atomic.prec-src->u.atomic.prec, FALSE); - } else { - H5T_bit_copy (d, dst->u.atomic.offset, - s, src->u.atomic.offset, - dst->u.atomic.prec); - } + /* + * Source and destination are both signed but the source + * value is positive. We could have an overflow in which + * case the destination is set to the largest possible + * positive value. + */ + if (first+1>=dst->u.atomic.prec) { + /*overflow*/ + if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, TRUE); + H5T_bit_set (d, (dst->u.atomic.offset + dst->u.atomic.prec-1), 1, FALSE); + } + } else if (src->u.atomic.prec<dst->u.atomic.prec) { + H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, + src->u.atomic.prec); + H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, + dst->u.atomic.prec-src->u.atomic.prec, FALSE); + } else { + H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, + dst->u.atomic.prec); + } } /* * Set padding areas in destination. */ if (dst->u.atomic.offset>0) { - assert (H5T_PAD_ZERO==dst->u.atomic.lsb_pad || - H5T_PAD_ONE==dst->u.atomic.lsb_pad); - H5T_bit_set (d, 0, dst->u.atomic.offset, - H5T_PAD_ONE==dst->u.atomic.lsb_pad); + assert (H5T_PAD_ZERO==dst->u.atomic.lsb_pad || H5T_PAD_ONE==dst->u.atomic.lsb_pad); + H5T_bit_set (d, 0, dst->u.atomic.offset, (hbool_t)(H5T_PAD_ONE==dst->u.atomic.lsb_pad)); } if (dst->u.atomic.offset+dst->u.atomic.prec!=8*dst->size) { - assert (H5T_PAD_ZERO==dst->u.atomic.msb_pad || - H5T_PAD_ONE==dst->u.atomic.msb_pad); - H5T_bit_set (d, dst->u.atomic.offset+dst->u.atomic.prec, - 8*dst->size - (dst->u.atomic.offset+ - dst->u.atomic.prec), - H5T_PAD_ONE==dst->u.atomic.msb_pad); + assert (H5T_PAD_ZERO==dst->u.atomic.msb_pad || H5T_PAD_ONE==dst->u.atomic.msb_pad); + H5T_bit_set (d, dst->u.atomic.offset+dst->u.atomic.prec, + 8*dst->size - (dst->u.atomic.offset+ dst->u.atomic.prec), + (hbool_t)(H5T_PAD_ONE==dst->u.atomic.msb_pad)); } /* @@ -2515,25 +2468,26 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * beginning of loop. */ if (H5T_ORDER_BE==dst->u.atomic.order) { - half_size = dst->size/2; - for (i=0; i<half_size; i++) { - uint8_t tmp = d[dst->size-(i+1)]; - d[dst->size-(i+1)] = d[i]; - d[i] = tmp; - } + half_size = dst->size/2; + for (i=0; i<half_size; i++) { + uint8_t tmp = d[dst->size-(i+1)]; + d[dst->size-(i+1)] = d[i]; + d[i] = tmp; + } } /* * If we had used a temporary buffer for the destination then we * should copy the value to the true destination buffer. */ - if (d==dbuf) HDmemcpy (dp, d, dst->size); + if (d==dbuf) + HDmemcpy (dp, d, dst->size); if (buf_stride) { - sp += direction * buf_stride; - dp += direction * buf_stride; + sp += direction * buf_stride; + dp += direction * buf_stride; } else { - sp += direction * src->size; - dp += direction * dst->size; + sp += direction * src->size; + dp += direction * dst->size; } } @@ -2572,9 +2526,9 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ herr_t -H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, - size_t buf_stride, size_t UNUSED bkg_stride, void *buf, - void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) +H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, + size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, + hid_t UNUSED dset_xfer_plist) { /* Traversal-related variables */ H5T_t *src_p; /*source data type */ @@ -2582,9 +2536,9 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5T_atomic_t src; /*atomic source info */ H5T_atomic_t dst; /*atomic destination info */ intn direction; /*forward or backward traversal */ - size_t elmtno; /*element number */ + hsize_t elmtno; /*element number */ size_t half_size; /*half the type size */ - size_t olap; /*num overlapping elements */ + hsize_t olap; /*num overlapping elements */ ssize_t bitno; /*bit number */ uint8_t *s, *sp, *d, *dp; /*source and dest traversal ptrs*/ uint8_t dbuf[64]; /*temp destination buffer */ @@ -2597,7 +2551,7 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t mrsh; /*amount to right shift mantissa*/ hbool_t carry; /*carry after rounding mantissa */ size_t i; /*miscellaneous counters */ - size_t implied; /*destination implied bits */ + hsize_t implied; /*destination implied bits */ FUNC_ENTER (H5T_conv_f_f, FAIL); @@ -2898,7 +2852,8 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, } /* Write the exponent */ - H5T_bit_set_d(d, dst.u.f.epos, dst.u.f.esize, expo); + H5_CHECK_OVERFLOW(expo,hssize_t,hsize_t); + H5T_bit_set_d(d, dst.u.f.epos, dst.u.f.esize, (hsize_t)expo); padding: #ifndef LATER @@ -2911,17 +2866,13 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * Set external padding areas */ if (dst.offset>0) { - assert (H5T_PAD_ZERO==dst.lsb_pad || - H5T_PAD_ONE==dst.lsb_pad); - H5T_bit_set (d, 0, dst.offset, - H5T_PAD_ONE==dst.lsb_pad); + assert (H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad); + H5T_bit_set (d, 0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad)); } if (dst.offset+dst.prec!=8*dst_p->size) { - assert (H5T_PAD_ZERO==dst.msb_pad || - H5T_PAD_ONE==dst.msb_pad); - H5T_bit_set (d, dst.offset+dst.prec, - 8*dst_p->size - (dst.offset+dst.prec), - H5T_PAD_ONE==dst.msb_pad); + assert (H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad); + H5T_bit_set (d, dst.offset+dst.prec, 8*dst_p->size - (dst.offset+dst.prec), + (hbool_t)(H5T_PAD_ONE==dst.msb_pad)); } /* @@ -2982,15 +2933,15 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *------------------------------------------------------------------------- */ herr_t -H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, +H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { H5T_t *src=NULL; /*source data type */ H5T_t *dst=NULL; /*destination data type */ intn direction; /*direction of traversal */ - size_t elmtno; /*element number */ - size_t olap; /*num overlapping elements */ + hsize_t elmtno; /*element number */ + hsize_t olap; /*num overlapping elements */ size_t nchars=0; /*number of characters copied */ uint8_t *s, *sp, *d, *dp; /*src and dst traversal pointers*/ uint8_t *dbuf=NULL; /*temp buf for overlap convers. */ @@ -2999,199 +2950,204 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, FUNC_ENTER(H5T_conv_s_s, FAIL); switch (cdata->command) { - case H5T_CONV_INIT: - if (H5I_DATATYPE!=H5I_get_type(src_id) || - NULL==(src=H5I_object(src_id)) || - H5I_DATATYPE!=H5I_get_type(dst_id) || - NULL==(dst=H5I_object(dst_id))) { - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - } - if (8*src->size != src->u.atomic.prec || - 8*dst->size != dst->u.atomic.prec) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision"); - } - if (0 != src->u.atomic.offset || - 0 != dst->u.atomic.offset) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad offset"); - } - if (H5T_CSET_ASCII != src->u.atomic.u.s.cset || - H5T_CSET_ASCII != dst->u.atomic.u.s.cset) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character set"); - } - if (src->u.atomic.u.s.pad<0 || src->u.atomic.u.s.pad>=H5T_NPAD || - dst->u.atomic.u.s.pad<0 || dst->u.atomic.u.s.pad>=H5T_NPAD) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character padding"); - } - cdata->need_bkg = H5T_BKG_NO; - break; + case H5T_CONV_INIT: + if (H5I_DATATYPE!=H5I_get_type(src_id) || + NULL==(src=H5I_object(src_id)) || + H5I_DATATYPE!=H5I_get_type(dst_id) || + NULL==(dst=H5I_object(dst_id))) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); + } + if (8*src->size != src->u.atomic.prec || + 8*dst->size != dst->u.atomic.prec) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision"); + } + if (0 != src->u.atomic.offset || + 0 != dst->u.atomic.offset) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad offset"); + } + if (H5T_CSET_ASCII != src->u.atomic.u.s.cset || + H5T_CSET_ASCII != dst->u.atomic.u.s.cset) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character set"); + } + if (src->u.atomic.u.s.pad<0 || src->u.atomic.u.s.pad>=H5T_NPAD || + dst->u.atomic.u.s.pad<0 || dst->u.atomic.u.s.pad>=H5T_NPAD) { + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character padding"); + } + cdata->need_bkg = H5T_BKG_NO; + break; - case H5T_CONV_FREE: - break; + case H5T_CONV_FREE: + break; - case H5T_CONV_CONV: - /* Get the data types */ - if (H5I_DATATYPE!=H5I_get_type(src_id) || - NULL==(src=H5I_object(src_id)) || - H5I_DATATYPE!=H5I_get_type(dst_id) || - NULL==(dst=H5I_object(dst_id))) { - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - } + case H5T_CONV_CONV: + /* Get the data types */ + if (H5I_DATATYPE!=H5I_get_type(src_id) || + NULL==(src=H5I_object(src_id)) || + H5I_DATATYPE!=H5I_get_type(dst_id) || + NULL==(dst=H5I_object(dst_id))) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); + } - /* - * Do we process the values from beginning to end or vice versa? Also, - * how many of the elements have the source and destination areas - * overlapping? - */ - if (src->size==dst->size || buf_stride) { - /* - * When the source and destination are the same size we can do - * all the conversions in place. - */ - sp = dp = (uint8_t*)buf; - direction = 1; - olap = 0; - } else if (src->size>=dst->size) { - double olapd = HDceil((double)(dst->size)/ - (double)(src->size-dst->size)); - olap = (size_t)olapd; - sp = dp = (uint8_t*)buf; - direction = 1; - } else { - double olapd = HDceil((double)(src->size)/ - (double)(dst->size-src->size)); - olap = (size_t)olapd; - sp = (uint8_t*)buf + (nelmts-1) * src->size; - dp = (uint8_t*)buf + (nelmts-1) * dst->size; - direction = -1; - } + /* + * Do we process the values from beginning to end or vice versa? Also, + * how many of the elements have the source and destination areas + * overlapping? + */ + if (src->size==dst->size || buf_stride) { + /* + * When the source and destination are the same size we can do + * all the conversions in place. + */ + sp = dp = (uint8_t*)buf; + direction = 1; + olap = 0; + } else if (src->size>=dst->size) { + double olapd = HDceil((double)(dst->size)/ + (double)(src->size-dst->size)); + olap = (size_t)olapd; + sp = dp = (uint8_t*)buf; + direction = 1; + } else { + double olapd = HDceil((double)(src->size)/ + (double)(dst->size-src->size)); + olap = (size_t)olapd; + sp = (uint8_t*)buf + (nelmts-1) * src->size; + dp = (uint8_t*)buf + (nelmts-1) * dst->size; + direction = -1; + } - /* Allocate the overlap buffer */ - if (NULL==(dbuf=H5MM_malloc(dst->size))) { - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed for string conversion"); - } - - /* The conversion loop. */ - for (elmtno=0; elmtno<nelmts; elmtno++) { + /* Allocate the overlap buffer */ + if (NULL==(dbuf=H5MM_malloc(dst->size))) { + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for string conversion"); + } + + /* The conversion loop. */ + for (elmtno=0; elmtno<nelmts; elmtno++) { - /* - * If the source and destination buffers overlap then use a - * temporary buffer for the destination. - */ - if (direction>0) { - s = sp; - d = elmtno<olap ? dbuf : dp; - } else { - s = sp; - d = elmtno+olap >= nelmts ? dbuf : dp; - } + /* + * If the source and destination buffers overlap then use a + * temporary buffer for the destination. + */ + if (direction>0) { + s = sp; + d = elmtno<olap ? dbuf : dp; + } else { + s = sp; + d = elmtno+olap >= nelmts ? dbuf : dp; + } #ifndef NDEBUG - /* I don't quite trust the overlap calculations yet --rpm */ - if (src->size==dst->size || buf_stride) { - assert(s==d); - } else if (d==dbuf) { - assert((dp>=sp && dp<sp+src->size) || - (sp>=dp && sp<dp+dst->size)); - } else { - assert((dp<sp && dp+dst->size<=sp) || - (sp<dp && sp+src->size<=dp)); - } + /* I don't quite trust the overlap calculations yet --rpm */ + if (src->size==dst->size || buf_stride) { + assert(s==d); + } else if (d==dbuf) { + assert((dp>=sp && dp<sp+src->size) || + (sp>=dp && sp<dp+dst->size)); + } else { + assert((dp<sp && dp+dst->size<=sp) || + (sp<dp && sp+src->size<=dp)); + } #endif - - /* Copy characters from source to destination */ - switch (src->u.atomic.u.s.pad) { - case H5T_STR_NULLTERM: - for (nchars=0; - nchars<dst->size && nchars<src->size && s[nchars]; - nchars++) { - d[nchars] = s[nchars]; - } - break; - - case H5T_STR_NULLPAD: - for (nchars=0; - nchars<dst->size && nchars<src->size && s[nchars]; - nchars++) { - d[nchars] = s[nchars]; - } - break; - - case H5T_STR_SPACEPAD: - nchars = src->size; - while (nchars>0 && ' '==s[nchars-1]) --nchars; - nchars = MIN(dst->size, nchars); - HDmemcpy(d, s, nchars); - break; - - case H5T_STR_RESERVED_3: - case H5T_STR_RESERVED_4: - case H5T_STR_RESERVED_5: - case H5T_STR_RESERVED_6: - case H5T_STR_RESERVED_7: - case H5T_STR_RESERVED_8: - case H5T_STR_RESERVED_9: - case H5T_STR_RESERVED_10: - case H5T_STR_RESERVED_11: - case H5T_STR_RESERVED_12: - case H5T_STR_RESERVED_13: - case H5T_STR_RESERVED_14: - case H5T_STR_RESERVED_15: - case H5T_STR_ERROR: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "source string padding method not supported"); - } - - /* Terminate or pad the destination */ - switch (dst->u.atomic.u.s.pad) { - case H5T_STR_NULLTERM: - while (nchars<dst->size) d[nchars++] = '\0'; - d[dst->size-1] = '\0'; - break; - - case H5T_STR_NULLPAD: - while (nchars<dst->size) d[nchars++] = '\0'; - break; - - case H5T_STR_SPACEPAD: - while (nchars<dst->size) d[nchars++] = ' '; - break; + + /* Copy characters from source to destination */ + switch (src->u.atomic.u.s.pad) { + case H5T_STR_NULLTERM: + for (nchars=0; + nchars<dst->size && nchars<src->size && s[nchars]; + nchars++) { + d[nchars] = s[nchars]; + } + break; + + case H5T_STR_NULLPAD: + for (nchars=0; + nchars<dst->size && nchars<src->size && s[nchars]; + nchars++) { + d[nchars] = s[nchars]; + } + break; + + case H5T_STR_SPACEPAD: + nchars = src->size; + while (nchars>0 && ' '==s[nchars-1]) + --nchars; + nchars = MIN(dst->size, nchars); + HDmemcpy(d, s, nchars); + break; + + case H5T_STR_RESERVED_3: + case H5T_STR_RESERVED_4: + case H5T_STR_RESERVED_5: + case H5T_STR_RESERVED_6: + case H5T_STR_RESERVED_7: + case H5T_STR_RESERVED_8: + case H5T_STR_RESERVED_9: + case H5T_STR_RESERVED_10: + case H5T_STR_RESERVED_11: + case H5T_STR_RESERVED_12: + case H5T_STR_RESERVED_13: + case H5T_STR_RESERVED_14: + case H5T_STR_RESERVED_15: + case H5T_STR_ERROR: + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "source string padding method not supported"); + } - case H5T_STR_RESERVED_3: - case H5T_STR_RESERVED_4: - case H5T_STR_RESERVED_5: - case H5T_STR_RESERVED_6: - case H5T_STR_RESERVED_7: - case H5T_STR_RESERVED_8: - case H5T_STR_RESERVED_9: - case H5T_STR_RESERVED_10: - case H5T_STR_RESERVED_11: - case H5T_STR_RESERVED_12: - case H5T_STR_RESERVED_13: - case H5T_STR_RESERVED_14: - case H5T_STR_RESERVED_15: - case H5T_STR_ERROR: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "destination string padding method not supported"); - } + /* Terminate or pad the destination */ + switch (dst->u.atomic.u.s.pad) { + case H5T_STR_NULLTERM: + while (nchars<dst->size) + d[nchars++] = '\0'; + d[dst->size-1] = '\0'; + break; + + case H5T_STR_NULLPAD: + while (nchars<dst->size) + d[nchars++] = '\0'; + break; + + case H5T_STR_SPACEPAD: + while (nchars<dst->size) + d[nchars++] = ' '; + break; + + case H5T_STR_RESERVED_3: + case H5T_STR_RESERVED_4: + case H5T_STR_RESERVED_5: + case H5T_STR_RESERVED_6: + case H5T_STR_RESERVED_7: + case H5T_STR_RESERVED_8: + case H5T_STR_RESERVED_9: + case H5T_STR_RESERVED_10: + case H5T_STR_RESERVED_11: + case H5T_STR_RESERVED_12: + case H5T_STR_RESERVED_13: + case H5T_STR_RESERVED_14: + case H5T_STR_RESERVED_15: + case H5T_STR_ERROR: + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "destination string padding method not supported"); + } - /* - * If we used a temporary buffer for the destination then we - * should copy the value to the true destination buffer. - */ - if (d==dbuf) HDmemcpy(dp, d, dst->size); - if (buf_stride) { - sp += direction * buf_stride; - dp += direction * buf_stride; - } else { - sp += direction * src->size; - dp += direction * dst->size; - } - } - break; + /* + * If we used a temporary buffer for the destination then we + * should copy the value to the true destination buffer. + */ + if (d==dbuf) + HDmemcpy(dp, d, dst->size); + if (buf_stride) { + sp += direction * buf_stride; + dp += direction * buf_stride; + } else { + sp += direction * src->size; + dp += direction * dst->size; + } + } + break; - default: - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "unknown converson command"); + default: + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "unknown converson command"); } ret_value = SUCCEED; @@ -3219,7 +3175,7 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ herr_t H5T_conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3248,7 +3204,7 @@ H5T_conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3278,7 +3234,7 @@ H5T_conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3307,7 +3263,7 @@ H5T_conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3336,7 +3292,7 @@ H5T_conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3366,7 +3322,7 @@ H5T_conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3395,7 +3351,7 @@ H5T_conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_schar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_schar_int, FAIL); @@ -3423,7 +3379,7 @@ H5T_conv_schar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_schar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_schar_uint, FAIL); @@ -3451,7 +3407,7 @@ H5T_conv_schar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uchar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_uchar_int, FAIL); @@ -3480,7 +3436,7 @@ H5T_conv_uchar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uchar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_uchar_uint, FAIL); @@ -3508,7 +3464,7 @@ H5T_conv_uchar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_schar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_schar_long, FAIL); @@ -3536,7 +3492,7 @@ H5T_conv_schar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_schar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3565,7 +3521,7 @@ H5T_conv_schar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uchar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_uchar_long, FAIL); @@ -3594,7 +3550,7 @@ H5T_conv_uchar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uchar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3623,7 +3579,7 @@ H5T_conv_uchar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_schar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3652,7 +3608,7 @@ H5T_conv_schar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_schar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3681,7 +3637,7 @@ H5T_conv_schar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uchar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3711,7 +3667,7 @@ H5T_conv_uchar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uchar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3740,7 +3696,7 @@ H5T_conv_uchar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_short_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3770,7 +3726,7 @@ H5T_conv_short_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_short_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3800,7 +3756,7 @@ H5T_conv_short_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ushort_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3830,7 +3786,7 @@ H5T_conv_ushort_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ushort_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3860,7 +3816,7 @@ H5T_conv_ushort_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_short_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3889,7 +3845,7 @@ H5T_conv_short_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ushort_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3919,7 +3875,7 @@ H5T_conv_ushort_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_short_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3948,7 +3904,7 @@ H5T_conv_short_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_short_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -3977,7 +3933,7 @@ H5T_conv_short_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ushort_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4007,7 +3963,7 @@ H5T_conv_ushort_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ushort_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4036,7 +3992,7 @@ H5T_conv_ushort_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_short_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4065,7 +4021,7 @@ H5T_conv_short_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_short_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4094,7 +4050,7 @@ H5T_conv_short_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ushort_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4124,7 +4080,7 @@ H5T_conv_ushort_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ushort_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4153,7 +4109,7 @@ H5T_conv_ushort_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_short_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4182,7 +4138,7 @@ H5T_conv_short_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_short_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4211,7 +4167,7 @@ H5T_conv_short_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ushort_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4241,7 +4197,7 @@ H5T_conv_ushort_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ushort_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4270,7 +4226,7 @@ H5T_conv_ushort_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_int_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4300,7 +4256,7 @@ H5T_conv_int_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_int_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4330,7 +4286,7 @@ H5T_conv_int_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uint_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4360,7 +4316,7 @@ H5T_conv_uint_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uint_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4390,7 +4346,7 @@ H5T_conv_uint_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_int_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4420,7 +4376,7 @@ H5T_conv_int_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_int_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4450,7 +4406,7 @@ H5T_conv_int_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uint_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4480,7 +4436,7 @@ H5T_conv_uint_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uint_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4510,7 +4466,7 @@ H5T_conv_uint_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_int_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_int_uint, FAIL); @@ -4538,7 +4494,7 @@ H5T_conv_int_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uint_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_uint_int, FAIL); @@ -4567,7 +4523,7 @@ H5T_conv_uint_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_int_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_int_long, FAIL); @@ -4595,7 +4551,7 @@ H5T_conv_int_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_int_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_int_ulong, FAIL); @@ -4623,7 +4579,7 @@ H5T_conv_int_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uint_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_uint_long, FAIL); @@ -4652,7 +4608,7 @@ H5T_conv_uint_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uint_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_uint_ulong, FAIL); @@ -4680,7 +4636,7 @@ H5T_conv_uint_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_int_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_int_llong, FAIL); @@ -4708,7 +4664,7 @@ H5T_conv_int_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_int_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_int_ullong, FAIL); @@ -4736,7 +4692,7 @@ H5T_conv_int_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uint_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_uint_llong, FAIL); @@ -4765,7 +4721,7 @@ H5T_conv_uint_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_uint_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4794,7 +4750,7 @@ H5T_conv_uint_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_long_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_long_schar, FAIL); @@ -4823,7 +4779,7 @@ H5T_conv_long_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_long_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_long_uchar, FAIL); @@ -4852,7 +4808,7 @@ H5T_conv_long_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ulong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4882,7 +4838,7 @@ H5T_conv_ulong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ulong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4912,7 +4868,7 @@ H5T_conv_ulong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_long_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_long_short, FAIL); @@ -4941,7 +4897,7 @@ H5T_conv_long_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_long_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -4971,7 +4927,7 @@ H5T_conv_long_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ulong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_ulong_short, FAIL); @@ -5000,7 +4956,7 @@ H5T_conv_ulong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ulong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5030,7 +4986,7 @@ H5T_conv_ulong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_long_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_long_int, FAIL); @@ -5059,7 +5015,7 @@ H5T_conv_long_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_long_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_long_uint, FAIL); @@ -5088,7 +5044,7 @@ H5T_conv_long_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ulong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_ulong_int, FAIL); @@ -5117,7 +5073,7 @@ H5T_conv_ulong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ulong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_ulong_uint, FAIL); @@ -5146,7 +5102,7 @@ H5T_conv_ulong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_long_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_long_ulong, FAIL); @@ -5174,7 +5130,7 @@ H5T_conv_long_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ulong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_ulong_long, FAIL); @@ -5203,7 +5159,7 @@ H5T_conv_ulong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_long_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_long_llong, FAIL); @@ -5231,7 +5187,7 @@ H5T_conv_long_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_long_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5260,7 +5216,7 @@ H5T_conv_long_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ulong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5290,7 +5246,7 @@ H5T_conv_ulong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ulong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5319,7 +5275,7 @@ H5T_conv_ulong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_llong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5349,7 +5305,7 @@ H5T_conv_llong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_llong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5379,7 +5335,7 @@ H5T_conv_llong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ullong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5409,7 +5365,7 @@ H5T_conv_ullong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ullong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5439,7 +5395,7 @@ H5T_conv_ullong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_llong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5469,7 +5425,7 @@ H5T_conv_llong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_llong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5499,7 +5455,7 @@ H5T_conv_llong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ullong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5529,7 +5485,7 @@ H5T_conv_ullong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ullong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5559,7 +5515,7 @@ H5T_conv_ullong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_llong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_llong_int, FAIL); @@ -5588,7 +5544,7 @@ H5T_conv_llong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_llong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_llong_uint, FAIL); @@ -5617,7 +5573,7 @@ H5T_conv_llong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ullong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_ullong_int, FAIL); @@ -5646,7 +5602,7 @@ H5T_conv_ullong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ullong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5676,7 +5632,7 @@ H5T_conv_ullong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_llong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { FUNC_ENTER(H5T_conv_llong_long, FAIL); @@ -5705,7 +5661,7 @@ H5T_conv_llong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_llong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5735,7 +5691,7 @@ H5T_conv_llong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ullong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5765,7 +5721,7 @@ H5T_conv_ullong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ullong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5795,7 +5751,7 @@ H5T_conv_ullong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_llong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5824,7 +5780,7 @@ H5T_conv_llong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_ullong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { @@ -5857,11 +5813,11 @@ H5T_conv_ullong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_float_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { - size_t elmtno; /*element number */ + hsize_t elmtno; /*element number */ uint8_t *src, *s; /*source buffer */ uint8_t *dst, *d; /*destination buffer */ H5T_t *st, *dt; /*type descriptors */ @@ -5871,82 +5827,85 @@ H5T_conv_float_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, FUNC_ENTER (H5T_conv_float_double, FAIL); switch (cdata->command) { - case H5T_CONV_INIT: - cdata->need_bkg = H5T_BKG_NO; - if (NULL==(st=H5I_object(src_id)) || - NULL==(dt=H5I_object(dst_id))) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, - "unable to dereference data type object ID"); - } - if (st->size!=sizeof(float) || dt->size!=sizeof(double)) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, - "disagreement about data type size"); - } - CI_ALLOC_PRIV - break; - - case H5T_CONV_FREE: - CI_PRINT_STATS(FLOAT, DOUBLE); - CI_FREE_PRIV - break; - - case H5T_CONV_CONV: - if (buf_stride) { - src = dst = (uint8_t*)buf + buf_stride*(nelmts-1); - } else { - src = (uint8_t*)buf + sizeof(float)*(nelmts-1); - dst = (uint8_t*)buf + sizeof(double)*(nelmts-1); - } - - /* Need alignment? */ - if (H5T_NATIVE_FLOAT_ALIGN_g>1) { - src_mv = ((size_t)buf % H5T_NATIVE_FLOAT_ALIGN_g) || - ((buf_stride?buf_stride:sizeof(float)) % - H5T_NATIVE_FLOAT_ALIGN_g); - } else { - src_mv = FALSE; - } - if (H5T_NATIVE_DOUBLE_ALIGN_g>1) { - dst_mv = ((size_t)buf % H5T_NATIVE_DOUBLE_ALIGN_g) || - ((buf_stride?buf_stride:sizeof(double)) % - H5T_NATIVE_DOUBLE_ALIGN_g); - } else { - dst_mv = FALSE; - } - CI_INC_SRC(src_mv) - CI_INC_DST(dst_mv) - - for (elmtno=0; elmtno<nelmts; elmtno++) { - /* Align source and/or destination */ - if (src_mv) { - HDmemcpy(&aligned, src, sizeof(float)); - s = (uint8_t*)&aligned; - } else { - s = src; - } - if (dst_mv) d = (uint8_t*)&aligned; - else d = dst; - - /* Conversion */ - *((double*)d) = *((float*)s); + case H5T_CONV_INIT: + cdata->need_bkg = H5T_BKG_NO; + if (NULL==(st=H5I_object(src_id)) || + NULL==(dt=H5I_object(dst_id))) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to dereference data type object ID"); + } + if (st->size!=sizeof(float) || dt->size!=sizeof(double)) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "disagreement about data type size"); + } + CI_ALLOC_PRIV + break; - /* Unalign destination */ - if (dst_mv) HDmemcpy(dst, &aligned, sizeof(double)); + case H5T_CONV_FREE: + CI_PRINT_STATS(FLOAT, DOUBLE); + CI_FREE_PRIV + break; - /* Advance buffer pointers */ - if (buf_stride) { - src -= buf_stride; - dst -= buf_stride; - } else { - src -= sizeof(float); - dst -= sizeof(double); - } - } - break; - - default: - HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "unknown conversion command"); + case H5T_CONV_CONV: + if (buf_stride) { + src = dst = (uint8_t*)buf + buf_stride*(nelmts-1); + } else { + src = (uint8_t*)buf + sizeof(float)*(nelmts-1); + dst = (uint8_t*)buf + sizeof(double)*(nelmts-1); + } + + /* Need alignment? */ + if (H5T_NATIVE_FLOAT_ALIGN_g>1) { + src_mv = ((size_t)buf % H5T_NATIVE_FLOAT_ALIGN_g) || + ((buf_stride?buf_stride:sizeof(float)) % + H5T_NATIVE_FLOAT_ALIGN_g); + } else { + src_mv = FALSE; + } + if (H5T_NATIVE_DOUBLE_ALIGN_g>1) { + dst_mv = ((size_t)buf % H5T_NATIVE_DOUBLE_ALIGN_g) || + ((buf_stride?buf_stride:sizeof(double)) % + H5T_NATIVE_DOUBLE_ALIGN_g); + } else { + dst_mv = FALSE; + } + CI_INC_SRC(src_mv) + CI_INC_DST(dst_mv) + + for (elmtno=0; elmtno<nelmts; elmtno++) { + /* Align source and/or destination */ + if (src_mv) { + HDmemcpy(&aligned, src, sizeof(float)); + s = (uint8_t*)&aligned; + } else { + s = src; + } + if (dst_mv) + d = (uint8_t*)&aligned; + else + d = dst; + + /* Conversion */ + *((double*)d) = *((float*)s); + + /* Unalign destination */ + if (dst_mv) + HDmemcpy(dst, &aligned, sizeof(double)); + + /* Advance buffer pointers */ + if (buf_stride) { + src -= buf_stride; + dst -= buf_stride; + } else { + src -= sizeof(float); + dst -= sizeof(double); + } + } + break; + + default: + HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "unknown conversion command"); } FUNC_LEAVE (SUCCEED); @@ -5977,11 +5936,11 @@ H5T_conv_float_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { - size_t elmtno; /*element number */ + hsize_t elmtno; /*element number */ uint8_t *src, *s; /*source buffer */ uint8_t *dst, *d; /*destination buffer */ H5T_t *st, *dt; /*type descriptors */ @@ -5991,90 +5950,93 @@ H5T_conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, FUNC_ENTER (H5T_conv_double_float, FAIL); switch (cdata->command) { - case H5T_CONV_INIT: - cdata->need_bkg = H5T_BKG_NO; - if (NULL==(st=H5I_object(src_id)) || - NULL==(dt=H5I_object(dst_id))) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, - "unable to dereference data type object ID"); - } - if (st->size!=sizeof(double) || dt->size!=sizeof(float)) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, - "disagreement about data type size"); - } - CI_ALLOC_PRIV - break; - - case H5T_CONV_FREE: - CI_PRINT_STATS(DOUBLE, FLOAT); - CI_FREE_PRIV - break; - - case H5T_CONV_CONV: - src = (uint8_t*)buf; - dst = (uint8_t*)buf; - - /* Need alignment? */ - if (H5T_NATIVE_DOUBLE_ALIGN_g>1) { - src_mv = ((size_t)buf % H5T_NATIVE_DOUBLE_ALIGN_g) || - ((buf_stride?buf_stride:sizeof(double)) % - H5T_NATIVE_DOUBLE_ALIGN_g); - } else { - src_mv = FALSE; - } - if (H5T_NATIVE_FLOAT_ALIGN_g>1) { - dst_mv = ((size_t)buf % H5T_NATIVE_FLOAT_ALIGN_g) || - ((buf_stride?buf_stride:sizeof(float)) % - H5T_NATIVE_FLOAT_ALIGN_g); - } else { - dst_mv = FALSE; - } - CI_INC_SRC(src_mv) - CI_INC_DST(dst_mv) - - for (elmtno=0; elmtno<nelmts; elmtno++) { - /* Align source and/or destination */ - if (src_mv) { - HDmemcpy(&aligned, src, sizeof(double)); - s = (uint8_t*)&aligned; - } else { - s = src; - } - if (dst_mv) d = (uint8_t*)&aligned; - else d = dst; - - /* Conversion */ - if (*((double*)s) > FLT_MAX) { - if (!H5T_overflow_g || - (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - *((float*)d) = FLT_MAX; - } - } else if (*((double*)s) < -FLT_MAX) { - if (!H5T_overflow_g || - (H5T_overflow_g)(src_id, dst_id, s, d)<0) { - *((float*)d) = -FLT_MAX; - } - } else { - *((float*)d) = *((double*)s); - } + case H5T_CONV_INIT: + cdata->need_bkg = H5T_BKG_NO; + if (NULL==(st=H5I_object(src_id)) || + NULL==(dt=H5I_object(dst_id))) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "unable to dereference data type object ID"); + } + if (st->size!=sizeof(double) || dt->size!=sizeof(float)) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, + "disagreement about data type size"); + } + CI_ALLOC_PRIV + break; - /* Unalign destination */ - if (dst_mv) HDmemcpy(dst, &aligned, sizeof(float)); + case H5T_CONV_FREE: + CI_PRINT_STATS(DOUBLE, FLOAT); + CI_FREE_PRIV + break; - /* Advance pointers */ - if (buf_stride) { - src += buf_stride; - dst += buf_stride; + case H5T_CONV_CONV: + src = (uint8_t*)buf; + dst = (uint8_t*)buf; + + /* Need alignment? */ + if (H5T_NATIVE_DOUBLE_ALIGN_g>1) { + src_mv = ((size_t)buf % H5T_NATIVE_DOUBLE_ALIGN_g) || + ((buf_stride?buf_stride:sizeof(double)) % + H5T_NATIVE_DOUBLE_ALIGN_g); } else { - src += sizeof(double); - dst += sizeof(float); + src_mv = FALSE; } - } - break; - - default: - HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "unknown conversion command"); + if (H5T_NATIVE_FLOAT_ALIGN_g>1) { + dst_mv = ((size_t)buf % H5T_NATIVE_FLOAT_ALIGN_g) || + ((buf_stride?buf_stride:sizeof(float)) % + H5T_NATIVE_FLOAT_ALIGN_g); + } else { + dst_mv = FALSE; + } + CI_INC_SRC(src_mv) + CI_INC_DST(dst_mv) + + for (elmtno=0; elmtno<nelmts; elmtno++) { + /* Align source and/or destination */ + if (src_mv) { + HDmemcpy(&aligned, src, sizeof(double)); + s = (uint8_t*)&aligned; + } else { + s = src; + } + if (dst_mv) + d = (uint8_t*)&aligned; + else + d = dst; + + /* Conversion */ + if (*((double*)s) > FLT_MAX) { + if (!H5T_overflow_g || + (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + *((float*)d) = FLT_MAX; + } + } else if (*((double*)s) < -FLT_MAX) { + if (!H5T_overflow_g || + (H5T_overflow_g)(src_id, dst_id, s, d)<0) { + *((float*)d) = -FLT_MAX; + } + } else { + *((float*)d) = *((double*)s); + } + + /* Unalign destination */ + if (dst_mv) + HDmemcpy(dst, &aligned, sizeof(float)); + + /* Advance pointers */ + if (buf_stride) { + src += buf_stride; + dst += buf_stride; + } else { + src += sizeof(double); + dst += sizeof(float); + } + } + break; + + default: + HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "unknown conversion command"); } FUNC_LEAVE (SUCCEED); @@ -6103,14 +6065,14 @@ H5T_conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, */ herr_t H5T_conv_i32le_f64le (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist) { uint8_t *s=NULL, *d=NULL; /*src and dst buf pointers */ uint8_t tmp[8]; /*temporary destination buffer */ H5T_t *src = NULL; /*source data type */ - size_t elmtno; /*element counter */ + hsize_t elmtno; /*element counter */ uintn sign; /*sign bit */ uintn cin, cout; /*carry in/out */ uintn mbits=0; /*mantissa bits */ @@ -6120,320 +6082,355 @@ H5T_conv_i32le_f64le (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, FUNC_ENTER (H5T_conv_i32le_f64le, FAIL); switch (cdata->command) { - case H5T_CONV_INIT: - assert (sizeof(intn)>=4); - cdata->need_bkg = H5T_BKG_NO; - break; - - case H5T_CONV_FREE: - /* Free private data */ - break; - - case H5T_CONV_CONV: - /* The conversion */ - if (H5I_DATATYPE!=H5I_get_type (src_id) || - NULL==(src=H5I_object (src_id)) || - H5I_DATATYPE!=H5I_get_type (dst_id) || - NULL==H5I_object (dst_id)) { - HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - } - - s = (uint8_t*)buf + (buf_stride?buf_stride:4)*(nelmts-1); - d = (uint8_t*)buf + (buf_stride?buf_stride:8)*(nelmts-1); - for (elmtno=0; elmtno<nelmts; elmtno++) { + case H5T_CONV_INIT: + assert (sizeof(intn)>=4); + cdata->need_bkg = H5T_BKG_NO; + break; - /* - * If this is the last element to convert (that is, the first - * element of the buffer) then the source and destination areas - * overlap so we need to use a temp buf for the destination. - */ - if ((void*)s==buf) d = tmp; + case H5T_CONV_FREE: + /* Free private data */ + break; - /* Convert the integer to a sign and magnitude */ - switch (src->u.atomic.u.i.sign) { - case H5T_SGN_NONE: - sign = 0; - break; - case H5T_SGN_2: - if (s[3] & 0x80) { - sign = 1; - for (i=0,cin=1; i<4; i++,cin=cout) { - s[i] = ~s[i]; - cout = ((unsigned)(s[i])+cin > 0xff) ? 1 : 0; - s[i] += cin; - } - } else { - sign = 0; - } - break; - default: - HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "unsupported integer sign method"); - } - - /* - * Where is the most significant bit that is set? We could do - * this in a loop, but testing it this way might be faster. - */ - if (s[3]) { - if (s[3] & 0x80) mbits = 32; - else if (s[3] & 0x40) mbits = 31; - else if (s[3] & 0x20) mbits = 30; - else if (s[3] & 0x10) mbits = 29; - else if (s[3] & 0x08) mbits = 28; - else if (s[3] & 0x04) mbits = 27; - else if (s[3] & 0x02) mbits = 26; - else if (s[3] & 0x01) mbits = 25; - } else if (s[2]) { - if (s[2] & 0x80) mbits = 24; - else if (s[2] & 0x40) mbits = 23; - else if (s[2] & 0x20) mbits = 22; - else if (s[2] & 0x10) mbits = 21; - else if (s[2] & 0x08) mbits = 20; - else if (s[2] & 0x04) mbits = 19; - else if (s[2] & 0x02) mbits = 18; - else if (s[2] & 0x01) mbits = 17; - } else if (s[1]) { - if (s[1] & 0x80) mbits = 16; - else if (s[1] & 0x40) mbits = 15; - else if (s[1] & 0x20) mbits = 14; - else if (s[1] & 0x10) mbits = 13; - else if (s[1] & 0x08) mbits = 12; - else if (s[1] & 0x04) mbits = 11; - else if (s[1] & 0x02) mbits = 10; - else if (s[1] & 0x01) mbits = 9; - } else if (s[0]) { - if (s[0] & 0x80) mbits = 8; - else if (s[0] & 0x40) mbits = 7; - else if (s[0] & 0x20) mbits = 6; - else if (s[0] & 0x10) mbits = 5; - else if (s[0] & 0x08) mbits = 4; - else if (s[0] & 0x04) mbits = 3; - else if (s[0] & 0x02) mbits = 2; - else if (s[0] & 0x01) mbits = 1; - } else { - /*zero*/ - d[7] = d[6] = d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; - continue; - } + case H5T_CONV_CONV: + /* The conversion */ + if (H5I_DATATYPE!=H5I_get_type (src_id) || + NULL==(src=H5I_object (src_id)) || + H5I_DATATYPE!=H5I_get_type (dst_id) || + NULL==H5I_object (dst_id)) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); + } + + s = (uint8_t*)buf + (buf_stride?buf_stride:4)*(nelmts-1); + d = (uint8_t*)buf + (buf_stride?buf_stride:8)*(nelmts-1); + for (elmtno=0; elmtno<nelmts; elmtno++) { - /* - * The sign and exponent. - */ - exponent = (mbits - 1) + 1023; - d[7] = (sign<<7) | ((exponent>>4) & 0x7f); - d[6] = (exponent & 0x0f) << 4; - - /* - * The mantissa. - */ - switch (mbits) { - case 32: - d[5] = d[4] = d[3] = d[1] = d[0] = 0; - break; - case 31: - d[6] |= 0x0f & (s[3]>>2); - d[5] = (s[3]<<6) | (s[2]>>2); - d[4] = (s[2]<<6) | (s[1]>>2); - d[3] = (s[1]<<6) | (s[0]>>2); - d[2] = (s[0]<<6); - d[1] = d[0] = 0; - break; - case 30: - d[6] |= 0x0f & (s[3]>>1); - d[5] = (s[3]<<7) | (s[2]>>1); - d[4] = (s[2]<<7) | (s[1]>>1); - d[3] = (s[1]<<7) | (s[0]>>1); - d[2] = (s[0]<<7); - d[1] = d[0] = 0; - break; - case 29: - d[6] |= 0x0f & s[3]; - d[5] = s[2]; - d[4] = s[1]; - d[3] = s[0]; - d[2] = d[1] = d[0] = 0; - break; - case 28: - d[6] |= ((s[3]<<1) | (s[2]>>7)) & 0x0f; - d[5] = (s[2]<<1) | (s[1]>>7); - d[4] = (s[1]<<1) | (s[0]>>7); - d[3] = (s[0]<<1); - d[2] = d[1] = d[0] = 0; - break; - case 27: - d[6] |= ((s[3]<<2) | (s[2]>>6)) & 0x0f; - d[5] = (s[2]<<2) | (s[1]>>6); - d[4] = (s[1]<<2) | (s[0]>>6); - d[3] = (s[0]<<2); - d[2] = d[1] = d[0] = 0; - break; - case 26: - d[6] |= ((s[3]<<3) | (s[2]>>5)) & 0x0f; - d[5] = (s[2]<<3) | (s[1]>>5); - d[4] = (s[1]<<3) | (s[0]>>5); - d[3] = (s[0]<<3); - d[2] = d[1] = d[0] = 0; - break; - case 25: - d[6] |= 0x0f & (s[2]>>4); - d[5] = (s[2]<<4) | (s[1]>>4); - d[4] = (s[1]<<4) | (s[0]>>4); - d[3] = (s[0]<<4); - d[2] = d[1] = d[0] = 0; - break; - case 24: - d[6] |= 0x0f & (s[2]>>3); - d[5] = (s[2]<<5) | (s[1]>>3); - d[4] = (s[1]<<5) | (s[0]>>3); - d[3] = (s[0]<<5); - d[2] = d[1] = d[0] = 0; - break; - case 23: - d[6] |= 0x0f & (s[2]>>2); - d[5] = (s[2]<<6) | (s[1]>>2); - d[4] = (s[1]<<6) | (s[0]>>2); - d[3] = (s[0]<<6); - d[2] = d[1] = d[0] = 0; - break; - case 22: - d[6] |= 0x0f & (s[2]>>1); - d[5] = (s[2]<<7) | (s[1]>>1); - d[4] = (s[1]<<7) | (s[0]>>1); - d[3] = (s[0]<<7); - d[2] = d[1] = d[0] = 0; - break; - case 21: - d[6] |= 0x0f & s[2]; - d[5] = s[1]; - d[4] = s[0]; - d[3] = d[2] = d[1] = d[0] = 0; - break; - case 20: - d[6] |= ((s[2]<<1) | (s[1]>>7)) & 0x0f; - d[5] = (s[1]<<1) | (s[0]>>7); - d[4] = (s[0]<<1); - d[3] = d[2] = d[1] = d[0] = 0; - break; - case 19: - d[6] |= ((s[2]<<2) | (s[1]>>6)) & 0x0f; - d[5] = (s[1]<<2) | (s[0]>>6); - d[4] = (s[0]<<2); - d[3] = d[2] = d[1] = d[0] = 0; - break; - case 18: - d[6] |= ((s[2]<<3) | (s[1]>>5)) & 0x0f; - d[5] = (s[1]<<3) | (s[0]>>5); - d[4] = (s[0]<<3); - d[3] = d[2] = d[1] = d[0] = 0; - break; - case 17: - d[6] |= 0x0f & (s[1]>>4); - d[5] = (s[1]<<4) | (s[0]>>4); - d[4] = (s[0]<<4); - d[3] = d[2] = d[1] = d[0] = 0; - break; - case 16: - d[6] |= 0x0f & (s[1]>>3); - d[5] = (s[1]<<5) | (s[0]>>3); - d[4] = (s[0]<<5); - d[3] = d[2] = d[1] = d[0] = 0; - break; - case 15: - d[6] |= 0x0f & (s[1]>>2); - d[5] = (s[1]<<6) | (s[0]>>2); - d[4] = (s[0]<<6); - d[3] = d[2] = d[1] = d[0] = 0; - break; - case 14: - d[6] |= 0x0f & (s[1]>>1); - d[5] = (s[1]<<7) | (s[0]>>1); - d[4] = (s[0]<<7); - d[3] = d[2] = d[1] = d[0] = 0; - break; - case 13: - d[6] |= 0x0f & s[1]; - d[5] = s[0]; - d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - case 12: - d[6] |= ((s[1]<<1) | (s[0]>>7)) & 0x0f; - d[5] = (s[0]<<1); - d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - case 11: - d[6] |= ((s[1]<<2) | (s[0]>>6)) & 0x0f; - d[5] = (s[0]<<2); - d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - case 10: - d[6] |= ((s[1]<<3) | (s[0]>>5)) & 0x0f; - d[5] = (s[0]<<3); - d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - case 9: - d[6] |= 0x0f & (s[0]>>4); - d[5] = (s[0]<<4); - d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - case 8: - d[6] |= 0x0f & (s[0]>>3); - d[5] = (s[0]<<5); - d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - case 7: - d[6] |= 0x0f & (s[0]>>2); - d[5] = (s[0]<<6); - d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - case 6: - d[6] |= 0x0f & (s[0]>>1); - d[5] = (s[0]<<7); - d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - case 5: - d[6] |= 0x0f & s[0]; - d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - case 4: - d[6] |= (s[0]<<1) & 0x0f; - d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - case 3: - d[6] |= (s[0]<<2) & 0x0f; - d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - case 2: - d[6] |= (s[0]<<3) & 0x0f; - d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - case 1: - d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; - break; - } + /* + * If this is the last element to convert (that is, the first + * element of the buffer) then the source and destination areas + * overlap so we need to use a temp buf for the destination. + */ + if ((void*)s==buf) + d = tmp; + + /* Convert the integer to a sign and magnitude */ + switch (src->u.atomic.u.i.sign) { + case H5T_SGN_NONE: + sign = 0; + break; + + case H5T_SGN_2: + if (s[3] & 0x80) { + sign = 1; + for (i=0,cin=1; i<4; i++,cin=cout) { + s[i] = ~s[i]; + cout = ((unsigned)(s[i])+cin > 0xff) ? 1 : 0; + s[i] += cin; + } + } else { + sign = 0; + } + break; + + default: + HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "unsupported integer sign method"); + } + + /* + * Where is the most significant bit that is set? We could do + * this in a loop, but testing it this way might be faster. + */ + if (s[3]) { + if (s[3] & 0x80) mbits = 32; + else if (s[3] & 0x40) mbits = 31; + else if (s[3] & 0x20) mbits = 30; + else if (s[3] & 0x10) mbits = 29; + else if (s[3] & 0x08) mbits = 28; + else if (s[3] & 0x04) mbits = 27; + else if (s[3] & 0x02) mbits = 26; + else if (s[3] & 0x01) mbits = 25; + } else if (s[2]) { + if (s[2] & 0x80) mbits = 24; + else if (s[2] & 0x40) mbits = 23; + else if (s[2] & 0x20) mbits = 22; + else if (s[2] & 0x10) mbits = 21; + else if (s[2] & 0x08) mbits = 20; + else if (s[2] & 0x04) mbits = 19; + else if (s[2] & 0x02) mbits = 18; + else if (s[2] & 0x01) mbits = 17; + } else if (s[1]) { + if (s[1] & 0x80) mbits = 16; + else if (s[1] & 0x40) mbits = 15; + else if (s[1] & 0x20) mbits = 14; + else if (s[1] & 0x10) mbits = 13; + else if (s[1] & 0x08) mbits = 12; + else if (s[1] & 0x04) mbits = 11; + else if (s[1] & 0x02) mbits = 10; + else if (s[1] & 0x01) mbits = 9; + } else if (s[0]) { + if (s[0] & 0x80) mbits = 8; + else if (s[0] & 0x40) mbits = 7; + else if (s[0] & 0x20) mbits = 6; + else if (s[0] & 0x10) mbits = 5; + else if (s[0] & 0x08) mbits = 4; + else if (s[0] & 0x04) mbits = 3; + else if (s[0] & 0x02) mbits = 2; + else if (s[0] & 0x01) mbits = 1; + } else { + /*zero*/ + d[7] = d[6] = d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; + continue; + } - /* - * Copy temp buffer to the destination. This only happens for - * the first value in the array, the last value processed. See - * beginning of loop. - */ - if (d==tmp) HDmemcpy (s, d, 8); + /* + * The sign and exponent. + */ + exponent = (mbits - 1) + 1023; + d[7] = (sign<<7) | ((exponent>>4) & 0x7f); + d[6] = (exponent & 0x0f) << 4; + + /* + * The mantissa. + */ + switch (mbits) { + case 32: + d[5] = d[4] = d[3] = d[1] = d[0] = 0; + break; + + case 31: + d[6] |= 0x0f & (s[3]>>2); + d[5] = (s[3]<<6) | (s[2]>>2); + d[4] = (s[2]<<6) | (s[1]>>2); + d[3] = (s[1]<<6) | (s[0]>>2); + d[2] = (s[0]<<6); + d[1] = d[0] = 0; + break; + + case 30: + d[6] |= 0x0f & (s[3]>>1); + d[5] = (s[3]<<7) | (s[2]>>1); + d[4] = (s[2]<<7) | (s[1]>>1); + d[3] = (s[1]<<7) | (s[0]>>1); + d[2] = (s[0]<<7); + d[1] = d[0] = 0; + break; + + case 29: + d[6] |= 0x0f & s[3]; + d[5] = s[2]; + d[4] = s[1]; + d[3] = s[0]; + d[2] = d[1] = d[0] = 0; + break; + + case 28: + d[6] |= ((s[3]<<1) | (s[2]>>7)) & 0x0f; + d[5] = (s[2]<<1) | (s[1]>>7); + d[4] = (s[1]<<1) | (s[0]>>7); + d[3] = (s[0]<<1); + d[2] = d[1] = d[0] = 0; + break; + + case 27: + d[6] |= ((s[3]<<2) | (s[2]>>6)) & 0x0f; + d[5] = (s[2]<<2) | (s[1]>>6); + d[4] = (s[1]<<2) | (s[0]>>6); + d[3] = (s[0]<<2); + d[2] = d[1] = d[0] = 0; + break; + + case 26: + d[6] |= ((s[3]<<3) | (s[2]>>5)) & 0x0f; + d[5] = (s[2]<<3) | (s[1]>>5); + d[4] = (s[1]<<3) | (s[0]>>5); + d[3] = (s[0]<<3); + d[2] = d[1] = d[0] = 0; + break; + + case 25: + d[6] |= 0x0f & (s[2]>>4); + d[5] = (s[2]<<4) | (s[1]>>4); + d[4] = (s[1]<<4) | (s[0]>>4); + d[3] = (s[0]<<4); + d[2] = d[1] = d[0] = 0; + break; + + case 24: + d[6] |= 0x0f & (s[2]>>3); + d[5] = (s[2]<<5) | (s[1]>>3); + d[4] = (s[1]<<5) | (s[0]>>3); + d[3] = (s[0]<<5); + d[2] = d[1] = d[0] = 0; + break; + + case 23: + d[6] |= 0x0f & (s[2]>>2); + d[5] = (s[2]<<6) | (s[1]>>2); + d[4] = (s[1]<<6) | (s[0]>>2); + d[3] = (s[0]<<6); + d[2] = d[1] = d[0] = 0; + break; + + case 22: + d[6] |= 0x0f & (s[2]>>1); + d[5] = (s[2]<<7) | (s[1]>>1); + d[4] = (s[1]<<7) | (s[0]>>1); + d[3] = (s[0]<<7); + d[2] = d[1] = d[0] = 0; + break; + + case 21: + d[6] |= 0x0f & s[2]; + d[5] = s[1]; + d[4] = s[0]; + d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 20: + d[6] |= ((s[2]<<1) | (s[1]>>7)) & 0x0f; + d[5] = (s[1]<<1) | (s[0]>>7); + d[4] = (s[0]<<1); + d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 19: + d[6] |= ((s[2]<<2) | (s[1]>>6)) & 0x0f; + d[5] = (s[1]<<2) | (s[0]>>6); + d[4] = (s[0]<<2); + d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 18: + d[6] |= ((s[2]<<3) | (s[1]>>5)) & 0x0f; + d[5] = (s[1]<<3) | (s[0]>>5); + d[4] = (s[0]<<3); + d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 17: + d[6] |= 0x0f & (s[1]>>4); + d[5] = (s[1]<<4) | (s[0]>>4); + d[4] = (s[0]<<4); + d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 16: + d[6] |= 0x0f & (s[1]>>3); + d[5] = (s[1]<<5) | (s[0]>>3); + d[4] = (s[0]<<5); + d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 15: + d[6] |= 0x0f & (s[1]>>2); + d[5] = (s[1]<<6) | (s[0]>>2); + d[4] = (s[0]<<6); + d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 14: + d[6] |= 0x0f & (s[1]>>1); + d[5] = (s[1]<<7) | (s[0]>>1); + d[4] = (s[0]<<7); + d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 13: + d[6] |= 0x0f & s[1]; + d[5] = s[0]; + d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 12: + d[6] |= ((s[1]<<1) | (s[0]>>7)) & 0x0f; + d[5] = (s[0]<<1); + d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 11: + d[6] |= ((s[1]<<2) | (s[0]>>6)) & 0x0f; + d[5] = (s[0]<<2); + d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 10: + d[6] |= ((s[1]<<3) | (s[0]>>5)) & 0x0f; + d[5] = (s[0]<<3); + d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 9: + d[6] |= 0x0f & (s[0]>>4); + d[5] = (s[0]<<4); + d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 8: + d[6] |= 0x0f & (s[0]>>3); + d[5] = (s[0]<<5); + d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 7: + d[6] |= 0x0f & (s[0]>>2); + d[5] = (s[0]<<6); + d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 6: + d[6] |= 0x0f & (s[0]>>1); + d[5] = (s[0]<<7); + d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 5: + d[6] |= 0x0f & s[0]; + d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 4: + d[6] |= (s[0]<<1) & 0x0f; + d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 3: + d[6] |= (s[0]<<2) & 0x0f; + d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 2: + d[6] |= (s[0]<<3) & 0x0f; + d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + + case 1: + d[5] = d[4] = d[3] = d[2] = d[1] = d[0] = 0; + break; + } - /* Advance pointers */ - if (buf_stride) { - s -= buf_stride; - d -= buf_stride; - } else { - s -= 4; - d -= 8; - } - } - break; + /* + * Copy temp buffer to the destination. This only happens for + * the first value in the array, the last value processed. See + * beginning of loop. + */ + if (d==tmp) + HDmemcpy (s, d, 8); + + /* Advance pointers */ + if (buf_stride) { + s -= buf_stride; + d -= buf_stride; + } else { + s -= 4; + d -= 8; + } + } + break; - default: - /* Some other command we don't know about yet.*/ - HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, - "unknown conversion command"); + default: + /* Some other command we don't know about yet.*/ + HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, + "unknown conversion command"); } FUNC_LEAVE (SUCCEED); diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 5917945..6158d70 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -219,519 +219,519 @@ __DLLVAR__ size_t H5T_NATIVE_UINT_FAST64_ALIGN_g; /* Conversion functions */ __DLL__ herr_t H5T_conv_noop(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_schar_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uchar_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_schar_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_schar_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uchar_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uchar_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_schar_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_schar_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uchar_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uchar_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_schar_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_schar_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uchar_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uchar_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_schar_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_schar_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uchar_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uchar_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_short_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_short_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ushort_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ushort_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_short_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ushort_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_short_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_short_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ushort_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ushort_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_short_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_short_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ushort_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ushort_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_short_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_short_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ushort_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ushort_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_int_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_int_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uint_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uint_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_int_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_int_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uint_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uint_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_int_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uint_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_int_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_int_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uint_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uint_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_int_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_int_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uint_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_uint_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_long_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_long_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ulong_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ulong_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_long_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_long_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ulong_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ulong_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_long_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_long_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ulong_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ulong_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_long_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ulong_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_long_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_long_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ulong_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ulong_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_llong_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_llong_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ullong_schar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ullong_uchar(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_llong_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_llong_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ullong_short(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ullong_ushort(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_llong_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_llong_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ullong_int(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ullong_uint(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_llong_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_llong_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ullong_long(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ullong_ulong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_llong_ullong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_ullong_llong(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_float_double(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_double_float(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_conv_i32le_f64le(hid_t src_id, hid_t dst_id, - H5T_cdata_t *cdata, size_t nelmts, + H5T_cdata_t *cdata, hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *_buf, void *bkg, hid_t dset_xfer_plist); @@ -763,7 +763,4 @@ __DLL__ herr_t H5T_vlen_disk_write(const H5D_xfer_t *xfer_parms, H5F_t *f, void __DLL__ H5T_t * H5T_array_create(H5T_t *base, int ndims, const hsize_t dim[/* ndims */], const int perm[/* ndims */]); -/* Reference specific functions */ -__DLL__ H5R_type_t H5T_get_ref_type(const H5T_t *dt); - #endif diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 697ac6f..98511aa 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -121,7 +121,7 @@ __DLL__ H5T_path_t *H5T_path_find(const H5T_t *src, const H5T_t *dst, __DLL__ herr_t H5T_sort_value(H5T_t *dt, int *map); __DLL__ herr_t H5T_sort_name(H5T_t *dt, int *map); __DLL__ herr_t H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, - size_t nelmts, size_t buf_stride, size_t bkg_stride, + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); __DLL__ herr_t H5T_set_size(H5T_t *dt, size_t size); __DLL__ herr_t H5T_set_precision(H5T_t *dt, size_t prec); @@ -132,6 +132,8 @@ __DLL__ herr_t H5T_enum_valueof(H5T_t *dt, const char *name, void *value/*out*/); __DLL__ herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, hsize_t UNUSED ndim, hssize_t UNUSED *point, void UNUSED *_op_data); __DLL__ htri_t H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc); + +/* Reference specific functions */ __DLL__ H5R_type_t H5T_get_ref_type(const H5T_t *dt); #endif diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 3abb8d5..160f642 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -163,9 +163,8 @@ typedef struct { /* All data type conversion functions are... */ typedef herr_t (*H5T_conv_t) (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, - size_t nelmts, size_t buf_stride, - size_t bkg_stride, void *buf, void *bkg, - hid_t dset_xfer_plist); + hsize_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, + void *bkg, hid_t dset_xfer_plist); /* * If an error occurs during a data type conversion then the function @@ -538,7 +537,7 @@ __DLL__ herr_t H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, __DLL__ herr_t H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5T_conv_t func); __DLL__ H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata); -__DLL__ herr_t H5Tconvert(hid_t src_id, hid_t dst_id, size_t nelmts, +__DLL__ herr_t H5Tconvert(hid_t src_id, hid_t dst_id, hsize_t nelmts, void *buf, void *background, hid_t plist_id); __DLL__ H5T_overflow_t H5Tget_overflow(void); __DLL__ herr_t H5Tset_overflow(H5T_overflow_t func); diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 3957f79..f454b0a 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -219,12 +219,13 @@ 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)(seq_len*base_size,xfer_parms->alloc_info))) + if(NULL==(vl->p=(xfer_parms->vlen_alloc)((size_t)(seq_len*base_size),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(seq_len*base_size))) + if(NULL==(vl->p=H5MM_malloc((size_t)(seq_len*base_size)))) HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data"); } /* end else */ @@ -327,12 +328,13 @@ 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)((seq_len+1)*base_size,xfer_parms->alloc_info))) + 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"); } /* end if */ else { /* Default to system malloc */ - if(NULL==(*s=H5MM_malloc((seq_len+1)*base_size))) + if(NULL==(*s=H5MM_malloc((size_t)((seq_len+1)*base_size)))) HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data"); } /* end else */ @@ -38,7 +38,7 @@ static intn interface_initialize_g = 0; *------------------------------------------------------------------------- */ herr_t -H5V_stride_optimize1(intn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, +H5V_stride_optimize1(uintn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, hsize_t *size, hssize_t *stride1) { FUNC_ENTER(H5V_stride_optimize1, FAIL); @@ -52,13 +52,12 @@ H5V_stride_optimize1(intn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, /* * Combine adjacent memory accesses */ - while (*np && - stride1[*np-1]>0 && - (hsize_t)(stride1[*np-1])==*elmt_size) { - *elmt_size *= size[*np-1]; - if (--*np) { - stride1[*np-1] += size[*np] * stride1[*np]; - } + while (*np && stride1[*np-1]>0 && + (hsize_t)(stride1[*np-1])==*elmt_size) { + *elmt_size *= size[*np-1]; + if (--*np) { + stride1[*np-1] += size[*np] * stride1[*np]; + } } FUNC_LEAVE(SUCCEED); @@ -85,7 +84,7 @@ H5V_stride_optimize1(intn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, *------------------------------------------------------------------------- */ herr_t -H5V_stride_optimize2(intn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, +H5V_stride_optimize2(uintn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, hsize_t *size, hssize_t *stride1, hssize_t *stride2) { FUNC_ENTER(H5V_stride_optimize2, FAIL); @@ -196,7 +195,6 @@ H5V_stride_optimize2(intn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, break; } /* end switch */ - FUNC_LEAVE(SUCCEED); } @@ -230,18 +228,18 @@ H5V_stride_optimize2(intn *np/*in,out*/, hsize_t *elmt_size/*in,out*/, *------------------------------------------------------------------------- */ hsize_t -H5V_hyper_stride(intn n, const hsize_t *size, +H5V_hyper_stride(uintn n, const hsize_t *size, const hsize_t *total_size, const hssize_t *offset, hssize_t *stride/*out*/) { hsize_t skip; /*starting point byte offset */ hsize_t acc; /*accumulator */ hsize_t tmp; - int i; /*counter */ + intn i; /*counter */ FUNC_ENTER(H5V_hyper_stride, (HDabort(), 0)); - assert(n >= 0 && n <= H5V_HYPER_NDIMS); + assert(n <= H5V_HYPER_NDIMS); assert(size); assert(total_size); assert(stride); @@ -295,7 +293,7 @@ H5V_hyper_stride(intn n, const hsize_t *size, default: /* others */ - for (i=n-2, acc=1; i>=0; --i) { + for (i=(intn)(n-2), acc=1; i>=0; --i) { hsize_t tmp = acc * (total_size[i+1] - size[i+1]); assert (tmp<((hsize_t)1<<(8*sizeof(hssize_t)-1))); stride[i] = (hssize_t)tmp; /*overflow checked*/ @@ -374,27 +372,28 @@ H5V_hyper_eq(intn n, *------------------------------------------------------------------------- */ htri_t -H5V_hyper_disjointp(intn n, +H5V_hyper_disjointp(uintn n, const hssize_t *offset1, const hsize_t *size1, const hssize_t *offset2, const hsize_t *size2) { - intn i; + uintn u; if (!n || !size1 || !size2) return TRUE; - for (i=0; i<n; i++) { - assert (size1[i]<HSSIZET_MAX); - assert (size2[i]<HSSIZET_MAX); - - if (0==size1[i] || 0==size2[i]) return TRUE; - if (((offset1?offset1[i]:0) < (offset2?offset2[i]:0) && - ((offset1?offset1[i]:0) + (hssize_t)size1[i] <= - (offset2?offset2[i]:0))) || - ((offset2?offset2[i]:0) < (offset1?offset1[i]:0) && - ((offset2?offset2[i]:0) + (hssize_t)size2[i] <= - (offset1?offset1[i]:0)))) { - return TRUE; - } + for (u=0; u<n; u++) { + assert (size1[u]<HSSIZET_MAX); + assert (size2[u]<HSSIZET_MAX); + + if (0==size1[u] || 0==size2[u]) + return TRUE; + if (((offset1?offset1[u]:0) < (offset2?offset2[u]:0) && + ((offset1?offset1[u]:0) + (hssize_t)size1[u] <= + (offset2?offset2[u]:0))) || + ((offset2?offset2[u]:0) < (offset1?offset1[u]:0) && + ((offset2?offset2[u]:0) + (hssize_t)size2[u] <= + (offset1?offset1[u]:0)))) { + return TRUE; + } } return FALSE; } @@ -421,7 +420,7 @@ H5V_hyper_disjointp(intn n, *------------------------------------------------------------------------- */ herr_t -H5V_hyper_fill(intn n, const hsize_t *_size, +H5V_hyper_fill(uintn n, const hsize_t *_size, const hsize_t *total_size, const hssize_t *offset, void *_dst, uintn fill_value) { @@ -432,7 +431,7 @@ H5V_hyper_fill(intn n, const hsize_t *_size, hsize_t elmt_size = 1; /*bytes per element */ herr_t status; /*function return status */ #ifndef NDEBUG - int i; + uintn u; #endif FUNC_ENTER(H5V_hyper_fill, FAIL); @@ -443,9 +442,9 @@ H5V_hyper_fill(intn n, const hsize_t *_size, assert(total_size); assert(dst); #ifndef NDEBUG - for (i = 0; i < n; i++) { - assert(_size[i] > 0); - assert(total_size[i] > 0); + for (u = 0; u < n; u++) { + assert(_size[u] > 0); + assert(total_size[u] > 0); } #endif @@ -496,7 +495,7 @@ H5V_hyper_fill(intn n, const hsize_t *_size, *------------------------------------------------------------------------- */ herr_t -H5V_hyper_copy(intn n, const hsize_t *_size, +H5V_hyper_copy(uintn n, const hsize_t *_size, /*destination*/ const hsize_t *dst_size, const hssize_t *dst_offset, @@ -517,7 +516,7 @@ H5V_hyper_copy(intn n, const hsize_t *_size, hsize_t tmp2; herr_t status; /*return status */ #ifndef NDEBUG - intn i; + uintn u; #endif FUNC_ENTER(H5V_hyper_copy, FAIL); @@ -530,10 +529,10 @@ H5V_hyper_copy(intn n, const hsize_t *_size, assert(dst); assert(src); #ifndef NDEBUG - for (i = 0; i < n; i++) { - assert(_size[i] > 0); - assert(dst_size[i] > 0); - assert(src_size[i] > 0); + for (u = 0; u < n; u++) { + assert(_size[u] > 0); + assert(dst_size[u] > 0); + assert(src_size[u] > 0); } #endif @@ -549,7 +548,7 @@ H5V_hyper_copy(intn n, const hsize_t *_size, { hsize_t dst_acc; /*accumulator */ hsize_t src_acc; /*accumulator */ - int ii; /*counter */ + intn ii; /*counter */ /* init */ dst_stride[n-1] = 1; @@ -633,7 +632,7 @@ H5V_hyper_copy(intn n, const hsize_t *_size, default: /* others */ - for (ii=n-2, dst_acc=1, src_acc=1; ii>=0; --ii) { + for (ii=(intn)(n-2), dst_acc=1, src_acc=1; ii>=0; --ii) { hsize_t tmp1 = dst_acc * (dst_size[ii+1] - size[ii+1]); hsize_t tmp2 = src_acc * (src_size[ii+1] - size[ii+1]); assert (tmp1<((hsize_t)1<<(8*sizeof(hssize_t)-1))); @@ -655,8 +654,7 @@ H5V_hyper_copy(intn n, const hsize_t *_size, /* Perform the copy in terms of stride */ status = H5V_stride_copy(n, elmt_size, size, - dst_stride, dst+dst_start, - src_stride, src+src_start); + dst_stride, dst+dst_start, src_stride, src+src_start); FUNC_LEAVE(status); } @@ -677,7 +675,7 @@ H5V_hyper_copy(intn n, const hsize_t *_size, *------------------------------------------------------------------------- */ herr_t -H5V_stride_fill(intn n, hsize_t elmt_size, const hsize_t *size, +H5V_stride_fill(uintn n, hsize_t elmt_size, const hsize_t *size, const hssize_t *stride, void *_dst, uintn fill_value) { uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic */ @@ -693,17 +691,18 @@ H5V_stride_fill(intn n, hsize_t elmt_size, const hsize_t *size, H5V_vector_cpy(n, idx, size); nelmts = H5V_vector_reduce_product(n, size); for (i=0; i<nelmts; i++) { - - /* Copy an element */ - HDmemset(dst, (signed)fill_value, (size_t)elmt_size); - - /* Decrement indices and advance pointer */ - for (j=n-1, carry=TRUE; j>=0 && carry; --j) { - dst += stride[j]; - - if (--idx[j]) carry = FALSE; - else idx[j] = size[j]; - } + /* Copy an element */ + HDmemset(dst, (signed)fill_value, (size_t)elmt_size); + + /* Decrement indices and advance pointer */ + for (j=(intn)(n-1), carry=TRUE; j>=0 && carry; --j) { + dst += stride[j]; + + if (--idx[j]) + carry = FALSE; + else + idx[j] = size[j]; + } } FUNC_LEAVE(SUCCEED); @@ -731,7 +730,7 @@ H5V_stride_fill(intn n, hsize_t elmt_size, const hsize_t *size, *------------------------------------------------------------------------- */ herr_t -H5V_stride_copy(int n, hsize_t elmt_size, const hsize_t *size, +H5V_stride_copy(uintn n, hsize_t elmt_size, const hsize_t *size, const hssize_t *dst_stride, void *_dst, const hssize_t *src_stride, const void *_src) { @@ -747,25 +746,28 @@ H5V_stride_copy(int n, hsize_t elmt_size, const hsize_t *size, assert (elmt_size<SIZET_MAX); if (n) { - H5V_vector_cpy(n, idx, size); - nelmts = H5V_vector_reduce_product(n, size); - for (i=0; i<nelmts; i++) { - - /* Copy an element */ - HDmemcpy(dst, src, (size_t)elmt_size); - - /* Decrement indices and advance pointers */ - for (j=n-1, carry=TRUE; j>=0 && carry; --j) { - src += src_stride[j]; - dst += dst_stride[j]; - - if (--idx[j]) carry = FALSE; - else idx[j] = size[j]; - } - } + H5V_vector_cpy(n, idx, size); + nelmts = H5V_vector_reduce_product(n, size); + for (i=0; i<nelmts; i++) { + + /* Copy an element */ + HDmemcpy(dst, src, (size_t)elmt_size); + + /* Decrement indices and advance pointers */ + for (j=(intn)(n-1), carry=TRUE; j>=0 && carry; --j) { + src += src_stride[j]; + dst += dst_stride[j]; + + if (--idx[j]) + carry = FALSE; + else + idx[j] = size[j]; + } + } } else { - HDmemcpy (dst, src, (size_t)elmt_size); - HRETURN (SUCCEED); + assert(elmt_size==(hsize_t)((size_t)elmt_size)); /*check for overflow*/ + HDmemcpy (dst, src, (size_t)elmt_size); + HRETURN (SUCCEED); } @@ -915,20 +917,20 @@ H5V_array_fill(void *_dst, const void *src, size_t size, size_t count) *------------------------------------------------------------------------- */ hsize_t -H5V_array_offset(intn n, const hsize_t *total_size, const hssize_t *offset) +H5V_array_offset(uintn n, const hsize_t *total_size, const hssize_t *offset) { hsize_t skip; /*starting point byte offset */ hsize_t acc; /*accumulator */ - int i; /*counter */ + intn i; /*counter */ FUNC_ENTER(H5V_array_stride, (HDabort(), 0)); - assert(n >= 0 && n <= H5V_HYPER_NDIMS); + assert(n <= H5V_HYPER_NDIMS); assert(total_size); assert(offset); /* others */ - for (i=n-1, acc=1, skip=0; i>=0; --i) { + for (i=(intn)(n-1), acc=1, skip=0; i>=0; --i) { skip += acc * offset[i]; acc *= total_size[i]; } diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h index c471b6a..7dcd45a 100644 --- a/src/H5Vprivate.h +++ b/src/H5Vprivate.h @@ -24,7 +24,7 @@ /* Other functions */ #define H5V_vector_cpy(N,DST,SRC) { \ - assert (sizeof(*(DST))==sizeof(*(SRC))); \ + assert (sizeof(*(DST))==sizeof(*(SRC))); \ if (SRC) HDmemcpy (DST, SRC, (N)*sizeof(*(DST))); \ else HDmemset (DST, 0, (N)*sizeof(*(DST))); \ } @@ -34,30 +34,30 @@ /* A null pointer is equivalent to a zero vector */ #define H5V_ZERO NULL -__DLL__ hsize_t H5V_hyper_stride(intn n, const hsize_t *size, +__DLL__ hsize_t H5V_hyper_stride(uintn n, const hsize_t *size, const hsize_t *total_size, const hssize_t *offset, hssize_t *stride); -__DLL__ htri_t H5V_hyper_disjointp(intn n, const hssize_t *offset1, +__DLL__ htri_t H5V_hyper_disjointp(uintn n, const hssize_t *offset1, const hsize_t *size1, const hssize_t *offset2, const hsize_t *size2); __DLL__ htri_t H5V_hyper_eq(intn n, const hssize_t *offset1, const hsize_t *size1, const hssize_t *offset2, const hsize_t *size2); -__DLL__ herr_t H5V_hyper_fill(intn n, const hsize_t *_size, +__DLL__ herr_t H5V_hyper_fill(uintn n, const hsize_t *_size, const hsize_t *total_size, const hssize_t *offset, void *_dst, uintn fill_value); -__DLL__ herr_t H5V_hyper_copy(intn n, const hsize_t *size, +__DLL__ herr_t H5V_hyper_copy(uintn n, const hsize_t *size, const hsize_t *dst_total_size, const hssize_t *dst_offset, void *_dst, const hsize_t *src_total_size, const hssize_t *src_offset, const void *_src); -__DLL__ herr_t H5V_stride_fill(intn n, hsize_t elmt_size, const hsize_t *size, +__DLL__ herr_t H5V_stride_fill(uintn n, hsize_t elmt_size, const hsize_t *size, const hssize_t *stride, void *_dst, uintn fill_value); -__DLL__ herr_t H5V_stride_copy(intn n, hsize_t elmt_size, const hsize_t *_size, +__DLL__ herr_t H5V_stride_copy(uintn n, hsize_t elmt_size, const hsize_t *_size, const hssize_t *dst_stride, void *_dst, const hssize_t *src_stride, const void *_src); __DLL__ herr_t H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size, intn dst_n, @@ -65,14 +65,14 @@ __DLL__ herr_t H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size, intn dst_n, const hssize_t *dst_stride, void *_dst, intn src_n, const hsize_t *src_size, const hssize_t *src_stride, const void *_src); -__DLL__ herr_t H5V_stride_optimize1(intn *np, hsize_t *elmt_size, +__DLL__ herr_t H5V_stride_optimize1(uintn *np, hsize_t *elmt_size, hsize_t *size, hssize_t *stride1); -__DLL__ herr_t H5V_stride_optimize2(intn *np, hsize_t *elmt_size, +__DLL__ herr_t H5V_stride_optimize2(uintn *np, hsize_t *elmt_size, hsize_t *size, hssize_t *stride1, hssize_t *stride2); __DLL__ herr_t H5V_array_fill(void *_dst, const void *src, size_t size, size_t count); -__DLL__ hsize_t H5V_array_offset(intn n, const hsize_t *total_size, +__DLL__ hsize_t H5V_array_offset(uintn n, const hsize_t *total_size, const hssize_t *offset); @@ -96,7 +96,7 @@ __DLL__ hsize_t H5V_array_offset(intn n, const hsize_t *total_size, *------------------------------------------------------------------------- */ static inline hsize_t UNUSED -H5V_vector_reduce_product(intn n, const hsize_t *v) +H5V_vector_reduce_product(uintn n, const hsize_t *v) { size_t ans = 1; @@ -212,7 +212,7 @@ H5V_vector_cmp_u (intn n, const hsize_t *v1, const hsize_t *v2) *------------------------------------------------------------------------- */ static inline intn UNUSED -H5V_vector_cmp_s (intn n, const hssize_t *v1, const hssize_t *v2) +H5V_vector_cmp_s (uintn n, const hssize_t *v1, const hssize_t *v2) { if (v1 == v2) return 0; while (n--) { @@ -260,7 +260,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, uintn flags, FUNC_ENTER(H5Z_append, FAIL); assert(pline); assert(filter>=0 && filter<=H5Z_FILTER_MAX); - assert(0==(flags & ~H5Z_FLAG_DEFMASK)); + assert(0==(flags & ~((uintn)H5Z_FLAG_DEFMASK))); assert(0==cd_nelmts || cd_values); /* @@ -386,7 +386,7 @@ H5Z_pipeline(H5F_t UNUSED *f, const H5O_pline_t *pline, uintn flags, FUNC_ENTER(H5Z_pipeline, FAIL); assert(f); - assert(0==(flags & ~H5Z_FLAG_INVMASK)); + assert(0==(flags & ~((uintn)H5Z_FLAG_INVMASK))); assert(filter_mask); assert(nbytes && *nbytes>0); assert(buf_size && *buf_size>0); diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c index 16ed966..cc7bd12 100644 --- a/src/H5Zdeflate.c +++ b/src/H5Zdeflate.c @@ -99,7 +99,7 @@ H5Z_filter_deflate (unsigned UNUSED flags, size_t cd_nelmts, "memory allocation failed for deflate " "uncompression"); } - z_strm.next_out = (char*)outbuf + z_strm.total_out; + z_strm.next_out = (unsigned char*)outbuf + z_strm.total_out; z_strm.avail_out = nalloc - z_strm.total_out; } } diff --git a/src/H5config.h.in b/src/H5config.h.in index 40eb656..0927b23 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -239,6 +239,9 @@ /* Define if you have the gettimeofday function. */ #undef HAVE_GETTIMEOFDAY +/* Define if you have the strdup function. */ +#undef HAVE_STRDUP + /* Define if you have the ioctl function. */ #undef HAVE_IOCTL diff --git a/src/H5private.h b/src/H5private.h index 93f0f9e..9d5c933 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -427,6 +427,19 @@ typedef unsigned uintn; #endif /* + * A macro for detecting over/under-flow when casting between types + */ +#ifndef NDEBUG +#define H5_CHECK_OVERFLOW(var,vartype,casttype) \ +{ \ + casttype _tmp_overflow=(casttype)(var); \ + assert((var)==(vartype)_tmp_overflow); \ +} +#else /* NDEBUG */ +#define H5_CHECK_OVERFLOW(var,vartype,casttype) +#endif /* NDEBUG */ + +/* * Data types and functions for timing certain parts of the library. */ typedef struct { @@ -708,7 +721,7 @@ __DLL__ int64_t HDstrtoll (const char *s, const char **rest, int base); * And now for a couple non-Posix functions... Watch out for systems that * define these in terms of macros. */ -#ifndef strdup +#if !defined strdup && !defined HAVE_STRDUP char *strdup(const char *s); #endif #define HDstrdup(S) strdup(S) @@ -77,7 +77,7 @@ is_sparse(void) struct stat sb; if ((fd=open("x.h5", O_RDWR|O_TRUNC|O_CREAT, 0666))<0) return 0; - if (lseek(fd, 1024*1024, SEEK_SET)!=1024*1024) 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; @@ -377,13 +377,13 @@ main (void) #endif /* H5_WANT_H5_V1_2_COMPAT */ printf("Changing file drivers to the family driver, %lu bytes each\n", (unsigned long)FAMILY_SIZE); - if (H5Pset_fapl_family(fapl, FAMILY_SIZE, H5P_DEFAULT)<0) goto error; + if (H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT)<0) goto error; } else if (H5Pget_fapl_family(fapl, &family_size, NULL)<0) { goto error; } else if (family_size!=FAMILY_SIZE) { printf("Changing family member size from %lu to %lu\n", (unsigned long)family_size, (unsigned long)FAMILY_SIZE); - if (H5Pset_fapl_family(fapl, FAMILY_SIZE, H5P_DEFAULT)<0) goto error; + if (H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT)<0) goto error; } /* diff --git a/test/dsets.c b/test/dsets.c index 4863d93..6b60991 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -182,7 +182,7 @@ test_simple_io(hid_t file) tconv_buf = malloc (1000); xfer = H5Pcreate (H5P_DATASET_XFER); assert (xfer>=0); - if (H5Pset_buffer (xfer, 1000, tconv_buf, NULL)<0) goto error; + if (H5Pset_buffer (xfer, (hsize_t)1000, tconv_buf, NULL)<0) goto error; /* Create the dataset */ if ((dataset = H5Dcreate(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space, @@ -368,7 +368,7 @@ test_compression(hid_t file) */ if ((xfer = H5Pcreate (H5P_DATASET_XFER))<0) goto error; tconv_buf = malloc (1000); - if (H5Pset_buffer (xfer, 1000, tconv_buf, NULL)<0) goto error; + if (H5Pset_buffer (xfer, (hsize_t)1000, tconv_buf, NULL)<0) goto error; /* Use chunked storage with compression */ if ((dc = H5Pcreate (H5P_DATASET_CREATE))<0) goto error; diff --git a/test/dtypes.c b/test/dtypes.c index 28862cd..77bf585 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -487,7 +487,7 @@ test_compound_2(void) H5Tclose(array_dt); /* Perform the conversion */ - if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(st, dt, (hsize_t)nelmts, buf, bkg, H5P_DEFAULT)<0) goto error; /* Compare results */ for (i=0; i<nelmts; i++) { @@ -602,7 +602,7 @@ test_compound_3(void) H5Tclose(array_dt); /* Perform the conversion */ - if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0) + if (H5Tconvert(st, dt, (hsize_t)nelmts, buf, bkg, H5P_DEFAULT)<0) goto error; /* Compare results */ @@ -722,7 +722,7 @@ test_compound_4(void) H5Tclose(array_dt); /* Perform the conversion */ - if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0) + if (H5Tconvert(st, dt, (hsize_t)nelmts, buf, bkg, H5P_DEFAULT)<0) goto error; /* Compare results */ @@ -843,7 +843,7 @@ test_compound_5(void) /* Convert data */ memcpy(buf, src, sizeof(src)); - H5Tconvert(src_type, dst_type, 2, buf, bkg, H5P_DEFAULT); + H5Tconvert(src_type, dst_type, (hsize_t)2, buf, bkg, H5P_DEFAULT); dst = (dst_type_t*)buf; /* Cleanup */ @@ -935,7 +935,7 @@ test_compound_6(void) goto error; /* Perform the conversion */ - if (H5Tconvert(st, dt, nelmts, buf, bkg, H5P_DEFAULT)<0) + if (H5Tconvert(st, dt, (hsize_t)nelmts, buf, bkg, H5P_DEFAULT)<0) goto error; /* Compare results */ @@ -1342,13 +1342,13 @@ test_conv_str_1(void) dst_type = mkstr(5, H5T_STR_NULLTERM); buf = calloc(2, 10); memcpy(buf, "abcdefghi\0abcdefghi\0", 20); - if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcd\0abcd\0abcdefghi\0", 20)) { FAILED(); puts(" Truncated C-string test failed"); goto error; } - if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcd\0\0\0\0\0\0abcd\0\0\0\0\0\0", 20)) { FAILED(); puts(" Extended C-string test failed"); @@ -1365,13 +1365,13 @@ test_conv_str_1(void) dst_type = mkstr(5, H5T_STR_NULLPAD); buf = calloc(2, 10); memcpy(buf, "abcdefghijabcdefghij", 20); - if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcdeabcdeabcdefghij", 20)) { FAILED(); puts(" Truncated C buffer test failed"); goto error; } - if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) { FAILED(); puts(" Extended C buffer test failed"); @@ -1388,13 +1388,13 @@ test_conv_str_1(void) dst_type = mkstr(5, H5T_STR_SPACEPAD); buf = calloc(2, 10); memcpy(buf, "abcdefghijabcdefghij", 20); - if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcdeabcdeabcdefghij", 20)) { FAILED(); puts(" Truncated Fortran-string test failed"); goto error; } - if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcde abcde ", 20)) { FAILED(); puts(" Extended Fortran-string test failed"); @@ -1414,7 +1414,7 @@ test_conv_str_1(void) dst_type = mkstr(10, H5T_STR_NULLTERM); buf = calloc(2, 10); memcpy(buf, "abcdefghijabcdefghij", 20); - if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcdefghijabcdefghij", 20)) { FAILED(); puts(" Non-terminated string test 1"); @@ -1423,14 +1423,14 @@ test_conv_str_1(void) H5Tclose(dst_type); dst_type = mkstr(5, H5T_STR_NULLTERM); memcpy(buf, "abcdefghijabcdefghij", 20); - if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcd\0abcd\0abcdefghij", 20)) { FAILED(); puts(" Non-terminated string test 2"); goto error; } memcpy(buf, "abcdeabcdexxxxxxxxxx", 20); - if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) { FAILED(); puts(" Non-terminated string test 2"); @@ -1447,13 +1447,13 @@ test_conv_str_1(void) dst_type = mkstr(10, H5T_STR_SPACEPAD); buf = calloc(2, 10); memcpy(buf, "abcdefghi\0abcdefghi\0", 20); - if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcdefghi abcdefghi ", 20)) { FAILED(); puts(" C string to Fortran test 1"); goto error; } - if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcdefghi\0abcdefghi\0", 20)) { FAILED(); puts(" Fortran to C string test 1"); @@ -1462,13 +1462,13 @@ test_conv_str_1(void) if (H5Tclose(dst_type)<0) goto error; dst_type = mkstr(5, H5T_STR_SPACEPAD); memcpy(buf, "abcdefgh\0\0abcdefgh\0\0", 20); - if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcdeabcdeabcdefgh\0\0", 20)) { FAILED(); puts(" C string to Fortran test 2"); goto error; } - if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) { FAILED(); puts(" Fortran to C string test 2"); @@ -1479,13 +1479,13 @@ test_conv_str_1(void) src_type = mkstr(5, H5T_STR_NULLTERM); dst_type = mkstr(10, H5T_STR_SPACEPAD); memcpy(buf, "abcd\0abcd\0xxxxxxxxxx", 20); - if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcd abcd ", 20)) { FAILED(); puts(" C string to Fortran test 3"); goto error; } - if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcd\0abcd\0abcd ", 20)) { FAILED(); puts(" Fortran to C string test 3"); @@ -1502,13 +1502,13 @@ test_conv_str_1(void) dst_type = mkstr(10, H5T_STR_SPACEPAD); buf = calloc(2, 10); memcpy(buf, "abcdefghijabcdefghij", 20); - if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcdefghijabcdefghij", 20)) { FAILED(); puts(" C buffer to Fortran test 1"); goto error; } - if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcdefghijabcdefghij", 20)) { FAILED(); puts(" Fortran to C buffer test 1"); @@ -1517,13 +1517,13 @@ test_conv_str_1(void) if (H5Tclose(dst_type)<0) goto error; dst_type = mkstr(5, H5T_STR_SPACEPAD); memcpy(buf, "abcdefgh\0\0abcdefgh\0\0", 20); - if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcdeabcdeabcdefgh\0\0", 20)) { FAILED(); puts(" C buffer to Fortran test 2"); goto error; } - if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcde\0\0\0\0\0abcde\0\0\0\0\0", 20)) { FAILED(); puts(" Fortran to C buffer test 2"); @@ -1534,13 +1534,13 @@ test_conv_str_1(void) src_type = mkstr(5, H5T_STR_NULLPAD); dst_type = mkstr(10, H5T_STR_SPACEPAD); memcpy(buf, "abcd\0abcd\0xxxxxxxxxx", 20); - if (H5Tconvert(src_type, dst_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src_type, dst_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcd abcd ", 20)) { FAILED(); puts(" C buffer to Fortran test 3"); goto error; } - if (H5Tconvert(dst_type, src_type, 2, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(dst_type, src_type, (hsize_t)2, buf, NULL, H5P_DEFAULT)<0) goto error; if (memcmp(buf, "abcd\0abcd\0abcd ", 20)) { FAILED(); puts(" Fortran to C buffer test 3"); @@ -1609,8 +1609,8 @@ test_conv_str_2(void) } printf("%-70s", s); fflush(stdout); - if (H5Tconvert(c_type, f_type, nelmts, buf, NULL, H5P_DEFAULT)<0) goto error; - if (H5Tconvert(f_type, c_type, nelmts, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(c_type, f_type, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(f_type, c_type, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error; PASSED(); } ret_value = 0; @@ -1671,7 +1671,7 @@ test_conv_enum_1(void) } printf("%-70s", s); fflush(stdout); - if (H5Tconvert(t1, t2, nelmts, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(t1, t2, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error; PASSED(); } @@ -1684,7 +1684,7 @@ test_conv_enum_1(void) } printf("%-70s", s); fflush(stdout); - if (H5Tconvert(t2, t1, nelmts, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(t2, t1, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error; PASSED(); } ret_value = 0; @@ -1731,7 +1731,7 @@ test_conv_bitfield(void) dt = H5Tcopy(H5T_STD_B32LE); buf[0] = buf[1] = 0xAA; buf[2] = buf[3] = 0x55; /*irrelevant*/ - if (H5Tconvert(st, dt, 1, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(st, dt, (hsize_t)1, buf, NULL, H5P_DEFAULT)<0) goto error; if (buf[0]!=0xAA || buf[1]!=0xAA || buf[2]!=0 || buf[3]!=0) { FAILED(); printf(" s=0xaaaa, d=0x%02x%02x%02x%02x (test 1)\n", @@ -1750,7 +1750,7 @@ test_conv_bitfield(void) H5Tset_precision(dt, 12); H5Tset_offset(dt, 10); buf[0] = 0xA8; buf[1] = 0x2A; buf[2] = buf[3] = 0; - if (H5Tconvert(st, dt, 1, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(st, dt, (hsize_t)1, buf, NULL, H5P_DEFAULT)<0) goto error; if (buf[0]!=0 || buf[1]!=0xA8 || buf[2]!=0x2A || buf[3]!=0) { FAILED(); printf(" s=0x2AA8 d=0x%02x%02x%02x%02x (test 2)\n", @@ -1764,7 +1764,7 @@ test_conv_bitfield(void) */ H5Tset_pad(dt, H5T_PAD_ONE, H5T_PAD_ONE); buf[0] = 0xA8; buf[1] = 0x2A; buf[2] = buf[3] = 0; - if (H5Tconvert(st, dt, 1, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(st, dt, (hsize_t)1, buf, NULL, H5P_DEFAULT)<0) goto error; if (buf[0]!=0xff || buf[1]!=0xAB || buf[2]!=0xEA || buf[3]!=0xff) { FAILED(); printf(" s=0x2AA8 d=0x%02x%02x%02x%02x (test 3)\n", @@ -1804,7 +1804,7 @@ test_conv_bitfield(void) */ static herr_t convert_opaque(hid_t UNUSED st, hid_t UNUSED dt, H5T_cdata_t *cdata, - size_t UNUSED nelmts, size_t UNUSED buf_stride, + hsize_t UNUSED nelmts, size_t UNUSED buf_stride, size_t UNUSED bkg_stride, void UNUSED *_buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plid) { @@ -1848,7 +1848,7 @@ test_opaque(void) /* Make sure that we can't convert between the types yet */ H5E_BEGIN_TRY { - status = H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL, H5P_DEFAULT); + status = H5Tconvert(st, dt, (hsize_t)OPAQUE_NELMTS, buf, NULL, H5P_DEFAULT); } H5E_END_TRY; if (status>=0) { FAILED(); @@ -1861,7 +1861,7 @@ test_opaque(void) goto error; /* Try the conversion again, this time it should work */ - if (H5Tconvert(st, dt, OPAQUE_NELMTS, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(st, dt, (hsize_t)OPAQUE_NELMTS, buf, NULL, H5P_DEFAULT)<0) goto error; if (saved+1 != num_opaque_conversions_g) { FAILED(); printf(" unexpected number of opaque conversions\n"); @@ -1911,7 +1911,7 @@ test_conv_int (void) /* (unsigned)0x80000000 -> (unsigned)0xffff */ byte[0] = byte[1] = byte[2] = 0; byte[3] = 0x80; - if (H5Tconvert (H5T_STD_U32LE, H5T_STD_U16LE, 1, byte, NULL, H5P_DEFAULT)<0) { + if (H5Tconvert (H5T_STD_U32LE, H5T_STD_U16LE, (hsize_t)1, byte, NULL, H5P_DEFAULT)<0) { goto error; } if (byte[0]!=0xff || byte[1]!=0xff) { @@ -1924,7 +1924,7 @@ test_conv_int (void) /* (unsigned)0xffffffff -> (signed)0x7fff */ byte[0] = byte[1] = byte[2] = byte[3] = 0xff; - if (H5Tconvert (H5T_STD_U32LE, H5T_STD_I16LE, 1, byte, NULL, H5P_DEFAULT)<0) { + if (H5Tconvert (H5T_STD_U32LE, H5T_STD_I16LE, (hsize_t)1, byte, NULL, H5P_DEFAULT)<0) { goto error; } if (byte[0]!=0xff || byte[1]!=0x7f) { @@ -1937,7 +1937,7 @@ test_conv_int (void) /* (signed)0xffffffff -> (unsigned)0x0000 */ byte[0] = byte[1] = byte[2] = byte[3] = 0xff; - if (H5Tconvert (H5T_STD_I32LE, H5T_STD_U16LE, 1, byte, NULL, H5P_DEFAULT)<0) { + if (H5Tconvert (H5T_STD_I32LE, H5T_STD_U16LE, (hsize_t)1, byte, NULL, H5P_DEFAULT)<0) { goto error; } if (byte[0]!=0x00 || byte[1]!=0x00) { @@ -1951,7 +1951,7 @@ test_conv_int (void) /* (signed)0x7fffffff -> (unsigned)0xffff */ byte[0] = byte[1] = byte[2] = 0xff; byte[3] = 0x7f; - if (H5Tconvert (H5T_STD_I32LE, H5T_STD_U16LE, 1, byte, NULL, H5P_DEFAULT)<0) { + if (H5Tconvert (H5T_STD_I32LE, H5T_STD_U16LE, (hsize_t)1, byte, NULL, H5P_DEFAULT)<0) { goto error; } if (byte[0]!=0xff || byte[1]!=0xff) { @@ -1965,7 +1965,7 @@ test_conv_int (void) /* (signed)0x7fffffff -> (signed)0x7fff */ byte[0] = byte[1] = byte[2] = 0xff; byte[3] = 0x7f; - if (H5Tconvert (H5T_STD_I32LE, H5T_STD_I16LE, 1, byte, NULL, H5P_DEFAULT)<0) { + if (H5Tconvert (H5T_STD_I32LE, H5T_STD_I16LE, (hsize_t)1, byte, NULL, H5P_DEFAULT)<0) { goto error; } if (byte[0]!=0xff || byte[1]!=0x7f) { @@ -1979,7 +1979,7 @@ test_conv_int (void) /* (signed)0xbfffffff -> (signed)0x8000 */ byte[0] = byte[1] = byte[2] = 0xff; byte[3] = 0xbf; - if (H5Tconvert (H5T_STD_I32LE, H5T_STD_I16LE, 1, byte, NULL, H5P_DEFAULT)<0) { + if (H5Tconvert (H5T_STD_I32LE, H5T_STD_I16LE, (hsize_t)1, byte, NULL, H5P_DEFAULT)<0) { goto error; } if (byte[0]!=0x00 || byte[1]!=0x80) { @@ -2174,7 +2174,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) for (j=0; j<nelmts*src_size; j++) buf[j] = saved[j] = rand(); /* Perform the conversion */ - if (H5Tconvert(src, dst, nelmts, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src, dst, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error; /* Check the results from the library against hardware */ for (j=0; j<nelmts; j++) { @@ -3067,17 +3067,17 @@ test_conv_int_2(void) /* Source type */ src_type = H5Tcopy(H5T_NATIVE_CHAR); - H5Tset_size(src_type, i); + H5Tset_size(src_type, (size_t)i); /* Destination type */ dst_type = H5Tcopy(H5T_NATIVE_CHAR); - H5Tset_size(dst_type, j); + H5Tset_size(dst_type, (size_t)j); /* * Conversion. If overlap calculations aren't right then an * assertion will fail in H5T_conv_i_i() */ - H5Tconvert(src_type, dst_type, 100, buf, NULL, H5P_DEFAULT); + H5Tconvert(src_type, dst_type, (hsize_t)100, buf, NULL, H5P_DEFAULT); H5Tclose(src_type); H5Tclose(dst_type); } @@ -3345,7 +3345,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) } /* Perform the conversion in software */ - if (H5Tconvert(src, dst, nelmts, buf, NULL, H5P_DEFAULT)<0) goto error; + if (H5Tconvert(src, dst, (hsize_t)nelmts, buf, NULL, H5P_DEFAULT)<0) goto error; /* Check the software results against the hardware */ for (j=0; j<nelmts; j++) { diff --git a/test/external.c b/test/external.c index 0ea5498..810d5b8 100644 --- a/test/external.c +++ b/test/external.c @@ -98,7 +98,7 @@ test_1a(hid_t file) /* Create the dataset */ if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error; cur_size[0] = max_size[0] = 100; - if (H5Pset_external(dcpl, "ext1.data", 0, + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)))<0) goto error; if ((space = H5Screate_simple (1, cur_size, max_size))<0) goto error; if ((dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, dcpl))<0) @@ -177,7 +177,7 @@ test_1b(hid_t file) TESTING("external storage is too small"); if ((dcpl = H5Pcreate (H5P_DATASET_CREATE))<0) goto error; cur_size[0] = max_size[0] = 100; - if (H5Pset_external(dcpl, "ext1.data", 0, + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)-1))<0) goto error; if ((space = H5Screate_simple (1, cur_size, max_size))<0) goto error; H5E_BEGIN_TRY { @@ -234,7 +234,7 @@ test_1c(hid_t file) if ((dcpl=H5Pcreate (H5P_DATASET_CREATE))<0) goto error; cur_size[0] = 100; max_size[0] = 200; - if (H5Pset_external(dcpl, "ext1.data", 0, + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)))<0) goto error; if ((space = H5Screate_simple (1, cur_size, max_size))<0) goto error; if ((dset = H5Dcreate (file, "dset3", H5T_NATIVE_INT, space, dcpl))<0) @@ -285,7 +285,7 @@ test_1d(hid_t file) if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error; cur_size[0] = 100; max_size[0] = 200; - if (H5Pset_external(dcpl, "ext1.data", 0, + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)-1))<0) goto error; if ((space=H5Screate_simple(1, cur_size, max_size))<0) goto error; H5E_BEGIN_TRY { @@ -345,7 +345,7 @@ test_1e(hid_t file) /* Create dataset */ if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error; - if (H5Pset_external(dcpl, "ext1.data", 0, H5F_UNLIMITED)<0) goto error; + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED)<0) goto error; cur_size[0] = 100; max_size[0] = H5S_UNLIMITED; if ((space=H5Screate_simple(1, cur_size, max_size))<0) goto error; @@ -423,13 +423,13 @@ test_1f(hid_t file) TESTING("multiple external files"); if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error; cur_size[0] = max_size[0] = 100; - if (H5Pset_external(dcpl, "ext1.data", 0, + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)/4))<0) goto error; - if (H5Pset_external(dcpl, "ext2.data", 0, + if (H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)/4))<0) goto error; - if (H5Pset_external(dcpl, "ext3.data", 0, + if (H5Pset_external(dcpl, "ext3.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)/4))<0) goto error; - if (H5Pset_external(dcpl, "ext4.data", 0, + if (H5Pset_external(dcpl, "ext4.data", (off_t)0, (hsize_t)(max_size[0]*sizeof(int)/4))<0) goto error; if ((space=H5Screate_simple(1, cur_size, max_size))<0) goto error; if ((dset=H5Dcreate(file, "dset6", H5T_NATIVE_INT, space, dcpl))<0) @@ -476,9 +476,9 @@ test_1g(void) TESTING("external file following unlimited file"); if ((dcpl=H5Pcreate (H5P_DATASET_CREATE))<0) goto error; - if (H5Pset_external(dcpl, "ext1.data", 0, H5F_UNLIMITED)<0) goto error; + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED)<0) goto error; H5E_BEGIN_TRY { - status = H5Pset_external(dcpl, "ext2.data", 0, (hsize_t)100); + status = H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)100); } H5E_END_TRY; if (status>=0) { FAILED(); @@ -528,9 +528,9 @@ test_1h(void) TESTING("address overflow in external files"); if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error; - if (H5Pset_external(dcpl, "ext1.data", 0, H5F_UNLIMITED-1)<0) goto error; + if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED-1)<0) goto error; H5E_BEGIN_TRY { - status = H5Pset_external(dcpl, "ext2.data", 0, (hsize_t)100); + status = H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)100); } H5E_END_TRY; if (status>=0) { FAILED(); @@ -596,7 +596,7 @@ test_2 (hid_t fapl) assert (fd>=0); /* n = lseek (fd, (off_t)(i*10), SEEK_SET); */ - n = write(fd,temparray,i*10); + n = write(fd,temparray,(size_t)i*10); assert (n>=0 && (size_t)n==i*10); n = write (fd, part, sizeof(part)); assert (n==sizeof(part)); @@ -617,10 +617,10 @@ test_2 (hid_t fapl) /* Create the dataset */ if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error; - if (H5Pset_external (dcpl, "extern_1a.raw", 0, (hsize_t)sizeof part)<0 || - H5Pset_external (dcpl, "extern_2a.raw", 10, (hsize_t)sizeof part)<0 || - H5Pset_external (dcpl, "extern_3a.raw", 20, (hsize_t)sizeof part)<0 || - H5Pset_external (dcpl, "extern_4a.raw", 30, (hsize_t)sizeof part)<0) + if (H5Pset_external (dcpl, "extern_1a.raw", (off_t)0, (hsize_t)sizeof part)<0 || + H5Pset_external (dcpl, "extern_2a.raw", (off_t)10, (hsize_t)sizeof part)<0 || + H5Pset_external (dcpl, "extern_3a.raw", (off_t)20, (hsize_t)sizeof part)<0 || + H5Pset_external (dcpl, "extern_4a.raw", (off_t)30, (hsize_t)sizeof part)<0) goto error; cur_size = 100; if ((space=H5Screate_simple (1, &cur_size, NULL))<0) goto error; @@ -721,10 +721,10 @@ test_3 (hid_t fapl) /* Create the external file list */ if ((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error; - if (H5Pset_external(dcpl, "extern_1b.raw", 0, (hsize_t)sizeof part)<0 || - H5Pset_external(dcpl, "extern_2b.raw", 10, (hsize_t)sizeof part)<0 || - H5Pset_external(dcpl, "extern_3b.raw", 20, (hsize_t)sizeof part)<0 || - H5Pset_external(dcpl, "extern_4b.raw", 30, H5F_UNLIMITED)<0) + if (H5Pset_external(dcpl, "extern_1b.raw", (off_t)0, (hsize_t)sizeof part)<0 || + H5Pset_external(dcpl, "extern_2b.raw", (off_t)10, (hsize_t)sizeof part)<0 || + H5Pset_external(dcpl, "extern_3b.raw", (off_t)20, (hsize_t)sizeof part)<0 || + H5Pset_external(dcpl, "extern_4b.raw", (off_t)30, H5F_UNLIMITED)<0) goto error; /* Make sure the output files are fresh*/ diff --git a/test/fillval.c b/test/fillval.c index f5f9700..86fa6a7 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -380,7 +380,8 @@ test_rdwr(hid_t fapl, const char *base_name, H5D_layout_t layout) nelmts *= hs_size[i]; } if ((mspace=H5Screate_simple(5, hs_size, hs_size))<0) goto error; - buf = malloc(nelmts*sizeof(int)); + assert((nelmts*sizeof(int))==(hssize_t)((size_t)(nelmts*sizeof(int)))); /*check for overflow*/ + buf = malloc((size_t)(nelmts*sizeof(int))); for (i=0; i<nelmts; i++) buf[i] = 9999; if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, hs_stride, hs_size, NULL)<0) goto error; @@ -519,7 +520,7 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) nelmts = max_size[0]*max_size[1]*max_size[2]*max_size[3]*max_size[4]; if ((fd=open(FILE_NAME_RAW, O_RDWR|O_CREAT|O_TRUNC, 0666))<0 || close(fd)<0) goto error; - if (H5Pset_external(dcpl, FILE_NAME_RAW, 0, nelmts*sizeof(int))<0) + if (H5Pset_external(dcpl, FILE_NAME_RAW, (off_t)0, (hsize_t)nelmts*sizeof(int))<0) goto error; } #endif @@ -577,7 +578,8 @@ test_extend(hid_t fapl, const char *base_name, H5D_layout_t layout) nelmts *= hs_size[i]; } if ((mspace=H5Screate_simple(5, hs_size, hs_size))<0) goto error; - buf = malloc(nelmts*sizeof(int)); + assert((nelmts*sizeof(int))==(hssize_t)((size_t)(nelmts*sizeof(int)))); /*check for overflow*/ + buf = malloc((size_t)(nelmts*sizeof(int))); for (i=0; i<nelmts; i++) buf[i] = 9999; if (H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, hs_stride, hs_size, NULL)<0) goto error; diff --git a/test/h5test.c b/test/h5test.c index f8de21a..db4d59d 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -272,7 +272,38 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) if (!base_name || !fullname || size<1) return NULL; -#ifndef H5_WANT_H5_V1_2_COMPAT +#ifdef H5_WANT_H5_V1_2_COMPAT + /* figure out the suffix */ + if (H5P_DEFAULT!=fapl){ + if ((driver=H5Pget_driver(fapl))<0) + return NULL; + if (H5F_LOW_FAMILY==driver) { + suffix = "%05d.h5"; + } else if (H5F_LOW_CORE==driver) { + suffix = NULL; + } + } + + /* Use different ones depending on parallel or serial driver used. */ + if (H5P_DEFAULT!=fapl && H5F_LOW_MPIO==driver){ + /* For parallel: + * First use command line option, then the environment variable, + * then try the constant + */ + prefix = (paraprefix ? paraprefix : getenv("HDF5_PARAPREFIX")); +#ifdef HDF5_PARAPREFIX + if (!prefix) prefix = HDF5_PARAPREFIX; +#endif + }else{ + /* For serial: + * First use the environment variable, then try the constant + */ + prefix = getenv("HDF5_PREFIX"); +#ifdef HDF5_PREFIX + if (!prefix) prefix = HDF5_PREFIX; +#endif + } +#else /* H5_WANT_H5_V1_2_COMPAT */ /* figure out the suffix */ if (H5P_DEFAULT!=fapl){ if ((driver=H5Pget_driver(fapl))<0) return NULL; @@ -307,7 +338,7 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) /* Prepend the prefix value to the base name */ if (prefix && *prefix) { - if (HDsnprintf(fullname, (long)size, "%s/%s", prefix, base_name)==(int)size) { + if (HDsnprintf(fullname, size, "%s/%s", prefix, base_name)==(int)size) { return NULL; /*buffer is too small*/ } } else if (strlen(base_name)>=size) { diff --git a/test/hyperslab.c b/test/hyperslab.c index 389e803..f2eeb2b 100644 --- a/test/hyperslab.c +++ b/test/hyperslab.c @@ -156,7 +156,7 @@ test_fill(size_t nx, size_t ny, size_t nz, uintn acc; /*accumulator */ size_t i, j, k, dx, dy, dz; /*counters */ size_t u, v, w; - int ndims; /*hyperslab dimensionality */ + uintn ndims; /*hyperslab dimensionality */ char dim[64], s[256]; /*temp string */ uintn fill_value; /*fill value */ @@ -330,7 +330,7 @@ test_copy(int mode, uintn acc; /*accumulator */ hsize_t i, j, k, dx, dy, dz; /*counters */ hsize_t u, v, w; - int ndims; /*hyperslab dimensionality */ + uintn ndims; /*hyperslab dimensionality */ char dim[64], s[256]; /*temp string */ const char *sub; diff --git a/test/istore.c b/test/istore.c index 3f266c8..f706d60 100644 --- a/test/istore.c +++ b/test/istore.c @@ -92,10 +92,10 @@ print_array(uint8_t *array, size_t nx, size_t ny, size_t nz) *------------------------------------------------------------------------- */ static int -new_object(H5F_t *f, const char *name, intn ndims, H5G_entry_t *ent/*out*/) +new_object(H5F_t *f, const char *name, uintn ndims, H5G_entry_t *ent/*out*/) { H5O_layout_t layout; - intn i; + uintn u; /* Create the object header */ if (H5O_create(f, 64, ent)) { @@ -107,11 +107,11 @@ new_object(H5F_t *f, const char *name, intn ndims, H5G_entry_t *ent/*out*/) /* create chunked storage */ layout.type = H5D_CHUNKED; layout.ndims = ndims; - for (i = 0; i < ndims; i++) { - if (i < (int)NELMTS(align_g)) { - layout.dim[i] = align_g[i]; + for (u = 0; u < ndims; u++) { + if (u < (int)NELMTS(align_g)) { + layout.dim[u] = align_g[u]; } else { - layout.dim[i] = 2; + layout.dim[u] = 2; } } H5F_arr_create(f, &layout/*in,out*/); @@ -158,14 +158,14 @@ static herr_t test_create(H5F_t *f, const char *prefix) { H5G_entry_t handle; - intn i; + uintn u; char name[256]; TESTING("istore create"); - for (i = 1; i <= H5O_LAYOUT_NDIMS; i++) { - HDsnprintf(name, sizeof name, "%s_%02d", prefix, i); - if (new_object(f, name, i, &handle) < 0) + for (u = 1; u <= H5O_LAYOUT_NDIMS; u++) { + HDsnprintf(name, sizeof name, "%s_%02u", prefix, u); + if (new_object(f, name, u, &handle) < 0) return FAIL; } @@ -198,7 +198,7 @@ test_extend(H5F_t *f, const char *prefix, { H5G_entry_t handle; hsize_t i, j, k, ctr; - int ndims; + uintn ndims; uint8_t *buf = NULL, *check = NULL, *whole = NULL; char dims[64], s[256], name[256]; hssize_t offset[3]; @@ -233,7 +233,7 @@ test_extend(H5F_t *f, const char *prefix, /* Build the new empty object */ sprintf(name, "%s_%s", prefix, dims); if (new_object(f, name, ndims, &handle) < 0) { - printf(" Cannot create %d-d object `%s'\n", ndims, name); + printf(" Cannot create %u-d object `%s'\n", ndims, name); goto error; } if (NULL == H5O_read(&handle, H5O_LAYOUT, 0, &layout)) { @@ -402,7 +402,7 @@ static herr_t test_sparse(H5F_t *f, const char *prefix, size_t nblocks, size_t nx, size_t ny, size_t nz) { - intn ndims; + uintn ndims; hsize_t ctr; char dims[64], s[256], name[256]; hssize_t offset[3]; @@ -434,7 +434,7 @@ test_sparse(H5F_t *f, const char *prefix, size_t nblocks, /* Build the new empty object */ sprintf(name, "%s_%s", prefix, dims); if (new_object(f, name, ndims, &handle) < 0) { - printf(" Cannot create %d-d object `%s'\n", ndims, name); + printf(" Cannot create %u-d object `%s'\n", ndims, name); goto error; } if (NULL == H5O_read(&handle, H5O_LAYOUT, 0, &layout)) { diff --git a/test/stream_test.c b/test/stream_test.c index 239c2c6..ffe1c18 100644 --- a/test/stream_test.c +++ b/test/stream_test.c @@ -291,7 +291,7 @@ static int receiver (void) /* * Read dataset from file into memory. */ - data = (int *) malloc (nelems * sizeof (int)); + data = (int *) malloc ((size_t)(nelems * sizeof (int))); status = H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); H5Dclose (dataset); diff --git a/test/tarray.c b/test/tarray.c index 41e92d3..ebb5ff8 100644 --- a/test/tarray.c +++ b/test/tarray.c @@ -1527,7 +1527,7 @@ typedef struct { int nsubfields; char *name[NMAX]; - off_t offset[NMAX]; + size_t offset[NMAX]; hid_t datatype[NMAX]; } CmpDTSinfo; diff --git a/test/testhdf5.h b/test/testhdf5.h index 7e6c9c6..cc5f8b6 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -26,8 +26,10 @@ #include <H5private.h> #include <H5Eprivate.h> +#ifndef HDF5_TEST_MASTER extern int num_errs; extern int Verbosity; +#endif /* HDF5_TEST_MASTER */ /* Use %ld to print the value because long should cover most cases. */ /* Used to make certain a return value _is_not_ a value */ diff --git a/test/trefer.c b/test/trefer.c index 28cf428..9935b5b 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -96,7 +96,7 @@ test_reference_obj(void) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a group */ - group=H5Gcreate(fid1,"Group1",-1); + group=H5Gcreate(fid1,"Group1",(size_t)-1); CHECK(group, FAIL, "H5Gcreate"); /* Set group's comment */ @@ -455,7 +455,7 @@ test_reference_region(void) ret = H5Sget_select_hyper_nblocks(sid2); VERIFY(ret, 1, "H5Sget_select_hyper_nblocks"); coords=HDmalloc(ret*SPACE2_RANK*sizeof(hsize_t)*2); /* allocate space for the hyperslab blocks */ - ret = H5Sget_select_hyper_blocklist(sid2,0,ret,coords); + ret = H5Sget_select_hyper_blocklist(sid2,(hsize_t)0,(hsize_t)ret,coords); CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); VERIFY(coords[0], 2, "Hyperslab Coordinates"); VERIFY(coords[1], 2, "Hyperslab Coordinates"); @@ -483,7 +483,7 @@ test_reference_region(void) ret = H5Sget_select_elem_npoints(sid2); VERIFY(ret, 10, "H5Sget_select_elem_npoints"); coords=HDmalloc(ret*SPACE2_RANK*sizeof(hsize_t)); /* allocate space for the element points */ - ret = H5Sget_select_elem_pointlist(sid2,0,ret,coords); + ret = H5Sget_select_elem_pointlist(sid2,(hsize_t)0,(hsize_t)ret,coords); CHECK(ret, FAIL, "H5Sget_select_elem_pointlist"); VERIFY((hssize_t)coords[0], coord1[0][0], "Element Coordinates"); VERIFY((hssize_t)coords[1], coord1[0][1], "Element Coordinates"); diff --git a/test/tselect.c b/test/tselect.c index 33e3988..3625e24 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -326,7 +326,7 @@ test_select_point(void) CHECK(ret, FAIL, "H5Sselect_elements"); /* Verify correct elements selected */ - H5Sget_select_elem_pointlist(sid1,0,POINT1_NPOINTS,(hsize_t *)temp_coord1); + H5Sget_select_elem_pointlist(sid1,(hsize_t)0,(hsize_t)POINT1_NPOINTS,(hsize_t *)temp_coord1); for(i=0; i<POINT1_NPOINTS; i++) { VERIFY(temp_coord1[i][0],coord1[i][0],"H5Sget_select_elem_pointlist"); VERIFY(temp_coord1[i][1],coord1[i][1],"H5Sget_select_elem_pointlist"); @@ -351,7 +351,7 @@ test_select_point(void) CHECK(ret, FAIL, "H5Sselect_elements"); /* Verify correct elements selected */ - H5Sget_select_elem_pointlist(sid1,POINT1_NPOINTS,POINT1_NPOINTS,(hsize_t *)temp_coord1); + H5Sget_select_elem_pointlist(sid1,(hsize_t)POINT1_NPOINTS,(hsize_t)POINT1_NPOINTS,(hsize_t *)temp_coord1); for(i=0; i<POINT1_NPOINTS; i++) { VERIFY(temp_coord1[i][0],coord1[i][0],"H5Sget_select_elem_pointlist"); VERIFY(temp_coord1[i][1],coord1[i][1],"H5Sget_select_elem_pointlist"); @@ -376,7 +376,7 @@ test_select_point(void) CHECK(ret, FAIL, "H5Sselect_elements"); /* Verify correct elements selected */ - H5Sget_select_elem_pointlist(sid2,0,POINT1_NPOINTS,(hsize_t *)temp_coord2); + H5Sget_select_elem_pointlist(sid2,(hsize_t)0,(hsize_t)POINT1_NPOINTS,(hsize_t *)temp_coord2); for(i=0; i<POINT1_NPOINTS; i++) { VERIFY(temp_coord2[i][0],coord2[i][0],"H5Sget_select_elem_pointlist"); VERIFY(temp_coord2[i][1],coord2[i][1],"H5Sget_select_elem_pointlist"); @@ -405,7 +405,7 @@ test_select_point(void) CHECK(ret, FAIL, "H5Sselect_elements"); /* Verify correct elements selected */ - H5Sget_select_elem_pointlist(sid2,0,POINT1_NPOINTS,(hsize_t *)temp_coord2); + H5Sget_select_elem_pointlist(sid2,(hsize_t)0,(hsize_t)POINT1_NPOINTS,(hsize_t *)temp_coord2); for(i=0; i<POINT1_NPOINTS; i++) { VERIFY(temp_coord2[i][0],coord2[i][0],"H5Sget_select_elem_pointlist"); VERIFY(temp_coord2[i][1],coord2[i][1],"H5Sget_select_elem_pointlist"); @@ -447,7 +447,7 @@ test_select_point(void) CHECK(ret, FAIL, "H5Sselect_elements"); /* Verify correct elements selected */ - H5Sget_select_elem_pointlist(sid2,0,POINT1_NPOINTS,(hsize_t *)temp_coord3); + H5Sget_select_elem_pointlist(sid2,(hsize_t)0,(hsize_t)POINT1_NPOINTS,(hsize_t *)temp_coord3); for(i=0; i<POINT1_NPOINTS; i++) { VERIFY(temp_coord3[i][0],coord3[i][0],"H5Sget_select_elem_pointlist"); VERIFY(temp_coord3[i][1],coord3[i][1],"H5Sget_select_elem_pointlist"); @@ -471,7 +471,7 @@ test_select_point(void) CHECK(ret, FAIL, "H5Sselect_elements"); /* Verify correct elements selected */ - H5Sget_select_elem_pointlist(sid2,POINT1_NPOINTS,POINT1_NPOINTS,(hsize_t *)temp_coord3); + H5Sget_select_elem_pointlist(sid2,(hsize_t)POINT1_NPOINTS,(hsize_t)POINT1_NPOINTS,(hsize_t *)temp_coord3); for(i=0; i<POINT1_NPOINTS; i++) { VERIFY(temp_coord3[i][0],coord3[i][0],"H5Sget_select_elem_pointlist"); VERIFY(temp_coord3[i][1],coord3[i][1],"H5Sget_select_elem_pointlist"); diff --git a/tools/h4toh5anno.c b/tools/h4toh5anno.c index 31ba145..cd09e26 100644 --- a/tools/h4toh5anno.c +++ b/tools/h4toh5anno.c @@ -104,7 +104,7 @@ int Annofil_h4_to_h5(int32 file_id,hid_t h5group){ return FAIL; } - ann_buf = malloc(ann_length + 1); + ann_buf = malloc((size_t)ann_length + 1); if(ann_buf == NULL) { printf("error in allocating memory. \n"); return FAIL; @@ -199,7 +199,7 @@ int Annofil_h4_to_h5(int32 file_id,hid_t h5group){ return FAIL; } - ann_buf = malloc(ann_length+1); + ann_buf = malloc((size_t)ann_length+1); if(ann_buf == NULL) { printf("error in allocating memory. \n"); ANend(an_id); @@ -317,8 +317,8 @@ int Annoobj_h4_to_h5(int32 file_id,int32 obj_ref, int32 obj_tag, int num_lab_anno; int num_des_anno; int32 istat; - int32* des_anno_list; - int32* lab_anno_list; + int32* des_anno_list=NULL; + int32* lab_anno_list=NULL; char* ann_buf; char* ann_obj_name; @@ -380,7 +380,7 @@ int Annoobj_h4_to_h5(int32 file_id,int32 obj_ref, int32 obj_tag, return FAIL; } - ann_buf = malloc(ann_length+1); + ann_buf = malloc((size_t)ann_length+1); if(ann_buf == NULL) { printf("error in allocating annotation memory.\n"); ANendaccess(ann_id); @@ -487,7 +487,7 @@ int Annoobj_h4_to_h5(int32 file_id,int32 obj_ref, int32 obj_tag, return FAIL; } - ann_buf = malloc(ann_length+1); + ann_buf = malloc((size_t)ann_length+1); if(ann_buf == NULL) { printf("error in allocating annotation memory.\n"); diff --git a/tools/h4toh5image.c b/tools/h4toh5image.c index f3d41dc..c5bc1df 100644 --- a/tools/h4toh5image.c +++ b/tools/h4toh5image.c @@ -522,7 +522,7 @@ int gr_palette(int32 file_id,int32 ri_id,hid_t h5dset,hid_t h5_palgroup) { int check_pal; int check_palname; int pal_stat; - char* h5pal_name; + char* h5pal_name=NULL; /* get palette id */ diff --git a/tools/h4toh5main.c b/tools/h4toh5main.c index c936b1b..9881ce0 100644 --- a/tools/h4toh5main.c +++ b/tools/h4toh5main.c @@ -560,7 +560,7 @@ int get_numof_hdf4obj(char*filename,int32 file_id) { int set_helpgroups(hid_t h5root,hid_t* h5dimgptr,hid_t* h5palgptr){ - hid_t h5_dimg;/* hdf5 dimensional scale group identifier. */ + hid_t h5_dimg=(-1);/* hdf5 dimensional scale group identifier. */ hid_t h5_palg;/* hdf5 palette group identifier. */ /*1. dimensional scale group.*/ @@ -581,7 +581,7 @@ int set_helpgroups(hid_t h5root,hid_t* h5dimgptr,hid_t* h5palgptr){ h5_palg = H5Gcreate(h5root,HDF4_PALG,0); if(h5_palg <0) { printf("error in creating hdf5 palette group. \n"); - H5Gclose(h5_dimg); + if(h5_dimg>0) H5Gclose(h5_dimg); return FAIL; } diff --git a/tools/h4toh5sds.c b/tools/h4toh5sds.c index eb90e4c..89e5ddf 100644 --- a/tools/h4toh5sds.c +++ b/tools/h4toh5sds.c @@ -973,7 +973,7 @@ int sdsdim_to_h5dataset(int32 sds_id,int32 sds_rank,hid_t sh5dset, attr_refDims[0] = count_h5objref; attr_refSpace = H5Screate_simple(1,attr_refDims,NULL); attr_refType = H5Tcopy(H5T_STD_REF_OBJ); - alldim_refdat = calloc(count_h5objref,sizeof(hobj_ref_t)); + alldim_refdat = calloc((size_t)count_h5objref,sizeof(hobj_ref_t)); if(alldim_refdat == NULL) { printf("error in allocating memory. \n"); diff --git a/tools/h4toh5util.c b/tools/h4toh5util.c index 64e32cf..879e8a9 100644 --- a/tools/h4toh5util.c +++ b/tools/h4toh5util.c @@ -933,7 +933,7 @@ hid_t mkstr(int size, H5T_str_t pad) { hid_t type; if((type=H5Tcopy(H5T_C_S1))<0) return -1; - if((H5Tset_size(type,size))<0) return -1; + if((H5Tset_size(type,(size_t)size))<0) return -1; if((H5Tset_strpad(type,pad))<0) return -1; return type; @@ -955,7 +955,7 @@ hid_t mkstr(int size, H5T_str_t pad) { */ int h4_transnumattr(hid_t h5g,const char *refname,uint16 group_ref) { - hid_t h5memtype; + hid_t h5memtype=(-1); hid_t h5a_id; hid_t h5a_sid; herr_t ret; diff --git a/tools/h4toh5vdata.c b/tools/h4toh5vdata.c index ed692a9..55a8bf9 100644 --- a/tools/h4toh5vdata.c +++ b/tools/h4toh5vdata.c @@ -28,6 +28,7 @@ Author: Kent Yang(ymuqun@ncsa.uiuc.edu) *****************************************************************************/ #include "h4toh5main.h" +#include <assert.h> /*------------------------------------------------------------------------- * Function: Vdata_h4_to_h5 @@ -152,10 +153,11 @@ int Vdata_h4_to_h5(int32 file_id,int32 vdata_id, hid_t group_id) { return FAIL; } - h5memtype = calloc(nfields,sizeof(hid_t)); - h5type = calloc(nfields,sizeof(hid_t)); - h4memsize = calloc(nfields,sizeof(size_t)); - h4size = calloc(nfields,sizeof(size_t)); + assert(nfields>0); + h5memtype = calloc((size_t)nfields,sizeof(hid_t)); + h5type = calloc((size_t)nfields,sizeof(hid_t)); + h4memsize = calloc((size_t)nfields,sizeof(size_t)); + h4size = calloc((size_t)nfields,sizeof(size_t)); for (i=0;i<nfields;i++) { @@ -199,7 +201,7 @@ int Vdata_h4_to_h5(int32 file_id,int32 vdata_id, hid_t group_id) { } - vd_data = malloc(vdatamem_size*n_records); + vd_data = malloc((size_t)(vdatamem_size*n_records)); istat = VSsetfields(vdata_id,field_name_list); diff --git a/tools/h5debug.c b/tools/h5debug.c index 7f4e91a..76eb472 100644 --- a/tools/h5debug.c +++ b/tools/h5debug.c @@ -71,7 +71,7 @@ main(int argc, char *argv[]) */ if (strchr (argv[1], '%')) { plist = H5Pcreate (H5P_FILE_ACCESS); - H5Pset_fapl_family (plist, 0, H5P_DEFAULT); + H5Pset_fapl_family (plist, (hsize_t)0, H5P_DEFAULT); } if ((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, plist)) < 0) { fprintf(stderr, "cannot open file\n"); diff --git a/tools/h5dump.c b/tools/h5dump.c index b8440a9..ae711a8 100644 --- a/tools/h5dump.c +++ b/tools/h5dump.c @@ -761,7 +761,7 @@ dump_selected_attr(hid_t loc_id, char *name) H5G_stat_t statbuf; j = (int)strlen(name) - 1; - obj_name = malloc(j + 2); + obj_name = malloc((size_t)j + 2); /* find the last / */ while (name[j] != '/' && j >=0) @@ -771,7 +771,7 @@ dump_selected_attr(hid_t loc_id, char *name) if (j == -1) { strcpy(obj_name, "/"); } else { - strncpy(obj_name, name, j+1); + strncpy(obj_name, name, (size_t)j+1); obj_name[j+1] = '\0'; } @@ -1245,7 +1245,7 @@ dump_data(hid_t obj_id, int obj_data) void *buf; hid_t space, type, p_type; int ndims, i; - hsize_t size[64], nelmts = 1; + hsize_t size[64], nelmts = 1, alloc_size; int depth; int stdindent = COL; /* should be 3*/ @@ -1276,7 +1276,9 @@ dump_data(hid_t obj_id, int obj_data) for (i = 0; i < ndims; i++) nelmts *= size[i]; - buf = malloc(nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type))); + alloc_size= nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)); + assert(alloc_size==(hsize_t)((size_t)alloc_size)); /*check for overflow*/ + buf = malloc((size_t)alloc_size); assert(buf); if (H5Aread(obj_id, p_type, buf) >= 0) @@ -1754,7 +1756,7 @@ main(int argc, const char *argv[]) /* init the find_objs_t */ info.threshold = 0; info.prefix_len = prefix_len; - info.prefix = malloc(info.prefix_len); + info.prefix = malloc((size_t)info.prefix_len); info.prefix[0] = '\0'; info.group_table = group_table; info.type_table = type_table; @@ -1876,8 +1878,9 @@ print_enum(hid_t type) } /* Get the names and raw values of all members */ - name = calloc(nmembs, sizeof(char *)); - value = calloc(nmembs, MAX(H5Tget_size(type), dst_size)); + assert(nmembs>0); + name = calloc((size_t)nmembs, sizeof(char *)); + value = calloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size)); for (i = 0; i < nmembs; i++) { name[i] = H5Tget_member_name(type, i); @@ -1886,7 +1889,7 @@ print_enum(hid_t type) /* Convert values to native data type */ if (native > 0) - H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT); + H5Tconvert(super, native, (hsize_t)nmembs, value, NULL, H5P_DEFAULT); /* Sort members by increasing value */ /*not implemented yet*/ diff --git a/tools/h5dumptst.c b/tools/h5dumptst.c index f31658e..d10b0d3 100644 --- a/tools/h5dumptst.c +++ b/tools/h5dumptst.c @@ -1090,7 +1090,7 @@ static hid_t mkstr(int size, H5T_str_t pad) { hid_t type; if ((type=H5Tcopy(H5T_C_S1))<0) return -1; - if (H5Tset_size(type, size)<0) return -1; + if (H5Tset_size(type, (size_t)size)<0) return -1; if (H5Tset_strpad(type, pad)<0) return -1; return type; @@ -1452,7 +1452,7 @@ static void test_objref(void) sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); /* Create a group */ - group=H5Gcreate(fid1,"Group1",-1); + group=H5Gcreate(fid1,"Group1",(size_t)-1); /* Set group's comment */ H5Gset_comment(group,".",write_comment); diff --git a/tools/h5ls.c b/tools/h5ls.c index 671ca42..4fdc673 100644 --- a/tools/h5ls.c +++ b/tools/h5ls.c @@ -833,15 +833,16 @@ display_enum_type(hid_t type, int ind) } /* Get the names and raw values of all members */ - name = calloc(nmembs, sizeof(char*)); - value = calloc(nmembs, MAX(H5Tget_size(type), dst_size)); + assert(nmembs>0); + name = calloc((size_t)nmembs, sizeof(char*)); + value = calloc((size_t)nmembs, MAX(H5Tget_size(type), dst_size)); for (i=0; i<nmembs; i++) { name[i] = H5Tget_member_name(type, i); H5Tget_member_value(type, i, value+i*H5Tget_size(type)); } /* Convert values to native data type */ - if (native>0) H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT); + if (native>0) H5Tconvert(super, native, (hsize_t)nmembs, value, NULL, H5P_DEFAULT); /* Sort members by increasing value */ /*not implemented yet*/ diff --git a/tools/h5toh4.c b/tools/h5toh4.c index 19f4bf3..30b381c 100644 --- a/tools/h5toh4.c +++ b/tools/h5toh4.c @@ -18,7 +18,7 @@ #include <h5tools.h> -#if WIN32 +#ifdef WIN32 typedef unsigned int mode_t; #endif @@ -41,11 +41,8 @@ extern herr_t convert_dataset_string(hid_t, char *, op_data_t *); extern int32 h5type_to_h4type(hid_t); extern hid_t h4type_to_memtype(int32); -extern void init_table(table_t **temp); extern void free_table(table_t **temp); -extern void init_prefix(char **prefix, int length); extern void dump_tables(char* name, table_t* table); -extern herr_t find_objs(hid_t , const char *, void *); extern int get_table_idx(table_t*, unsigned long *); extern int get_tableflag(table_t*, int); extern int set_tableflag(table_t*, int); @@ -129,7 +126,7 @@ main(int argc, char *argv[]) break; } #ifndef WIN32 - if (test_file(h5_filename,O_EXCL,292) != 0 ) { /* 292 Decimal - 0444 Octal, a+r */ + if (test_file(h5_filename,O_EXCL,(mode_t)(S_IRUSR|S_IRGRP|S_IROTH)) != 0 ) { /* 292 Decimal - 0444 Octal, a+r */ DEBUG_PRINT("Error detected in %s() [%s line %d]\n", "main", __FILE__, __LINE__); status = -1; break; @@ -150,7 +147,7 @@ main(int argc, char *argv[]) break; } #ifndef WIN32 - if (test_file(h4_filename,O_CREAT|O_EXCL,436) != 0) { /* 436 Decimal - 0664 Octal, ug+rw,o+r */ + if (test_file(h4_filename,O_CREAT|O_EXCL,(mode_t)(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH)) != 0) { /* 436 Decimal - 0664 Octal, ug+rw,o+r */ DEBUG_PRINT("Error detected in %s() [%s line %d]\n", "main", __FILE__, __LINE__); status = -1; break; diff --git a/tools/h5toh4.h b/tools/h5toh4.h index a6ff37c..d268060 100644 --- a/tools/h5toh4.h +++ b/tools/h5toh4.h @@ -1,13 +1,3 @@ -#ifndef _H5TOH4_H -#define _H5TOH4_H - -#include <mfhdf.h> -#include <hdf5.h> - -#ifdef H5_HAVE_SYS_STAT_H -# include <sys/stat.h> -#endif - /* * Copyright © 1998 NCSA * All rights reserved. @@ -18,6 +8,16 @@ * Purpose: Convert H5 files to H4 files. */ +#ifndef _H5TOH4_H +#define _H5TOH4_H + +#include "hdf.h" +#include "mfhdf.h" +#include "hdf5.h" + +#ifdef H5_HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif typedef struct op_data_t { /* diff --git a/tools/h5tools.c b/tools/h5tools.c index 1af7a6b..f88602d 100644 --- a/tools/h5tools.c +++ b/tools/h5tools.c @@ -52,11 +52,10 @@ #define H5DUMP_BUFSIZE (1024) #endif -#define OPT(X,S) ((X) ? (X) : (S)) -#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) - -#define START_OF_DATA 0x0001 -#define END_OF_DATA 0x0002 +#define OPT(X,S) ((X) ? (X) : (S)) +#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) +#define START_OF_DATA 0x0001 +#define END_OF_DATA 0x0002 /* Special strings embedded in the output */ #define OPTIONAL_LINE_BREAK "\001" @@ -105,13 +104,8 @@ typedef struct h5dump_context_t { typedef herr_t (*H5G_operator_t)(hid_t, const char*, void*); -extern int print_data(hid_t oid, hid_t _p_type, int obj_data); -extern void init_prefix(char **temp, int length); -extern void init_table(table_t **table); extern void free_table(table_t **table); extern void dump_table(char *name, table_t* table); -extern herr_t find_objs(hid_t group, const char *name, void *op_data); -extern int search_obj (table_t *temp, unsigned long *); extern int get_table_idx(table_t *table, unsigned long *); extern int get_tableflag(table_t*, int); extern int set_tableflag(table_t*, int); @@ -720,6 +714,7 @@ static int h5dump_region(hid_t region, h5dump_str_t *str/*in,out*/, const h5dump_t *info) { hssize_t nblocks, npoints; + hsize_t alloc_size; hsize_t *ptdata; int ndims = H5Sget_simple_extent_ndims(region); @@ -729,62 +724,68 @@ h5dump_region(hid_t region, h5dump_str_t *str/*in,out*/, const h5dump_t *info) * the other. */ H5E_BEGIN_TRY { - nblocks = H5Sget_select_hyper_nblocks(region); - npoints = H5Sget_select_elem_npoints(region); + nblocks = H5Sget_select_hyper_nblocks(region); + npoints = H5Sget_select_elem_npoints(region); } H5E_END_TRY; h5dump_str_append(str, "{"); /* Print block information */ if (nblocks > 0) { - int i; + int i; - ptdata = malloc(nblocks * ndims * 2 * sizeof(ptdata[0])); - H5Sget_select_hyper_blocklist(region, 0, nblocks, ptdata); + alloc_size=nblocks * ndims * 2 * sizeof(ptdata[0]); + assert(alloc_size==(hsize_t)((size_t)alloc_size)); /*check for overflow*/ + ptdata = malloc((size_t)alloc_size); + H5_CHECK_OVERFLOW(nblocks,hssize_t,hsize_t); + H5Sget_select_hyper_blocklist(region, (hsize_t)0, (hsize_t)nblocks, ptdata); - for (i = 0; i < nblocks; i++) { - int j; + for (i = 0; i < nblocks; i++) { + int j; - h5dump_str_append(str, info->dset_blockformat_pre, - i ? "," OPTIONAL_LINE_BREAK " " : "", - (unsigned long)i); - - /* Start coordinates and opposite corner */ - for (j = 0; j < ndims; j++) - h5dump_str_append(str, "%s%lu", j ? "," : "(", - (unsigned long)ptdata[i * 2 * ndims + j]); + h5dump_str_append(str, info->dset_blockformat_pre, + i ? "," OPTIONAL_LINE_BREAK " " : "", + (unsigned long)i); + + /* Start coordinates and opposite corner */ + for (j = 0; j < ndims; j++) + h5dump_str_append(str, "%s%lu", j ? "," : "(", + (unsigned long)ptdata[i * 2 * ndims + j]); - for (j = 0; j < ndims; j++) - h5dump_str_append(str, "%s%lu", j ? "," : ")-(", - (unsigned long)ptdata[i * 2 * ndims + j + ndims]); + for (j = 0; j < ndims; j++) + h5dump_str_append(str, "%s%lu", j ? "," : ")-(", + (unsigned long)ptdata[i * 2 * ndims + j + ndims]); - h5dump_str_append(str, ")"); - } - free(ptdata); + h5dump_str_append(str, ")"); + } + free(ptdata); } /* Print point information */ if (npoints > 0) { - int i; + int i; - ptdata = malloc(npoints * ndims * sizeof(ptdata[0])); - H5Sget_select_elem_pointlist(region, 0, npoints, ptdata); + alloc_size=npoints * ndims * sizeof(ptdata[0]); + assert(alloc_size==(hsize_t)((size_t)alloc_size)); /*check for overflow*/ + ptdata = malloc((size_t)alloc_size); + H5_CHECK_OVERFLOW(npoints,hssize_t,hsize_t); + H5Sget_select_elem_pointlist(region, (hsize_t)0, (hsize_t)npoints, ptdata); - for (i = 0; i < npoints; i++) { - int j; + for (i = 0; i < npoints; i++) { + int j; - h5dump_str_append(str, info->dset_ptformat_pre , - i ? "," OPTIONAL_LINE_BREAK " " : "", - (unsigned long)i); - - for (j = 0; j < ndims; j++) - h5dump_str_append(str, "%s%lu", j ? "," : "(", - (unsigned long)(ptdata[i * ndims + j])); + h5dump_str_append(str, info->dset_ptformat_pre , + i ? "," OPTIONAL_LINE_BREAK " " : "", + (unsigned long)i); + + for (j = 0; j < ndims; j++) + h5dump_str_append(str, "%s%lu", j ? "," : "(", + (unsigned long)(ptdata[i * ndims + j])); - h5dump_str_append(str, ")"); - } + h5dump_str_append(str, ")"); + } - free(ptdata); + free(ptdata); } h5dump_str_append(str, "}"); @@ -1459,7 +1460,7 @@ h5dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, if (info->line_ncols > 0) ncols = info->line_ncols; - h5dump_simple_prefix(stream, info, ctx, 0, 0); + h5dump_simple_prefix(stream, info, ctx, (hsize_t)0, 0); for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) { /* Render the element */ @@ -1688,7 +1689,8 @@ h5dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset, else sm_nbytes = p_type_nbytes; - sm_buf = malloc(sm_nbytes); + assert(sm_nbytes==(hsize_t)((size_t)sm_nbytes)); /*check for overflow*/ + sm_buf = malloc((size_t)sm_nbytes); sm_nelmts = sm_nbytes / p_type_nbytes; sm_space = H5Screate_simple(1, &sm_nelmts, NULL); @@ -1920,8 +1922,9 @@ h5dump_fixtype(hid_t f_type) * and add the members. */ nmembs = H5Tget_nmembers(f_type); - memb = calloc(nmembs, sizeof(hid_t)); - name = calloc(nmembs, sizeof(char *)); + assert(nmembs>0); + memb = calloc((size_t)nmembs, sizeof(hid_t)); + name = calloc((size_t)nmembs, sizeof(char *)); for (i = 0, size = 0; i < nmembs; i++) { @@ -2268,7 +2271,10 @@ init_table(table_t** temp) void init_prefix(char **prefix, int prefix_len) { - char *temp = malloc(prefix_len); + char *temp; + + assert(prefix_len>0); + temp = malloc((size_t)prefix_len); *temp = '\0'; *prefix = temp; @@ -2621,7 +2627,10 @@ h5dump_fopen(const char *fname, char *drivername, size_t drivername_size) hid_t fapl; } driver[16]; static int ndrivers = 0; - hid_t fid=(-1), fapl = H5P_DEFAULT; + hid_t fid=(-1); +#ifdef VERSION13 + hid_t fapl = H5P_DEFAULT; +#endif int drivernum; if (!ndrivers) { |