diff options
-rw-r--r-- | src/H5B.c | 560 | ||||
-rw-r--r-- | src/H5Bpkg.h | 4 | ||||
-rw-r--r-- | src/H5D.c | 862 | ||||
-rw-r--r-- | src/H5Dio.c | 407 | ||||
-rw-r--r-- | src/H5Distore.c | 250 | ||||
-rw-r--r-- | src/H5Dprivate.h | 9 | ||||
-rw-r--r-- | src/H5Dseq.c | 4 | ||||
-rw-r--r-- | src/H5F.c | 744 | ||||
-rw-r--r-- | src/H5Fistore.c | 250 | ||||
-rw-r--r-- | src/H5Fpkg.h | 9 | ||||
-rw-r--r-- | src/H5Fprivate.h | 28 | ||||
-rw-r--r-- | src/H5Fseq.c | 4 | ||||
-rw-r--r-- | src/H5Oefl.c | 114 | ||||
-rw-r--r-- | src/H5Opline.c | 28 | ||||
-rw-r--r-- | src/H5Oprivate.h | 8 | ||||
-rw-r--r-- | src/H5Pdcpl.c | 24 | ||||
-rw-r--r-- | src/H5Z.c | 202 | ||||
-rw-r--r-- | src/H5Zprivate.h | 7 | ||||
-rw-r--r-- | test/dsets.c | 146 | ||||
-rw-r--r-- | test/set_extent.c | 177 | ||||
-rw-r--r-- | test/tmisc.c | 4 |
21 files changed, 2111 insertions, 1730 deletions
@@ -118,9 +118,6 @@ #include "H5Pprivate.h" /* Property lists */ /* Local macros */ - -#define BOUND(MIN,X,MAX) ((X)<(MIN)?(MIN):((X)>(MAX)?(MAX):(X))) - #define H5B_SIZEOF_HDR(F) \ (H5B_SIZEOF_MAGIC + /*magic number */ \ 4 + /*type, level, num entries */ \ @@ -137,17 +134,17 @@ static H5B_ins_t H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, uint8_t *rt_key, hbool_t *rt_key_changed, haddr_t *retval); -static herr_t H5B_insert_child(H5F_t *f, const H5B_class_t *type, - H5B_t *bt, int idx, haddr_t child, - H5B_ins_t anchor, void *md_key); -static herr_t H5B_decode_key(H5F_t *f, H5B_t *bt, int idx); -static herr_t H5B_decode_keys(H5F_t *f, H5B_t *bt, int idx); -static size_t H5B_nodesize(H5F_t *f, const H5B_class_t *type, +static herr_t H5B_insert_child(const H5F_t *f, const H5B_class_t *type, + H5B_t *bt, unsigned idx, haddr_t child, + H5B_ins_t anchor, const void *md_key); +static herr_t H5B_decode_key(H5F_t *f, H5B_t *bt, unsigned idx); +static herr_t H5B_decode_keys(H5F_t *f, H5B_t *bt, unsigned idx); +static size_t H5B_nodesize(const H5F_t *f, const H5B_class_t *type, size_t *total_nkey_size, size_t sizeof_rkey); static herr_t H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, - haddr_t old_addr, int idx, - void *udata, haddr_t *new_addr/*out*/); -static H5B_t * H5B_copy(H5F_t *f, const H5B_t *old_bt); + haddr_t old_addr, unsigned idx, + void *udata, haddr_t *new_addr/*out*/); +static H5B_t * H5B_copy(const H5F_t *f, const H5B_t *old_bt); #ifdef H5B_DEBUG static herr_t H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void *udata); @@ -217,13 +214,13 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, { H5B_t *bt = NULL; size_t sizeof_rkey; - size_t size; + size_t size=0; size_t total_native_keysize; size_t offset; - int i; + unsigned u; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5B_create, FAIL); + FUNC_ENTER_NOAPI(H5B_create, FAIL) /* * Check arguments. @@ -239,9 +236,9 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, size = H5B_nodesize(f, type, &total_native_keysize, sizeof_rkey); H5_CHECK_OVERFLOW(size,size_t,hsize_t); if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree root node"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree root node") if (NULL==(bt = H5FL_CALLOC(H5B_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node") bt->type = type; bt->sizeof_rkey = sizeof_rkey; bt->cache_info.dirty = TRUE; @@ -254,21 +251,21 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, NULL==(bt->native=H5FL_BLK_MALLOC(native_block,total_native_keysize)) || NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) || NULL==(bt->key=H5FL_SEQ_MALLOC(H5B_key_t,(size_t)(2*H5F_KVALUE(f,type)+1)))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node") /* * Initialize each entry's raw child and key pointers to point into the * `page' buffer. Each native key pointer should be null until the key is * translated to native format. */ - for (i = 0, offset = H5B_SIZEOF_HDR(f); - i < 2 * H5F_KVALUE(f, type); - i++, offset += bt->sizeof_rkey + H5F_SIZEOF_ADDR(f)) { - - bt->key[i].dirty = FALSE; - bt->key[i].rkey = bt->page + offset; - bt->key[i].nkey = NULL; - bt->child[i] = HADDR_UNDEF; + for (u = 0, offset = H5B_SIZEOF_HDR(f); + u < 2 * H5F_KVALUE(f, type); + u++, offset += bt->sizeof_rkey + H5F_SIZEOF_ADDR(f)) { + + bt->key[u].dirty = FALSE; + bt->key[u].rkey = bt->page + offset; + bt->key[u].nkey = NULL; + bt->child[u] = HADDR_UNDEF; } /* @@ -282,21 +279,23 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, * Cache the new B-tree node. */ if (H5AC_set(f, dxpl_id, H5AC_BT, *addr_p, bt) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree root node to cache"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree root node to cache") #ifdef H5B_DEBUG H5B_assert(f, dxpl_id, *addr_p, type, udata); #endif done: if (ret_value<0) { - H5_CHECK_OVERFLOW(size,size_t,hsize_t); - H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, *addr_p, (hsize_t)size); + if(size>0) { + H5_CHECK_OVERFLOW(size,size_t,hsize_t); + (void)H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, *addr_p, (hsize_t)size); + } /* end if */ if (bt) - H5B_dest(f,bt); + (void)H5B_dest(f,bt); } - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /*lint !e818 Can't make udata a pointer to const */ /*------------------------------------------------------------------------- @@ -328,11 +327,11 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) size_t total_nkey_size; size_t size; H5B_t *bt = NULL; - int i; uint8_t *p; + unsigned u; /* Local index variable */ H5B_t *ret_value; - FUNC_ENTER_NOAPI(H5B_load, NULL); + FUNC_ENTER_NOAPI(H5B_load, NULL) /* Check arguments */ assert(f); @@ -341,7 +340,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) assert(type->get_sizeof_rkey); if (NULL==(bt = H5FL_CALLOC(H5B_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") bt->sizeof_rkey = (type->get_sizeof_rkey) (f, udata); size = H5B_nodesize(f, type, &total_nkey_size, bt->sizeof_rkey); bt->type = type; @@ -351,19 +350,19 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) NULL==(bt->native=H5FL_BLK_MALLOC(native_block,total_nkey_size)) || NULL==(bt->key=H5FL_SEQ_MALLOC(H5B_key_t,(size_t)(2*H5F_KVALUE(f,type)+1))) || NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type))))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if (H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, bt->page)<0) - HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree node"); + HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree node") p = bt->page; /* magic number */ if (HDmemcmp(p, H5B_MAGIC, H5B_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree signature"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree signature") p += 4; /* node type and level */ if (*p++ != type->id) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree node level"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree node type") bt->level = *p++; /* entries used */ @@ -374,17 +373,17 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) H5F_addr_decode(f, (const uint8_t **) &p, &(bt->right)); /* the child/key pairs */ - for (i = 0; i < 2 * H5F_KVALUE(f, type); i++) { + for (u = 0; u < 2 * H5F_KVALUE(f, type); u++) { - bt->key[i].dirty = FALSE; - bt->key[i].rkey = p; + bt->key[u].dirty = FALSE; + bt->key[u].rkey = p; p += bt->sizeof_rkey; - bt->key[i].nkey = NULL; + bt->key[u].nkey = NULL; - if (i < bt->nchildren) { - H5F_addr_decode(f, (const uint8_t **) &p, bt->child + i); + if (u < bt->nchildren) { + H5F_addr_decode(f, (const uint8_t **) &p, bt->child + u); } else { - bt->child[i] = HADDR_UNDEF; + bt->child[u] = HADDR_UNDEF; p += H5F_SIZEOF_ADDR(f); } } @@ -398,9 +397,9 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) done: if (!ret_value && bt) - H5B_dest(f,bt); - FUNC_LEAVE_NOAPI(ret_value); -} + (void)H5B_dest(f,bt); + FUNC_LEAVE_NOAPI(ret_value) +} /*lint !e818 Can't make udata a pointer to const */ /*------------------------------------------------------------------------- @@ -429,16 +428,14 @@ done: static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt) { - int i; + unsigned i; size_t size = 0; uint8_t *p = bt->page; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5B_flush, FAIL); + FUNC_ENTER_NOAPI(H5B_flush, FAIL) - /* - * Check arguments. - */ + /* check arguments */ assert(f); assert(H5F_addr_defined(addr)); assert(bt); @@ -488,22 +485,22 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt) } /* - * Write the disk page. We always write the header, but we don't - * bother writing data for the child entries that don't exist or - * for the final unchanged children. + * Write the disk page. We always write the header, but we don't + * bother writing data for the child entries that don't exist or + * for the final unchanged children. */ if (H5F_block_write(f, H5FD_MEM_BTREE, addr, size, dxpl_id, bt->page)<0) HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree node to disk"); bt->cache_info.dirty = FALSE; bt->ndirty = 0; } - if (destroy) { - if(H5B_dest(f,bt)<0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node"); - } + + if (destroy) + if (H5B_dest(f,bt) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to destroy B-tree node") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -522,10 +519,11 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t H5B_dest(H5F_t UNUSED *f, H5B_t *bt) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_dest); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_dest) /* * Check arguments. @@ -541,7 +539,7 @@ H5B_dest(H5F_t UNUSED *f, H5B_t *bt) H5FL_BLK_FREE(native_block,bt->native); H5FL_FREE(H5B_t,bt); - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B_dest() */ @@ -563,9 +561,9 @@ H5B_dest(H5F_t UNUSED *f, H5B_t *bt) static herr_t H5B_clear(H5B_t *bt) { - int i; /* Local index variable */ + unsigned u; /* Local index variable */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_clear); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_clear) /* * Check arguments. @@ -573,11 +571,11 @@ H5B_clear(H5B_t *bt) assert(bt); /* Look for dirty keys and reset the dirty flag. */ - for (i=0; i<=bt->nchildren; i++) - bt->key[i].dirty = FALSE; + for (u=0; u<=bt->nchildren; u++) + bt->key[u].dirty = FALSE; bt->cache_info.dirty = FALSE; - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5B_clear() */ @@ -611,10 +609,11 @@ herr_t H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata) { H5B_t *bt = NULL; - int idx = -1, lt = 0, rt, cmp = 1; + unsigned idx=0, lt = 0, rt; /* Final, left & right key indices */ + int cmp = 1; /* Key comparison value */ int ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5B_find, FAIL); + FUNC_ENTER_NOAPI(H5B_find, FAIL) /* * Check arguments. @@ -631,13 +630,13 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u * the thing for which we're searching. */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") rt = bt->nchildren; while (lt < rt && cmp) { idx = (lt + rt) / 2; if (H5B_decode_keys(f, bt, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode B-tree key(s)"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode B-tree key(s)") /* compare */ if ((cmp = (type->cmp3) (f, dxpl_id, bt->key[idx].nkey, udata, bt->key[idx+1].nkey)) < 0) { @@ -647,25 +646,25 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u } } if (cmp) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree key not found"); + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree key not found") /* * Follow the link to the subtree or to the data node. */ - assert(idx >= 0 && idx < bt->nchildren); + assert(idx < bt->nchildren); if (bt->level > 0) { if (H5B_find(f, dxpl_id, type, bt->child[idx], udata) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in subtree"); + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in subtree") } else { if ((type->found) (f, dxpl_id, bt->child[idx], bt->key[idx].nkey, udata, bt->key[idx+1].nkey) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in leaf node"); + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in leaf node") } done: - if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) < 0 && ret_value>=0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node"); + if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node") - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -697,16 +696,18 @@ done: */ static herr_t H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, haddr_t old_addr, - int idx, void *udata, haddr_t *new_addr_p/*out*/) + unsigned idx, void *udata, haddr_t *new_addr_p/*out*/) { H5P_genplist_t *dx_plist; /* Data transfer property list */ H5B_t *new_bt = NULL, *tmp_bt = NULL; - herr_t ret_value = SUCCEED; - int i, k, nleft, nright; - double split_ratios[3]; /* B-tree split ratios */ + unsigned k; /* B-tree 'K' value for the maximum number of entries in node */ + unsigned nleft, nright; /* Number of keys in left & right halves */ size_t recsize = 0; + double split_ratios[3]; /* B-tree split ratios */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5B_split); + FUNC_ENTER_NOAPI_NOINIT(H5B_split) /* * Check arguments. @@ -744,7 +745,7 @@ H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, haddr } else { side = "MIDDLE"; } - fprintf(H5DEBUG(B), "H5B_split: %3d {%5.3f,%5.3f,%5.3f} %6s", + fprintf(H5DEBUG(B), "H5B_split: %3u {%5.3f,%5.3f,%5.3f} %6s", 2*k, split_ratios[0], split_ratios[1], split_ratios[2], side); } #endif @@ -754,11 +755,11 @@ H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, haddr * and the new node. */ if (!H5F_addr_defined(old_bt->right)) { - nleft = (int)(2 * k * split_ratios[2]); /*right*/ + nleft = (unsigned)(2 * (double)k * split_ratios[2]); /*right*/ } else if (!H5F_addr_defined(old_bt->left)) { - nleft = (int)(2 * k * split_ratios[0]); /*left*/ + nleft = (unsigned)(2 * (double)k * split_ratios[0]); /*left*/ } else { - nleft = (int)(2 * k * split_ratios[1]); /*middle*/ + nleft = (unsigned)(2 * (double)k * split_ratios[1]); /*middle*/ } /* @@ -781,9 +782,9 @@ H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, haddr * Create the new B-tree node. */ if (H5B_create(f, dxpl_id, type, udata, new_addr_p/*out*/) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create B-tree"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create B-tree") if (NULL==(new_bt=H5AC_protect(f, dxpl_id, H5AC_BT, *new_addr_p, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to protect B-tree"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to protect B-tree") new_bt->level = old_bt->level; /* @@ -796,15 +797,15 @@ H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, haddr old_bt->native + nleft * type->sizeof_nkey, (nright+1) * type->sizeof_nkey); - for (i=0; i<=nright; i++) { + for (u=0; u<=nright; u++) { /* key */ - new_bt->key[i].dirty = old_bt->key[nleft+i].dirty; - if (old_bt->key[nleft+i].nkey) - new_bt->key[i].nkey = new_bt->native + i * type->sizeof_nkey; + new_bt->key[u].dirty = old_bt->key[nleft+u].dirty; + if (old_bt->key[nleft+u].nkey) + new_bt->key[u].nkey = new_bt->native + u * type->sizeof_nkey; /* child */ - if (i < nright) - new_bt->child[i] = old_bt->child[nleft+i]; + if (u < nright) + new_bt->child[u] = old_bt->child[nleft+u]; } new_bt->ndirty = new_bt->nchildren = nright; @@ -823,17 +824,17 @@ H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, haddr if (H5F_addr_defined(old_bt->right)) { if (NULL == (tmp_bt = H5AC_find(f, dxpl_id, H5AC_BT, old_bt->right, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load right sibling"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load right sibling") tmp_bt->cache_info.dirty = TRUE; tmp_bt->left = *new_addr_p; } old_bt->right = *new_addr_p; done: - if (new_bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_addr_p, new_bt, FALSE) < 0 && ret_value>=0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node"); + if (new_bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_addr_p, new_bt, FALSE) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node") - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -855,20 +856,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B_decode_key(H5F_t *f, H5B_t *bt, int idx) +H5B_decode_key(H5F_t *f, H5B_t *bt, unsigned idx) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5B_decode_key); + FUNC_ENTER_NOAPI_NOINIT(H5B_decode_key) assert(bt->key[idx].dirty==0); bt->key[idx].nkey = bt->native + idx * bt->type->sizeof_nkey; if ((bt->type->decode) (f, bt, bt->key[idx].rkey, bt->key[idx].nkey) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -887,23 +888,23 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B_decode_keys(H5F_t *f, H5B_t *bt, int idx) +H5B_decode_keys(H5F_t *f, H5B_t *bt, unsigned idx) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5B_decode_keys); + FUNC_ENTER_NOAPI_NOINIT(H5B_decode_keys) assert(f); assert(bt); - assert(idx >= 0 && idx < bt->nchildren); + assert(idx < bt->nchildren); if (!bt->key[idx].nkey && H5B_decode_key(f, bt, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key") if (!bt->key[idx+1].nkey && H5B_decode_key(f, bt, idx+1) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -954,11 +955,9 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, H5B_ins_t my_ins = H5B_INS_ERROR; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5B_insert, FAIL); + FUNC_ENTER_NOAPI(H5B_insert, FAIL) - /* - * Check arguments. - */ + /* Check arguments. */ assert(f); assert(type); assert(type->sizeof_nkey <= sizeof _lt_key); @@ -967,28 +966,29 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, if ((my_ins = H5B_insert_helper(f, dxpl_id, addr, type, lt_key, <_key_changed, md_key, udata, rt_key, &rt_key_changed, &child/*out*/))<0 || my_ins<0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to insert key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to insert key") if (H5B_INS_NOOP == my_ins) - HGOTO_DONE(SUCCEED); + HGOTO_DONE(SUCCEED) assert(H5B_INS_RIGHT == my_ins); /* the current root */ if (NULL == (bt = H5AC_find(f, dxpl_id, H5AC_BT, addr, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to locate root of B-tree"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to locate root of B-tree") level = bt->level; if (!lt_key_changed) { if (!bt->key[0].nkey && H5B_decode_key(f, bt, 0) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key") HDmemcpy(lt_key, bt->key[0].nkey, type->sizeof_nkey); } /* the new node */ if (NULL == (bt = H5AC_find(f, dxpl_id, H5AC_BT, child, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new node") + if (!rt_key_changed) { if (!bt->key[bt->nchildren].nkey && H5B_decode_key(f, bt, bt->nchildren) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key") HDmemcpy(rt_key, bt->key[bt->nchildren].nkey, type->sizeof_nkey); } @@ -999,11 +999,12 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, */ size = H5B_nodesize(f, type, NULL, bt->sizeof_rkey); if (HADDR_UNDEF==(old_root=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space to move root"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space to move root") /* update the new child's left pointer */ if (NULL == (bt = H5AC_find(f, dxpl_id, H5AC_BT, child, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child") + bt->cache_info.dirty = TRUE; bt->left = old_root; @@ -1013,7 +1014,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, */ /* Bring the old root into the cache if it's not already */ if (NULL == (bt = H5AC_find(f, dxpl_id, H5AC_BT, addr, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child") /* Make certain the old root info is marked as dirty before moving it, */ /* so it is certain to be written out at the new location */ @@ -1021,11 +1022,11 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, /* Make a copy of the old root information */ if (NULL == (bt = H5B_copy(f, bt))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to copy old root"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to copy old root") /* Move the location on the disk */ if (H5AC_rename(f, dxpl_id, H5AC_BT, addr, old_root) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to move B-tree root node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to move B-tree root node") /* Insert the copy of the old root into the file again */ if (H5AC_set(f, dxpl_id, H5AC_BT, addr, bt) < 0) @@ -1060,7 +1061,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, #endif done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1083,13 +1084,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B_insert_child(H5F_t *f, const H5B_class_t *type, H5B_t *bt, - int idx, haddr_t child, H5B_ins_t anchor, void *md_key) +H5B_insert_child(const H5F_t *f, const H5B_class_t *type, H5B_t *bt, + unsigned idx, haddr_t child, H5B_ins_t anchor, const void *md_key) { size_t recsize; - int i; + unsigned u; /* Local index variable */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_insert_child); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_insert_child) assert(bt); assert(bt->nchildren<2*H5F_KVALUE(f, type)); @@ -1111,12 +1112,12 @@ H5B_insert_child(H5F_t *f, const H5B_class_t *type, H5B_t *bt, bt->native + idx * type->sizeof_nkey, ((bt->nchildren - idx) + 1) * type->sizeof_nkey); - for (i=bt->nchildren; i>=idx; --i) { - bt->key[i+1].dirty = bt->key[i].dirty; - if (bt->key[i].nkey) { - bt->key[i+1].nkey = bt->native + (i+1) * type->sizeof_nkey; + for (u=bt->nchildren; u>=idx; --u) { + bt->key[u+1].dirty = bt->key[u].dirty; + if (bt->key[u].nkey) { + bt->key[u+1].nkey = bt->native + (u+1) * type->sizeof_nkey; } else { - bt->key[i+1].nkey = NULL; + bt->key[u+1].nkey = NULL; } } bt->key[idx].dirty = TRUE; @@ -1137,12 +1138,12 @@ H5B_insert_child(H5F_t *f, const H5B_class_t *type, H5B_t *bt, bt->native + (idx+1) * type->sizeof_nkey, (bt->nchildren - idx) * type->sizeof_nkey); - for (i = bt->nchildren; i > idx; --i) { - bt->key[i+1].dirty = bt->key[i].dirty; - if (bt->key[i].nkey) { - bt->key[i+1].nkey = bt->native + (i+1) * type->sizeof_nkey; + for (u = bt->nchildren; u > idx; --u) { + bt->key[u+1].dirty = bt->key[u].dirty; + if (bt->key[u].nkey) { + bt->key[u+1].nkey = bt->native + (u+1) * type->sizeof_nkey; } else { - bt->key[i+1].nkey = NULL; + bt->key[u+1].nkey = NULL; } } bt->key[idx+1].dirty = TRUE; @@ -1158,7 +1159,7 @@ H5B_insert_child(H5F_t *f, const H5B_class_t *type, H5B_t *bt, bt->nchildren += 1; bt->ndirty = bt->nchildren; - FUNC_LEAVE_NOAPI(SUCCEED); + FUNC_LEAVE_NOAPI(SUCCEED) } @@ -1216,12 +1217,13 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type haddr_t *new_node_p/*out*/) { H5B_t *bt = NULL, *twin = NULL, *tmp_bt = NULL; - int lt = 0, idx = -1, rt, cmp = -1; - haddr_t child_addr; + unsigned lt = 0, idx = 0, rt; /* Left, final & right index values */ + int cmp = -1; /* Key comparison value */ + haddr_t child_addr = HADDR_UNDEF; H5B_ins_t my_ins = H5B_INS_ERROR; - H5B_ins_t ret_value = H5B_INS_ERROR; + H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5B_insert_helper); + FUNC_ENTER_NOAPI_NOINIT(H5B_insert_helper) /* * Check arguments @@ -1247,13 +1249,13 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type * should get the new data. */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node") rt = bt->nchildren; while (lt < rt && cmp) { idx = (lt + rt) / 2; if (H5B_decode_keys(f, bt, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key") if ((cmp = (type->cmp3) (f, dxpl_id, bt->key[idx].nkey, udata, bt->key[idx+1].nkey)) < 0) { rt = idx; @@ -1273,7 +1275,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type if ((type->new_node)(f, dxpl_id, H5B_INS_FIRST, bt->key[0].nkey, udata, bt->key[1].nkey, bt->child + 0/*out*/) < 0) { bt->key[0].nkey = bt->key[1].nkey = NULL; - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR, "unable to create leaf node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR, "unable to create leaf node") } bt->nchildren = 1; bt->cache_info.dirty = TRUE; @@ -1286,51 +1288,48 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type if ((my_ins = (type->insert)(f, dxpl_id, bt->child[idx], bt->key[idx].nkey, lt_key_changed, md_key, udata, bt->key[idx+1].nkey, rt_key_changed, &child_addr/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert first leaf node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert first leaf node") } else { my_ins = H5B_INS_NOOP; } - } else if (cmp < 0 && idx <= 0 && bt->level > 0) { + } else if (cmp < 0 && idx == 0 && bt->level > 0) { /* * The value being inserted is less than any value in this tree. * Follow the minimum branch out of this node to a subtree. */ - idx = 0; if (H5B_decode_keys(f, bt, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key") if ((my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, bt->key[idx].nkey, lt_key_changed, md_key, udata, bt->key[idx+1].nkey, rt_key_changed, &child_addr/*out*/))<0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum subtree"); - } else if (cmp < 0 && idx <= 0 && type->follow_min) { + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum subtree") + } else if (cmp < 0 && idx == 0 && type->follow_min) { /* * The value being inserted is less than any leaf node out of this * current node. Follow the minimum branch to a leaf node and let the * subclass handle the problem. */ - idx = 0; if (H5B_decode_keys(f, bt, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key") if ((my_ins = (type->insert)(f, dxpl_id, bt->child[idx], bt->key[idx].nkey, lt_key_changed, md_key, udata, bt->key[idx+1].nkey, rt_key_changed, &child_addr/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node"); - } else if (cmp < 0 && idx <= 0) { + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node") + } else if (cmp < 0 && idx == 0) { /* * The value being inserted is less than any leaf node out of the * current node. Create a new minimum leaf node out of this B-tree * node. This node is not empty (handled above). */ - idx = 0; if (H5B_decode_keys(f, bt, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key") my_ins = H5B_INS_LEFT; HDmemcpy(md_key, bt->key[idx].nkey, type->sizeof_nkey); if ((type->new_node)(f, dxpl_id, H5B_INS_LEFT, bt->key[idx].nkey, udata, md_key, &child_addr/*out*/) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node") *lt_key_changed = TRUE; } else if (cmp > 0 && idx + 1 >= bt->nchildren && bt->level > 0) { @@ -1340,11 +1339,11 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ idx = bt->nchildren - 1; if (H5B_decode_keys(f, bt, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key") if ((my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, bt->key[idx].nkey, lt_key_changed, md_key, udata, bt->key[idx+1].nkey, rt_key_changed, &child_addr/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum subtree"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum subtree") } else if (cmp > 0 && idx + 1 >= bt->nchildren && type->follow_max) { /* * The value being inserted is larger than any leaf node out of the @@ -1353,11 +1352,11 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ idx = bt->nchildren - 1; if (H5B_decode_keys(f, bt, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key") if ((my_ins = (type->insert)(f, dxpl_id, bt->child[idx], bt->key[idx].nkey, lt_key_changed, md_key, udata, bt->key[idx+1].nkey, rt_key_changed, &child_addr/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node") } else if (cmp > 0 && idx + 1 >= bt->nchildren) { /* * The value being inserted is larger than any leaf node out of the @@ -1366,12 +1365,12 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ idx = bt->nchildren - 1; if (H5B_decode_keys(f, bt, idx) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key") my_ins = H5B_INS_RIGHT; HDmemcpy(md_key, bt->key[idx+1].nkey, type->sizeof_nkey); if ((type->new_node)(f, dxpl_id, H5B_INS_RIGHT, md_key, udata, bt->key[idx+1].nkey, &child_addr/*out*/) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node") *rt_key_changed = TRUE; } else if (cmp) { @@ -1380,26 +1379,27 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type * IS A MAJOR PROBLEM THAT NEEDS TO BE FIXED --rpm. */ assert("INTERNAL HDF5 ERROR (contact rpm)" && 0); +#ifdef NDEBUG HDabort(); - +#endif /* NDEBUG */ } else if (bt->level > 0) { /* * Follow a branch out of this node to another subtree. */ - assert(idx >= 0 && idx < bt->nchildren); + assert(idx < bt->nchildren); if ((my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type, bt->key[idx].nkey, lt_key_changed, md_key, udata, bt->key[idx+1].nkey, rt_key_changed, &child_addr/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert subtree"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert subtree") } else { /* * Follow a branch out of this node to a leaf node of some other type. */ - assert(idx >= 0 && idx < bt->nchildren); + assert(idx < bt->nchildren); if ((my_ins = (type->insert)(f, dxpl_id, bt->child[idx], bt->key[idx].nkey, lt_key_changed, md_key, udata, bt->key[idx+1].nkey, rt_key_changed, &child_addr/*out*/)) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert leaf node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert leaf node") } assert(my_ins >= 0); @@ -1439,9 +1439,9 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ if (bt->nchildren == 2 * H5F_KVALUE(f, type)) { if (H5B_split(f, dxpl_id, type, bt, addr, idx, udata, new_node_p/*out*/)<0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node") if (NULL == (twin = H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node") if (idx<bt->nchildren) { tmp_bt = bt; } else { @@ -1454,7 +1454,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type /* Insert the child */ if (H5B_insert_child(f, type, tmp_bt, idx, child_addr, my_ins, md_key) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert child"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert child") } /* @@ -1463,7 +1463,7 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ if (twin) { if (!twin->key[0].nkey && H5B_decode_key(f, twin, 0) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key") HDmemcpy(md_key, twin->key[0].nkey, type->sizeof_nkey); ret_value = H5B_INS_RIGHT; #ifdef H5B_DEBUG @@ -1488,10 +1488,10 @@ done: herr_t e1 = (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) < 0); herr_t e2 = (twin && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_node_p, twin, FALSE)<0); if (e1 || e2) /*use vars to prevent short-circuit of side effects */ - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node(s)"); + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node(s)") } - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1526,10 +1526,11 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op haddr_t cur_addr = HADDR_UNDEF; haddr_t *child = NULL; uint8_t *key = NULL; - int i, nchildren; + unsigned nchildren; /* Number of children of B-tree node */ + unsigned u; /* Local index variable */ herr_t ret_value; - FUNC_ENTER_NOAPI(H5B_iterate, FAIL); + FUNC_ENTER_NOAPI(H5B_iterate, FAIL) /* * Check arguments. @@ -1541,11 +1542,11 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op assert(udata); if (NULL == (bt=H5AC_find(f, dxpl_id, H5AC_BT, addr, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") if (bt->level > 0) { /* Keep following the left-most child until we reach a leaf node. */ if ((ret_value=H5B_iterate(f, dxpl_id, type, op, bt->child[0], udata))<0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node") } else { /* * We've reached the left-most leaf. Now follow the right-sibling @@ -1553,22 +1554,22 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op */ if (NULL==(child=H5FL_SEQ_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) || NULL==(key=H5MM_malloc((2*H5F_KVALUE(f, type)+1)*type->sizeof_nkey))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - for (cur_addr=addr, ret_value=0; H5F_addr_defined(cur_addr) && !ret_value; cur_addr=next_addr) { + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + for (cur_addr=addr, ret_value=0; H5F_addr_defined(cur_addr) && !ret_value; cur_addr=next_addr) { /* * Save all the child addresses and native keys since we can't * leave the B-tree node protected during an application * callback. */ if (NULL==(bt=H5AC_find (f, dxpl_id, H5AC_BT, cur_addr, type, udata))) - HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node"); - for (i=0; i<bt->nchildren; i++) - child[i] = bt->child[i]; - for (i=0; i<bt->nchildren+1; i++) { - if (!bt->key[i].nkey) - H5B_decode_key(f, bt, i); - HDmemcpy(key+i*type->sizeof_nkey, bt->key[i].nkey, + HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node") + for (u=0; u<bt->nchildren; u++) + child[u] = bt->child[u]; + for (u=0; u<bt->nchildren+1; u++) { + if (!bt->key[u].nkey) + H5B_decode_key(f, bt, u); + HDmemcpy(key+u*type->sizeof_nkey, bt->key[u].nkey, type->sizeof_nkey); } next_addr = bt->right; @@ -1579,11 +1580,11 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op * Perform the iteration operator, which might invoke an * application callback. */ - for (i=0, ret_value=H5B_ITER_CONT; i<nchildren && !ret_value; i++) { - ret_value = (*op)(f, dxpl_id, key+i*type->sizeof_nkey, - child[i], key+(i+1)*type->sizeof_nkey, udata); + for (u=0, ret_value=H5B_ITER_CONT; u<nchildren && !ret_value; u++) { + ret_value = (*op)(f, dxpl_id, key+u*type->sizeof_nkey, + child[u], key+(u+1)*type->sizeof_nkey, udata); if (ret_value<0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iterator function failed"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iterator function failed") } /* end for */ } /* end for */ } /* end else */ @@ -1593,7 +1594,7 @@ done: H5FL_SEQ_FREE(haddr_t,child); if(key!=NULL) H5MM_xfree(key); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1632,11 +1633,13 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type { H5B_t *bt = NULL, *sibling = NULL; H5B_ins_t ret_value = H5B_INS_ERROR; - int idx=-1, lt=0, rt, cmp=1, i; + unsigned idx=0, lt=0, rt; /* Final, left & right indices */ + int cmp=1; /* Key comparison value */ + unsigned u; /* Local index variable */ size_t sizeof_rkey, sizeof_rec; hsize_t sizeof_node; - FUNC_ENTER_NOAPI(H5B_remove_helper, H5B_INS_ERROR); + FUNC_ENTER_NOAPI(H5B_remove_helper, H5B_INS_ERROR) assert(f); assert(H5F_addr_defined(addr)); @@ -1653,12 +1656,12 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type * for which we're searching. */ if (NULL==(bt=H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load B-tree node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load B-tree node") rt = bt->nchildren; while (lt<rt && cmp) { idx = (lt+rt)/2; if (H5B_decode_keys(f, bt, idx)<0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode B-tree key(s)"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode B-tree key(s)") if ((cmp=(type->cmp3)(f, dxpl_id, bt->key[idx].nkey, udata, bt->key[idx+1].nkey))<0) { rt = idx; @@ -1667,20 +1670,20 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type } } if (cmp) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "B-tree key not found"); + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "B-tree key not found") /* * Follow the link to the subtree or to the data node. The return value * will be one of H5B_INS_ERROR, H5B_INS_NOOP, or H5B_INS_REMOVE. */ - assert(idx>=0 && idx<bt->nchildren); + assert(idx<bt->nchildren); if (bt->level>0) { /* We're at an internal node -- call recursively */ if ((ret_value=H5B_remove_helper(f, dxpl_id, bt->child[idx], type, level+1, bt->key[idx].nkey/*out*/, lt_key_changed/*out*/, udata, bt->key[idx+1].nkey/*out*/, rt_key_changed/*out*/))<0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in subtree"); + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in subtree") } else if (type->remove) { /* * We're at a leaf node but the leaf node points to an object that @@ -1690,7 +1693,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type if ((ret_value=(type->remove)(f, dxpl_id, bt->child[idx], bt->key[idx].nkey, lt_key_changed, udata, bt->key[idx+1].nkey, rt_key_changed))<0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in leaf node"); + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in leaf node") } else { /* * We're at a leaf node which points to an object that has no removal @@ -1736,7 +1739,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type if (ret_value!=H5B_INS_REMOVE && level>0) { if (H5F_addr_defined(bt->right)) { if (NULL==(sibling=H5AC_find(f, dxpl_id, H5AC_BT, bt->right, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") /* Make certain the native key for the right sibling is set up */ if (!sibling->key[0].nkey && H5B_decode_key(f, sibling, 0) < 0) @@ -1766,13 +1769,13 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type if (level>0) { if (H5F_addr_defined(bt->left)) { if (NULL==(sibling=H5AC_find(f, dxpl_id, H5AC_BT, bt->left, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") sibling->right = bt->right; sibling->cache_info.dirty = TRUE; } if (H5F_addr_defined(bt->right)) { if (NULL==(sibling=H5AC_find(f, dxpl_id, H5AC_BT, bt->right, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") /* Copy left-most key from deleted node to left-most key in it's right neighbor */ /* (Make certain the native key for the right sibling is set up) */ @@ -1791,7 +1794,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, sizeof_node)<0 || H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, TRUE)<0) { bt = NULL; - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to free B-tree node"); + HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to free B-tree node") } bt = NULL; } @@ -1817,12 +1820,12 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type HDmemmove(bt->child, bt->child+1, bt->nchildren * sizeof(haddr_t)); - for (i=0; i<=bt->nchildren; i++) { - bt->key[i].dirty = bt->key[i+1].dirty; - if (bt->key[i+1].nkey) { - bt->key[i].nkey = bt->native + i*type->sizeof_nkey; + for (u=0; u<=bt->nchildren; u++) { + bt->key[u].dirty = bt->key[u+1].dirty; + if (bt->key[u+1].nkey) { + bt->key[u].nkey = bt->native + u*type->sizeof_nkey; } else { - bt->key[i].nkey = NULL; + bt->key[u].nkey = NULL; } } assert(bt->key[0].nkey); @@ -1851,7 +1854,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type if (level>0) { if (H5F_addr_defined(bt->right)) { if (NULL==(sibling=H5AC_find(f, dxpl_id, H5AC_BT, bt->right, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree") /* Make certain the native key for the right sibling is set up */ if (!sibling->key[0].nkey && H5B_decode_key(f, sibling, 0) < 0) @@ -1885,12 +1888,12 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type HDmemmove(bt->child+idx, bt->child+idx+1, (bt->nchildren-idx) * sizeof(haddr_t)); - for (i=idx; i<=bt->nchildren; i++) { - bt->key[i].dirty = bt->key[i+1].dirty; - if (bt->key[i+1].nkey) { - bt->key[i].nkey = bt->native + i*type->sizeof_nkey; + for (u=idx; u<=bt->nchildren; u++) { + bt->key[u].dirty = bt->key[u+1].dirty; + if (bt->key[u+1].nkey) { + bt->key[u].nkey = bt->native + u*type->sizeof_nkey; } else { - bt->key[i].nkey = NULL; + bt->key[u].nkey = NULL; } } ret_value = H5B_INS_NOOP; @@ -1898,13 +1901,12 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type } else { ret_value = H5B_INS_NOOP; } - - + done: - if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE)<0 && ret_value>=0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node"); + if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE)<0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node") - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1914,6 +1916,7 @@ done: * Purpose: Removes an item from a B-tree. * * Note: The current version does not attempt to rebalance the tree. + * (Read the paper Yao & Lehman paper for details on why) * * Return: Non-negative on success/Negative on failure (failure includes * not being able to find the object which is to be removed). @@ -1938,7 +1941,7 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void H5B_t *bt = NULL; /*btree node */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5B_remove, FAIL); + FUNC_ENTER_NOAPI(H5B_remove, FAIL) /* Check args */ assert(f); @@ -1949,14 +1952,15 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void /* The actual removal */ if (H5B_remove_helper(f, dxpl_id, addr, type, 0, lt_key, <_key_changed, udata, rt_key, &rt_key_changed)==H5B_INS_ERROR) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to remove entry from B-tree"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to remove entry from B-tree") /* * If the B-tree is now empty then make sure we mark the root node as * being at level zero */ if (NULL==(bt=H5AC_find(f, dxpl_id, H5AC_BT, addr, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree root node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree root node") + if (0==bt->nchildren && 0!=bt->level) { bt->level = 0; bt->cache_info.dirty = TRUE; @@ -1966,7 +1970,7 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void H5B_assert(f, dxpl_id, addr, type, udata); #endif done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1991,10 +1995,10 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void H5B_t *bt; /* B-tree node being operated on */ size_t sizeof_rkey; /* Size of raw key */ hsize_t sizeof_node; /* Size of B-tree node */ - int i; /* Local index variable */ - herr_t ret_value=SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5B_delete, FAIL); + FUNC_ENTER_NOAPI(H5B_delete, FAIL) /* Check args */ assert(f); @@ -2003,14 +2007,14 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void /* Lock this B-tree node into memory for now */ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") /* Iterate over all children in tree, deleting them */ if (bt->level > 0) { /* Iterate over all children in node, deleting them */ - for (i=0; i<bt->nchildren; i++) - if (H5B_delete(f, dxpl_id, type, bt->child[i], udata)<0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to delete B-tree node"); + for (u=0; u<bt->nchildren; u++) + if (H5B_delete(f, dxpl_id, type, bt->child[u], udata)<0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to delete B-tree node") } else { hbool_t lt_key_changed, rt_key_changed; /* Whether key changed (unused here, just for callback) */ @@ -2018,16 +2022,16 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void /* Check for removal callback */ if(type->remove) { /* Iterate over all entries in node, calling callback */ - for (i=0; i<bt->nchildren; i++) { + for (u=0; u<bt->nchildren; u++) { /* Decode native keys */ - if (H5B_decode_keys(f, bt, i)<0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode B-tree key(s)"); + if (H5B_decode_keys(f, bt, u)<0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode B-tree key(s)") /* Call user's callback for each entry */ if ((type->remove)(f, dxpl_id, - bt->child[i], bt->key[i].nkey, <_key_changed, udata, - bt->key[i+1].nkey, &rt_key_changed)<0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "can't remove B-tree node"); + bt->child[u], bt->key[u].nkey, <_key_changed, udata, + bt->key[u+1].nkey, &rt_key_changed)<0) + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "can't remove B-tree node") } /* end for */ } /* end if */ } /* end else */ @@ -2036,14 +2040,14 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void sizeof_rkey = (type->get_sizeof_rkey)(f, udata); sizeof_node = H5B_nodesize(f, type, NULL, sizeof_rkey); if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, sizeof_node)<0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free B-tree node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free B-tree node") /* Release node in metadata cache */ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, TRUE)<0) - HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node in cache"); + HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node in cache") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_delete() */ @@ -2071,13 +2075,13 @@ done: *------------------------------------------------------------------------- */ static size_t -H5B_nodesize(H5F_t *f, const H5B_class_t *type, +H5B_nodesize(const H5F_t *f, const H5B_class_t *type, size_t *total_nkey_size/*out*/, size_t sizeof_rkey) { size_t size; size_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5B_nodesize, (size_t) 0); + FUNC_ENTER_NOAPI(H5B_nodesize, 0) /* * Check arguments. @@ -2104,7 +2108,7 @@ H5B_nodesize(H5F_t *f, const H5B_class_t *type, ret_value=size; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -2126,7 +2130,7 @@ done: *------------------------------------------------------------------------- */ static H5B_t * -H5B_copy(H5F_t *f, const H5B_t *old_bt) +H5B_copy(const H5F_t *f, const H5B_t *old_bt) { H5B_t *new_node = NULL; size_t total_native_keysize; @@ -2135,7 +2139,7 @@ H5B_copy(H5F_t *f, const H5B_t *old_bt) size_t u; H5B_t *ret_value; - FUNC_ENTER_NOAPI(H5B_copy, NULL); + FUNC_ENTER_NOAPI(H5B_copy, NULL) /* * Check arguments. @@ -2150,7 +2154,7 @@ H5B_copy(H5F_t *f, const H5B_t *old_bt) /* Allocate memory for the new H5B_t object */ if (NULL==(new_node = H5FL_MALLOC(H5B_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node") /* Copy the main structure */ HDmemcpy(new_node,old_bt,sizeof(H5B_t)); @@ -2162,7 +2166,7 @@ H5B_copy(H5F_t *f, const H5B_t *old_bt) NULL==(new_node->native=H5FL_BLK_MALLOC(native_block,total_native_keysize)) || NULL==(new_node->child=H5FL_SEQ_MALLOC(haddr_t,nkeys)) || NULL==(new_node->key=H5FL_SEQ_MALLOC(H5B_key_t,(nkeys+1)))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node") /* Copy the other structures */ HDmemcpy(new_node->page,old_bt->page,(size_t)size); @@ -2191,7 +2195,7 @@ done: } /* end if */ } /* end if */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5B_copy */ @@ -2216,10 +2220,10 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f const H5B_class_t *type, void *udata) { H5B_t *bt = NULL; - int i; + unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5B_debug, FAIL); + FUNC_ENTER_NOAPI(H5B_debug, FAIL) /* * Check arguments. @@ -2235,7 +2239,7 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f * Load the tree node. */ if (NULL == (bt = H5AC_find(f, dxpl_id, H5AC_BT, addr, type, udata))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") /* * Print the values. @@ -2253,9 +2257,9 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Dirty flag:", bt->cache_info.dirty ? "True" : "False"); - HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of initial dirty children:", - (int) (bt->ndirty)); + bt->ndirty); HDfprintf(stream, "%*s%-*s %d\n", indent, "", fwidth, "Level:", (int) (bt->level)); @@ -2268,41 +2272,44 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f "Address of right sibling:", bt->right); - HDfprintf(stream, "%*s%-*s %d (%d)\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %u (%u)\n", indent, "", fwidth, "Number of children (max):", - (int) (bt->nchildren), - (int) (2 * H5F_KVALUE(f, type))); + bt->nchildren, (2 * H5F_KVALUE(f, type))); /* * Print the child addresses */ - for (i = 0; i < bt->nchildren; i++) { - HDfprintf(stream, "%*sChild %d...\n", indent, "", i); + for (u = 0; u < bt->nchildren; u++) { + HDfprintf(stream, "%*sChild %d...\n", indent, "", u); HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", MAX(0, fwidth - 3), - "Address:", bt->child[i]); + "Address:", bt->child[u]); /* If there is a key debugging routine, use it to display the left & right keys */ if (type->debug_key) { /* Decode the 'left' key & print it */ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Left Key:"); - if(bt->key[i].nkey==NULL) - H5B_decode_key(f, bt, i); - (type->debug_key)(stream, f, dxpl_id, indent+6, MAX (0, fwidth-6), - bt->key[i].nkey, udata); + if(bt->key[u].nkey==NULL) { + if(H5B_decode_key(f, bt, u)<0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode B-tree key(s)") + } /* end if */ + (void)(type->debug_key)(stream, f, dxpl_id, indent+6, MAX (0, fwidth-6), + bt->key[u].nkey, udata); /* Decode the 'right' key & print it */ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Right Key:"); - if(bt->key[i+1].nkey==NULL) - H5B_decode_key(f, bt, i+1); - (type->debug_key)(stream, f, dxpl_id, indent+6, MAX (0, fwidth-6), - bt->key[i+1].nkey, udata); + if(bt->key[u+1].nkey==NULL) { + if(H5B_decode_key(f, bt, u+1)<0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode B-tree key(s)") + } /* end if */ + (void)(type->debug_key)(stream, f, dxpl_id, indent+6, MAX (0, fwidth-6), + bt->key[u+1].nkey, udata); } } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -2340,7 +2347,7 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void struct child_t *next; } *head = NULL, *tail = NULL, *prev = NULL, *cur = NULL, *tmp = NULL; - FUNC_ENTER_NOAPI(H5B_assert, FAIL); + FUNC_ENTER_NOAPI(H5B_assert, FAIL) if (0==ncalls++) { if (H5DEBUG(B)) { @@ -2367,7 +2374,7 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void assert(bt); /* Check node header */ - assert(bt->ndirty >= 0 && bt->ndirty <= bt->nchildren); + assert(bt->ndirty <= bt->nchildren); assert(bt->level == cur->level); if (cur->next && cur->next->level == bt->level) { assert(H5F_addr_eq(bt->right, cur->next->addr)); @@ -2410,6 +2417,7 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void /* Release node */ status = H5AC_unprotect(f, dxpl_id, H5AC_BT, cur->addr, bt, FALSE); assert(status >= 0); + bt=NULL; /* Make certain future references will be caught */ /* Advance current location in queue */ prev = cur; @@ -2424,6 +2432,6 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } #endif /* H5B_DEBUG */ diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index 707285d..6e28d93 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -54,11 +54,11 @@ struct H5B_t { /* first field in structure */ const H5B_class_t *type; /*type of tree */ size_t sizeof_rkey; /*size of raw (disk) key */ - int ndirty; /*num child ptrs to emit */ + unsigned ndirty; /*num child ptrs to emit */ int level; /*node level */ haddr_t left; /*address of left sibling */ haddr_t right; /*address of right sibling */ - int nchildren; /*number of child pointers */ + unsigned nchildren; /*number of child pointers */ uint8_t *page; /*disk page */ uint8_t *native; /*array of keys in native format */ H5B_key_t *key; /*2k+1 key entries */ @@ -54,10 +54,10 @@ static int H5D_crt_data_pipeline_cmp(const void *value1, const void *value2, siz static H5D_t * H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type); static H5D_t * H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dxpl_id); -static H5D_t * H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id); -static herr_t H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id); -static hsize_t H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id); -static haddr_t H5D_get_offset(H5D_t *dset); +static H5D_t * H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id); +static herr_t H5D_get_space_status(const H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id); +static hsize_t H5D_get_storage_size(const H5D_t *dset, hid_t dxpl_id); +static haddr_t H5D_get_offset(const H5D_t *dset); static herr_t H5D_extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id); static herr_t H5D_set_extent(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id); static herr_t H5D_close(H5D_t *dataset); @@ -110,11 +110,11 @@ H5D_init(void) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5D_init, FAIL); + FUNC_ENTER_NOAPI(H5D_init, FAIL) /* FUNC_ENTER() does all the work */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -200,11 +200,11 @@ H5D_init_interface(void) size_t nprops; /* Number of properties */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_init_interface); + FUNC_ENTER_NOAPI_NOINIT(H5D_init_interface) /* Initialize the atom group for the dataset IDs */ if (H5I_init_group(H5I_DATASET, H5I_DATASETID_HASHSIZE, H5D_RESERVED_ATOMS, (H5I_free_t)H5D_close)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize interface"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize interface") /* =========Dataset Transfer Property Class Initialization========= */ /* Register the default dataset transfer properties */ @@ -212,90 +212,90 @@ H5D_init_interface(void) /* Get the pointer to the dataset transfer class */ if (NULL == (xfer_pclass = H5I_object(H5P_CLS_DATASET_XFER_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Get the number of properties in the class */ if(H5P_get_nprops_pclass(xfer_pclass,&nprops)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties") /* Assume that if there are properties in the class, they are the default ones */ if(nprops==0) { /* Register the max. temp buffer size property */ if(H5P_register(xfer_pclass,H5D_XFER_MAX_TEMP_BUF_NAME,H5D_XFER_MAX_TEMP_BUF_SIZE,&def_max_temp_buf,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the type conversion buffer property */ if(H5P_register(xfer_pclass,H5D_XFER_TCONV_BUF_NAME,H5D_XFER_TCONV_BUF_SIZE,&def_tconv_buf,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the background buffer property */ if(H5P_register(xfer_pclass,H5D_XFER_BKGR_BUF_NAME,H5D_XFER_BKGR_BUF_SIZE,&def_bkgr_buf,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the background buffer type property */ if(H5P_register(xfer_pclass,H5D_XFER_BKGR_BUF_TYPE_NAME,H5D_XFER_BKGR_BUF_TYPE_SIZE,&def_bkgr_buf_type,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the B-Tree node splitting ratios property */ if(H5P_register(xfer_pclass,H5D_XFER_BTREE_SPLIT_RATIO_NAME,H5D_XFER_BTREE_SPLIT_RATIO_SIZE,def_btree_split_ratio,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #ifdef H5_WANT_H5_V1_4_COMPAT /* Register the hyperslab caching property */ if(H5P_register(xfer_pclass,H5D_XFER_HYPER_CACHE_NAME,H5D_XFER_HYPER_CACHE_SIZE,&def_hyper_cache,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the hyperslab cache limit property */ if(H5P_register(xfer_pclass,H5D_XFER_HYPER_CACHE_LIM_NAME,H5D_XFER_HYPER_CACHE_LIM_SIZE,&def_hyper_cache_lim,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") #endif /* H5_WANT_H5_V1_4_COMPAT */ /* Register the vlen allocation function property */ if(H5P_register(xfer_pclass,H5D_XFER_VLEN_ALLOC_NAME,H5D_XFER_VLEN_ALLOC_SIZE,&def_vlen_alloc,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen allocation information property */ if(H5P_register(xfer_pclass,H5D_XFER_VLEN_ALLOC_INFO_NAME,H5D_XFER_VLEN_ALLOC_INFO_SIZE,&def_vlen_alloc_info,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen free function property */ if(H5P_register(xfer_pclass,H5D_XFER_VLEN_FREE_NAME,H5D_XFER_VLEN_FREE_SIZE,&def_vlen_free,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vlen free information property */ if(H5P_register(xfer_pclass,H5D_XFER_VLEN_FREE_INFO_NAME,H5D_XFER_VLEN_FREE_INFO_SIZE,&def_vlen_free_info,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file driver ID property */ if(H5P_register(xfer_pclass,H5D_XFER_VFL_ID_NAME,H5D_XFER_VFL_ID_SIZE,&def_vfl_id,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file driver info property */ if(H5P_register(xfer_pclass,H5D_XFER_VFL_INFO_NAME,H5D_XFER_VFL_INFO_SIZE,&def_vfl_info,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the vector size property */ if(H5P_register(xfer_pclass,H5D_XFER_HYPER_VECTOR_SIZE_NAME,H5D_XFER_HYPER_VECTOR_SIZE_SIZE,&def_hyp_vec_size,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the I/O transfer mode property */ if(H5P_register(xfer_pclass,H5D_XFER_IO_XFER_MODE_NAME,H5D_XFER_IO_XFER_MODE_SIZE,&def_io_xfer_mode,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the EDC property */ if(H5P_register(xfer_pclass,H5D_XFER_EDC_NAME,H5D_XFER_EDC_SIZE,&enable_edc,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the filter callback property */ if(H5P_register(xfer_pclass,H5D_XFER_FILTER_CB_NAME,H5D_XFER_FILTER_CB_SIZE,&filter_cb,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") } /* end if */ /* Only register the default property list if it hasn't been created yet */ if(H5P_LST_DATASET_XFER_g==(-1)) { /* Register the default data transfer property list */ if ((H5P_LST_DATASET_XFER_g = H5P_create_id (xfer_pclass))<0) - HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register default property list"); + HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register default property list") } /* end if */ /* =========Dataset Creation Property Class Initialization========== */ @@ -304,52 +304,52 @@ H5D_init_interface(void) /* Get the pointer to the dataset creation class */ if(NULL == (crt_pclass = H5I_object(H5P_CLS_DATASET_CREATE_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Get the number of properties in the class */ if(H5P_get_nprops_pclass(crt_pclass,&nprops)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties") /* Assume that if there are properties in the class, they are the default ones */ if(nprops==0) { /* Register the storage layout property */ if(H5P_register(crt_pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &layout, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the chunking dimensionality property */ if(H5P_register(crt_pclass, H5D_CRT_CHUNK_DIM_NAME, H5D_CRT_CHUNK_DIM_SIZE, &chunk_ndims, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the chunking size property */ if(H5P_register(crt_pclass, H5D_CRT_CHUNK_SIZE_NAME, H5D_CRT_CHUNK_SIZE_SIZE, chunk_size, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the fill value property */ if(H5P_register(crt_pclass, H5D_CRT_FILL_VALUE_NAME, H5D_CRT_FILL_VALUE_SIZE, &fill, NULL, NULL, NULL, NULL, NULL, H5D_CRT_FILL_VALUE_CMP, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the space allocation time property */ if(H5P_register(crt_pclass, H5D_CRT_ALLOC_TIME_NAME, H5D_CRT_ALLOC_TIME_SIZE, &alloc_time, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the fill value writing time property */ if(H5P_register(crt_pclass, H5D_CRT_FILL_TIME_NAME, H5D_CRT_FILL_TIME_SIZE, &fill_time, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the external file list property */ if(H5P_register(crt_pclass, H5D_CRT_EXT_FILE_LIST_NAME, H5D_CRT_EXT_FILE_LIST_SIZE, &efl, NULL, NULL, NULL, NULL, NULL, H5D_CRT_EXT_FILE_LIST_CMP, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the data pipeline property */ if(H5P_register(crt_pclass, H5D_CRT_DATA_PIPELINE_NAME, H5D_CRT_DATA_PIPELINE_SIZE, &pline, NULL, NULL, NULL, NULL, NULL, H5D_CRT_DATA_PIPELINE_CMP, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") } /* end if */ /* Only register the default property list if it hasn't been created yet */ if(H5P_LST_DATASET_CREATE_g==(-1)) { /* Register the default data transfer property list */ if ((H5P_LST_DATASET_CREATE_g = H5P_create_id (crt_pclass))<0) - HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register default property list"); + HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register default property list") } /* end if */ /* Reset the "default dataset" information */ @@ -359,29 +359,29 @@ H5D_init_interface(void) * default dataset with them. */ if (NULL == (def_dcpl = H5I_object(H5P_LST_DATASET_CREATE_g))) - HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get default dataset creation property list"); + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get default dataset creation property list") /* Set up the default allocation time information */ if(H5P_get(def_dcpl, H5D_CRT_ALLOC_TIME_NAME, &H5D_def_dset.alloc_time) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve space allocation time"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve space allocation time") if(H5D_def_dset.alloc_time==H5D_ALLOC_TIME_DEFAULT) H5D_def_dset.alloc_time=H5D_ALLOC_TIME_LATE; /* Get the default external file list information */ if(H5P_get(def_dcpl, H5D_CRT_EXT_FILE_LIST_NAME, &H5D_def_dset.efl) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve external file list"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve external file list") /* Get the default data storage method */ if(H5P_get(def_dcpl, H5D_CRT_LAYOUT_NAME, &H5D_def_dset.layout.type) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") /* Get the default fill value time */ if (H5P_get(def_dcpl, H5D_CRT_FILL_TIME_NAME, &H5D_def_dset.fill_time) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill time"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill time") /* Get the default fill value */ if (H5P_get(def_dcpl, H5D_CRT_FILL_VALUE_NAME, &H5D_def_dset.fill) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill value"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill value") /* Reset the "default DXPL cache" information */ HDmemset(&H5D_def_dxpl_cache,0,sizeof(H5D_dxpl_cache_t)); @@ -391,7 +391,7 @@ H5D_init_interface(void) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve default DXPL info") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -417,7 +417,7 @@ H5D_term_interface(void) { int n=0; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_term_interface); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_term_interface) if (interface_initialize_g) { if ((n=H5I_nmembers(H5I_DATASET))) { @@ -450,7 +450,7 @@ H5D_term_interface(void) n = 1; /*H5I*/ } } - FUNC_LEAVE_NOAPI(n); + FUNC_LEAVE_NOAPI(n) } @@ -472,6 +472,7 @@ H5D_term_interface(void) * *------------------------------------------------------------------------- */ +/* ARGSUSED */ herr_t H5D_crt_copy(hid_t new_plist_id, hid_t old_plist_id, void UNUSED *copy_data) { @@ -482,22 +483,22 @@ H5D_crt_copy(hid_t new_plist_id, hid_t old_plist_id, void UNUSED *copy_data) H5P_genplist_t *new_plist; herr_t ret_value=SUCCEED; - FUNC_ENTER_NOAPI(H5D_crt_copy, FAIL); + FUNC_ENTER_NOAPI(H5D_crt_copy, FAIL) /* Verify property list ID */ if (NULL == (new_plist = H5I_object(new_plist_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") if (NULL == (old_plist = H5I_object(old_plist_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Get the fill value, external file list, and data pipeline properties * from the old property list */ if(H5P_get(old_plist, H5D_CRT_FILL_VALUE_NAME, &src_fill) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") if(H5P_get(old_plist, H5D_CRT_EXT_FILE_LIST_NAME, &src_efl) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") if(H5P_get(old_plist, H5D_CRT_DATA_PIPELINE_NAME, &src_pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Make copies of fill value, external file list, and data pipeline */ if(src_fill.buf) { @@ -510,21 +511,21 @@ H5D_crt_copy(hid_t new_plist_id, hid_t old_plist_id, void UNUSED *copy_data) } HDmemset(&dst_efl,0,sizeof(H5O_efl_t)); if(NULL==H5O_copy(H5O_EFL_ID, &src_efl, &dst_efl)) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy external file list"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy external file list") if(NULL==H5O_copy(H5O_PLINE_ID, &src_pline, &dst_pline)) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy data pipeline"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy data pipeline") /* Set the fill value, external file list, and data pipeline property * for the new property list */ if(H5P_set(new_plist, H5D_CRT_FILL_VALUE_NAME, &dst_fill) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") if(H5P_set(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &dst_efl) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file list"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file list") if(H5P_set(new_plist, H5D_CRT_DATA_PIPELINE_NAME, &dst_pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -546,6 +547,7 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ herr_t H5D_crt_close(hid_t dcpl_id, void UNUSED *close_data) { @@ -555,29 +557,32 @@ H5D_crt_close(hid_t dcpl_id, void UNUSED *close_data) H5P_genplist_t *plist; /* Property list */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5D_crt_close, FAIL); + FUNC_ENTER_NOAPI(H5D_crt_close, FAIL) /* Check arguments */ if (NULL == (plist = H5I_object(dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Get the fill value, external file list, and data pipeline properties * from the old property list */ if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") if(H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Clean up any values set for the fill-value, external file-list and * data pipeline */ - H5O_reset(H5O_FILL_ID, &fill); - H5O_reset(H5O_EFL_ID, &efl); - H5O_reset(H5O_PLINE_ID, &pline); + if(H5O_reset(H5O_FILL_ID, &fill)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release fill info") + if(H5O_reset(H5O_EFL_ID, &efl)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release external file list info") + if(H5O_reset(H5O_PLINE_ID, &pline)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release pipeline info") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_crt_close() */ @@ -599,7 +604,7 @@ done: *------------------------------------------------------------------------- */ static int -H5D_crt_fill_value_cmp(const void *value1, const void *value2, size_t UNUSED size) +H5D_crt_fill_value_cmp(const void *value1, const void *value2, size_t size) { const H5O_fill_t *fill1=(const H5O_fill_t *)value1, /* Create local aliases for values */ *fill2=(const H5O_fill_t *)value2; @@ -655,7 +660,7 @@ done: *------------------------------------------------------------------------- */ static int -H5D_crt_ext_file_list_cmp(const void *value1, const void *value2, size_t UNUSED size) +H5D_crt_ext_file_list_cmp(const void *value1, const void *value2, size_t size) { const H5O_efl_t *efl1=(const H5O_efl_t *)value1, /* Create local aliases for values */ *efl2=(const H5O_efl_t *)value2; @@ -689,28 +694,28 @@ H5D_crt_ext_file_list_cmp(const void *value1, const void *value2, size_t UNUSED if(efl1->slot==NULL && efl2->slot!=NULL) HGOTO_DONE(-1); if(efl1->slot!=NULL && efl2->slot==NULL) HGOTO_DONE(1); if(efl1->slot!=NULL && efl1->nused>0) { - int i; /* Local index variable */ + size_t u; /* Local index variable */ /* Loop through all entries, comparing them */ - for(i=0; i<efl1->nused; i++) { + for(u=0; u<efl1->nused; u++) { /* Check the name offset of the efl entry */ - if(efl1->slot[i].name_offset < efl2->slot[i].name_offset) HGOTO_DONE(-1); - if(efl1->slot[i].name_offset > efl2->slot[i].name_offset) HGOTO_DONE(1); + if(efl1->slot[u].name_offset < efl2->slot[u].name_offset) HGOTO_DONE(-1); + if(efl1->slot[u].name_offset > efl2->slot[u].name_offset) HGOTO_DONE(1); /* Check the name of the efl entry */ - if(efl1->slot[i].name==NULL && efl2->slot[i].name!=NULL) HGOTO_DONE(-1); - if(efl1->slot[i].name!=NULL && efl2->slot[i].name==NULL) HGOTO_DONE(1); - if(efl1->slot[i].name!=NULL) - if((cmp_value=HDstrcmp(efl1->slot[i].name,efl2->slot[i].name))!=0) + if(efl1->slot[u].name==NULL && efl2->slot[u].name!=NULL) HGOTO_DONE(-1); + if(efl1->slot[u].name!=NULL && efl2->slot[u].name==NULL) HGOTO_DONE(1); + if(efl1->slot[u].name!=NULL) + if((cmp_value=HDstrcmp(efl1->slot[u].name,efl2->slot[u].name))!=0) HGOTO_DONE(cmp_value); /* Check the file offset of the efl entry */ - if(efl1->slot[i].offset < efl2->slot[i].offset) HGOTO_DONE(-1); - if(efl1->slot[i].offset > efl2->slot[i].offset) HGOTO_DONE(1); + if(efl1->slot[u].offset < efl2->slot[u].offset) HGOTO_DONE(-1); + if(efl1->slot[u].offset > efl2->slot[u].offset) HGOTO_DONE(1); /* Check the file size of the efl entry */ - if(efl1->slot[i].size < efl2->slot[i].size) HGOTO_DONE(-1); - if(efl1->slot[i].size > efl2->slot[i].size) HGOTO_DONE(1); + if(efl1->slot[u].size < efl2->slot[u].size) HGOTO_DONE(-1); + if(efl1->slot[u].size > efl2->slot[u].size) HGOTO_DONE(1); } /* end for */ } /* end if */ @@ -737,7 +742,7 @@ done: *------------------------------------------------------------------------- */ static int -H5D_crt_data_pipeline_cmp(const void *value1, const void *value2, size_t UNUSED size) +H5D_crt_data_pipeline_cmp(const void *value1, const void *value2, size_t size) { const H5O_pline_t *pline1=(const H5O_pline_t *)value1, /* Create local aliases for values */ *pline2=(const H5O_pline_t *)value2; @@ -756,17 +761,17 @@ H5D_crt_data_pipeline_cmp(const void *value1, const void *value2, size_t UNUSED if(pline1->nalloc > pline2->nalloc) HGOTO_DONE(1); /* Check the number of used pipeline entries */ - if(pline1->nfilters < pline2->nfilters) HGOTO_DONE(-1); - if(pline1->nfilters > pline2->nfilters) HGOTO_DONE(1); + if(pline1->nused < pline2->nused) HGOTO_DONE(-1); + if(pline1->nused > pline2->nused) HGOTO_DONE(1); /* Check the filter entry information */ if(pline1->filter==NULL && pline2->filter!=NULL) HGOTO_DONE(-1); if(pline1->filter!=NULL && pline2->filter==NULL) HGOTO_DONE(1); - if(pline1->filter!=NULL && pline1->nfilters>0) { + if(pline1->filter!=NULL && pline1->nused>0) { size_t u; /* Local index variable */ /* Loop through all filters, comparing them */ - for(u=0; u<pline1->nfilters; u++) { + for(u=0; u<pline1->nused; u++) { /* Check the ID of the filter */ if(pline1->filter[u].id < pline2->filter[u].id) HGOTO_DONE(-1); if(pline1->filter[u].id > pline2->filter[u].id) HGOTO_DONE(1); @@ -829,6 +834,7 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ herr_t H5D_xfer_create(hid_t dxpl_id, void UNUSED *create_data) { @@ -837,17 +843,17 @@ H5D_xfer_create(hid_t dxpl_id, void UNUSED *create_data) H5P_genplist_t *plist; /* Property list */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5D_xfer_create, FAIL); + FUNC_ENTER_NOAPI(H5D_xfer_create, FAIL) /* Check arguments */ if (NULL == (plist = H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Get the driver information */ if(H5P_get(plist, H5D_XFER_VFL_ID_NAME, &driver_id)<0) - HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve VFL driver ID"); + HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve VFL driver ID") if(H5P_get(plist, H5D_XFER_VFL_INFO_NAME, &driver_info)<0) - HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve VFL driver info"); + HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve VFL driver info") /* Check if we have a valid driver ID */ if(driver_id>0) { @@ -857,7 +863,7 @@ H5D_xfer_create(hid_t dxpl_id, void UNUSED *create_data) } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_xfer_create() */ @@ -879,6 +885,7 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ herr_t H5D_xfer_copy(hid_t new_dxpl_id, hid_t old_dxpl_id, void UNUSED *copy_data) { @@ -888,7 +895,7 @@ H5D_xfer_copy(hid_t new_dxpl_id, hid_t old_dxpl_id, void UNUSED *copy_data) H5P_genplist_t *old_plist; /* Old property list */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5D_xfer_copy, FAIL); + FUNC_ENTER_NOAPI(H5D_xfer_copy, FAIL) if(NULL == (new_plist = H5I_object(new_dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") @@ -908,7 +915,7 @@ H5D_xfer_copy(hid_t new_dxpl_id, hid_t old_dxpl_id, void UNUSED *copy_data) } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -932,6 +939,7 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ herr_t H5D_xfer_close(hid_t dxpl_id, void UNUSED *close_data) { @@ -940,16 +948,16 @@ H5D_xfer_close(hid_t dxpl_id, void UNUSED *close_data) H5P_genplist_t *plist; /* Property list */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5D_xfer_close, FAIL); + FUNC_ENTER_NOAPI(H5D_xfer_close, FAIL) /* Check arguments */ if (NULL == (plist = H5I_object(dxpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") if(H5P_get(plist, H5D_XFER_VFL_ID_NAME, &driver_id)<0) - HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve VFL driver ID"); + HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve VFL driver ID") if(H5P_get(plist, H5D_XFER_VFL_INFO_NAME, &driver_info)<0) - HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve VFL driver info"); + HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve VFL driver info") if(driver_id>0) { /* Close the driver for the property list */ if(H5FD_dxpl_close(driver_id, driver_info)<0) @@ -957,7 +965,7 @@ H5D_xfer_close(hid_t dxpl_id, void UNUSED *close_data) } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_xfer_close() */ @@ -1061,43 +1069,45 @@ H5Dcreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, const H5S_t *space; /* Dataspace for dataset */ hid_t ret_value; /* Return value */ - FUNC_ENTER_API(H5Dcreate, FAIL); + FUNC_ENTER_API(H5Dcreate, FAIL) H5TRACE5("i","isiii",loc_id,name,type_id,space_id,dcpl_id); /* Check arguments */ if (NULL == (loc = H5G_loc(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if (H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID") if (NULL == (space = H5I_object_verify(space_id,H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") if(H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; else if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID") /* build and open the new dataset */ if (NULL == (new_dset = H5D_create(loc, name, type_id, space, dcpl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") /* Register the new dataset to get an ID for it */ if ((ret_value = H5I_register(H5I_DATASET, new_dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") /* Add the dataset to the list of opened objects in the file */ if(H5FO_insert(new_dset->ent.file,new_dset->ent.header,ret_value)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert dataset into list of open objects"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert dataset into list of open objects") done: if(ret_value<0) { - if(new_dset!=NULL) - H5D_close(new_dset); + if(new_dset!=NULL) { + if(H5D_close(new_dset)<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") + } /* end if */ } /* end if */ - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -1128,25 +1138,25 @@ H5Dopen(hid_t loc_id, const char *name) H5G_entry_t ent; /*dataset symbol table entry */ hid_t ret_value; - FUNC_ENTER_API(H5Dopen, FAIL); + FUNC_ENTER_API(H5Dopen, FAIL) H5TRACE2("i","is",loc_id,name); /* Check args */ if (NULL == (loc = H5G_loc(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Find the dataset object */ if (H5G_find(loc, name, NULL, &ent, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found"); + HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") /* Open the dataset */ if ((ret_value = H5D_open(&ent, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -1176,24 +1186,24 @@ H5Dclose(hid_t dset_id) H5D_t *dset = NULL; /* Dataset object to release */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Dclose, FAIL); + FUNC_ENTER_API(H5Dclose, FAIL) H5TRACE1("e","i",dset_id); /* Check args */ if (NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (NULL == dset->ent.file) - HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") /* * Decrement the counter on the dataset. It will be freed if the count * reaches zero. */ if (H5I_dec_ref(dset_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't free"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't free") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -1224,28 +1234,30 @@ H5Dget_space(hid_t dset_id) H5S_t *space = NULL; hid_t ret_value; - FUNC_ENTER_API(H5Dget_space, FAIL); + FUNC_ENTER_API(H5Dget_space, FAIL) H5TRACE1("i","i",dset_id); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Read the data space message and return a data space object */ if (NULL==(space=H5S_copy (dset->space, FALSE))) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get data space"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get data space") /* Create an atom */ if ((ret_value=H5I_register (H5I_DATASPACE, space))<0) - HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space"); + HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space") done: if(ret_value<0) { - if(space!=NULL) - H5S_close(space); + if(space!=NULL) { + if(H5S_close(space)<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + } /* end if */ } /* end if */ - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -1271,19 +1283,19 @@ H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) H5D_t *dset = NULL; herr_t ret_value = SUCCEED; - FUNC_ENTER_API(H5Dget_space_status, FAIL); + FUNC_ENTER_API(H5Dget_space_status, FAIL) H5TRACE2("e","i*Ds",dset_id,allocation); /* Check arguments */ if(NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Read data space address and return */ if(FAIL==(ret_value=H5D_get_space_status(dset, allocation, H5AC_ind_dxpl_id))) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -1304,7 +1316,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) +H5D_get_space_status(const H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) { H5S_t *space; /* Dataset's dataspace */ hsize_t space_allocated; /* The number of bytes allocated for chunks */ @@ -1313,7 +1325,7 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) hsize_t full_size; /* The number of bytes in the dataset when fully populated */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT(H5D_get_space_status); + FUNC_ENTER_NOAPI_NOINIT(H5D_get_space_status) assert(dset); @@ -1327,7 +1339,7 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) /* Get the size of the dataset's datatype */ if((type_size=H5T_get_size(dset->type))==0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get size of datatype"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get size of datatype") /* Compute the maximum size of the dataset in bytes */ H5_CHECK_OVERFLOW(total_elem,hssize_t,hsize_t); @@ -1349,7 +1361,7 @@ H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id) } /* end else */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1384,16 +1396,16 @@ H5Dget_type(hid_t dset_id) H5T_t *copied_type = NULL; hid_t ret_value = FAIL; - FUNC_ENTER_API(H5Dget_type, FAIL); + FUNC_ENTER_API(H5Dget_type, FAIL) H5TRACE1("i","i",dset_id); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Copy the data type and mark it read-only */ if (NULL==(copied_type=H5T_copy (dset->type, H5T_COPY_REOPEN))) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy the data type"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy the data type") /* Mark any VL datatypes as being in memory now */ if (H5T_vlen_mark(copied_type, NULL, H5T_VLEN_MEMORY)<0) @@ -1401,19 +1413,21 @@ H5Dget_type(hid_t dset_id) /* Unlock copied type */ if (H5T_lock (copied_type, FALSE)<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient data type"); + HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient data type") /* Create an atom */ if ((ret_value=H5I_register (H5I_DATATYPE, copied_type))<0) - HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type"); + HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type") done: if(ret_value<0) { - if(copied_type!=NULL) - H5T_close (copied_type); + if(copied_type!=NULL) { + if(H5T_close (copied_type)<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") + } /* end if */ } /* end if */ - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -1450,33 +1464,33 @@ H5Dget_create_plist(hid_t dset_id) hid_t new_dcpl_id = FAIL; hid_t ret_value = FAIL; - FUNC_ENTER_API(H5Dget_create_plist, FAIL); + FUNC_ENTER_API(H5Dget_create_plist, FAIL) H5TRACE1("i","i",dset_id); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (NULL == (dcpl_plist = H5I_object(dset->dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Copy the creation property list */ if((new_dcpl_id = H5P_copy_plist(dcpl_plist)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to copy the creation property list"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to copy the creation property list") if (NULL == (new_plist = H5I_object(new_dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Get the fill value property */ if(H5P_get(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Copy the dataset type into the fill value message */ if(copied_fill.type==NULL) if(NULL==(copied_fill.type=H5T_copy(dset->type, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy dataset data type for fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy dataset data type for fill value") /* Set back the fill value property to property list */ if(H5P_set(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property list fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property list fill value") /* Set the return value */ ret_value=new_dcpl_id; @@ -1487,7 +1501,7 @@ done: (void)H5I_dec_ref(new_dcpl_id); } /* end if */ - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -1513,21 +1527,21 @@ H5Dextend(hid_t dset_id, const hsize_t *size) H5D_t *dset = NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Dextend, FAIL); + FUNC_ENTER_API(H5Dextend, FAIL) H5TRACE2("e","i*h",dset_id,size); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (!size) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") /* Increase size */ if (H5D_extend (dset, size, H5AC_dxpl_id)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to extend dataset"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to extend dataset") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -1561,10 +1575,10 @@ H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type) H5D_t *new_dset = NULL; /* New dataset object */ H5D_t *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5D_new, NULL); + FUNC_ENTER_NOAPI(H5D_new, NULL) if (NULL==(new_dset = H5FL_MALLOC(H5D_t))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* If we are using the default dataset creation property list, during creation * don't bother to copy it, just increment the reference count @@ -1574,7 +1588,7 @@ H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type) HDmemcpy(new_dset,&H5D_def_dset,sizeof(H5D_t)); if(H5I_inc_ref(dcpl_id)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINC, NULL, "Can't increment default DCPL ID"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINC, NULL, "Can't increment default DCPL ID") new_dset->dcpl_id = dcpl_id; } /* end if */ else { @@ -1583,7 +1597,7 @@ H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type) /* Get the property list */ if (NULL == (plist = H5I_object(dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") new_dset->dcpl_id = H5P_copy_plist(plist); } /* end else */ @@ -1597,12 +1611,12 @@ done: if(ret_value==NULL) { if(new_dset!=NULL) { if(new_dset->dcpl_id!=0) - H5I_dec_ref(new_dset->dcpl_id); + (void)H5I_dec_ref(new_dset->dcpl_id); H5FL_FREE(H5D_t,new_dset); } /* end if */ } /* end if */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1649,7 +1663,7 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p /* return code */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5D_update_entry_info, FAIL); + FUNC_ENTER_NOAPI(H5D_update_entry_info, FAIL) /* Sanity checking */ assert(file); @@ -1669,11 +1683,11 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p /* Create (open for write access) an object header */ if (H5O_create(file, dxpl_id, ohdr_size, ent) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset object header"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset object header") /* Get a pointer to the object header itself */ if((oh=H5O_protect(ent, dxpl_id))==NULL) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to protect dataset object header"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to protect dataset object header") /* Point at dataset's copy, to cache it for later */ fill_prop=&dset->fill; @@ -1683,20 +1697,19 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p if(dset->dcpl_id!=H5P_DATASET_CREATE_DEFAULT) { /* * Retrieve properties of fill value and others. Copy them into new fill - * value struct. Convert the fill value to the dataset type and write - * the message + * value struct. */ if (H5P_get(plist, H5D_CRT_FILL_TIME_NAME, &fill_time) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill time"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill time") dset->fill_time=fill_time; /* Cache this for later */ /* Get the fill value information from the property list */ if (H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill value"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve fill value") } /* end if */ if (H5P_is_fill_value_defined(fill_prop, &fill_status) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* Special case handling for variable-length types */ if(H5T_detect_class(type, H5T_VLEN)) { @@ -1712,69 +1725,68 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p /* Don't allow never writing fill values with variable-length types */ if(fill_time==H5D_FILL_TIME_NEVER) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Dataset doesn't support VL datatype when fill value is not defined"); + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Dataset doesn't support VL datatype when fill value is not defined") } /* end if */ if (fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED) { if (H5O_copy(H5O_FILL_ID, fill_prop, &fill) == NULL) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT,FAIL, "unable to copy fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT,FAIL, "unable to copy fill value") if (fill_prop->buf && fill_prop->size > 0 && H5O_fill_convert(&fill, type, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert fill value to dataset type"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert fill value to dataset type") fill.fill_defined = TRUE; } else if (fill_status == H5D_FILL_VALUE_UNDEFINED) { fill.size = -1; fill.type = fill.buf = NULL; fill.fill_defined = FALSE; - } else { - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine if fill value is defined"); - } + } else + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine if fill value is defined") fill.alloc_time = alloc_time; fill.fill_time = fill_time; if (fill.fill_defined == FALSE && fill_time == H5D_FILL_TIME_ALLOC) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT,FAIL, "unable to create dataset"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT,FAIL, "unable to create dataset") /* Write new fill value message */ if (H5O_append(file, dxpl_id, oh, H5O_FILL_NEW_ID, H5O_FLAG_CONSTANT, &fill) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update fill value header message"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update fill value header message") /* If there is valid information for the old fill value struct, update it */ if (fill.buf) { /* Clear any previous values */ - H5O_reset(H5O_FILL_ID, fill_prop); + if(H5O_reset(H5O_FILL_ID, fill_prop)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release fill info") /* Copy new fill value information to old fill value struct */ if(H5O_copy(H5O_FILL_ID, &fill, fill_prop) == NULL) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT,FAIL,"unable to copy fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT,FAIL,"unable to copy fill value") /* Write old fill value */ if (fill_prop->buf && H5O_append(file, dxpl_id, oh, H5O_FILL_ID, H5O_FLAG_CONSTANT, fill_prop) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update fill value header message"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update fill value header message") /* Update dataset creation property */ assert(dset->dcpl_id!=H5P_DATASET_CREATE_DEFAULT); if (H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") } /* end if */ /* Update the type and space header messages */ if (H5O_append(file, dxpl_id, oh, H5O_DTYPE_ID, H5O_FLAG_CONSTANT | H5O_FLAG_SHARED, type) < 0 || H5S_append(file, dxpl_id, oh, space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update type or space header messages"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update type or space header messages") /* Update the filters message, if this is a chunked dataset */ if(layout->type==H5D_CHUNKED) { H5O_pline_t pline; /* Chunked data I/O pipeline info */ if (H5P_get(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve pipeline filter"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve pipeline filter") - if (pline.nfilters > 0 && - H5O_append(file, dxpl_id, oh, H5O_PLINE_ID, H5O_FLAG_CONSTANT, &pline) < 0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update filter header message"); + if (pline.nused > 0 && H5O_append(file, dxpl_id, oh, H5O_PLINE_ID, H5O_FLAG_CONSTANT, &pline) < 0) + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update filter header message") } /* end if */ /* @@ -1783,53 +1795,53 @@ H5D_update_entry_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, H5P_genplist_t *p */ if (alloc_time == H5D_ALLOC_TIME_EARLY) if (H5D_alloc_storage(file, dxpl_id, dset, H5D_ALLOC_CREATE, FALSE, FALSE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") /* Update external storage message */ if (efl->nused > 0) { size_t heap_size = H5HL_ALIGN(1); - int i; + size_t u; - for (i = 0; i < efl->nused; ++i) - heap_size += H5HL_ALIGN(HDstrlen(efl->slot[i].name) + 1); + for (u = 0; u < efl->nused; ++u) + heap_size += H5HL_ALIGN(HDstrlen(efl->slot[u].name) + 1); if (H5HL_create(file, dxpl_id, heap_size, &efl->heap_addr/*out*/) < 0 || H5HL_insert(file, dxpl_id, efl->heap_addr, 1, "") == (size_t)(-1)) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create external file list name heap"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create external file list name heap") - for (i = 0; i < efl->nused; ++i) { + for (u = 0; u < efl->nused; ++u) { size_t offset = H5HL_insert(file, dxpl_id, efl->heap_addr, - HDstrlen(efl->slot[i].name) + 1, efl->slot[i].name); + HDstrlen(efl->slot[u].name) + 1, efl->slot[u].name); - assert(0 == efl->slot[i].name_offset); + assert(0 == efl->slot[u].name_offset); if (offset == (size_t)(-1)) - HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, FAIL, "unable to insert URL into name heap"); + HGOTO_ERROR(H5E_EFL, H5E_CANTINIT, FAIL, "unable to insert URL into name heap") - efl->slot[i].name_offset = offset; + efl->slot[u].name_offset = offset; } if (H5O_append(file, dxpl_id, oh, H5O_EFL_ID, H5O_FLAG_CONSTANT, efl) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update external file list message"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update external file list message") } /* Update layout message */ /* (Don't make layout message constant unless allocation time is early, since space may not be allocated) */ /* Note: this is relying on H5D_alloc_storage not calling H5O_modify during dataset creation */ if (H5D_COMPACT != layout->type && H5O_append(file, dxpl_id, oh, H5O_LAYOUT_ID, (alloc_time == H5D_ALLOC_TIME_EARLY ? H5O_FLAG_CONSTANT : 0), layout) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout") #ifdef H5O_ENABLE_BOGUS /* * Add a "bogus" message. */ if (H5O_bogus_oh(file, dxpl_id, oh))<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to update 'bogus' message"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to update 'bogus' message") #endif /* H5O_ENABLE_BOGUS */ /* Add a modification time message. */ if (H5O_touch_oh(file, oh, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time message"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time message") done: /* Release fill value information */ @@ -1839,9 +1851,9 @@ done: /* Release pointer to object header itself */ if(ent!=NULL && oh!=NULL) if(H5O_unprotect(ent,oh, dxpl_id)<0) - HDONE_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to unprotect dataset object header"); + HDONE_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to unprotect dataset object header") - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1911,12 +1923,12 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space int i, ndims; unsigned u; H5F_t *file=NULL; - int chunk_ndims = 0; + unsigned chunk_ndims = 0; /* Dimensionality of chunk */ H5P_genplist_t *dc_plist=NULL; /* New Property list */ hbool_t has_vl_type=FALSE; /* Flag to indicate a VL-type for dataset */ H5D_t *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5D_create, NULL); + FUNC_ENTER_NOAPI(H5D_create, NULL) /* check args */ assert (loc); @@ -1928,15 +1940,15 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space /* Check if the filters in the DCPL can be applied to this dataset */ if(H5Z_can_apply(dcpl_id,type_id)<0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, NULL, "I/O filters can't operate on this dataset"); + HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, NULL, "I/O filters can't operate on this dataset") /* Get the dataset's datatype */ if (NULL == (type = H5I_object(type_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") /* Check if the datatype is "sensible" for use in a dataset */ if(H5T_is_sensible(type)!=TRUE) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") /* Check if the datatype is/contains a VL-type */ if(H5T_detect_class(type, H5T_VLEN)) @@ -1944,31 +1956,31 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space /* Initialize the dataset object */ if(NULL == (new_dset = H5D_new(dcpl_id,TRUE,has_vl_type))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Make the "set local" filter callbacks for this dataset */ if(H5Z_set_local(new_dset->dcpl_id,type_id)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set local filter parameters"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set local filter parameters") /* What file is the dataset being added to? */ - if (NULL==(file=H5G_insertion_file(loc, name, dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to locate insertion point"); + if(NULL==(file=H5G_insertion_file(loc, name, dxpl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to locate insertion point") /* Copy datatype for dataset */ if((new_dset->type = H5T_copy(type, H5T_COPY_ALL))==NULL) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy datatype") /* Mark any VL datatypes as being on disk now */ if (H5T_vlen_mark(new_dset->type, file, H5T_VLEN_DISK)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location") /* Copy dataspace for dataset */ if((new_dset->space = H5S_copy(space, FALSE))==NULL) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy dataspace"); + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy dataspace") /* Set the dataset's dataspace to 'all' selection */ if(H5S_select_all(new_dset->space,1)<0) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection"); + HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") /* Check if the dataset has a non-default DCPL & get important values, if so */ if(new_dset->dcpl_id!=H5P_DATASET_CREATE_DEFAULT) { @@ -1978,16 +1990,16 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space /* Get new dataset's property list object */ if (NULL == (dc_plist = H5I_object(new_dset->dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list") if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &dcpl_pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve pipeline filter"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve pipeline filter") if(H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, &dcpl_layout) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout"); - if(dcpl_pline.nfilters > 0 && H5D_CHUNKED != dcpl_layout) - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "filters can only be used with chunked layout"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout") + if(dcpl_pline.nused > 0 && H5D_CHUNKED != dcpl_layout) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "filters can only be used with chunked layout") if(H5P_get(dc_plist, H5D_CRT_ALLOC_TIME_NAME, &alloc_time) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve space allocation time"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve space allocation time") /* Check if the alloc_time is the default and set it accordingly */ if(alloc_time==H5D_ALLOC_TIME_DEFAULT) { @@ -2005,36 +2017,36 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space break; default: - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet"); + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet") } /* end switch */ } /* end if */ /* Don't allow compact datasets to allocate space later */ if(dcpl_layout==H5D_COMPACT && alloc_time!=H5D_ALLOC_TIME_EARLY) - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "compact dataset doesn't support late space allocation"); + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "compact dataset doesn't support late space allocation") /* Set the alloc_time for the dataset, in case the default was used */ new_dset->alloc_time=alloc_time; - /* If MPIO, MPIPOSIX, or FPHDF5 is used, no filter support yet. */ - if((IS_H5FD_MPIO(file) || IS_H5FD_MPIPOSIX(file) || IS_H5FD_FPHDF5(file)) && dcpl_pline.nfilters > 0) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "Parallel I/O does not support filters yet"); + /* If MPI VFD is used, no filter support yet. */ + if(IS_H5FD_MPI(file) && dcpl_pline.nused > 0) + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "Parallel I/O does not support filters yet") /* Chunked datasets are non-default, so retrieve their info here */ if(H5P_get(dc_plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve chunk dimensions"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve chunk dimensions") /* Get the dataset's external file list information */ if(H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, &new_dset->efl) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve external file list"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve external file list") /* Get the dataset's data storage method */ if(H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, &(new_dset->layout.type)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout") } /* end if */ /* Check if this dataset is going into a parallel file and set space allocation time */ - if(IS_H5FD_MPIO(file) || IS_H5FD_MPIPOSIX(file) || IS_H5FD_FPHDF5(file)) + if(IS_H5FD_MPI(file)) new_dset->alloc_time=H5D_ALLOC_TIME_EARLY; /* Set up layout information */ @@ -2101,7 +2113,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space * Chunked storage allows any type of data space extension, so we * don't even bother checking. */ - if(chunk_ndims != ndims) + if(chunk_ndims != (unsigned)ndims) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "dimensionality of chunks doesn't match the data space") if (new_dset->efl.nused>0) HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, NULL, "external storage not supported with chunked layout") @@ -2149,14 +2161,12 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space break; default: - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet"); + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet") } /* end switch */ - /* - * Update the dataset's entry info. - */ + /* Update the dataset's entry info. */ if (H5D_update_entry_info(file, dxpl_id, new_dset, dc_plist) != SUCCEED) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't update the metadata cache"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't update the metadata cache") /* Get the dataset's DCPL cache info */ if (H5D_get_dcpl_cache(new_dset->dcpl_id,&new_dset->dcpl_cache)<0) @@ -2168,30 +2178,38 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space * created in. */ if (H5G_insert(loc, name, &new_dset->ent, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset") /* Success */ ret_value = new_dset; done: if (!ret_value && new_dset) { - if (new_dset->space) - H5S_close(new_dset->space); - if (new_dset->type) - H5T_close(new_dset->type); + if (new_dset->space) { + if(H5S_close(new_dset->space)<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") + } /* end if */ + if (new_dset->type) { + if(H5T_close(new_dset->type)<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") + } /* end if */ if (H5F_addr_defined(new_dset->ent.header)) { if(H5O_close(&(new_dset->ent))<0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header"); - if(H5O_delete(file, dxpl_id,new_dset->ent.header)<0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDELETE, NULL, "unable to delete object header"); + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header") + if(file) { + if(H5O_delete(file, dxpl_id,new_dset->ent.header)<0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDELETE, NULL, "unable to delete object header") + } /* end if */ + } /* end if */ + if(new_dset->dcpl_id!=0) { + if(H5I_dec_ref(new_dset->dcpl_id)<0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") } /* end if */ - if(new_dset->dcpl_id!=0) - H5I_dec_ref(new_dset->dcpl_id); new_dset->ent.file = NULL; H5FL_FREE(H5D_t,new_dset); } - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -2220,27 +2238,27 @@ H5D_isa(H5G_entry_t *ent, hid_t dxpl_id) htri_t exists; htri_t ret_value=TRUE; /* Return value */ - FUNC_ENTER_NOAPI(H5D_isa, FAIL); + FUNC_ENTER_NOAPI(H5D_isa, FAIL) assert(ent); /* Data type */ if ((exists=H5O_exists(ent, H5O_DTYPE_ID, 0, dxpl_id))<0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") } else if (!exists) { - HGOTO_DONE(FALSE); + HGOTO_DONE(FALSE) } /* Layout */ if ((exists=H5O_exists(ent, H5O_LAYOUT_ID, 0, dxpl_id))<0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header") } else if (!exists) { - HGOTO_DONE(FALSE); + HGOTO_DONE(FALSE) } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -2268,7 +2286,7 @@ H5D_open(H5G_entry_t *ent, hid_t dxpl_id) { hid_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5D_open, FAIL); + FUNC_ENTER_NOAPI(H5D_open, FAIL) /* check args */ assert (ent); @@ -2277,35 +2295,39 @@ H5D_open(H5G_entry_t *ent, hid_t dxpl_id) if((ret_value=H5FO_opened(ent->file,ent->header))<0) { H5D_t *dataset; /*the dataset which was found */ + /* Clear any errors from H5FO_opened() */ H5E_clear(); /* Open the dataset object */ if ((dataset=H5D_open_oid(ent, dxpl_id)) ==NULL) - HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found"); + HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") /* Create an atom for the dataset */ if ((ret_value = H5I_register(H5I_DATASET, dataset)) < 0) { - H5D_close(dataset); - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset"); + (void)H5D_close(dataset); + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset") } /* end if */ /* Add the dataset to the list of opened objects in the file */ if(H5FO_insert(ent->file,ent->header,ret_value)<0) { (void)H5I_dec_ref(ret_value); - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert dataset into list of open objects"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert dataset into list of open objects") } /* end if */ } /* end if */ else { /* Dataset is already open, increment the reference count on the ID */ if(H5I_inc_ref(ret_value)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, FAIL, "Can't increment dataset ID"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINC, FAIL, "Can't increment dataset ID") - /* Release the dataset entry we located earlier */ - H5G_free_ent_name(ent); + /* Release the dataset entry we located earlier (in H5Dopen()) */ + if(H5G_free_ent_name(ent)<0) { + (void)H5I_dec_ref(ret_value); + HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release group entry") + } /* end if */ } /* end else */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -2337,7 +2359,7 @@ done: *------------------------------------------------------------------------- */ static H5D_t * -H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id) +H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) { H5D_t *dataset = NULL; /*new dataset struct */ H5O_fill_new_t fill = {NULL, 0, NULL, H5D_ALLOC_TIME_LATE, H5D_CRT_FILL_TIME_DEF, TRUE}; @@ -2346,7 +2368,7 @@ H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id) H5P_genplist_t *plist; /* Property list */ H5D_t *ret_value = NULL; /*return value */ - FUNC_ENTER_NOAPI(H5D_open_oid, NULL); + FUNC_ENTER_NOAPI(H5D_open_oid, NULL) /* check args */ assert (ent); @@ -2354,25 +2376,26 @@ H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id) /* Allocate the dataset structure */ /* (Set the 'vl_type' parameter to FALSE since it doesn't matter from here) */ if(NULL==(dataset = H5D_new(H5P_DATASET_CREATE_DEFAULT,FALSE,FALSE))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Shallow copy (take ownership) of the group entry object */ - H5G_ent_copy(&(dataset->ent),ent,H5G_COPY_SHALLOW); + if(H5G_ent_copy(&(dataset->ent),ent,H5G_COPY_SHALLOW)<0) + HGOTO_ERROR (H5E_DATASET, H5E_CANTCOPY, NULL, "can't copy group entry") /* Find the dataset object */ if (H5O_open(&(dataset->ent)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open") /* Get the type and space */ if (NULL==(dataset->type=H5O_read(&(dataset->ent), H5O_DTYPE_ID, 0, NULL, dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load type info from dataset header"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load type info from dataset header") if (NULL==(dataset->space=H5S_read(&(dataset->ent),dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load space info from dataset header"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load space info from dataset header") /* Get dataset creation property list object */ if (NULL == (plist = H5I_object(dataset->dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list") /* Get the optional filters message */ if(NULL == H5O_read(&(dataset->ent), H5O_PLINE_ID, 0, &pline, dxpl_id)) { @@ -2380,11 +2403,11 @@ H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id) HDmemset(&pline, 0, sizeof(pline)); } if(H5P_set(plist, H5D_CRT_DATA_PIPELINE_NAME, &pline) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set pipeline"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set pipeline") - /* If MPIO, MPIPOSIX, or FPHDF5 is used, no filter support yet. */ - if((IS_H5FD_MPIO(dataset->ent.file) || IS_H5FD_MPIPOSIX(dataset->ent.file) || IS_H5FD_FPHDF5(dataset->ent.file)) && pline.nfilters > 0) - HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, "Parallel IO does not support filters yet"); + /* If MPI VFD is used, no filter support yet. */ + if(IS_H5FD_MPI(dataset->ent.file) && pline.nused > 0) + HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, "Parallel IO does not support filters yet") /* * Get the raw data layout info. It's actually stored in two locations: @@ -2393,7 +2416,7 @@ H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id) * them. */ if (NULL==H5O_read(&(dataset->ent), H5O_LAYOUT_ID, 0, &(dataset->layout), dxpl_id)) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to read data layout message"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to read data layout message") if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &dataset->layout.type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set layout") switch (dataset->layout.type) { @@ -2433,7 +2456,7 @@ H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id) break; default: - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet"); + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet") } /* end switch */ /* Point at dataset's copy, to cache it for later */ @@ -2441,8 +2464,9 @@ H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id) /* Retrieve & release the previous fill-value settings */ if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't get fill value"); - H5O_reset(H5O_FILL_ID, fill_prop); + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't get fill value") + if(H5O_reset(H5O_FILL_ID, fill_prop)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, NULL, "can't release fill info") /* Get the new fill value message */ if(NULL == H5O_read(&(dataset->ent), H5O_FILL_NEW_ID, 0, &fill, dxpl_id)) { @@ -2464,7 +2488,7 @@ H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id) break; default: - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet"); + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet") } /* end switch */ /* Set the default fill time */ @@ -2472,7 +2496,7 @@ H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id) } /* end if */ if(fill.fill_defined) { if(NULL==H5O_copy(H5O_FILL_ID, &fill, fill_prop)) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't copy fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't copy fill value") } else { /* For compatibility with v1.4. Retrieve the old fill value message. * If size is 0, make it -1 for undefined. */ @@ -2488,13 +2512,13 @@ H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id) /* Set revised fill value properties */ if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value") dataset->alloc_time=fill.alloc_time; /* Cache this for later */ if(H5P_set(plist, H5D_CRT_ALLOC_TIME_NAME, &fill.alloc_time) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value") dataset->fill_time=fill.fill_time; /* Cache this for later */ if(H5P_set(plist, H5D_CRT_FILL_TIME_NAME, &fill.fill_time) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value") /* Get the external file list message, which might not exist. Space is * also undefined when space allocate time is H5D_ALLOC_TIME_LATE. */ @@ -2503,7 +2527,7 @@ H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id) HDmemset(&dataset->efl,0,sizeof(H5O_efl_t)); if(NULL != H5O_read(&(dataset->ent), H5O_EFL_ID, 0, &dataset->efl, dxpl_id)) if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &dataset->efl) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set external file list"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set external file list") } /* @@ -2516,7 +2540,7 @@ H5D_open_oid(H5G_entry_t *ent, hid_t dxpl_id) || (dataset->layout.type==H5D_CHUNKED && !H5F_addr_defined(dataset->layout.u.chunk.addr))) && IS_H5FD_MPI(dataset->ent.file)) { if (H5D_alloc_storage(dataset->ent.file, dxpl_id, dataset,H5D_ALLOC_OPEN, TRUE, FALSE)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize file storage"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize file storage") } /* Get the dataset's DCPL cache info */ @@ -2532,17 +2556,23 @@ done: HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to release fill-value info") if (ret_value==NULL && dataset) { - if (H5F_addr_defined(dataset->ent.header)) - H5O_close(&(dataset->ent)); - if (dataset->space) - H5S_close(dataset->space); - if (dataset->type) - H5T_close(dataset->type); + if (H5F_addr_defined(dataset->ent.header)) { + if(H5O_close(&(dataset->ent))<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header") + } /* end if */ + if (dataset->space) { + if(H5S_close(dataset->space)<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") + } /* end if */ + if (dataset->type) { + if(H5T_close(dataset->type)<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") + } /* end if */ dataset->ent.file = NULL; H5FL_FREE(H5D_t,dataset); - } - FUNC_LEAVE_NOAPI(ret_value); -} + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_open_oid() */ /*------------------------------------------------------------------------- @@ -2573,7 +2603,7 @@ H5D_close(H5D_t *dataset) unsigned free_failed; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5D_close, FAIL); + FUNC_ENTER_NOAPI(H5D_close, FAIL) /* check args */ assert(dataset && dataset->ent.file); @@ -2594,11 +2624,12 @@ H5D_close(H5D_t *dataset) /* Remove the dataset from the list of opened objects in the file */ if(H5FO_delete(dataset->ent.file, H5AC_dxpl_id, dataset->ent.header)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects") /* Close the dataset object */ /* (This closes the file, if this is the last object open) */ - H5O_close(&(dataset->ent)); + if(H5O_close(&(dataset->ent))<0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header"); /* * Free memory. Before freeing the memory set the file pointer to NULL. @@ -2613,10 +2644,10 @@ H5D_close(H5D_t *dataset) H5FL_FREE(H5D_t,dataset); if (free_failed) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't free the type or creation property list, but the dataset was freed anyway."); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't free the type or creation property list, but the dataset was freed anyway.") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -2646,7 +2677,7 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) H5S_t *space = NULL; /* Dataset's dataspace */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5D_extend, FAIL); + FUNC_ENTER_NOAPI(H5D_extend, FAIL) /* Check args */ assert (dataset); @@ -2661,21 +2692,26 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id) /* Increase the size of the data space */ space=dataset->space; if ((changed=H5S_extend (space, size))<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to increase size of data space"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to increase size of data space") if (changed>0){ /* Save the new dataspace in the file if necessary */ if (H5S_modify (&(dataset->ent), space, TRUE, dxpl_id)<0) - HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace"); + HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace") + + /* Update the index values for the cached chunks for this dataset */ + if(H5D_CHUNKED == dataset->layout.type) + if(H5F_istore_update_cache(dataset->ent.file, dxpl_id, &dataset->layout, space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update cached chunk indices") /* Allocate space for the new parts of the dataset, if appropriate */ if(dataset->alloc_time==H5D_ALLOC_TIME_EARLY) if (H5D_alloc_storage(dataset->ent.file, dxpl_id, dataset, H5D_ALLOC_EXTEND, TRUE, FALSE)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -2699,9 +2735,9 @@ H5G_entry_t * H5D_entof (H5D_t *dataset) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_entof); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_entof) - FUNC_LEAVE_NOAPI( dataset ? &(dataset->ent) : NULL); + FUNC_LEAVE_NOAPI( dataset ? &(dataset->ent) : (H5G_entry_t *)NULL) } @@ -2723,15 +2759,15 @@ H5D_entof (H5D_t *dataset) *------------------------------------------------------------------------- */ H5T_t * -H5D_typeof (H5D_t *dset) +H5D_typeof (const H5D_t *dset) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_typeof); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_typeof) assert (dset); assert (dset->type); - FUNC_LEAVE_NOAPI(dset->type); + FUNC_LEAVE_NOAPI(dset->type) } @@ -2755,12 +2791,12 @@ static H5F_t * H5D_get_file (const H5D_t *dset) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_get_file); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_get_file) assert (dset); assert (dset->ent.file); - FUNC_LEAVE_NOAPI(dset->ent.file); + FUNC_LEAVE_NOAPI(dset->ent.file) } @@ -2791,7 +2827,7 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo unsigned addr_set=0; /* Flag to indicate that the dataset's storage address was set */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_alloc_storage); + FUNC_ENTER_NOAPI_NOINIT(H5D_alloc_storage) /* check args */ assert (f); @@ -2810,7 +2846,7 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo if(layout->u.contig.addr==HADDR_UNDEF) { /* Reserve space in the file for the entire array */ if (H5F_contig_create (f, dxpl_id, layout/*out*/)<0) - HGOTO_ERROR (H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize contiguous storage"); + HGOTO_ERROR (H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize contiguous storage") /* Indicate that we set the storage addr */ addr_set=1; @@ -2824,7 +2860,7 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo if(layout->u.chunk.addr==HADDR_UNDEF) { /* Create the root of the B-tree that describes chunked storage */ if (H5F_istore_create (f, dxpl_id, layout/*out*/)<0) - HGOTO_ERROR (H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize chunked storage"); + HGOTO_ERROR (H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize chunked storage") /* Indicate that we set the storage addr */ addr_set=1; @@ -2861,7 +2897,9 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo default: assert ("not implemented yet" && 0); - HGOTO_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout"); +#ifdef NDEBUG + HGOTO_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "unsupported storage layout") +#endif /* NDEBUG */ } /* end switch */ /* Check if we need to initialize the space */ @@ -2878,7 +2916,7 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo */ if(!(dset->alloc_time==H5D_ALLOC_TIME_INCR && time_alloc==H5D_ALLOC_WRITE)) { if(H5D_init_storage(dset, full_overwrite, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") } /* end if */ } /* end if */ else { @@ -2886,14 +2924,14 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo /* Check the dataset's fill-value status */ if (H5P_is_fill_value_defined(&(dset->fill), &fill_status) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* If we are filling the dataset on allocation or "if set" and * the fill value _is_ set, do that now */ if(dset->fill_time==H5D_FILL_TIME_ALLOC || (dset->fill_time==H5D_FILL_TIME_IFSET && fill_status==H5D_FILL_VALUE_USER_DEFINED)) { if(H5D_init_storage(dset, full_overwrite, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") } /* end if */ } /* end else */ } /* end if */ @@ -2903,11 +2941,11 @@ H5D_alloc_storage (H5F_t *f, hid_t dxpl_id, H5D_t *dset/*in,out*/, H5D_time_allo */ if(time_alloc!=H5D_ALLOC_CREATE && addr_set) if (H5O_modify (&(dset->ent), H5O_LAYOUT_ID, 0, H5O_FLAG_CONSTANT, update_time, &(dset->layout), dxpl_id) < 0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout message"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update layout message") } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_alloc_storage() */ @@ -2940,7 +2978,7 @@ H5D_init_storage(H5D_t *dset, hbool_t full_overwrite, hid_t dxpl_id) H5S_t *space; /* Dataset's dataspace */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_init_storage); + FUNC_ENTER_NOAPI_NOINIT(H5D_init_storage) assert(dset); @@ -2971,7 +3009,7 @@ H5D_init_storage(H5D_t *dset, hbool_t full_overwrite, hid_t dxpl_id) if((dset->efl.nused==0 || dset->fill.buf) && !full_overwrite) { if (H5F_contig_fill(dset->ent.file, dxpl_id, &(dset->layout), space, &dset->fill, H5T_get_size(dset->type))<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to allocate all chunks of dataset"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to allocate all chunks of dataset") } /* end if */ break; @@ -2987,7 +3025,7 @@ H5D_init_storage(H5D_t *dset, hbool_t full_overwrite, hid_t dxpl_id) /* Get dataset's creation property list */ if (NULL == (plist = H5I_object(dset->dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* We only handle simple data spaces so far */ if ((ndims=H5S_get_simple_extent_dims(space, dim, NULL))<0) @@ -2995,7 +3033,7 @@ H5D_init_storage(H5D_t *dset, hbool_t full_overwrite, hid_t dxpl_id) dim[ndims] = dset->layout.u.chunk.dim[ndims]; if (H5F_istore_allocate(dset->ent.file, dxpl_id, &(dset->layout), dim, plist, full_overwrite)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to allocate all chunks of dataset"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to allocate all chunks of dataset") } /* end if */ break; @@ -3007,7 +3045,7 @@ H5D_init_storage(H5D_t *dset, hbool_t full_overwrite, hid_t dxpl_id) } /* end switch */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -3037,18 +3075,18 @@ H5Dget_storage_size(hid_t dset_id) H5D_t *dset=NULL; hsize_t ret_value; /* Return value */ - FUNC_ENTER_API(H5Dget_storage_size, 0); + FUNC_ENTER_API(H5Dget_storage_size, 0) H5TRACE1("h","i",dset_id); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset") /* Set return value */ ret_value = H5D_get_storage_size(dset,H5AC_ind_dxpl_id); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -3070,19 +3108,18 @@ done: *------------------------------------------------------------------------- */ static hsize_t -H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id) +H5D_get_storage_size(const H5D_t *dset, hid_t dxpl_id) { hsize_t ret_value; - FUNC_ENTER_NOAPI(H5D_get_storage_size, 0); + FUNC_ENTER_NOAPI(H5D_get_storage_size, 0) switch(dset->layout.type) { case H5D_CHUNKED: if(dset->layout.u.chunk.addr == HADDR_UNDEF) ret_value=0; else - ret_value = H5F_istore_allocated(dset->ent.file, dxpl_id, dset->layout.u.chunk.ndims, - dset->layout.u.chunk.addr); + ret_value = H5F_istore_allocated(dset->ent.file, dxpl_id, &dset->layout); break; case H5D_CONTIGUOUS: @@ -3098,11 +3135,11 @@ H5D_get_storage_size(H5D_t *dset, hid_t dxpl_id) break; default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset type") } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -3128,18 +3165,18 @@ H5Dget_offset(hid_t dset_id) H5D_t *dset=NULL; haddr_t ret_value; /* Return value */ - FUNC_ENTER_API(H5Dget_offset, HADDR_UNDEF); + FUNC_ENTER_API(H5Dget_offset, HADDR_UNDEF) H5TRACE1("a","i",dset_id); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a dataset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a dataset") /* Set return value */ ret_value = H5D_get_offset(dset); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -3161,13 +3198,13 @@ done: *------------------------------------------------------------------------- */ static haddr_t -H5D_get_offset(H5D_t *dset) +H5D_get_offset(const H5D_t *dset) { haddr_t ret_value=HADDR_UNDEF; haddr_t base_addr; H5F_t *f; - FUNC_ENTER_NOAPI(H5D_get_offset, HADDR_UNDEF); + FUNC_ENTER_NOAPI(H5D_get_offset, HADDR_UNDEF) assert(dset); @@ -3198,7 +3235,7 @@ H5D_get_offset(H5D_t *dset) } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -3270,23 +3307,23 @@ H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op, H5S_t *space = NULL; herr_t ret_value; - FUNC_ENTER_API(H5Diterate, FAIL); + FUNC_ENTER_API(H5Diterate, FAIL) H5TRACE5("e","xiixx",buf,type_id,space_id,op,operator_data); /* Check args */ if (NULL==op) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid operator"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid operator") if (buf==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") if (H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype") if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") ret_value=H5S_select_iterate(buf,type_id,space,op,operator_data); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Diterate() */ @@ -3312,27 +3349,27 @@ H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf) { herr_t ret_value; - FUNC_ENTER_API(H5Dvlen_reclaim, FAIL); + FUNC_ENTER_API(H5Dvlen_reclaim, FAIL) H5TRACE4("e","iiix",type_id,space_id,plist_id,buf); /* Check args */ if (H5I_DATATYPE!=H5I_get_type(type_id) || H5I_DATASPACE!=H5I_get_type(space_id) || buf==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == plist_id) plist_id= H5P_DATASET_XFER_DEFAULT; else if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") /* Call H5Diterate with args, etc. */ ret_value=H5Diterate(buf,type_id,space_id,H5T_vlen_reclaim,&plist_id); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Dvlen_reclaim() */ @@ -3359,7 +3396,7 @@ H5D_vlen_get_buf_size_alloc(size_t size, void *info) H5D_vlen_bufsize_t *vlen_bufsize=(H5D_vlen_bufsize_t *)info; void *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5D_vlen_get_buf_size_alloc, NULL); + FUNC_ENTER_NOAPI(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) @@ -3369,7 +3406,7 @@ H5D_vlen_get_buf_size_alloc(size_t size, void *info) ret_value=vlen_bufsize->vl_tbuf; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_vlen_get_buf_size_alloc() */ @@ -3400,6 +3437,7 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t H5D_vlen_get_buf_size(void UNUSED *elem, hid_t type_id, hsize_t UNUSED ndim, hssize_t *point, void *op_data) { @@ -3407,29 +3445,29 @@ H5D_vlen_get_buf_size(void UNUSED *elem, hid_t type_id, hsize_t UNUSED ndim, hss H5T_t *dt = NULL; herr_t ret_value=0; /* The correct return value, if this function succeeds */ - FUNC_ENTER_NOAPI(H5D_vlen_get_buf_size, FAIL); + FUNC_ENTER_NOAPI(H5D_vlen_get_buf_size, FAIL) assert(op_data); assert(H5I_DATATYPE == H5I_get_type(type_id)); /* Check args */ if (NULL==(dt=H5I_object(type_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); + 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) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't resize tbuf"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't resize tbuf") /* Select point to read in */ if (H5Sselect_elements(vlen_bufsize->fspace_id,H5S_SELECT_SET,1,(const hssize_t **)point)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't select point"); + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't select point") /* Read in the point (with the custom VL memory allocator) */ if(H5Dread(vlen_bufsize->dataset_id,type_id,vlen_bufsize->mspace_id,vlen_bufsize->fspace_id,vlen_bufsize->xfer_pid,vlen_bufsize->fl_tbuf)<0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point"); + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_vlen_get_buf_size() */ @@ -3469,47 +3507,47 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, H5P_genplist_t *plist; /* Property list */ herr_t ret_value=FAIL; - FUNC_ENTER_API(H5Dvlen_get_buf_size, FAIL); + FUNC_ENTER_API(H5Dvlen_get_buf_size, FAIL) H5TRACE4("e","iii*h",dataset_id,type_id,space_id,size); /* Check args */ if (H5I_DATASET!=H5I_get_type(dataset_id) || H5I_DATATYPE!=H5I_get_type(type_id) || H5I_DATASPACE!=H5I_get_type(space_id) || size==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") /* Save the dataset ID */ vlen_bufsize.dataset_id=dataset_id; /* Get a copy of the dataspace ID */ if((vlen_bufsize.fspace_id=H5Dget_space(dataset_id))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy dataspace"); + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy dataspace") /* Create a scalar for the memory dataspace */ if((vlen_bufsize.mspace_id=H5Screate(H5S_SCALAR))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't create dataspace"); + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't create dataspace") /* Grab the temporary buffers required */ if((vlen_bufsize.fl_tbuf=H5FL_BLK_MALLOC(vlen_fl_buf,1))==NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available") if((vlen_bufsize.vl_tbuf=H5FL_BLK_MALLOC(vlen_vl_buf,1))==NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "no temporary buffers available") /* Get the pointer to the dataset transfer class */ if (NULL == (pclass = H5I_object(H5P_CLS_DATASET_XFER_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Change to the custom memory allocation routines for reading VL data */ if((vlen_bufsize.xfer_pid=H5P_create_id(pclass))<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "no dataset xfer plists available"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "no dataset xfer plists available") /* Get the property list struct */ if (NULL == (plist = H5I_object(vlen_bufsize.xfer_pid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Set the memory manager to the special allocation routine */ if(H5P_set_vlen_mem_manager(plist,H5D_vlen_get_buf_size_alloc,&vlen_bufsize,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set VL data allocation routine"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set VL data allocation routine") /* Set the initial number of bytes required */ vlen_bufsize.size=0; @@ -3522,18 +3560,24 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, *size=vlen_bufsize.size; done: - if(vlen_bufsize.fspace_id>0) - H5Sclose(vlen_bufsize.fspace_id); - if(vlen_bufsize.mspace_id>0) - H5Sclose(vlen_bufsize.mspace_id); + if(vlen_bufsize.fspace_id>0) { + if(H5I_dec_ref(vlen_bufsize.fspace_id)<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + } /* end if */ + if(vlen_bufsize.mspace_id>0) { + if(H5I_dec_ref(vlen_bufsize.mspace_id)<0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + } /* end if */ if(vlen_bufsize.fl_tbuf!=NULL) H5FL_BLK_FREE(vlen_fl_buf,vlen_bufsize.fl_tbuf); if(vlen_bufsize.vl_tbuf!=NULL) H5FL_BLK_FREE(vlen_vl_buf,vlen_bufsize.vl_tbuf); - if(vlen_bufsize.xfer_pid>0) - H5I_dec_ref(vlen_bufsize.xfer_pid); + if(vlen_bufsize.xfer_pid>0) { + if(H5I_dec_ref(vlen_bufsize.xfer_pid)<0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref count on property list") + } /* end if */ - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Dvlen_get_buf_size() */ @@ -3562,21 +3606,21 @@ H5Dset_extent(hid_t dset_id, const hsize_t *size) H5D_t *dset = NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Dset_extent, FAIL); + FUNC_ENTER_API(H5Dset_extent, FAIL) H5TRACE2("e","i*h",dset_id,size); /* Check args */ if(NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(!size) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") /* Private function */ if(H5D_set_extent(dset, size, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extend dataset"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extend dataset") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -3611,7 +3655,7 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) unsigned expand = 0; /* Flag to indicate a dimension has grown */ int changed = 0; - FUNC_ENTER_NOAPI(H5D_set_extent, FAIL); + FUNC_ENTER_NOAPI(H5D_set_extent, FAIL) /* Check args */ assert(dset); @@ -3628,7 +3672,7 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) *------------------------------------------------------------------------- */ if((rank = H5S_get_simple_extent_dims(space, curr_dims, NULL)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") for(u = 0; u < rank; u++) { if(size[u] < curr_dims[u]) @@ -3642,7 +3686,7 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) *------------------------------------------------------------------------- */ if((changed=H5S_set_extent(space, size)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of data space"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of data space") /* Don't bother updating things, unless they've changed */ if(changed) { @@ -3652,12 +3696,17 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) */ /* Save the new dataspace in the file if necessary */ if(H5S_modify(&(dset->ent), space, TRUE, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace"); + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace") + + /* Update the index values for the cached chunks for this dataset */ + if(H5D_CHUNKED == dset->layout.type) + if(H5F_istore_update_cache(dset->ent.file, dxpl_id, &dset->layout, space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update cached chunk indices") /* Allocate space for the new parts of the dataset, if appropriate */ if(expand && dset->alloc_time==H5D_ALLOC_TIME_EARLY) if(H5D_alloc_storage(dset->ent.file, dxpl_id, dset, H5D_ALLOC_EXTEND, TRUE, FALSE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset storage"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset storage") /*------------------------------------------------------------------------- @@ -3671,7 +3720,7 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) /* Get the dataset creation property list */ if(NULL == (plist = H5I_object(dset->dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dset creation property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dset creation property list") /* Fill the DXPL cache values for later use */ if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) @@ -3679,16 +3728,16 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) /* Remove excess chunks */ if(H5F_istore_prune_by_extent(dset->ent.file, &dxpl_cache, dxpl_id, &dset->layout, space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to remove chunks "); + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to remove chunks ") /* Reset the elements outsize the new dimensions, but in existing chunks */ if(H5F_istore_initialize_by_extent(dset->ent.file, &dxpl_cache, dxpl_id, &dset->layout, plist, space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to initialize chunks "); + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to initialize chunks ") } /* end if */ } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -3712,7 +3761,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_flush(H5F_t *f, hid_t dxpl_id) +H5D_flush(const H5F_t *f, hid_t dxpl_id) { int num_dsets; /* Number of datasets in file */ hid_t *id_list=NULL; /* list of dataset IDs */ @@ -3720,21 +3769,22 @@ H5D_flush(H5F_t *f, hid_t dxpl_id) herr_t ret_value = SUCCEED; /* Return value */ int j; /* Index variable */ - FUNC_ENTER_NOAPI(H5D_flush, FAIL); + FUNC_ENTER_NOAPI(H5D_flush, FAIL) /* Check args */ assert(f); /* Update layout message for compact dataset */ if((num_dsets=H5F_get_obj_count(f, H5F_OBJ_DATASET))<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to get dataset count"); + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to get dataset count") - /* check for something to do */ + /* Check for something to do */ if(num_dsets>0) { - if(NULL==(id_list=H5MM_malloc(num_dsets*sizeof(hid_t)))) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to allocate memory for ID list"); + H5_CHECK_OVERFLOW(num_dsets,int,size_t); + if(NULL==(id_list=H5MM_malloc((size_t)num_dsets*sizeof(hid_t)))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to allocate memory for ID list") if(H5F_get_obj_ids(f, H5F_OBJ_DATASET, -1, id_list)<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to get dataset ID list"); + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to get dataset ID list") for(j=0; j<num_dsets; j++) { if(NULL==(dataset=H5I_object_verify(id_list[j], H5I_DATASET))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to get dataset object") @@ -3749,7 +3799,7 @@ H5D_flush(H5F_t *f, hid_t dxpl_id) done: if(id_list!=NULL) H5MM_xfree(id_list); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_flush() */ @@ -3776,12 +3826,12 @@ H5Ddebug(hid_t dset_id, unsigned UNUSED flags) H5D_t *dset=NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Ddebug, FAIL); - H5TRACE2("e","iIu",dset_id,flags); + FUNC_ENTER_API(H5Ddebug, FAIL) + H5TRACE1("e","i",dset_id); /* Check args */ if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Print B-tree information */ if (H5D_CHUNKED==dset->layout.type) { @@ -3791,5 +3841,5 @@ H5Ddebug(hid_t dset_id, unsigned UNUSED flags) } done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } diff --git a/src/H5Dio.c b/src/H5Dio.c index d8a8f3c..7347d8f 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -65,7 +65,7 @@ typedef struct fm_map { unsigned m_ndims; /* Number of dimensions for memory dataspace */ hsize_t chunks[H5O_LAYOUT_NDIMS]; /* Number of chunks in each dimension */ hsize_t chunk_dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in each dimension */ - hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each dimension */ + hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each dimension */ H5O_layout_t *layout; /* Dataset layout information*/ H5S_sel_type msel_type; /* Selection type in memory */ } fm_map; @@ -110,7 +110,7 @@ H5D_io_restore_mpio(hid_t dxpl_id); #endif /*H5_HAVE_PARALLEL*/ static herr_t H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_space, const H5S_t *mem_space, fm_map *fm); -static herr_t H5D_destroy_chunk_map(fm_map *fm); +static herr_t H5D_destroy_chunk_map(const fm_map *fm); static void H5D_free_chunk_info(void *chunk_info); static herr_t H5D_create_chunk_file_map_hyper(fm_map *fm); static herr_t H5D_create_chunk_mem_map_hyper(const fm_map *fm); @@ -163,25 +163,25 @@ H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_ H5T_t *buf_type; /* Buffer datatype */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Dfill, FAIL); + FUNC_ENTER_API(H5Dfill, FAIL) H5TRACE5("e","xixii",fill,fill_type_id,buf,buf_type_id,space_id); /* Check args */ if (buf==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") if (NULL == (space=H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataspace"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataspace") if (NULL == (fill_type=H5I_object_verify(fill_type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") if (NULL == (buf_type=H5I_object_verify(buf_type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") /* Fill the selection in the memory buffer */ if(H5D_fill(fill,fill_type,buf,buf_type,space, H5AC_dxpl_id)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* H5Dfill() */ @@ -221,7 +221,7 @@ H5D_fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_t size_t buf_size; /* Desired buffer size */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_fill); + FUNC_ENTER_NOAPI_NOINIT(H5D_fill) /* Check args */ assert(fill_type); @@ -236,7 +236,7 @@ H5D_fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_t /* Get the maximum buffer size needed and allocate it */ buf_size=MAX(src_type_size,dst_type_size); if (NULL==(tconv_buf = H5FL_BLK_MALLOC(type_elem,buf_size)) || NULL==(bkg_buf = H5FL_BLK_CALLOC(type_elem,buf_size))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Check for actual fill value to replicate */ if(fill==NULL) @@ -248,30 +248,30 @@ H5D_fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_t /* Set up type conversion function */ if (NULL == (tpath = H5T_path_find(fill_type, buf_type, NULL, NULL, dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types"); + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types") /* Convert memory buffer into disk buffer */ if (!H5T_path_noop(tpath)) { if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill_type, H5T_COPY_ALL)))<0 || (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(buf_type, H5T_COPY_ALL)))<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") /* Perform data type conversion */ if (H5T_convert(tpath, src_id, dst_id, (hsize_t)1, 0, 0, tconv_buf, bkg_buf, dxpl_id)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") } /* end if */ } /* end if */ /* Fill the selection in the memory buffer */ if(H5S_select_fill(tconv_buf, dst_type_size, space, buf)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") done: if (tconv_buf) H5FL_BLK_FREE(type_elem,tconv_buf); if (bkg_buf) H5FL_BLK_FREE(type_elem,bkg_buf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5D_fill() */ @@ -447,32 +447,32 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, const H5S_t *file_space = NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Dread, FAIL); + FUNC_ENTER_API(H5Dread, FAIL) H5TRACE6("e","iiiiix",dset_id,mem_type_id,mem_space_id,file_space_id, plist_id,buf); /* check arguments */ if (NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (NULL == dset->ent.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (H5S_ALL != mem_space_id) { if (NULL == (mem_space = H5I_object_verify(mem_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Check for valid selection */ if(H5S_SELECT_VALID(mem_space)!=TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent"); + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") } if (H5S_ALL != file_space_id) { if (NULL == (file_space = H5I_object_verify(file_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Check for valid selection */ if(H5S_SELECT_VALID(file_space)!=TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent"); + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") } /* Get the default dataset transfer property list if the user didn't provide one */ @@ -480,16 +480,16 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, plist_id= H5P_DATASET_XFER_DEFAULT; else if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") if (!buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") /* read raw data */ if (H5D_read(dset, mem_type, mem_space, file_space, plist_id, buf/*out*/) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data"); + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -538,32 +538,32 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, const H5S_t *file_space = NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Dwrite, FAIL); + FUNC_ENTER_API(H5Dwrite, FAIL) H5TRACE6("e","iiiiix",dset_id,mem_type_id,mem_space_id,file_space_id, plist_id,buf); /* check arguments */ if (NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (NULL == dset->ent.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type") if (H5S_ALL != mem_space_id) { if (NULL == (mem_space = H5I_object_verify(mem_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Check for valid selection */ if (H5S_SELECT_VALID(mem_space)!=TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent"); + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") } if (H5S_ALL != file_space_id) { if (NULL == (file_space = H5I_object_verify(file_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Check for valid selection */ if (H5S_SELECT_VALID(file_space)!=TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent"); + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") } /* Get the default dataset transfer property list if the user didn't provide one */ @@ -571,16 +571,16 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, plist_id= H5P_DATASET_XFER_DEFAULT; else if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") if (!buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") /* write raw data */ if (H5D_write(dset, mem_type, mem_space, file_space, plist_id, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data"); + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -648,7 +648,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, unsigned sconv_flags=0; /* Flags for the space conversion */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_read); + FUNC_ENTER_NOAPI_NOINIT(H5D_read) /* check args */ assert(dataset && dataset->ent.file); @@ -660,7 +660,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, if (!mem_space) mem_space = file_space; if((snelmts = H5S_GET_SELECT_NPOINTS(mem_space))<0) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,hsize_t); /* Fill the DXPL cache values for later use */ @@ -680,7 +680,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, /* Make certain that the number of elements in each selection is the same */ if (nelmts!=(hsize_t)H5S_GET_SELECT_NPOINTS(file_space)) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes") /* Retrieve dataset properties */ /* <none needed in the general case> */ @@ -698,22 +698,22 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, /* Retrieve dataset's fill-value properties */ if(H5P_is_fill_value_defined(&dataset->dcpl_cache.fill, &fill_status)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't tell if fill value defined") /* Should be impossible, but check anyway... */ if(fill_status == H5D_FILL_VALUE_UNDEFINED && (dataset->dcpl_cache.fill_time == H5D_FILL_TIME_ALLOC || dataset->dcpl_cache.fill_time == H5D_FILL_TIME_IFSET)) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "read failed: dataset doesn't exist, no data can be read"); + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "read failed: dataset doesn't exist, no data can be read") /* If we're never going to fill this dataset, just leave the junk in the user's buffer */ if(dataset->dcpl_cache.fill_time == H5D_FILL_TIME_NEVER) - HGOTO_DONE(SUCCEED); + HGOTO_DONE(SUCCEED) /* Go fill the user's selection with the dataset's fill value */ - if(H5D_fill(dataset->dcpl_cache.fill.buf,dataset->type,buf,mem_type,mem_space,dxpl_id)<0) { - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "filling buf failed"); - } else - HGOTO_DONE(SUCCEED); + if(H5D_fill(dataset->dcpl_cache.fill.buf,dataset->type,buf,mem_type,mem_space,dxpl_id)<0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "filling buf failed") + else + HGOTO_DONE(SUCCEED) } /* end if */ /* @@ -725,11 +725,11 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, * turns off background preservation. */ if (NULL==(tpath=H5T_path_find(dataset->type, mem_type, NULL, NULL, dxpl_id))) { - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types"); + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types") } else if (!H5T_path_noop(tpath)) { if ((src_id=H5I_register(H5I_DATATYPE, H5T_copy(dataset->type, H5T_COPY_ALL)))<0 || (dst_id=H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL)))<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") } /* end if */ /* Set the storage flags for the space conversion check */ @@ -752,7 +752,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, /* Get dataspace functions */ if (NULL==(sconv=H5S_find(mem_space, file_space, sconv_flags, &use_par_opt_io))) - HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert from file to memory data space"); + HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert from file to memory data space") #ifdef H5_HAVE_PARALLEL /* Don't reset the transfer mode if we can't or won't use it */ @@ -764,12 +764,12 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, if(dataset->layout.type!=H5D_CHUNKED) { if(H5D_contig_read(nelmts, dataset, mem_type, mem_space, file_space, tpath, sconv, &dxpl_cache, dxpl_id, src_id, dst_id, buf)<0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data"); + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") } /* end if */ else { if(H5D_chunk_read(nelmts, dataset, mem_type, mem_space, file_space, tpath, sconv, &dxpl_cache, dxpl_id, src_id, dst_id, buf)<0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data"); + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") } /* end else */ done: @@ -787,7 +787,7 @@ done: HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") } /* end if */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_read() */ @@ -852,7 +852,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, unsigned sconv_flags=0; /* Flags for the space conversion */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_write); + FUNC_ENTER_NOAPI_NOINIT(H5D_write) /* check args */ assert(dataset && dataset->ent.file); @@ -873,11 +873,11 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, if (IS_H5FD_MPI(dataset->ent.file) && H5T_get_class(mem_type)==H5T_REFERENCE && H5T_get_ref_type(mem_type)==H5R_DATASET_REGION) - HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Parallel IO does not support writing region reference datatypes yet"); + HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "Parallel IO does not support writing region reference datatypes yet") /* Check if we are allowed to write to this file */ if (0==(H5F_get_intent(dataset->ent.file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "no write intent on file"); + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "no write intent on file") /* Fill the DXPL cache values for later use */ if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) @@ -888,7 +888,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, if (!mem_space) mem_space = file_space; if((snelmts = H5S_GET_SELECT_NPOINTS(mem_space))<0) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection") H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,hsize_t); #ifdef H5_HAVE_PARALLEL @@ -904,7 +904,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, /* Make certain that the number of elements in each selection is the same */ if (nelmts!=(hsize_t)H5S_GET_SELECT_NPOINTS(file_space)) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes") /* Retrieve dataset properties */ /* <none needed currently> */ @@ -928,7 +928,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, /* Allocate storage */ if(H5D_alloc_storage(dataset->ent.file,dxpl_id,dataset,H5D_ALLOC_WRITE, TRUE, full_overwrite)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage") } /* end if */ /* @@ -940,11 +940,11 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, * turns off background preservation. */ if (NULL==(tpath=H5T_path_find(mem_type, dataset->type, NULL, NULL, dxpl_id))) { - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types"); + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types") } else if (!H5T_path_noop(tpath)) { if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL)))<0 || (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(dataset->type, H5T_COPY_ALL)))<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") } /* end if */ /* Set the storage flags for the space conversion check */ @@ -967,7 +967,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, /* Get dataspace functions */ if (NULL==(sconv=H5S_find(mem_space, file_space, sconv_flags, &use_par_opt_io))) - HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert from memory to file data space"); + HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert from memory to file data space") #ifdef H5_HAVE_PARALLEL /* Don't reset the transfer mode if we can't or won't use it */ @@ -979,12 +979,12 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, if(dataset->layout.type!=H5D_CHUNKED) { if(H5D_contig_write(nelmts, dataset, mem_type, mem_space, file_space, tpath, sconv, &dxpl_cache, dxpl_id, src_id, dst_id, buf)<0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data"); + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") } /* end if */ else { if(H5D_chunk_write(nelmts, dataset, mem_type, mem_space, file_space, tpath, sconv, &dxpl_cache, dxpl_id, src_id, dst_id, buf)<0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data"); + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") } /* end else */ #ifdef OLD_WAY @@ -999,7 +999,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, * writing to a dataset doesn't necessarily change the object header. */ if (H5O_touch(&(dataset->ent), FALSE, dxpl_id)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update modification time") #endif /* OLD_WAY */ done: @@ -1017,7 +1017,7 @@ done: HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") } /* end if */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_write() */ @@ -1037,6 +1037,7 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t H5D_contig_read(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, H5T_path_t *tpath, @@ -1065,8 +1066,8 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, hsize_t n, smine_nelmts; /*elements per strip */ herr_t ret_value = SUCCEED; /*return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_contig_read); - + FUNC_ENTER_NOAPI_NOINIT(H5D_contig_read) + /* * If there is no type conversion then read directly into the * application's buffer. This saves at least one mem-to-mem copy. @@ -1092,12 +1093,12 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, /* Check return value from optimized read */ if (status<0) { - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "optimized read failed"); + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "optimized read failed") } else - /* direct xfer accomplished successfully */ - HGOTO_DONE(SUCCEED); + /* direct xfer accomplished successfully */ + HGOTO_DONE(SUCCEED) } /* end if */ - + /* * This is the general case(type conversion). */ @@ -1117,17 +1118,17 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, /* Sanity check elements in temporary buffer */ if (request_nelmts==0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") /* Figure out the strip mine size. */ if (H5S_select_iter_init(&file_iter, file_space, src_type_size)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") file_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&mem_iter, mem_space, dst_type_size)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&bkg_iter, mem_space, dst_type_size)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") bkg_iter_init=1; /*file selection iteration info has been initialized */ /* @@ -1150,13 +1151,13 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, if (NULL==(tconv_buf=dxpl_cache->tconv_buf)) { /* Allocate temporary buffer */ if((tconv_buf=H5FL_BLK_MALLOC(type_conv,target_size))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") } /* end if */ if (need_bkg && NULL==(bkg_buf=dxpl_cache->bkgr_buf)) { /* Allocate background buffer */ H5_CHECK_OVERFLOW((request_nelmts*dst_type_size),hsize_t,size_t); if((bkg_buf=H5FL_BLK_CALLOC(type_conv,(size_t)(request_nelmts*dst_type_size)))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion") } /* end if */ /* Start strip mining... */ @@ -1188,7 +1189,7 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, sconv->stats[1].gath_ncalls++; #endif if (n!=smine_nelmts) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed"); + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") if (H5T_BKG_YES==need_bkg) { #ifdef H5S_DEBUG @@ -1202,14 +1203,14 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, sconv->stats[1].bkg_ncalls++; #endif if (n!=smine_nelmts) - HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "mem gather failed"); + HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "mem gather failed") } /* end if */ - /* + /* * Perform data type conversion. */ 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"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data type conversion failed") /* * Scatter the data into memory. @@ -1225,7 +1226,7 @@ H5D_contig_read(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, sconv->stats[1].scat_ncalls++; #endif if (status<0) - HGOTO_ERROR (H5E_DATASET, H5E_READERROR, FAIL, "scatter failed"); + HGOTO_ERROR (H5E_DATASET, H5E_READERROR, FAIL, "scatter failed") } /* end for */ @@ -1249,7 +1250,7 @@ done: if (bkg_buf && NULL==dxpl_cache->bkgr_buf) H5FL_BLK_FREE(type_conv,bkg_buf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_contig_read() */ @@ -1269,6 +1270,7 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t H5D_contig_write(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, const H5S_t *file_space, H5T_path_t *tpath, H5S_conv_t *sconv, @@ -1296,8 +1298,8 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5 hsize_t n, smine_nelmts; /*elements per strip */ herr_t ret_value = SUCCEED; /*return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_contig_write); - + FUNC_ENTER_NOAPI_NOINIT(H5D_contig_write) + /* * If there is no type conversion then write directly from the * application's buffer. This saves at least one mem-to-mem copy. @@ -1311,17 +1313,17 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5 &dataset->dcpl_cache, (H5D_storage_t *)&(dataset->efl), (size_t)nelmts, H5T_get_size(dataset->type), file_space, mem_space, dxpl_cache, dxpl_id, buf); #ifdef H5S_DEBUG - H5_timer_end(&(sconv->stats[0].write_timer), &timer); - sconv->stats[0].write_nbytes += nelmts * H5T_get_size(mem_type); - sconv->stats[0].write_ncalls++; + H5_timer_end(&(sconv->stats[0].write_timer), &timer); + sconv->stats[0].write_nbytes += nelmts * H5T_get_size(mem_type); + sconv->stats[0].write_ncalls++; #endif /* Check return value from optimized write */ if (status<0) { - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "optimized write failed"); + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "optimized write failed") } else /* direct xfer accomplished successfully */ - HGOTO_DONE(SUCCEED); + HGOTO_DONE(SUCCEED) } /* end if */ /* @@ -1343,17 +1345,17 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5 /* Sanity check elements in temporary buffer */ if (request_nelmts==0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") /* Figure out the strip mine size. */ if (H5S_select_iter_init(&file_iter, file_space, dst_type_size)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") file_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&mem_iter, mem_space, src_type_size)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&bkg_iter, file_space, dst_type_size)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") bkg_iter_init=1; /*file selection iteration info has been initialized */ /* @@ -1380,13 +1382,13 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5 if (NULL==(tconv_buf=dxpl_cache->tconv_buf)) { /* Allocate temporary buffer */ if((tconv_buf=H5FL_BLK_MALLOC(type_conv,target_size))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") } /* end if */ if (need_bkg && NULL==(bkg_buf=dxpl_cache->bkgr_buf)) { /* Allocate background buffer */ H5_CHECK_OVERFLOW((request_nelmts*dst_type_size),hsize_t,size_t); if((bkg_buf=H5FL_BLK_CALLOC(type_conv,(size_t)(request_nelmts*dst_type_size)))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion") } /* end if */ /* Start strip mining... */ @@ -1411,7 +1413,7 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5 sconv->stats[0].gath_ncalls++; #endif if (n!=smine_nelmts) - HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "mem gather failed"); + HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "mem gather failed") if (H5T_BKG_YES==need_bkg) { #ifdef H5S_DEBUG @@ -1427,14 +1429,14 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5 sconv->stats[0].bkg_ncalls++; #endif if (n!=smine_nelmts) - HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "file gather failed"); + HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "file gather failed") } /* end if */ - /* + /* * Perform data type conversion. */ 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"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data type conversion failed") /* * Scatter the data out to the file. @@ -1442,17 +1444,16 @@ H5D_contig_write(hsize_t nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5 #ifdef H5S_DEBUG H5_timer_begin(&timer); #endif - status = H5S_select_fscat(dataset->ent.file, &(dataset->layout), + status = H5S_select_fscat(dataset->ent.file, &(dataset->layout), &dataset->dcpl_cache, (H5D_storage_t *)&(dataset->efl), file_space, &file_iter, smine_nelmts, dxpl_cache, dxpl_id, tconv_buf); - #ifdef H5S_DEBUG H5_timer_end(&(sconv->stats[0].scat_timer), &timer); sconv->stats[0].scat_nbytes += smine_nelmts * dst_type_size; sconv->stats[0].scat_ncalls++; #endif if (status<0) - HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "scatter failed"); + HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "scatter failed") } /* end for */ done: @@ -1475,7 +1476,7 @@ done: if (bkg_buf && NULL==dxpl_cache->bkgr_buf) H5FL_BLK_FREE(type_conv,bkg_buf); - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_contig_write() */ @@ -1495,6 +1496,7 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t H5D_chunk_read(hsize_t #ifdef NDEBUG @@ -1529,11 +1531,11 @@ UNUSED H5D_storage_t store; /*union of EFL and chunk pointer in file space */ herr_t ret_value = SUCCEED; /*return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_read); + FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_read) /* Map elements between file and memory for each chunk*/ if(H5D_create_chunk_map(dataset, mem_type, file_space, mem_space, &fm)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't build chunk mapping"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't build chunk mapping") /* * If there is no type conversion then read directly into the @@ -1559,7 +1561,8 @@ UNUSED chunk_info=chunk_node->data; /* Pass in chunk's coordinates in a union. */ - store.chunk_coords = chunk_info->coords; + store.chunk.offset = chunk_info->coords; + store.chunk.index = chunk_info->index; /* Perform the actual read operation */ status = (sconv->read)(dataset->ent.file, &(dataset->layout), @@ -1568,7 +1571,7 @@ UNUSED /* Check return value from optimized read */ if (status<0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "optimized read failed"); + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "optimized read failed") /* Get the next chunk node in the tree */ chunk_node=H5TB_next(chunk_node); @@ -1581,7 +1584,7 @@ UNUSED #endif /* direct xfer accomplished successfully */ - HGOTO_DONE(SUCCEED); + HGOTO_DONE(SUCCEED) } /* end if */ /* @@ -1603,7 +1606,7 @@ UNUSED /* Sanity check elements in temporary buffer */ if (request_nelmts==0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") /* * Get a temporary buffer for type conversion unless the app has already @@ -1625,13 +1628,13 @@ UNUSED if (NULL==(tconv_buf=dxpl_cache->tconv_buf)) { /* Allocate temporary buffer */ if((tconv_buf=H5FL_BLK_MALLOC(type_conv,target_size))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") } /* end if */ if (need_bkg && NULL==(bkg_buf=dxpl_cache->bkgr_buf)) { /* Allocate background buffer */ H5_CHECK_OVERFLOW((request_nelmts*dst_type_size),hsize_t,size_t); if((bkg_buf=H5FL_BLK_CALLOC(type_conv,(size_t)(request_nelmts*dst_type_size)))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion") } /* end if */ /* Loop over all the chunks, performing I/O on each */ @@ -1648,17 +1651,18 @@ UNUSED /* initialize selection iterator */ if (H5S_select_iter_init(&file_iter, chunk_info->fspace, src_type_size)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") file_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&mem_iter, chunk_info->mspace, dst_type_size)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&bkg_iter, chunk_info->mspace, dst_type_size)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") bkg_iter_init=1; /*file selection iteration info has been initialized */ /* Pass in chunk's coordinates in a union*/ - store.chunk_coords = chunk_info->coords; + store.chunk.offset = chunk_info->coords; + store.chunk.index = chunk_info->index; for (smine_start=0; smine_start<chunk_info->chunk_points; smine_start+=smine_nelmts) { /* Go figure out how many elements to read from the file */ @@ -1687,7 +1691,7 @@ UNUSED sconv->stats[1].gath_ncalls++; #endif if (n!=smine_nelmts) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed"); + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") if (H5T_BKG_YES==need_bkg) { #ifdef H5S_DEBUG @@ -1701,7 +1705,7 @@ UNUSED sconv->stats[1].bkg_ncalls++; #endif if (n!=smine_nelmts) - HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "mem gather failed"); + HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "mem gather failed") } /* end if */ /* @@ -1709,7 +1713,7 @@ UNUSED */ 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"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data type conversion failed") /* * Scatter the data into memory. @@ -1725,7 +1729,7 @@ UNUSED sconv->stats[1].scat_ncalls++; #endif if (status<0) - HGOTO_ERROR (H5E_DATASET, H5E_READERROR, FAIL, "scatter failed"); + HGOTO_ERROR (H5E_DATASET, H5E_READERROR, FAIL, "scatter failed") } /* end for */ /* Release selection iterators */ @@ -1771,9 +1775,9 @@ done: /* Release chunk mapping information */ if(H5D_destroy_chunk_map(&fm) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release chunk mapping"); + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release chunk mapping") - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5D_chunk_read() */ @@ -1793,6 +1797,7 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t H5D_chunk_write(hsize_t #ifdef NDEBUG @@ -1827,7 +1832,7 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, H5D_storage_t store; /*union of EFL and chunk pointer in file space */ herr_t ret_value = SUCCEED; /*return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_write); + FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_write) #ifdef QAK { @@ -1840,7 +1845,7 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, #endif /* QAK */ /* Map elements between file and memory for each chunk*/ if(H5D_create_chunk_map(dataset, mem_type, file_space, mem_space, &fm)<0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't build chunk mapping"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't build chunk mapping") #ifdef QAK { int mpi_rank; @@ -1879,7 +1884,8 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, chunk_info=chunk_node->data; /* Pass in chunk's coordinates in a union. */ - store.chunk_coords = chunk_info->coords; + store.chunk.offset = chunk_info->coords; + store.chunk.index = chunk_info->index; /* Perform the actual write operation */ status = (sconv->write)(dataset->ent.file, &(dataset->layout), @@ -1888,7 +1894,7 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, /* Check return value from optimized write */ if (status<0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "optimized write failed"); + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "optimized write failed") /* Get the next chunk node in the tree */ chunk_node=H5TB_next(chunk_node); @@ -1910,7 +1916,7 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, #endif /* direct xfer accomplished successfully */ - HGOTO_DONE(SUCCEED); + HGOTO_DONE(SUCCEED) } /* end if */ #ifdef QAK { @@ -1939,7 +1945,7 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, /* Sanity check elements in temporary buffer */ if (request_nelmts==0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") /* * Get a temporary buffer for type conversion unless the app has already @@ -1965,13 +1971,13 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, if (NULL==(tconv_buf=dxpl_cache->tconv_buf)) { /* Allocate temporary buffer */ if((tconv_buf=H5FL_BLK_MALLOC(type_conv,target_size))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") } /* end if */ if (need_bkg && NULL==(bkg_buf=dxpl_cache->bkgr_buf)) { /* Allocate background buffer */ H5_CHECK_OVERFLOW((request_nelmts*dst_type_size),hsize_t,size_t); if((bkg_buf=H5FL_BLK_CALLOC(type_conv,(size_t)(request_nelmts*dst_type_size)))==NULL) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion"); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for background conversion") } /* end if */ /* Loop over all the chunks, performing I/O on each */ @@ -1988,17 +1994,18 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, /* initialize selection iterator */ if (H5S_select_iter_init(&file_iter, chunk_info->fspace, dst_type_size)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") file_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&mem_iter, chunk_info->mspace, src_type_size)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init=1; /*file selection iteration info has been initialized */ if (H5S_select_iter_init(&bkg_iter, chunk_info->fspace, dst_type_size)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information") bkg_iter_init=1; /*file selection iteration info has been initialized */ /*pass in chunk's coordinates in a union*/ - store.chunk_coords = chunk_info->coords; + store.chunk.offset = chunk_info->coords; + store.chunk.index = chunk_info->index; for (smine_start=0; smine_start<chunk_info->chunk_points; smine_start+=smine_nelmts) { /* Go figure out how many elements to read from the file */ @@ -2022,7 +2029,7 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, sconv->stats[1].gath_ncalls++; #endif if (n!=smine_nelmts) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed"); + HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed") if (H5T_BKG_YES==need_bkg) { #ifdef H5S_DEBUG @@ -2038,15 +2045,15 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, sconv->stats[0].bkg_ncalls++; #endif if (n!=smine_nelmts) - HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "file gather failed"); + HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "file gather failed") } /* end if */ - - /* + + /* * Perform data type conversion. */ 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"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "data type conversion failed") /* * Scatter the data out to the file. @@ -2064,7 +2071,7 @@ nelmts, H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, sconv->stats[0].scat_ncalls++; #endif if (status<0) - HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "scatter failed"); + HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "scatter failed") } /* end for */ /* Release selection iterators */ @@ -2110,10 +2117,10 @@ done: /* Release chunk mapping information */ if(H5D_destroy_chunk_map(&fm) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release chunk mapping"); + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't release chunk mapping") - FUNC_LEAVE_NOAPI(ret_value); -} /* H5D_chunk_write() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* H5D_chunk_write() */ #ifdef H5_HAVE_PARALLEL @@ -2140,7 +2147,7 @@ H5D_io_assist_mpio(hid_t dxpl_id, H5D_dxpl_cache_t *dxpl_cache, { herr_t ret_value = SUCCEED; /*return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_io_assist_mpio); + FUNC_ENTER_NOAPI_NOINIT(H5D_io_assist_mpio) /* The following may not handle a collective call correctly * since it does not ensure all processes can handle the write @@ -2166,8 +2173,8 @@ H5D_io_assist_mpio(hid_t dxpl_id, H5D_dxpl_cache_t *dxpl_cache, } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_io_assist_mpio() */ /*------------------------------------------------------------------------- @@ -2240,14 +2247,13 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp hbool_t iter_init=0; /* Selection iteration info has been initialized */ unsigned f_ndims; /* The number of dimensions of the file's dataspace */ int sm_ndims; /* The number of dimensions of the memory buffer's dataspace (signed) */ - hsize_t nchunks, last_nchunks; /* Number of chunks in dataset */ H5TB_NODE *curr_node; /* Current node in TBBT */ H5S_sel_type fsel_type; /* Selection type on disk */ char bogus; /* "bogus" buffer to pass to selection iterator */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_create_chunk_map); + FUNC_ENTER_NOAPI_NOINIT(H5D_create_chunk_map) #ifdef QAK { int mpi_rank; @@ -2293,34 +2299,24 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp fm->f_ndims=f_ndims=dataset->layout.u.chunk.ndims-1; if(H5S_get_simple_extent_dims(file_space, fm->f_dims, NULL)<0) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality"); + HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality") /* Decide the number of chunks in each dimension*/ - last_nchunks=0; - nchunks=1; for(u=0; u<f_ndims; u++) { /* Keep the size of the chunk dimensions as hsize_t for various routines */ fm->chunk_dim[u]=fm->layout->u.chunk.dim[u]; /* Round up to the next integer # of chunks, to accomodate partial chunks */ fm->chunks[u] = ((fm->f_dims[u]+dataset->layout.u.chunk.dim[u])-1) / dataset->layout.u.chunk.dim[u]; - - /* Track total number of chunks in dataset */ - nchunks *= fm->chunks[u]; - - /* Check if the chunk indices will overflow */ - if(nchunks<last_nchunks) - HGOTO_ERROR (H5E_DATASET, H5E_OVERFLOW, FAIL, "too many chunks"); - last_nchunks=nchunks; } /* end for */ /* Compute the "down" size of 'chunks' information */ if(H5V_array_down(f_ndims,fm->chunks,fm->down_chunks)<0) - HGOTO_ERROR (H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute 'down' sizes"); + HGOTO_ERROR (H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute 'down' sizes") /* Initialize TBBT for chunk selections */ if((fm->fsel=H5TB_fast_dmake(H5TB_FAST_HSIZE_COMPARE))==NULL) - HGOTO_ERROR(H5E_DATASET,H5E_CANTMAKETREE,FAIL,"can't create TBBT for chunk selections"); + HGOTO_ERROR(H5E_DATASET,H5E_CANTMAKETREE,FAIL,"can't create TBBT for chunk selections") /* Initialize "last chunk" information */ fm->last_index=(hsize_t)-1; @@ -2399,7 +2395,7 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp * to generate the memory chunk information quickly. */ if(H5D_create_chunk_mem_map_hyper(fm)<0) - HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create memory chunk selections"); + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create memory chunk selections") } /* end if */ else { size_t elmt_size; /* Memory datatype size */ @@ -2418,14 +2414,14 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp /* Create temporary datatypes for selection iteration */ if(f_tid<0) { if((f_tid = H5I_register(H5I_DATATYPE, H5T_copy(dataset->type, H5T_COPY_ALL)))<0) - HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register file datatype"); + HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register file datatype") } /* end if */ /* Create selection iterator for memory selection */ if((elmt_size=H5T_get_size(mem_type))==0) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid"); + HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid") if (H5S_select_iter_init(&(fm->mem_iter), equiv_mspace, elmt_size)<0) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator"); + HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") iter_init=1; /* Selection iteration info has been initialized */ /* Spaces aren't the same shape, iterate over the memory selection directly */ @@ -2468,11 +2464,11 @@ done: if(ret_value<0) { if(tmp_mspace && !fm->mchunk_tmpl) { if(H5S_close(tmp_mspace)<0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template"); + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template") } /* end if */ if (H5D_destroy_chunk_map(fm)<0) - HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release chunk mapping"); + HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release chunk mapping") } /* end if */ /* Reset the global dataspace info */ @@ -2481,11 +2477,11 @@ done: if(equiv_mspace_init && equiv_mspace) { if(H5S_close(equiv_mspace)<0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template"); + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template") } /* end if */ if(iter_init) { if (H5S_SELECT_ITER_RELEASE(&(fm->mem_iter))<0) - HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator"); + HDONE_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") } if(f_tid!=(-1)) { if(H5I_dec_ref(f_tid)<0) @@ -2501,7 +2497,7 @@ done: HDfprintf(stderr,"%s: rank=%d - Leaving, time=%f\n",FUNC,mpi_rank,time); } #endif /* QAK */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_create_chunk_map() */ @@ -2528,21 +2524,21 @@ H5D_free_chunk_info(void *_chunk_info) { H5D_chunk_info_t *chunk_info=(H5D_chunk_info_t *)_chunk_info; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_free_chunk_info); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_free_chunk_info) assert(chunk_info); - /* Close the chunk's dataspace */ - H5S_close(chunk_info->fspace); + /* Close the chunk's file dataspace */ + (void)H5S_close(chunk_info->fspace); /* Close the chunk's memory dataspace, if it's not shared */ if(!chunk_info->mspace_shared) - H5S_close(chunk_info->mspace); + (void)H5S_close(chunk_info->mspace); /* Free the actual chunk info */ H5FL_FREE(H5D_chunk_info_t,chunk_info); - FUNC_LEAVE_NOAPI_VOID; + FUNC_LEAVE_NOAPI_VOID } /* H5D_free_chunk_info() */ @@ -2561,11 +2557,11 @@ H5D_free_chunk_info(void *_chunk_info) *------------------------------------------------------------------------- */ static herr_t -H5D_destroy_chunk_map(fm_map *fm) +H5D_destroy_chunk_map(const fm_map *fm) { herr_t ret_value = SUCCEED; /*return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_destroy_chunk_map); + FUNC_ENTER_NOAPI_NOINIT(H5D_destroy_chunk_map) /* Free the chunk info tree */ if(fm->fsel) @@ -2574,10 +2570,10 @@ H5D_destroy_chunk_map(fm_map *fm) /* Free the memory chunk dataspace template */ if(fm->mchunk_tmpl) if(H5S_close(fm->mchunk_tmpl)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template"); + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_destroy_chunk_map() */ @@ -2609,18 +2605,18 @@ H5D_create_chunk_file_map_hyper(fm_map *fm) unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_create_chunk_file_map_hyper); + FUNC_ENTER_NOAPI_NOINIT(H5D_create_chunk_file_map_hyper) /* Sanity check */ assert(fm->f_ndims>0); /* Get number of elements selected in file */ if((sel_points=H5S_GET_SELECT_NPOINTS(fm->file_space))<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements"); + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection # of elements") /* Get bounding box for selection (to reduce the number of chunks to iterate over) */ if(H5S_SELECT_BOUNDS(fm->file_space, sel_start, sel_end)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info"); + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") /* Set initial chunk location & hyperslab size */ for(u=0; u<fm->f_ndims; u++) { @@ -2669,16 +2665,16 @@ H5D_create_chunk_file_map_hyper(fm_map *fm) /* Move selection back to have correct offset in chunk */ if(H5S_hyper_adjust(tmp_fchunk,coords)<0) { - H5S_close(tmp_fchunk); - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection"); + (void)H5S_close(tmp_fchunk); + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection") } /* end if */ /* Add temporary chunk to the list of chunks */ /* Allocate the file & memory chunk information */ if (NULL==(new_chunk_info = H5FL_MALLOC (H5D_chunk_info_t))) { - H5S_close(tmp_fchunk); - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info"); + (void)H5S_close(tmp_fchunk); + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info") } /* end if */ /* Initialize the chunk information */ @@ -2700,7 +2696,7 @@ H5D_create_chunk_file_map_hyper(fm_map *fm) /* Insert the new chunk into the TBBT tree */ if(H5TB_dins(fm->fsel,new_chunk_info,new_chunk_info)==NULL) { H5D_free_chunk_info(new_chunk_info); - HGOTO_ERROR(H5E_DATASPACE,H5E_CANTINSERT,FAIL,"can't insert chunk into TBBT"); + HGOTO_ERROR(H5E_DATASPACE,H5E_CANTINSERT,FAIL,"can't insert chunk into TBBT") } /* end if */ /* Get number of elements selected in chunk */ @@ -2713,7 +2709,7 @@ H5D_create_chunk_file_map_hyper(fm_map *fm) /* Leave if we are done */ if(sel_points==0) - HGOTO_DONE(SUCCEED); + HGOTO_DONE(SUCCEED) assert(sel_points>0); } /* end if */ @@ -2732,7 +2728,7 @@ H5D_create_chunk_file_map_hyper(fm_map *fm) if(coords[curr_dim]>sel_end[curr_dim]) { do { /* Reset current dimension's location to 0 */ - coords[curr_dim]=start_coords[curr_dim]; + coords[curr_dim]=start_coords[curr_dim]; /*lint !e771 The start_coords will always be initialized */ /* Decrement current dimension */ curr_dim--; @@ -2749,7 +2745,7 @@ H5D_create_chunk_file_map_hyper(fm_map *fm) } /* end while */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_create_chunk_file_map_hyper() */ @@ -2784,13 +2780,13 @@ H5D_create_chunk_mem_map_hyper(const fm_map *fm) unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_create_chunk_mem_map_hyper); + FUNC_ENTER_NOAPI_NOINIT(H5D_create_chunk_mem_map_hyper) #ifdef QAK { hsize_t mem_dims[H5O_LAYOUT_NDIMS]; /* Dimensions of memory space */ if(H5S_get_simple_extent_dims(fm->mem_space, mem_dims, NULL)<0) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality"); + HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality") HDfprintf(stderr,"%s: mem_dims={",FUNC); for(u=0; u<fm->m_ndims; u++) @@ -2874,7 +2870,7 @@ H5D_create_chunk_mem_map_hyper(const fm_map *fm) /* Release the current selection */ if(H5S_SELECT_RELEASE(chunk_info->mspace)<0) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection"); + HGOTO_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection") /* Copy the file chunk's selection */ if(H5S_select_copy(chunk_info->mspace,chunk_info->fspace,FALSE)<0) @@ -2902,8 +2898,8 @@ H5D_create_chunk_mem_map_hyper(const fm_map *fm) HDfprintf(stderr,"%Hd%s",chunk_adjust[u],(u<(fm->f_ndims-1) ? ", " : "}\n")); #endif /* QAK */ /* Adjust the selection */ - if(H5S_hyper_adjust(chunk_info->mspace,chunk_adjust)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection"); + if(H5S_hyper_adjust(chunk_info->mspace,chunk_adjust)<0) /*lint !e772 The chunk_adjust array will always be initialized */ + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSELECT, FAIL, "can't adjust chunk selection") #ifdef QAK { int mpi_rank; @@ -2919,7 +2915,7 @@ H5D_create_chunk_mem_map_hyper(const fm_map *fm) hsize_t mem_dims[H5O_LAYOUT_NDIMS]; /* Dimensions of memory space */ if(H5S_get_simple_extent_dims(chunk_info->mspace, mem_dims, NULL)<0) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality"); + HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get dimensionality") HDfprintf(stderr,"%s: mem_dims={",FUNC); for(u=0; u<fm->m_ndims; u++) @@ -2932,7 +2928,7 @@ H5D_create_chunk_mem_map_hyper(const fm_map *fm) } /* end else */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_create_chunk_mem_map_hyper() */ @@ -3075,6 +3071,7 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static herr_t H5D_chunk_mem_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize_t *coords, void *_fm) { @@ -3084,7 +3081,7 @@ H5D_chunk_mem_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize_ hsize_t chunk_index; /* Chunk index */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_mem_cb); + FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_mem_cb) /* Calculate the index of this chunk */ if(H5V_chunk_index((unsigned)ndims,coords,fm->layout->u.chunk.dim,fm->down_chunks,&chunk_index)<0) @@ -3124,7 +3121,7 @@ H5D_chunk_mem_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize_ /* Get coordinates of selection iterator for memory */ if(H5S_SELECT_ITER_COORDS(&fm->mem_iter,coords_in_mem)<0) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator coordinates"); + HGOTO_ERROR (H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator coordinates") /* Add point to memory selection for chunk */ if(fm->msel_type==H5S_SEL_POINTS) { @@ -3138,8 +3135,8 @@ H5D_chunk_mem_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize_ /* Move memory selection iterator to next element in selection */ if(H5S_SELECT_ITER_NEXT(&fm->mem_iter,1)<0) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to move to next iterator location"); + HGOTO_ERROR (H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to move to next iterator location") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_mem_cb() */ diff --git a/src/H5Distore.c b/src/H5Distore.c index 2775548..bf4cc66 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -944,7 +944,7 @@ H5F_istore_flush_entry(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, alloc = ent->alloc_size; /* Should the chunk be filtered before writing it to disk? */ - if (ent->pline.nfilters) { + if (ent->pline.nused) { if (!reset) { /* * Copy the chunk to a new buffer before running it through @@ -1350,7 +1350,7 @@ static void * H5F_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const H5O_layout_t *layout, const H5O_pline_t *pline, const H5O_fill_t *fill, H5D_fill_time_t fill_time, H5F_istore_ud1_t *udata, - const hssize_t offset[], hbool_t relax, + const H5D_storage_t *store, hbool_t relax, unsigned *idx_hint/*in,out*/) { int idx=0; /*hash index number */ @@ -1373,18 +1373,14 @@ H5F_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, con /* Search for the chunk in the cache */ if (rdcc->nslots>0) { - for (u=0, temp_idx=0; u<layout->u.chunk.ndims; u++) { - temp_idx += offset[u]; - temp_idx *= layout->u.chunk.dim[u]; - } - temp_idx += (hsize_t)(layout->u.chunk.addr); + temp_idx = store->chunk.index + (hsize_t)(layout->u.chunk.addr); idx=H5F_HASH(f,temp_idx); ent = rdcc->slot[idx]; if (ent && layout->u.chunk.ndims==ent->layout.u.chunk.ndims && H5F_addr_eq(layout->u.chunk.addr, ent->layout.u.chunk.addr)) { for (u=0, found=TRUE; u<ent->layout.u.chunk.ndims; u++) { - if (offset[u]!=ent->offset[u]) { + if (store->chunk.offset[u]!=ent->offset[u]) { found = FALSE; break; } @@ -1427,7 +1423,7 @@ H5F_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, con * 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. */ - chunk_addr = H5F_istore_get_addr(f, dxpl_id, layout, offset, udata); + chunk_addr = H5F_istore_get_addr(f, dxpl_id, layout, store->chunk.offset, udata); } /* end else */ if (H5F_addr_defined(chunk_addr)) { @@ -1444,7 +1440,7 @@ H5F_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, con if (H5F_block_read(f, H5FD_MEM_DRAW, chunk_addr, udata->key.nbytes, dxpl_id, chunk)<0) HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL, "unable to read raw data chunk"); - if (pline->nfilters) + if (pline->nused) if (H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &(udata->key.filter_mask), dxpl_cache->err_detect, dxpl_cache->filter_cb, &(udata->key.nbytes), &chunk_alloc, &chunk)<0) { HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL, "data pipeline read failed"); @@ -1512,7 +1508,7 @@ H5F_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, con H5O_copy(H5O_LAYOUT_ID, layout, &ent->layout); H5O_copy(H5O_PLINE_ID, pline, &ent->pline); for (u=0; u<layout->u.chunk.ndims; u++) - ent->offset[u] = offset[u]; + ent->offset[u] = store->chunk.offset[u]; ent->rd_count = chunk_size; ent->wr_count = chunk_size; ent->chunk = chunk; @@ -1616,7 +1612,7 @@ done: static herr_t H5F_istore_unlock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const H5O_layout_t *layout, const H5O_pline_t *pline, hbool_t dirty, - const hssize_t offset[], unsigned *idx_hint, uint8_t *chunk, size_t naccessed) + const H5D_storage_t *store, unsigned idx_hint, uint8_t *chunk, size_t naccessed) { H5F_rdcc_t *rdcc = &(f->shared->rdcc); H5F_rdcc_ent_t *ent = NULL; @@ -1625,13 +1621,13 @@ H5F_istore_unlock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_istore_unlock); - if (UINT_MAX==*idx_hint) { + if (UINT_MAX==idx_hint) { /*not in cache*/ } else { - assert(*idx_hint<rdcc->nslots); - assert(rdcc->slot[*idx_hint]); - assert(rdcc->slot[*idx_hint]->chunk==chunk); - found = *idx_hint; + assert(idx_hint<rdcc->nslots); + assert(rdcc->slot[idx_hint]); + assert(rdcc->slot[idx_hint]->chunk==chunk); + found = idx_hint; } if (found<0) { @@ -1649,7 +1645,7 @@ H5F_istore_unlock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, H5O_copy (H5O_LAYOUT_ID, layout, &x.layout); H5O_copy (H5O_PLINE_ID, pline, &x.pline); for (u=0; u<layout->u.chunk.ndims; u++) - x.offset[u] = offset[u]; + x.offset[u] = store->chunk.offset[u]; assert(layout->u.chunk.size>0); H5_ASSIGN_OVERFLOW(x.chunk_size,layout->u.chunk.size,hsize_t,size_t); x.alloc_size = x.chunk_size; @@ -1696,7 +1692,7 @@ H5F_istore_unlock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, */ ssize_t H5F_istore_readvv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, - const H5O_layout_t *layout, const struct H5D_dcpl_cache_t *dcpl_cache, hssize_t chunk_coords[], + const H5O_layout_t *layout, const struct H5D_dcpl_cache_t *dcpl_cache, const H5D_storage_t *store, size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], void *buf) @@ -1722,7 +1718,7 @@ H5F_istore_readvv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxp #ifndef NDEBUG for (u=0; u<layout->u.chunk.ndims; u++) - assert(chunk_coords[u]>=0); /*negative coordinates not supported (yet) */ + assert(store->chunk.offset[u]>=0); /*negative coordinates not supported (yet) */ #endif /* Get the address of this chunk on disk */ @@ -1731,7 +1727,7 @@ HDfprintf(stderr,"%s: chunk_coords={",FUNC); for(u=0; u<layout->u.chunk.ndims; u++) HDfprintf(stderr,"%Hd%s",chunk_coords[u],(u<(layout->u.chunk.ndims-1) ? ", " : "}\n")); #endif /* QAK */ - chunk_addr=H5F_istore_get_addr(f, dxpl_id, layout, chunk_coords, &udata); + chunk_addr=H5F_istore_get_addr(f, dxpl_id, layout, store->chunk.offset, &udata); #ifdef QAK HDfprintf(stderr,"%s: chunk_addr=%a, chunk_size=%Hu\n",FUNC,chunk_addr,layout->u.chunk.size); HDfprintf(stderr,"%s: chunk_len_arr[%Zu]=%Zu\n",FUNC,*chunk_curr_seq,chunk_len_arr[*chunk_curr_seq]); @@ -1746,7 +1742,7 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a * for the chunk has been defined, then don't load the chunk into the * cache, just write the data to it directly. */ - if (layout->u.chunk.size>f->shared->rdcc_nbytes && dcpl_cache->pline.nfilters==0 && + if (layout->u.chunk.size>f->shared->rdcc_nbytes && dcpl_cache->pline.nused==0 && chunk_addr!=HADDR_UNDEF) { if ((ret_value=H5F_contig_readvv(f, (hsize_t)layout->u.chunk.size, chunk_addr, chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, dxpl_id, buf))<0) HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "unable to read raw data to file"); @@ -1761,7 +1757,7 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a * chunk. */ if (NULL==(chunk=H5F_istore_lock(f, dxpl_cache, dxpl_id, layout, &dcpl_cache->pline, &dcpl_cache->fill, dcpl_cache->fill_time, - &udata, chunk_coords, FALSE, &idx_hint))) + &udata, store, FALSE, &idx_hint))) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk"); /* Use the vectorized memory copy routine to do actual work */ @@ -1770,7 +1766,7 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a H5_CHECK_OVERFLOW(naccessed,ssize_t,size_t); if (H5F_istore_unlock(f, dxpl_cache, dxpl_id, layout, &dcpl_cache->pline, FALSE, - chunk_coords, &idx_hint, chunk, (size_t)naccessed)<0) + store, idx_hint, chunk, (size_t)naccessed)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to unlock raw data chunk"); /* Set return value */ @@ -1800,7 +1796,7 @@ done: ssize_t H5F_istore_writevv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const H5O_layout_t *layout, - const struct H5D_dcpl_cache_t *dcpl_cache, hssize_t chunk_coords[], + const struct H5D_dcpl_cache_t *dcpl_cache, const H5D_storage_t *store, size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], const void *buf) @@ -1826,7 +1822,7 @@ H5F_istore_writevv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, #ifndef NDEBUG for (u=0; u<layout->u.chunk.ndims; u++) - assert(chunk_coords[u]>=0); /*negative coordinates not supported (yet) */ + assert(store->chunk.offset[u]>=0); /*negative coordinates not supported (yet) */ #endif /* Get the address of this chunk on disk */ @@ -1835,7 +1831,7 @@ HDfprintf(stderr,"%s: chunk_coords={",FUNC); for(u=0; u<layout->u.chunk.ndims; u++) HDfprintf(stderr,"%Hd%s",chunk_coords[u],(u<(layout->u.chunk.ndims-1) ? ", " : "}\n")); #endif /* QAK */ - chunk_addr=H5F_istore_get_addr(f, dxpl_id, layout, chunk_coords, &udata); + chunk_addr=H5F_istore_get_addr(f, dxpl_id, layout, store->chunk.offset, &udata); #ifdef QAK HDfprintf(stderr,"%s: chunk_addr=%a, chunk_size=%Hu\n",FUNC,chunk_addr,layout->u.chunk.size); HDfprintf(stderr,"%s: chunk_len_arr[%Zu]=%Zu\n",FUNC,*chunk_curr_seq,chunk_len_arr[*chunk_curr_seq]); @@ -1855,11 +1851,11 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a * writing to other elements in the same chunk. Do a direct * write-through of only the elements requested. */ - if ((layout->u.chunk.size>f->shared->rdcc_nbytes && dcpl_cache->pline.nfilters==0 && chunk_addr!=HADDR_UNDEF) + if ((layout->u.chunk.size>f->shared->rdcc_nbytes && dcpl_cache->pline.nused==0 && chunk_addr!=HADDR_UNDEF) || (IS_H5FD_MPI(f) && (H5F_ACC_RDWR & f->shared->flags))) { #ifdef H5_HAVE_PARALLEL /* Additional sanity check when operating in parallel */ - if (chunk_addr==HADDR_UNDEF || dcpl_cache->pline.nfilters>0) + if (chunk_addr==HADDR_UNDEF || dcpl_cache->pline.nused>0) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to locate raw data chunk"); #endif /* H5_HAVE_PARALLEL */ if ((ret_value=H5F_contig_writevv(f, (hsize_t)layout->u.chunk.size, chunk_addr, chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, dxpl_id, buf))<0) @@ -1881,7 +1877,7 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a relax = FALSE; if (NULL==(chunk=H5F_istore_lock(f, dxpl_cache, dxpl_id, layout, &dcpl_cache->pline, &dcpl_cache->fill, dcpl_cache->fill_time, - &udata, chunk_coords, relax, &idx_hint))) + &udata, store, relax, &idx_hint))) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk"); /* Use the vectorized memory copy routine to do actual work */ @@ -1890,7 +1886,7 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a H5_CHECK_OVERFLOW(naccessed,ssize_t,size_t); if (H5F_istore_unlock(f, dxpl_cache, dxpl_id, layout, &dcpl_cache->pline, TRUE, - chunk_coords, &idx_hint, chunk, (size_t)naccessed)<0) + store, idx_hint, chunk, (size_t)naccessed)<0) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "uanble to unlock raw data chunk"); /* Set return value */ @@ -1971,16 +1967,33 @@ done: *------------------------------------------------------------------------- */ hsize_t -H5F_istore_allocated(H5F_t *f, hid_t dxpl_id, unsigned ndims, haddr_t addr) +H5F_istore_allocated(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout) { + H5F_rdcc_t *rdcc = &(f->shared->rdcc); /*raw data chunk cache */ + H5F_rdcc_ent_t *ent; /*cache entry */ + H5D_dxpl_cache_t dxpl_cache; /* Cached data transfer properties */ H5F_istore_ud1_t udata; hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5F_istore_allocated, 0); + /* Fill the DXPL cache values for later use */ + if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't fill dxpl cache") + + /* Search for cached chunks that haven't been written out */ + for(ent = rdcc->head; ent; ent = ent->next) { + /* Make certain we are dealing with the correct B-tree, etc */ + if (H5F_addr_eq(layout->u.chunk.addr, ent->layout.u.chunk.addr)) { + /* Flush the chunk out to disk, to make certain the size is correct later */ + if (H5F_istore_flush_entry(f, &dxpl_cache, dxpl_id, ent, FALSE)<0) + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, 0, "cannot flush indexed storage buffer"); + } /* end if */ + } /* end for */ + HDmemset(&udata, 0, sizeof udata); - udata.mesg.u.chunk.ndims = ndims; - if (H5B_iterate(f, dxpl_id, H5B_ISTORE, H5F_istore_iter_allocated, addr, &udata)<0) + udata.mesg.u.chunk.ndims = layout->u.chunk.ndims; + if (H5B_iterate(f, dxpl_id, H5B_ISTORE, H5F_istore_iter_allocated, layout->u.chunk.addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree"); /* Set return value */ @@ -1988,7 +2001,7 @@ H5F_istore_allocated(H5F_t *f, hid_t dxpl_id, unsigned ndims, haddr_t addr) done: FUNC_LEAVE_NOAPI(ret_value); -} +} /* end H5F_istore_allocated() */ /*------------------------------------------------------------------------- @@ -2074,7 +2087,7 @@ H5F_istore_chunk_alloc(size_t size, const H5O_pline_t *pline) assert(size); assert(pline); - if(pline->nfilters>0) + if(pline->nused>0) ret_value=H5MM_malloc(size); else ret_value=H5FL_BLK_MALLOC(chunk,size); @@ -2107,7 +2120,7 @@ H5F_istore_chunk_xfree(void *chk, const H5O_pline_t *pline) assert(pline); if(chk) { - if(pline->nfilters>0) + if(pline->nused>0) H5MM_xfree(chk); else H5FL_BLK_FREE(chunk,chk); @@ -2297,7 +2310,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, } /* end else */ /* Check if there are filters which need to be applied to the chunk */ - if (pline.nfilters>0) { + if (pline.nused>0) { unsigned filter_mask=0; size_t buf_size=(size_t)chunk_size; size_t nbytes=(size_t)chunk_size; @@ -2517,7 +2530,7 @@ H5F_istore_prune_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, H5F_rdcc_t *rdcc = &(f->shared->rdcc); /*raw data chunk cache */ H5F_rdcc_ent_t *ent = NULL, *next = NULL; /*cache entry */ unsigned u; /*counters */ - int found = 0; /*remove this entry */ + int found; /*remove this entry */ H5F_istore_ud1_t udata; /*B-tree pass-through */ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */ herr_t ret_value=SUCCEED; /* Return value */ @@ -2540,13 +2553,12 @@ H5F_istore_prune_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, * and release them from the linked list raw data cache *------------------------------------------------------------------------- */ + found = 0; for(ent = rdcc->head; ent; ent = next) { next = ent->next; /* Make certain we are dealing with the correct B-tree, etc */ - if (layout->u.chunk.ndims==ent->layout.u.chunk.ndims && - H5F_addr_eq(layout->u.chunk.addr, ent->layout.u.chunk.addr)) { - found = 0; + if (H5F_addr_eq(layout->u.chunk.addr, ent->layout.u.chunk.addr)) { for(u = 0; u < ent->layout.u.chunk.ndims - 1; u++) { if((hsize_t)ent->offset[u] > curr_dims[u]) { found = 1; @@ -2556,17 +2568,18 @@ H5F_istore_prune_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, } /* end if */ if(found) { -#if defined (H5F_ISTORE_DEBUG) - HDfputs("cache:remove:[", stdout); - for(u = 0; u < ent->layout.u.chunk.ndims - 1; u++) { - HDfprintf(stdout, "%s%Hd", u ? ", " : "", ent->offset[u]); - } - HDfputs("]\n", stdout); +#ifdef H5F_ISTORE_DEBUG + HDfputs("cache:remove:[", stderr); + for(u = 0; u < ent->layout.u.chunk.ndims - 1; u++) + HDfprintf(stderr, "%s%Hd", u ? ", " : "", ent->offset[u]); + HDfputs("]\n", stderr); #endif /* Preempt the entry from the cache, but do not flush it to disk */ if(H5F_istore_preempt(f, dxpl_cache, dxpl_id, ent, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to preempt chunk"); + + found=0; } } @@ -2627,12 +2640,10 @@ H5F_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t UNUSED a /* Figure out what chunks are no longer in use for the specified extent and release them */ for(u = 0; u < bt_udata->mesg.u.chunk.ndims - 1; u++) if((hsize_t)lt_key->offset[u] > bt_udata->dims[u]) { -#if defined (H5F_ISTORE_DEBUG) +#ifdef H5F_ISTORE_DEBUG HDfputs("b-tree:remove:[", bt_udata->stream); - for(u = 0; u < bt_udata->mesg.u.chunk.ndims - 1; u++) { - HDfprintf(bt_udata->stream, "%s%Hd", u ? ", " : "", - lt_key->offset[u]); - } + for(u = 0; u < bt_udata->mesg.u.chunk.ndims - 1; u++) + HDfprintf(bt_udata->stream, "%s%Hd", u ? ", " : "", lt_key->offset[u]); HDfputs("]\n", bt_udata->stream); #endif @@ -2740,6 +2751,8 @@ H5F_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca H5S_t *space_chunk = NULL; /*dataspace for a chunk */ hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; /*current chunk dimensions */ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */ + hsize_t chunks[H5O_LAYOUT_NDIMS]; /*current number of chunks in each dimension */ + hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of elements in each dimension */ int srank; /*current # of dimensions (signed) */ unsigned rank; /*current # of dimensions */ int i, carry; /*counters */ @@ -2748,6 +2761,7 @@ H5F_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca H5O_pline_t pline; /* I/O pipeline information */ H5O_fill_t fill; /* Fill value information */ H5D_fill_time_t fill_time; /* Fill time information */ + H5D_storage_t store; /* Dataset storage information */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5F_istore_initialize_by_extent, FAIL); @@ -2777,10 +2791,18 @@ H5F_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca H5_ASSIGN_OVERFLOW(rank,srank,int,unsigned); /* Copy current dimensions */ - for(u = 0; u < rank; u++) + for(u = 0; u < rank; u++) { size[u] = curr_dims[u]; + + /* Round up to the next integer # of chunks, to accomodate partial chunks */ + chunks[u] = ((curr_dims[u]+layout->u.chunk.dim[u])-1) / layout->u.chunk.dim[u]; + } /* end for */ size[u] = layout->u.chunk.dim[u]; + /* Get the "down" sizes for each dimension */ + if(H5V_array_down(rank,chunks,down_chunks)<0) + HGOTO_ERROR (H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute 'down' sizes") + /* Create a data space for a chunk & set the extent */ for(u = 0; u < rank; u++) chunk_dims[u] = layout->u.chunk.dim[u]; @@ -2822,8 +2844,13 @@ H5F_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca if(found) { + /* Calculate the index of this chunk */ + if(H5V_chunk_index(rank,chunk_offset,layout->u.chunk.dim,down_chunks,&store.chunk.index)<0) + HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") + + store.chunk.offset=chunk_offset; if(NULL == (chunk = H5F_istore_lock(f, dxpl_cache, dxpl_id, layout, &pline, &fill, fill_time, - NULL, chunk_offset, FALSE, &idx_hint))) + NULL, &store, FALSE, &idx_hint))) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk"); if(H5S_select_all(space_chunk,1) < 0) @@ -2832,7 +2859,7 @@ H5F_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca for(u = 0; u < rank; u++) count[u] = MIN((idx_cur[u] + 1) * layout->u.chunk.dim[u], size[u] - chunk_offset[u]); -#if defined (H5F_ISTORE_DEBUG) +#ifdef H5F_ISTORE_DEBUG HDfputs("cache:initialize:offset:[", stdout); for(u = 0; u < layout->u.chunk.ndims - 1; u++) HDfprintf(stdout, "%s%Hd", u ? ", " : "", chunk_offset[u]); @@ -2856,7 +2883,7 @@ H5F_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed"); if(H5F_istore_unlock(f, dxpl_cache, dxpl_id, layout, &pline, TRUE, - chunk_offset, &idx_hint, chunk, (size_t)naccessed) < 0) + &store, idx_hint, chunk, (size_t)naccessed) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to unlock raw data chunk"); } /*found */ @@ -2917,8 +2944,8 @@ H5F_istore_delete(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout) /* Is the chunk to be deleted this cache entry? */ if(layout->u.chunk.addr==ent->layout.u.chunk.addr) /* Remove entry without flushing */ - if (H5F_istore_preempt(f, &dxpl_cache, dxpl_id, ent, FALSE )<0) - HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks"); + if (H5F_istore_preempt(f, &dxpl_cache, dxpl_id, ent, FALSE )<0) + HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks"); } /* end for */ /* Set up user data for B-tree deletion */ @@ -2936,6 +2963,111 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_istore_update_cache + * + * Purpose: Update any cached chunks index values after the dataspace + * size has changed + * + * Return: Success: Non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Saturday, May 29, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_istore_update_cache(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, const H5S_t * space) +{ + H5F_rdcc_t *rdcc = &(f->shared->rdcc); /*raw data chunk cache */ + H5F_rdcc_ent_t *ent, *next; /*cache entry */ + H5F_rdcc_ent_t *old_ent; /* Old cache entry */ + H5D_dxpl_cache_t dxpl_cache; /* Cached data transfer properties */ + int srank; /*current # of dimensions (signed) */ + unsigned rank; /*current # of dimensions */ + hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */ + hsize_t chunks[H5O_LAYOUT_NDIMS]; /*current number of chunks in each dimension */ + hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of elements in each dimension */ + hsize_t idx; /* Chunk index */ + hsize_t temp_idx; /* temporary index number */ + unsigned old_idx; /* Previous index number */ + unsigned u; /*counters */ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5F_istore_update_cache, FAIL); + + /* Check args */ + assert(f); + assert(layout && H5D_CHUNKED == layout->type); + assert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); + assert(space); + + /* Go get the rank & dimensions */ + if((srank = H5S_get_simple_extent_dims(space, curr_dims, NULL)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions"); + H5_ASSIGN_OVERFLOW(rank,srank,int,unsigned); + + /* Copy current dimensions */ + for(u = 0; u < rank; u++) { + /* Round up to the next integer # of chunks, to accomodate partial chunks */ + chunks[u] = ((curr_dims[u]+layout->u.chunk.dim[u])-1) / layout->u.chunk.dim[u]; + } /* end for */ + + /* Get the "down" sizes for each dimension */ + if(H5V_array_down(rank,chunks,down_chunks)<0) + HGOTO_ERROR (H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute 'down' sizes") + + /* Fill the DXPL cache values for later use */ + if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") + + /* Recompute the index for each cached chunk that is in a dataset */ + for(ent = rdcc->head; ent; ent = next) { + next=ent->next; + + /* Make certain we are dealing with the correct B-tree, etc */ + if (H5F_addr_eq(layout->u.chunk.addr, ent->layout.u.chunk.addr)) { + /* Calculate the index of this chunk */ + if(H5V_chunk_index(rank,ent->offset,layout->u.chunk.dim,down_chunks,&idx)<0) + HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") + + /* Compute the index for the chunk entry */ + temp_idx = idx + (hsize_t)(layout->u.chunk.addr); + old_idx=ent->idx; /* Save for later */ + ent->idx=H5F_HASH(f,temp_idx); + + if(old_idx!=ent->idx) { + /* Check if there is already a chunk at this chunk's new location */ + old_ent = rdcc->slot[ent->idx]; + if(old_ent!=NULL) { + assert(old_ent->locked==0); + + /* Check if we are removing the entry we would walk to next */ + if(old_ent==next) + next=old_ent->next; + + /* Remove the old entry from the cache */ + if (H5F_istore_preempt(f, &dxpl_cache, dxpl_id, old_ent, TRUE )<0) + HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks"); + } /* end if */ + + /* Insert this chunk into correct location in hash table */ + rdcc->slot[ent->idx]=ent; + + /* Null out previous location */ + rdcc->slot[old_idx]=NULL; + } /* end if */ + } /* end if */ + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5F_istore_update_cache() */ + + +/*------------------------------------------------------------------------- * Function: H5F_istore_dump_btree * * Purpose: Prints information about the storage B-tree to the specified diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 688d3e3..193e524 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -167,7 +167,10 @@ typedef struct H5D_t H5D_t; /* Typedef for dataset storage information */ typedef union H5D_storage_t { H5O_efl_t efl; /* External file list information for dataset */ - hssize_t *chunk_coords; /* chunk's coordinates in file chunks */ + struct { + hsize_t index; /* "Index" of chunk in dataset (must be first for TBBT routines) */ + hssize_t *offset; /* Chunk's coordinates in elements */ + } chunk; } H5D_storage_t; /* Typedef for cached dataset transfer property list information */ @@ -197,7 +200,7 @@ H5_DLL herr_t H5D_init(void); H5_DLL hid_t H5D_open(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL htri_t H5D_isa(H5G_entry_t *ent, hid_t dxpl_id); H5_DLL H5G_entry_t *H5D_entof(H5D_t *dataset); -H5_DLL H5T_t *H5D_typeof(H5D_t *dset); +H5_DLL H5T_t *H5D_typeof(const H5D_t *dset); H5_DLL herr_t H5D_crt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_data); H5_DLL herr_t H5D_crt_close(hid_t dxpl_id, void *close_data); @@ -205,7 +208,7 @@ H5_DLL herr_t H5D_xfer_create(hid_t dxpl_id, void *create_data); H5_DLL herr_t H5D_xfer_copy(hid_t new_plist_id, hid_t old_plist_id, void *copy_data); H5_DLL herr_t H5D_xfer_close(hid_t dxpl_id, void *close_data); -H5_DLL herr_t H5D_flush(H5F_t *f, hid_t dxpl_id); +H5_DLL herr_t H5D_flush(const H5F_t *f, hid_t dxpl_id); H5_DLL herr_t H5D_get_dxpl_cache(hid_t dxpl_id, H5D_dxpl_cache_t *cache); H5_DLL herr_t H5D_get_dxpl_cache_real(hid_t dxpl_id, H5D_dxpl_cache_t *cache); diff --git a/src/H5Dseq.c b/src/H5Dseq.c index 6fd583c..9bd9f72 100644 --- a/src/H5Dseq.c +++ b/src/H5Dseq.c @@ -241,7 +241,7 @@ H5F_seq_readvv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_i case H5D_CHUNKED: assert(store); - if((ret_value=H5F_istore_readvv(f, dxpl_cache, dxpl_id, layout, dcpl_cache, store->chunk_coords, + if((ret_value=H5F_istore_readvv(f, dxpl_cache, dxpl_id, layout, dcpl_cache, store, dset_max_nseq, dset_curr_seq, dset_len_arr, dset_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0) @@ -350,7 +350,7 @@ H5F_seq_writevv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, case H5D_CHUNKED: assert(store); - if((ret_value=H5F_istore_writevv(f, dxpl_cache, dxpl_id, layout, dcpl_cache, store->chunk_coords, + if((ret_value=H5F_istore_writevv(f, dxpl_cache, dxpl_id, layout, dcpl_cache, store, dset_max_nseq, dset_curr_seq, dset_len_arr, dset_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0) @@ -84,9 +84,9 @@ static H5F_t *H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id); static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id); static herr_t H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags); static haddr_t H5F_locate_signature(H5FD_t *file, hid_t dxpl_id); -static int H5F_get_objects(H5F_t *f, unsigned types, int max_objs, hid_t *obj_id_list); +static int H5F_get_objects(const H5F_t *f, unsigned types, int max_objs, hid_t *obj_id_list); static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); -static herr_t H5F_get_vfd_handle(H5F_t *file, hid_t fapl, void** file_handle); +static herr_t H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void** file_handle); /* Declare a free list to manage the H5F_t struct */ H5FL_DEFINE_STATIC(H5F_t); @@ -122,11 +122,11 @@ H5F_init(void) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5F_init, FAIL); + FUNC_ENTER_NOAPI(H5F_init, FAIL) /* FUNC_ENTER() does all the work */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -185,13 +185,13 @@ H5F_init_interface(void) H5P_genclass_t *crt_pclass; hsize_t userblock_size = H5F_CRT_USER_BLOCK_DEF; unsigned sym_leaf_k = H5F_CRT_SYM_LEAF_DEF; - int btree_k[H5B_NUM_BTREE_ID] = H5F_CRT_BTREE_RANK_DEF; + unsigned btree_k[H5B_NUM_BTREE_ID] = H5F_CRT_BTREE_RANK_DEF; size_t sizeof_addr = H5F_CRT_ADDR_BYTE_NUM_DEF; size_t sizeof_size = H5F_CRT_OBJ_BYTE_NUM_DEF; - int superblock_ver = H5F_CRT_SUPER_VERS_DEF; - int freespace_ver = H5F_CRT_FREESPACE_VERS_DEF; - int objectdir_ver = H5F_CRT_OBJ_DIR_VERS_DEF; - int sharedheader_ver = H5F_CRT_SHARE_HEAD_VERS_DEF; + unsigned superblock_ver = H5F_CRT_SUPER_VERS_DEF; + unsigned freespace_ver = H5F_CRT_FREESPACE_VERS_DEF; + unsigned objectdir_ver = H5F_CRT_OBJ_DIR_VERS_DEF; + unsigned sharedheader_ver = H5F_CRT_SHARE_HEAD_VERS_DEF; /* File access property class variables. In sequence, they are * - File access property class to modify * - Size of meta data cache(elements) @@ -230,7 +230,7 @@ H5F_init_interface(void) H5P_genclass_t *mnt_pclass; hbool_t local = H5F_MNT_SYM_LOCAL_DEF; - FUNC_ENTER_NOAPI_NOINIT(H5F_init_interface); + FUNC_ENTER_NOAPI_NOINIT(H5F_init_interface) /* * Initialize the atom group for the file IDs. There are two groups: @@ -242,173 +242,173 @@ H5F_init_interface(void) */ if (H5I_init_group(H5I_FILE, H5I_FILEID_HASHSIZE, 0, (H5I_free_t)H5F_close)<0 || H5I_init_group(H5I_FILE_CLOSING, H5I_FILEID_HASHSIZE, 0, (H5I_free_t)H5F_close)<0) - HGOTO_ERROR (H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface"); + HGOTO_ERROR (H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface") /* ========== File Creation Property Class Initialization ============*/ assert(H5P_CLS_FILE_CREATE_g!=-1); /* Get the pointer to file creation class */ if(NULL == (crt_pclass = H5I_object(H5P_CLS_FILE_CREATE_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Get the number of properties in the class */ if(H5P_get_nprops_pclass(crt_pclass,&nprops)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties") /* Assume that if there are properties in the class, they are the default ones */ if(nprops==0) { /* Register the user block size */ if(H5P_register(crt_pclass,H5F_CRT_USER_BLOCK_NAME,H5F_CRT_USER_BLOCK_SIZE, &userblock_size,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 1/2 rank for symbol table leaf nodes */ if(H5P_register(crt_pclass,H5F_CRT_SYM_LEAF_NAME,H5F_CRT_SYM_LEAF_SIZE, &sym_leaf_k,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the 1/2 rank for btree internal nodes */ if(H5P_register(crt_pclass,H5F_CRT_BTREE_RANK_NAME,H5F_CRT_BTREE_RANK_SIZE, btree_k,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the byte number for an address */ if(H5P_register(crt_pclass,H5F_CRT_ADDR_BYTE_NUM_NAME, H5F_CRT_ADDR_BYTE_NUM_SIZE, &sizeof_addr,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the byte number for object size */ if(H5P_register(crt_pclass,H5F_CRT_OBJ_BYTE_NUM_NAME, H5F_CRT_OBJ_BYTE_NUM_SIZE,&sizeof_size,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the superblock version number */ if(H5P_register(crt_pclass,H5F_CRT_SUPER_VERS_NAME,H5F_CRT_SUPER_VERS_SIZE, &superblock_ver,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the free-space version number */ if(H5P_register(crt_pclass,H5F_CRT_FREESPACE_VERS_NAME, H5F_CRT_FREESPACE_VERS_SIZE,&freespace_ver,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the object directory version number */ if(H5P_register(crt_pclass,H5F_CRT_OBJ_DIR_VERS_NAME, H5F_CRT_OBJ_DIR_VERS_SIZE,&objectdir_ver,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the shared-header version number */ if(H5P_register(crt_pclass,H5F_CRT_SHARE_HEAD_VERS_NAME, H5F_CRT_SHARE_HEAD_VERS_SIZE, &sharedheader_ver,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") } /* end if */ /* Only register the default property list if it hasn't been created yet */ if(H5P_LST_FILE_CREATE_g==(-1)) { /* Register the default file creation property list */ if((H5P_LST_FILE_CREATE_g = H5P_create_id(crt_pclass))<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") } /* end if */ /* Register predefined file drivers */ H5E_BEGIN_TRY { - if ((status=H5FD_SEC2)<0) goto end_registration; - if ((status=H5FD_STDIO)<0) goto end_registration; - if ((status=H5FD_FAMILY)<0) goto end_registration; + if ((status=H5FD_SEC2)<0) goto end_registration; /*lint !e801 Tell lint that our use of goto is OK here */ + if ((status=H5FD_STDIO)<0) goto end_registration; /*lint !e801 Tell lint that our use of goto is OK here */ + if ((status=H5FD_FAMILY)<0) goto end_registration; /*lint !e801 Tell lint that our use of goto is OK here */ #ifdef H5_HAVE_GASS - if ((status=H5FD_GASS)<0) goto end_registration; + if ((status=H5FD_GASS)<0) goto end_registration; /*lint !e801 Tell lint that our use of goto is OK here */ #endif #ifdef H5_HAVE_SRB - if ((status=H5FD_SRB)<0) goto end_registration; + if ((status=H5FD_SRB)<0) goto end_registration; /*lint !e801 Tell lint that our use of goto is OK here */ #endif - if ((status=H5FD_CORE)<0) goto end_registration; - if ((status=H5FD_MULTI)<0) goto end_registration; + if ((status=H5FD_CORE)<0) goto end_registration; /*lint !e801 Tell lint that our use of goto is OK here */ + if ((status=H5FD_MULTI)<0) goto end_registration; /*lint !e801 Tell lint that our use of goto is OK here */ #ifdef H5_HAVE_PARALLEL - if ((status=H5FD_MPIO)<0) goto end_registration; - if ((status=H5FD_MPIPOSIX)<0) goto end_registration; + if ((status=H5FD_MPIO)<0) goto end_registration; /*lint !e801 Tell lint that our use of goto is OK here */ + if ((status=H5FD_MPIPOSIX)<0) goto end_registration; /*lint !e801 Tell lint that our use of goto is OK here */ #ifdef H5_HAVE_FPHDF5 - if ((status=H5FD_FPHDF5)<0) goto end_registration; + if ((status=H5FD_FPHDF5)<0) goto end_registration; /*lint !e801 Tell lint that our use of goto is OK here */ #endif /* H5_HAVE_FPHDF5 */ #endif /* H5_HAVE_PARALLEL */ #ifdef H5_HAVE_STREAM - if ((status=H5FD_STREAM)<0) goto end_registration; + if ((status=H5FD_STREAM)<0) goto end_registration; /*lint !e801 Tell lint that our use of goto is OK here */ #endif - end_registration: ; +end_registration: ; } H5E_END_TRY; if (status<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "file driver registration failed"); + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "file driver registration failed") /* ========== File Access Property Class Initialization ============*/ assert(H5P_CLS_FILE_ACCESS_g!=-1); /* Get the pointer to file creation class */ if(NULL == (acs_pclass = H5I_object(H5P_CLS_FILE_ACCESS_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Get the number of properties in the class */ if(H5P_get_nprops_pclass(acs_pclass,&nprops)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties") /* Assume that if there are properties in the class, they are the default ones */ if(nprops==0) { /* Register the size of meta data cache(elements) */ if(H5P_register(acs_pclass,H5F_ACS_META_CACHE_SIZE_NAME,H5F_ACS_META_CACHE_SIZE_SIZE, &mdc_nelmts,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache (elements) */ if(H5P_register(acs_pclass,H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME,H5F_ACS_DATA_CACHE_ELMT_SIZE_SIZE, &rdcc_nelmts,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache(bytes) */ if(H5P_register(acs_pclass,H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME,H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE, &rdcc_nbytes,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the preemption for reading chunks */ if(H5P_register(acs_pclass,H5F_ACS_PREEMPT_READ_CHUNKS_NAME,H5F_ACS_PREEMPT_READ_CHUNKS_SIZE, &rdcc_w0,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the threshold for alignment */ if(H5P_register(acs_pclass,H5F_ACS_ALIGN_THRHD_NAME,H5F_ACS_ALIGN_THRHD_SIZE, &threshold,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the alignment */ if(H5P_register(acs_pclass,H5F_ACS_ALIGN_NAME,H5F_ACS_ALIGN_SIZE, &alignment,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the minimum metadata allocation block size */ if(H5P_register(acs_pclass,H5F_ACS_META_BLOCK_SIZE_NAME,H5F_ACS_META_BLOCK_SIZE_SIZE, &meta_block_size,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the maximum sieve buffer size */ if(H5P_register(acs_pclass,H5F_ACS_SIEVE_BUF_SIZE_NAME,H5F_ACS_SIEVE_BUF_SIZE_SIZE, &sieve_buf_size,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the minimum "small data" allocation block size */ if(H5P_register(acs_pclass,H5F_ACS_SDATA_BLOCK_SIZE_NAME,H5F_ACS_SDATA_BLOCK_SIZE_SIZE, &sdata_block_size,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the garbage collection reference */ if(H5P_register(acs_pclass,H5F_ACS_GARBG_COLCT_REF_NAME,H5F_ACS_GARBG_COLCT_REF_SIZE, &gc_ref,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file driver ID */ if(H5P_register(acs_pclass,H5F_ACS_FILE_DRV_ID_NAME,H5F_ACS_FILE_DRV_ID_SIZE, &driver_id,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file driver info */ if(H5P_register(acs_pclass,H5F_ACS_FILE_DRV_INFO_NAME,H5F_ACS_FILE_DRV_INFO_SIZE, &driver_info,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file close degree */ if(H5P_register(acs_pclass,H5F_CLOSE_DEGREE_NAME,H5F_CLOSE_DEGREE_SIZE, &close_degree,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the offset of family driver info */ if(H5P_register(acs_pclass,H5F_ACS_FAMILY_OFFSET_NAME,H5F_ACS_FAMILY_OFFSET_SIZE, &family_offset,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the data type of multi driver info */ if(H5P_register(acs_pclass,H5F_ACS_MULTI_TYPE_NAME,H5F_ACS_MULTI_TYPE_SIZE, &mem_type,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") } /* end if */ /* Only register the default property list if it hasn't been created yet */ if(H5P_LST_FILE_ACCESS_g==(-1)) { /* Register the default file access property list */ if((H5P_LST_FILE_ACCESS_g = H5P_create_id(acs_pclass))<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") } /* end if */ /* ================ Mount Porperty Class Initialization ==============*/ @@ -416,28 +416,28 @@ H5F_init_interface(void) /* Get the pointer to file mount class */ if(NULL == (mnt_pclass = H5I_object(H5P_CLS_MOUNT_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Get the number of properties in the class */ if(H5P_get_nprops_pclass(mnt_pclass,&nprops)<0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't query number of properties") /* Assume that if there are properties in the class, they are the default ones */ if(nprops==0) { /* Register property of whether symlinks is local to file */ if(H5P_register(mnt_pclass,H5F_MNT_SYM_LOCAL_NAME,H5F_MNT_SYM_LOCAL_SIZE, &local,NULL,NULL,NULL,NULL,NULL,NULL,NULL)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") } /* end if */ /* Only register the default property list if it hasn't been created yet */ if(H5P_LST_MOUNT_g==(-1)) { /* Register the default file mount property list */ if((H5P_LST_MOUNT_g = H5P_create_id(mnt_pclass))<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't insert property into class") } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -466,7 +466,7 @@ H5F_term_interface(void) { int n = 0; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_term_interface); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_term_interface) if (interface_initialize_g) { if ((n=H5I_nmembers(H5I_FILE))) { @@ -478,7 +478,7 @@ H5F_term_interface(void) n = 1; /*H5I*/ } } - FUNC_LEAVE_NOAPI(n); + FUNC_LEAVE_NOAPI(n) } @@ -500,6 +500,7 @@ H5F_term_interface(void) * *---------------------------------------------------------------------------- */ +/* ARGSUSED */ herr_t H5F_acs_create(hid_t fapl_id, void UNUSED *copy_data) { @@ -508,17 +509,17 @@ H5F_acs_create(hid_t fapl_id, void UNUSED *copy_data) H5P_genplist_t *plist; /* Property list */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5F_acs_create, FAIL); + FUNC_ENTER_NOAPI(H5F_acs_create, FAIL) /* Check argument */ if(NULL == (plist = H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Retrieve properties */ if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver ID"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver ID") if(H5P_get(plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver info"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver info") if(driver_id > 0) { /* Set the driver for the property list */ @@ -527,7 +528,7 @@ H5F_acs_create(hid_t fapl_id, void UNUSED *copy_data) } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -547,6 +548,7 @@ done: * *-------------------------------------------------------------------------- */ +/* ARGSUSED */ herr_t H5F_acs_copy(hid_t new_fapl_id, hid_t old_fapl_id, void UNUSED *copy_data) { @@ -556,18 +558,18 @@ H5F_acs_copy(hid_t new_fapl_id, hid_t old_fapl_id, void UNUSED *copy_data) H5P_genplist_t *old_plist; /* Old property list */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5F_acs_copy, FAIL); + FUNC_ENTER_NOAPI(H5F_acs_copy, FAIL) if(NULL == (new_plist = H5I_object(new_fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") if(NULL == (old_plist = H5I_object(old_fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") /* Get values from old property list */ if(H5P_get(old_plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver ID"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver ID") if(H5P_get(old_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver info"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get drver info") if(driver_id > 0) { /* Set the driver for the property list */ @@ -576,7 +578,7 @@ H5F_acs_copy(hid_t new_fapl_id, hid_t old_fapl_id, void UNUSED *copy_data) } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -598,6 +600,7 @@ done: * *--------------------------------------------------------------------------- */ +/* ARGSUSED */ herr_t H5F_acs_close(hid_t fapl_id, void UNUSED *close_data) { @@ -606,16 +609,16 @@ H5F_acs_close(hid_t fapl_id, void UNUSED *close_data) H5P_genplist_t *plist; /* Property list */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5F_acs_close, FAIL); + FUNC_ENTER_NOAPI(H5F_acs_close, FAIL) /* Check argument */ if(NULL == (plist = H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) - HGOTO_DONE(FAIL); /* Can't return errors when library is shutting down */ + HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ if(H5P_get(plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) - HGOTO_DONE(FAIL); /* Can't return errors when library is shutting down */ + HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ if(driver_id > 0) { /* Close the driver for the property list */ @@ -624,7 +627,7 @@ H5F_acs_close(hid_t fapl_id, void UNUSED *close_data) } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } #ifdef NOT_YET @@ -652,11 +655,11 @@ H5F_flush_all_cb(void *_f, hid_t UNUSED fid, void *_invalidate) H5F_t *f=(H5F_t *)_f; unsigned invalidate = (*((hbool_t*)_invalidate); - FUNC_ENTER_NOAPI_NOINIT(H5F_flush_all_cb); + FUNC_ENTER_NOAPI_NOINIT(H5F_flush_all_cb) H5F_flush(f, H5F_SCOPE_LOCAL, (invalidate ? H5F_FLUSH_INVALIDATE : H5F_FLUSH_NONE)); - FUNC_LEAVE_NOAPI(0); + FUNC_LEAVE_NOAPI(0) } @@ -682,12 +685,12 @@ H5F_flush_all(hbool_t invalidate) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5F_flush_all, FAIL); + FUNC_ENTER_NOAPI(H5F_flush_all, FAIL) H5I_search(H5I_FILE,H5F_flush_all_cb,&invalidate); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } #endif /* NOT_YET */ @@ -793,21 +796,21 @@ H5Fget_create_plist(hid_t file_id) H5P_genplist_t *plist; /* Property list */ hid_t ret_value; - FUNC_ENTER_API(H5Fget_create_plist, FAIL); + FUNC_ENTER_API(H5Fget_create_plist, FAIL) H5TRACE1("i","i",file_id); /* check args */ if (NULL==(file=H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") if(NULL == (plist = H5I_object(file->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Create the property list object to return */ if((ret_value=H5P_copy_plist(plist)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file creation properties"); + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file creation properties") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -851,72 +854,72 @@ H5Fget_access_plist(hid_t file_id) hid_t ret_value = SUCCEED; void *driver_info=NULL; - FUNC_ENTER_API(H5Fget_access_plist, FAIL); + FUNC_ENTER_API(H5Fget_access_plist, FAIL) H5TRACE1("i","i",file_id); /* Check args */ if (NULL==(f=H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Make a copy of the default file access property list */ if(NULL == (old_plist = H5I_object(H5P_LST_FILE_ACCESS_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") if((ret_value=H5P_copy_plist(old_plist)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy file access property list"); + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy file access property list") if(NULL == (new_plist = H5I_object(ret_value))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Copy properties of the file access property list */ if(H5P_set(new_plist, H5F_ACS_META_CACHE_SIZE_NAME, &(f->shared->mdc_nelmts)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set meta data cache size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set meta data cache size") if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, &(f->shared->rdcc_nelmts)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache element size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache element size") if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size") if(H5P_set(new_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks") if(H5P_set(new_plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment threshold"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment threshold") if(H5P_set(new_plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment") if(H5P_set(new_plist, H5F_ACS_GARBG_COLCT_REF_NAME, &(f->shared->gc_ref)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set garbage collect reference"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set garbage collect reference") if(H5P_set(new_plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->lf->def_meta_block_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set meta data cache size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set meta data cache size") if(H5P_set(new_plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't sieve buffer size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't sieve buffer size") if(H5P_set(new_plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->lf->def_sdata_block_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' cache size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' cache size") /* * Since we're resetting the driver ID and info, close them if they * exist in this new property list. */ if (H5F_acs_close(ret_value, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't free the old driver information"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't free the old driver information") /* Increment the reference count on the driver ID and insert it into the property list */ if(H5I_inc_ref(f->shared->lf->driver_id)<0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver") if(H5P_set(new_plist, H5F_ACS_FILE_DRV_ID_NAME, &(f->shared->lf->driver_id)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver ID"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver ID") /* Set the driver "info" in the property list */ driver_info = H5FD_fapl_get(f->shared->lf); if(driver_info != NULL && H5P_set(new_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver info"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver info") /* Set the file close degree appropriately */ if(f->shared->fc_degree == H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_CLOSE_DEGREE_NAME, &(f->shared->lf->cls->fc_degree)) < 0) { - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") } else if(f->shared->fc_degree != H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_CLOSE_DEGREE_NAME, &(f->shared->fc_degree)) < 0) { - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") } done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -941,19 +944,19 @@ H5Fget_obj_count(hid_t file_id, unsigned types) H5F_t *f=NULL; int ret_value; /* Return value */ - FUNC_ENTER_API(H5Fget_obj_count, FAIL); + FUNC_ENTER_API(H5Fget_obj_count, FAIL) H5TRACE2("Is","iIu",file_id,types); - if( file_id != H5F_OBJ_ALL && (NULL==(f=H5I_object_verify(file_id,H5I_FILE))) ) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id"); + if( file_id != (hid_t)H5F_OBJ_ALL && (NULL==(f=H5I_object_verify(file_id,H5I_FILE))) ) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") if( (types&H5F_OBJ_ALL)==0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type") if((ret_value = H5F_get_obj_count(f, types))<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCOUNT, FAIL, "can't get object count"); + HGOTO_ERROR(H5E_FILE, H5E_CANTCOUNT, FAIL, "can't get object count") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -973,17 +976,17 @@ done: *------------------------------------------------------------------------- */ int -H5F_get_obj_count(H5F_t *f, unsigned types) +H5F_get_obj_count(const H5F_t *f, unsigned types) { int ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5F_get_obj_count); + FUNC_ENTER_NOAPI_NOINIT(H5F_get_obj_count) if((ret_value=H5F_get_objects(f, types, -1, NULL)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get counts of opened file IDs and object IDs in the file"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get counts of opened file IDs and object IDs in the file") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1007,19 +1010,19 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, int max_objs, hid_t *oid_list) herr_t ret_value; H5F_t *f=NULL; - FUNC_ENTER_API(H5Fget_obj_ids, FAIL); + FUNC_ENTER_API(H5Fget_obj_ids, FAIL) H5TRACE4("e","iIuIs*i",file_id,types,max_objs,oid_list); - if( file_id != H5F_OBJ_ALL && (NULL==(f=H5I_object_verify(file_id,H5I_FILE))) ) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id"); + if( file_id != (hid_t)H5F_OBJ_ALL && (NULL==(f=H5I_object_verify(file_id,H5I_FILE))) ) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") if( (types&H5F_OBJ_ALL)==0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type") assert(oid_list); ret_value = H5F_get_obj_ids(f, types, max_objs, oid_list); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -1038,17 +1041,17 @@ done: *------------------------------------------------------------------------- */ int -H5F_get_obj_ids(H5F_t *f, unsigned types, int max_objs, hid_t *oid_list) +H5F_get_obj_ids(const H5F_t *f, unsigned types, int max_objs, hid_t *oid_list) { int ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5F_get_obj_ids); + FUNC_ENTER_NOAPI_NOINIT(H5F_get_obj_ids) if((ret_value=H5F_get_objects(f, types, max_objs, oid_list)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get object IDs opened in the file"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get object IDs opened in the file") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1068,13 +1071,13 @@ done: *--------------------------------------------------------------------------- */ static int -H5F_get_objects(H5F_t *f, unsigned types, int max_index, hid_t *obj_id_list) +H5F_get_objects(const H5F_t *f, unsigned types, int max_index, hid_t *obj_id_list) { unsigned obj_id_count=0; /* Number of open IDs */ H5F_olist_t olist; /* Structure to hold search results */ int ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_objects); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_objects) /* Set up search information */ olist.obj_id_list = (max_index==0 ? NULL : obj_id_list); @@ -1092,44 +1095,44 @@ H5F_get_objects(H5F_t *f, unsigned types, int max_index, hid_t *obj_id_list) * IDs on the object list */ if( (types & H5F_OBJ_FILE) && H5I_nmembers(H5I_FILE) > 0 ) { olist.obj_type = H5I_FILE; - H5I_search(H5I_FILE, H5F_get_objects_cb, &olist); + (void)H5I_search(H5I_FILE, H5F_get_objects_cb, &olist); } /* Search through dataset IDs to count number of datasets, and put their * IDs on the object list */ if( (max_index<0 || (int)olist.list_index< max_index) && (types & H5F_OBJ_DATASET) && H5I_nmembers(H5I_DATASET) > 0 ) { olist.obj_type = H5I_DATASET; - H5I_search(H5I_DATASET, H5F_get_objects_cb, &olist); + (void)H5I_search(H5I_DATASET, H5F_get_objects_cb, &olist); } /* Search through group IDs to count number of groups, and put their * IDs on the object list */ if( (max_index<0 || (int)olist.list_index< max_index) && (types & H5F_OBJ_GROUP) && H5I_nmembers(H5I_GROUP) > 0 ) { olist.obj_type = H5I_GROUP; - H5I_search(H5I_GROUP, H5F_get_objects_cb, &olist); + (void)H5I_search(H5I_GROUP, H5F_get_objects_cb, &olist); } /* Search through datatype IDs to count number of named datatypes, and put their * IDs on the object list */ if( (max_index<0 || (int)olist.list_index< max_index) && (types & H5F_OBJ_DATATYPE) && H5I_nmembers(H5I_DATATYPE) > 0 ) { olist.obj_type = H5I_DATATYPE; - H5I_search(H5I_DATATYPE, H5F_get_objects_cb, &olist); + (void)H5I_search(H5I_DATATYPE, H5F_get_objects_cb, &olist); } /* Search through attribute IDs to count number of attributes, and put their * IDs on the object list */ if( (max_index<0 || (int)olist.list_index< max_index) && (types & H5F_OBJ_ATTR) && H5I_nmembers(H5I_ATTR) > 0 ) { olist.obj_type = H5I_ATTR; - H5I_search(H5I_ATTR, H5F_get_objects_cb, &olist); + (void)H5I_search(H5I_ATTR, H5F_get_objects_cb, &olist); } /* Set the number of objects currently open */ - ret_value=obj_id_count; + H5_ASSIGN_OVERFLOW(ret_value,obj_id_count,unsigned,int); #ifdef LATER done: #endif /* LATER */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1153,7 +1156,7 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) H5F_olist_t *olist = (H5F_olist_t *)key; /* Alias for search info */ int ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5F_get_objects_cb); + FUNC_ENTER_NOAPI_NOINIT(H5F_get_objects_cb) assert(obj_ptr); assert(olist); @@ -1173,7 +1176,7 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) /* Check if we've filled up the array */ if(olist->max_index>=0 && (int)olist->list_index>=olist->max_index) - HGOTO_DONE(TRUE); /* Indicate that the iterator should stop */ + HGOTO_DONE(TRUE) /* Indicate that the iterator should stop */ } } else { /* either count opened object IDs or put the IDs on the list */ H5G_entry_t *ent; /* Group entry info for object */ @@ -1195,7 +1198,7 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) ent = NULL; break; default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown data object"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown data object") } if( (!olist->shared && olist->obj_type==H5I_DATATYPE && H5T_is_immutable((H5T_t*)obj_ptr)==FALSE) @@ -1213,12 +1216,12 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) /* Check if we've filled up the array */ if(olist->max_index>=0 && (int)olist->list_index>=olist->max_index) - HGOTO_DONE(TRUE); /* Indicate that the iterator should stop */ + HGOTO_DONE(TRUE) /* Indicate that the iterator should stop */ } } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1240,22 +1243,23 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void** file_handle) +H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle) { H5F_t *file=NULL; herr_t ret_value; - FUNC_ENTER_API(H5Fget_vfd_handle, FAIL); + FUNC_ENTER_API(H5Fget_vfd_handle, FAIL) + H5TRACE3("e","iix",file_id,fapl,file_handle); /* Check args */ assert(file_handle); if(NULL==(file=H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") ret_value=H5F_get_vfd_handle(file, fapl, file_handle); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -1277,18 +1281,18 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5F_get_vfd_handle(H5F_t *file, hid_t fapl, void**file_handle) +H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void**file_handle) { herr_t ret_value; - FUNC_ENTER_NOAPI_NOINIT(H5F_get_vfd_handle); + FUNC_ENTER_NOAPI_NOINIT(H5F_get_vfd_handle) assert(file_handle); if((ret_value=H5FD_get_vfd_handle(file->shared->lf, fapl, file_handle)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver"); + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1309,6 +1313,7 @@ done: * *------------------------------------------------------------------------- */ +/* ARGSUSED */ static int H5F_equal(void *_haystack, hid_t UNUSED id, void *_needle) { @@ -1316,11 +1321,11 @@ H5F_equal(void *_haystack, hid_t UNUSED id, void *_needle) const H5FD_t *needle = (const H5FD_t*)_needle; int retval; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_equal); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_equal) retval = (0==H5FD_cmp(haystack->shared->lf, needle)); - FUNC_LEAVE_NOAPI(retval); + FUNC_LEAVE_NOAPI(retval) } @@ -1351,12 +1356,12 @@ H5F_locate_signature(H5FD_t *file, hid_t dxpl_id) unsigned n, maxpow; haddr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5F_locate_signature); + FUNC_ENTER_NOAPI_NOINIT(H5F_locate_signature) /* Find the least N such that 2^N is larger than the file size */ if (HADDR_UNDEF==(addr=H5FD_get_eof(file)) || HADDR_UNDEF==(eoa=H5FD_get_eoa(file))) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to obtain EOF/EOA value"); + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to obtain EOF/EOA value") for (maxpow=0; addr; maxpow++) addr>>=1; maxpow = MAX(maxpow, 9); @@ -1368,9 +1373,9 @@ H5F_locate_signature(H5FD_t *file, hid_t dxpl_id) for (n=8; n<maxpow; n++) { addr = (8==n) ? 0 : (haddr_t)1 << n; if (H5FD_set_eoa(file, addr+H5F_SIGNATURE_LEN)<0) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to set EOA value for file signature"); + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to set EOA value for file signature") if (H5FD_read(file, H5FD_MEM_SUPER, dxpl_id, addr, H5F_SIGNATURE_LEN, buf)<0) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to read file signature"); + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to read file signature") if (!HDmemcmp(buf, H5F_SIGNATURE, H5F_SIGNATURE_LEN)) break; } @@ -1380,15 +1385,15 @@ H5F_locate_signature(H5FD_t *file, hid_t dxpl_id) * failure. */ if (n>=maxpow) { - H5FD_set_eoa(file, eoa); - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to find a valid file signature"); + (void)H5FD_set_eoa(file, eoa); /* Ignore return value */ + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to find a valid file signature") } /* Set return value */ ret_value=addr; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1418,16 +1423,16 @@ H5Fis_hdf5(const char *name) H5FD_t *file = NULL; htri_t ret_value; - FUNC_ENTER_API(H5Fis_hdf5, FAIL); + FUNC_ENTER_API(H5Fis_hdf5, FAIL) H5TRACE1("b","s",name); /* Check args and all the boring stuff. */ if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified"); + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified") /* Open the file at the virtual file layer */ if (NULL==(file=H5FD_open(name, H5F_ACC_RDONLY, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF))) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file"); + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file") /* The file is an hdf5 file if the hdf5 file signature can be found */ ret_value = (HADDR_UNDEF!=H5F_locate_signature(file, H5AC_ind_dxpl_id)); @@ -1436,9 +1441,9 @@ done: /* Close the file */ if (file) if(H5FD_close(file)<0 && ret_value>=0) - HDONE_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file"); + HDONE_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -1477,10 +1482,10 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id) int n; H5P_genplist_t *plist; /* Property list */ - FUNC_ENTER_NOAPI_NOINIT(H5F_new); + FUNC_ENTER_NOAPI_NOINIT(H5F_new) if (NULL==(f=H5FL_CALLOC(H5F_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if (shared) { f->shared = shared; @@ -1497,53 +1502,53 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id) * to change as the file is being opened. */ if(NULL == (plist = H5I_object(fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list") f->shared->fcpl_id = H5P_copy_plist(plist); /* Get the FCPL values to cache */ if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &f->shared->sizeof_addr)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for address"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for address") if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &f->shared->sizeof_size)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size") if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &f->shared->sym_leaf_k)<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size") if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, &f->shared->btree_k[0])<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes") /* Check for non-default indexed storage B-tree internal 'K' value * and increment the version # of the superblock if it is a non-default * value. */ if(f->shared->btree_k[H5B_ISTORE_ID]!=HDF5_BTREE_ISTORE_IK_DEF) { - int super_vers=HDF5_SUPERBLOCK_VERSION_MAX; /* Super block version */ + unsigned super_vers=HDF5_SUPERBLOCK_VERSION_MAX; /* Super block version */ H5P_genplist_t *c_plist; /* Property list */ if(NULL == (c_plist = H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not property list") if(H5P_set(c_plist, H5F_CRT_SUPER_VERS_NAME, &super_vers) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set superblock version"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set superblock version") } /* end if */ if(NULL == (plist = H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") if(H5P_get(plist, H5F_ACS_META_CACHE_SIZE_NAME, &(f->shared->mdc_nelmts)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get meta data cache size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get meta data cache size") if(H5P_get(plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, &(f->shared->rdcc_nelmts)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache element size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache element size") if(H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache cache size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache cache size") if(H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get preempt read chunk"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get preempt read chunk") if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold))<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment threshold"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment threshold") if(H5P_get(plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment") if(H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME,&(f->shared->gc_ref))<0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get garbage collect reference"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get garbage collect reference") if(H5P_get(plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get sieve buffer size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get sieve buffer size") /* * Create a meta data cache with the specified number of elements. @@ -1551,15 +1556,17 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id) * the access property list should be updated to reflect that. */ if ((n=H5AC_create(f, f->shared->mdc_nelmts))<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create meta data cache"); + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create meta data cache") + f->shared->mdc_nelmts = n; /* Create the chunk cache */ - H5F_istore_init(f); + if(H5F_istore_init(f)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to initialize indexed storage routines") /* Create the file's "open object" information */ if(H5FO_create(f)<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create open object TBBT"); + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to create open object TBBT") } /* end else */ f->shared->nrefs++; @@ -1575,7 +1582,7 @@ done: H5FL_FREE(H5F_t,f); } - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1618,7 +1625,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT(H5F_dest); + FUNC_ENTER_NOAPI_NOINIT(H5F_dest) if (f && 1==f->nrefs) { if (1==f->shared->nrefs) { @@ -1628,7 +1635,10 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) */ if (f->shared->root_grp) { /* Free the ID to name buffer */ - H5G_free_grp_name(f->shared->root_grp); + if(H5G_free_grp_name(f->shared->root_grp)<0) { + HERROR(H5E_FILE, H5E_CANTRELEASE, "problems closing file"); + ret_value = FAIL; /*but keep going*/ + } /* end if */ /* Free the memory for the root group */ H5FL_FREE(H5G_t,f->shared->root_grp); @@ -1656,9 +1666,9 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) /* Destroy file creation properties */ if(H5I_GENPROP_LST != H5I_get_type(f->shared->fcpl_id)) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list"); + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") if((ret_value=H5I_dec_ref(f->shared->fcpl_id)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close property list"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close property list") /* Destroy shared file struct */ if (H5FD_close(f->shared->lf)<0) { @@ -1689,7 +1699,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id) } done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1794,10 +1804,10 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d H5FD_class_t *drvr; /* File driver class info */ hbool_t driver_has_cmp; /*`cmp' callback defined? */ hsize_t userblock_size = 0; - int super_vers; /* Superblock version # */ - int freespace_vers; /* File freespace version # */ - int obj_dir_vers; - int share_head_vers; + unsigned super_vers; /* Superblock version # */ + unsigned freespace_vers; /* File freespace version # */ + unsigned obj_dir_vers; + unsigned share_head_vers; size_t sizeof_addr = 0; size_t sizeof_size = 0; unsigned sym_leaf_k = 0; @@ -1808,7 +1818,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d unsigned chksum; /* Checksum temporary variable */ unsigned i; /* Index variable */ - FUNC_ENTER_NOAPI(H5F_open, NULL); + FUNC_ENTER_NOAPI(H5F_open, NULL) /* * If the driver has a `cmp' method then the driver is capable of @@ -1838,13 +1848,14 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d } else { tent_flags = flags; } + if (NULL==(lf=H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { if (tent_flags == flags) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") H5E_clear(); tent_flags = flags; if (NULL==(lf=H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") } /* end if */ /* Is the file already open? */ @@ -1859,22 +1870,25 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d * exists), or if the new request adds write access (since the * readers don't expect the file to change under them). */ - H5FD_close(lf); + if(H5FD_close(lf)<0) { + file = NULL; /*to prevent destruction of wrong file*/ + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") + } /* end if */ if (flags & H5F_ACC_TRUNC) { file = NULL; /*to prevent destruction of wrong file*/ - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to truncate a file which is already open"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to truncate a file which is already open") } if (flags & H5F_ACC_EXCL) { file = NULL; /*to prevent destruction of wrong file*/ - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file exists"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file exists") } if ((flags & H5F_ACC_RDWR) && 0==(file->intent & H5F_ACC_RDWR)) { file = NULL; /*to prevent destruction of wrong file*/ - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for read-only"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is already open for read-only") } if ((file = H5F_new(file->shared, fcpl_id, fapl_id)) == NULL) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") lf = file->shared->lf; } else if (flags!=tent_flags) { @@ -1883,13 +1897,16 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d * open it are different than the desired flags. Close the tentative * file and open it for real. */ - H5FD_close(lf); + if(H5FD_close(lf)<0) { + file = NULL; /*to prevent destruction of wrong file*/ + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") + } /* end if */ if (NULL==(lf=H5FD_open(name, flags, fapl_id, HADDR_UNDEF))) { file = NULL; /*to prevent destruction of wrong file*/ - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") } if (NULL==(file = H5F_new(NULL, fcpl_id, fapl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") file->shared->flags = flags; file->shared->lf = lf; } else { @@ -1898,7 +1915,8 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d * above is good enough. */ if (NULL==(file = H5F_new(NULL, fcpl_id, fapl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") + file->shared->flags = flags; file->shared->lf = lf; } @@ -2197,15 +2215,16 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to set end-of-address marker for file"); } - /* Decide the file close degree. If it's the first time to open the + /* + * Decide the file close degree. If it's the first time to open the * file, set the degree to access property list value; if it's the * second time or later, verify the access property list value matches * the degree in shared file structure. */ if(NULL == (a_plist = H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") if(H5P_get(a_plist, H5F_CLOSE_DEGREE_NAME, &fc_degree) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file close degree"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file close degree") if(shared->nrefs == 1) { if(fc_degree == H5F_CLOSE_DEFAULT) @@ -2214,9 +2233,9 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d shared->fc_degree = fc_degree; } else if(shared->nrefs > 1) { if(fc_degree==H5F_CLOSE_DEFAULT && shared->fc_degree!=shared->lf->cls->fc_degree) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match"); + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match") if(fc_degree!=H5F_CLOSE_DEFAULT && fc_degree != shared->fc_degree) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match"); + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match") } /* Success */ @@ -2224,8 +2243,9 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d done: if (!ret_value && file) - H5F_dest(file, dxpl_id); /* Don't indicate error here, to leave the error stack with the correct error */ - FUNC_LEAVE_NOAPI(ret_value); + if(H5F_dest(file, dxpl_id)<0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + FUNC_LEAVE_NOAPI(ret_value) } @@ -2284,37 +2304,36 @@ done: *------------------------------------------------------------------------- */ hid_t -H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, - hid_t fapl_id) +H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { H5F_t *new_file = NULL; /*file struct for new file */ hid_t ret_value; /*return value */ - FUNC_ENTER_API(H5Fcreate, FAIL); + FUNC_ENTER_API(H5Fcreate, FAIL) H5TRACE4("i","sIuii",filename,flags,fcpl_id,fapl_id); /* Check/fix arguments */ if (!filename || !*filename) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name") if (flags & ~(H5F_ACC_EXCL|H5F_ACC_TRUNC|H5F_ACC_DEBUG)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags") if ((flags & H5F_ACC_EXCL) && (flags & H5F_ACC_TRUNC)) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "mutually exclusive flags for file creation"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "mutually exclusive flags for file creation") /* Check file creation property list */ if(H5P_DEFAULT == fcpl_id) fcpl_id = H5P_FILE_CREATE_DEFAULT; else if(TRUE != H5P_isa_class(fcpl_id, H5P_FILE_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file create property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file create property list") /* Check the file access property list */ if(H5P_DEFAULT == fapl_id) fapl_id = H5P_FILE_ACCESS_DEFAULT; else if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") /* * Adjust bit flags by turning on the creation bit and making sure that @@ -2322,26 +2341,27 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, * reading and writing. */ if (0==(flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) - flags |= H5F_ACC_EXCL; /*default*/ + flags |= H5F_ACC_EXCL; /*default*/ flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; /* * Create a new file or truncate an existing file. */ if (NULL==(new_file=H5F_open(filename, flags, fcpl_id, fapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file"); - + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file") + /* Get an atom for the file */ if ((ret_value = H5I_register(H5I_FILE, new_file))<0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file"); + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") /* Keep this ID in file object structure */ new_file->file_id = ret_value; done: if (ret_value<0 && new_file) - H5F_close(new_file); - FUNC_LEAVE_API(ret_value); + if(H5F_close(new_file)<0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") + FUNC_LEAVE_API(ret_value) } @@ -2391,36 +2411,37 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) H5F_t *new_file = NULL; /*file struct for new file */ hid_t ret_value; /*return value */ - FUNC_ENTER_API(H5Fopen, FAIL); + FUNC_ENTER_API(H5Fopen, FAIL) H5TRACE3("i","sIui",filename,flags,fapl_id); /* Check/fix arguments. */ if (!filename || !*filename) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name") if ((flags & ~H5F_ACC_PUBLIC_FLAGS) || (flags & H5F_ACC_TRUNC) || (flags & H5F_ACC_EXCL)) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file open flags"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file open flags") if(H5P_DEFAULT == fapl_id) fapl_id = H5P_FILE_ACCESS_DEFAULT; else if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") /* Open the file */ if (NULL==(new_file=H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file"); + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file") /* Get an atom for the file */ if ((ret_value = H5I_register(H5I_FILE, new_file))<0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle"); + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") /* Keep this ID in file object structure */ new_file->file_id = ret_value; done: if (ret_value<0 && new_file) - H5F_close(new_file); - FUNC_LEAVE_API(ret_value); + if(H5F_close(new_file)<0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") + FUNC_LEAVE_API(ret_value) } @@ -2457,57 +2478,57 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) H5G_entry_t *ent = NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Fflush, FAIL); + FUNC_ENTER_API(H5Fflush, FAIL) H5TRACE2("e","iFs",object_id,scope); switch (H5I_get_type(object_id)) { case H5I_FILE: if (NULL==(f=H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") break; case H5I_GROUP: if (NULL==(grp=H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier") ent = H5G_entof(grp); break; case H5I_DATATYPE: if (NULL==(type=H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid type identifier"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid type identifier") ent = H5T_entof(type); break; case H5I_DATASET: if (NULL==(dset=H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") ent = H5D_entof(dset); break; case H5I_ATTR: if (NULL==(attr=H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier") ent = H5A_entof(attr); break; default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") } if (!f) { if (!ent) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not assocated with a file"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not assocated with a file") f = ent->file; } if (!f) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file") /* Flush the file */ if (H5F_flush(f, H5AC_dxpl_id, scope, H5F_FLUSH_NONE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "flush failed"); + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "flush failed") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -2577,14 +2598,14 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) size_t superblock_size;/* Size of superblock, in bytes */ size_t driver_size; /* Size of driver info block, in bytes */ char driver_name[9]; /* Name of driver, for driver info block */ - int super_vers; /* Super block version */ - int freespace_vers; /* Freespace info version */ - int obj_dir_vers; /* Object header info version */ - int share_head_vers;/* Shared header info version */ + unsigned super_vers; /* Super block version */ + unsigned freespace_vers; /* Freespace info version */ + unsigned obj_dir_vers; /* Object header info version */ + unsigned share_head_vers;/* Shared header info version */ H5P_genplist_t *plist; /* Property list */ herr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5F_flush); + FUNC_ENTER_NOAPI_NOINIT(H5F_flush) /* Sanity check arguments */ assert(f); @@ -2597,7 +2618,7 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) * to be flushed. */ if (0 == (H5F_ACC_RDWR & f->shared->flags)) - HGOTO_DONE(SUCCEED); + HGOTO_DONE(SUCCEED) /* Flush other stuff depending on scope */ if (H5F_SCOPE_GLOBAL == scope) { @@ -2859,13 +2880,13 @@ H5F_flush(H5F_t *f, hid_t dxpl_id, H5F_scope_t scope, unsigned flags) /* ...flush file buffers to disk. */ if (H5FD_flush(f->shared->lf, dxpl_id, (unsigned)((flags & H5F_FLUSH_CLOSING) > 0)) < 0) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed"); + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed") /* Check flush errors for children - errors are already on the stack */ ret_value = (nerrors ? FAIL : SUCCEED); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_flush() */ @@ -2914,7 +2935,7 @@ H5F_close(H5F_t *f) unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5F_close, FAIL); + FUNC_ENTER_NOAPI(H5F_close, FAIL) assert(f->nrefs>0); @@ -2925,8 +2946,8 @@ H5F_close(H5F_t *f) if (f->nrefs>1) { /* Decrement reference counts */ if (H5F_dest(f, H5AC_dxpl_id)<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file"); - HGOTO_DONE(SUCCEED); + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") + HGOTO_DONE(SUCCEED) } /* end if */ /* Double-check that this file should be closed */ @@ -2938,7 +2959,7 @@ H5F_close(H5F_t *f) /* if close degree if "semi" and there are objects left open and we are * holding open the file with this file ID, fail now */ if(fc_degree==H5F_CLOSE_SEMI && f->nopen_objs>0 && f->shared->nrefs==1) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, there are objects still open"); + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, there are objects still open") /* * Unmount and close each child before closing the current file. @@ -2946,8 +2967,10 @@ H5F_close(H5F_t *f) assert(NULL==f->mtab.parent); for (u=0; u<f->mtab.nmounts; u++) { f->mtab.child[u].file->mtab.parent = NULL; - H5G_close(f->mtab.child[u].group); - H5F_close(f->mtab.child[u].file); + if(H5G_close(f->mtab.child[u].group)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close child group") + if(H5F_close(f->mtab.child[u].file)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close child file") } /* end if */ f->mtab.nmounts = 0; @@ -2986,10 +3009,10 @@ H5F_close(H5F_t *f) if (!f->closing) f->closing = H5I_register(H5I_FILE_CLOSING, f); - /* Invalidate file ID */ + /* Invalidate file ID */ f->file_id = -1; - HGOTO_DONE(SUCCEED); + HGOTO_DONE(SUCCEED) } else { if (f->closing) { @@ -3023,10 +3046,10 @@ H5F_close(H5F_t *f) /* Invalidate file ID */ f->file_id = -1; - HGOTO_DONE(SUCCEED); + HGOTO_DONE(SUCCEED) } else { if (!f->closing && f->shared->nrefs>1) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, there are objects still open"); + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, there are objects still open") /* Indicate that the file will be closing */ closing=1; @@ -3034,7 +3057,7 @@ H5F_close(H5F_t *f) break; case H5F_CLOSE_STRONG: - /* Forcefully close all opened objects in file */ + /* Force to close all opened objects in file */ while(f->nopen_objs > 0) { int obj_count; /* # of open objects */ hid_t objs[128]; /* Array of objects to close */ @@ -3046,7 +3069,7 @@ H5F_close(H5F_t *f) /* Try to close all the open objects */ for(i=0; i<obj_count; i++) if(H5I_dec_ref(objs[i]) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object"); + HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") } /* end while */ /* Get the list of IDs of open group objects */ @@ -3055,7 +3078,7 @@ H5F_close(H5F_t *f) /* Try to close all the open objects */ for(i=0; i<obj_count; i++) if(H5I_dec_ref(objs[i]) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object"); + HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") } /* end while */ /* Get the list of IDs of open named datatype objects */ @@ -3064,7 +3087,7 @@ H5F_close(H5F_t *f) /* Try to close all the open objects */ for(i=0; i<obj_count; i++) if(H5I_dec_ref(objs[i]) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object"); + HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") } /* end while */ /* Get the list of IDs of open attribute objects */ @@ -3073,7 +3096,7 @@ H5F_close(H5F_t *f) /* Try to close all the open objects */ for(i=0; i<obj_count; i++) if(H5I_dec_ref(objs[i]) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object"); + HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") } /* end while */ } /* end while */ @@ -3082,7 +3105,7 @@ H5F_close(H5F_t *f) break; default: - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, unknown file close degree"); + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, unknown file close degree") } /* end switch */ /* Invalidate file ID */ @@ -3139,10 +3162,10 @@ H5F_close(H5F_t *f) * struct reaches zero then destroy it also. */ if (H5F_dest(f,H5AC_dxpl_id)<0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file"); + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_close() */ @@ -3172,22 +3195,22 @@ H5Fclose(hid_t file_id) { herr_t ret_value = SUCCEED; - FUNC_ENTER_API(H5Fclose, FAIL); + FUNC_ENTER_API(H5Fclose, FAIL) H5TRACE1("e","i",file_id); /* Check/fix arguments. */ if (NULL==H5I_object_verify(file_id,H5I_FILE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file atom"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file atom") /* * Decrement reference count on atom. When it reaches zero the file will * be closed. */ if (H5I_dec_ref (file_id)<0) - HGOTO_ERROR (H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed"); + HGOTO_ERROR (H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -3221,12 +3244,13 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, H5G_entry_t *mp_ent = NULL; /*mount point symbol table entry*/ H5F_t *ancestor = NULL; /*ancestor files */ H5F_t *parent = NULL; /*file containing mount point */ - int lt, rt, md, cmp; /*binary search indices */ + unsigned lt, rt, md; /*binary search indices */ + int cmp; /*binary search comparison value*/ H5G_entry_t *ent = NULL; /*temporary symbol table entry */ H5RS_str_t *name_r; /* Ref-counted version of name */ herr_t ret_value = SUCCEED; /*return value */ - FUNC_ENTER_NOAPI_NOINIT(H5F_mount); + FUNC_ENTER_NOAPI_NOINIT(H5F_mount) assert(loc); assert(name && *name); @@ -3238,15 +3262,15 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, * that the mount wouldn't introduce a cycle in the mount tree. */ if (child->mtab.parent) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "file is already mounted"); + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "file is already mounted") if (NULL==(mount_point=H5G_open(loc, name, dxpl_id))) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found"); + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") parent = H5G_fileof(mount_point); mp_ent = H5G_entof(mount_point); for (ancestor=parent; ancestor; ancestor=ancestor->mtab.parent) { if (ancestor==child) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle"); + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") } /* @@ -3255,7 +3279,7 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, * `md' will be the index where the child should be inserted. */ lt = md = 0; - rt = parent->mtab.nmounts; + rt=parent->mtab.nmounts; cmp = -1; while (lt<rt && cmp) { md = (lt+rt)/2; @@ -3270,7 +3294,7 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, if (cmp>0) md++; if (!cmp) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use"); + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") /* Make room in the table */ if (parent->mtab.nmounts>=parent->mtab.nalloc) { @@ -3278,15 +3302,14 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, H5F_mount_t *x = H5MM_realloc(parent->mtab.child, n*sizeof(parent->mtab.child[0])); if (!x) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") parent->mtab.child = x; parent->mtab.nalloc = n; } /* Insert into table */ - HDmemmove(parent->mtab.child+md+1, - parent->mtab.child+md, - (parent->mtab.nmounts-md)*sizeof(parent->mtab.child[0])); + HDmemmove(parent->mtab.child+md+1, parent->mtab.child+md, + (parent->mtab.nmounts-md)*sizeof(parent->mtab.child[0])); parent->mtab.nmounts++; parent->mtab.child[md].group = mount_point; parent->mtab.child[md].file = child; @@ -3298,14 +3321,16 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child, name_r=H5RS_wrap(name); assert(name_r); if (H5G_replace_name( H5G_UNKNOWN, loc, name_r, NULL, NULL, NULL, OP_MOUNT )<0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name"); - H5RS_decr(name_r); + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") + if(H5RS_decr(name_r)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement name string") done: if (ret_value<0 && mount_point) - H5G_close(mount_point); + if(H5G_close(mount_point)<0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close mounted group") - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -3345,9 +3370,10 @@ H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id) H5G_entry_t *ent = NULL; /*temporary symbol table entry */ herr_t ret_value = FAIL; /*return value */ unsigned i; /*coutners */ - int lt, rt, md=(-1), cmp; /*binary search indices */ + unsigned lt, rt, md=0; /*binary search indices */ + int cmp; /*binary search comparison value*/ - FUNC_ENTER_NOAPI_NOINIT(H5F_unmount); + FUNC_ENTER_NOAPI_NOINIT(H5F_unmount) assert(loc); assert(name && *name); @@ -3358,7 +3384,7 @@ H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id) * then we must have found the mount point. */ if (NULL==(mounted=H5G_open(loc, name, dxpl_id))) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found"); + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found") child = H5G_fileof(mounted); mnt_ent = H5G_entof(mounted); ent = H5G_entof(child->shared->root_grp); @@ -3374,17 +3400,17 @@ H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id) if (parent->mtab.child[i].file==child) { /* Search the open IDs replace names to reflect unmount operation */ if (H5G_replace_name( H5G_UNKNOWN, mnt_ent, mnt_ent->user_path_r, NULL, NULL, NULL, OP_UNMOUNT )<0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name "); + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name ") /* Unmount the child */ parent->mtab.nmounts -= 1; - H5G_close(parent->mtab.child[i].group); + if(H5G_close(parent->mtab.child[i].group)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close unmounted group") child->mtab.parent = NULL; - H5F_close(child); - HDmemmove(parent->mtab.child+i, - parent->mtab.child+i+1, - ((parent->mtab.nmounts-i)* - sizeof(parent->mtab.child[0]))); + if(H5F_close(child)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close unmounted file") + HDmemmove(parent->mtab.child+i, parent->mtab.child+i+1, + (parent->mtab.nmounts-i)* sizeof(parent->mtab.child[0])); ret_value = SUCCEED; } } @@ -3397,7 +3423,7 @@ H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id) */ parent = child; /*we guessed wrong*/ lt = 0; - rt = parent->mtab.nmounts; + rt = parent->mtab.nmounts; cmp = -1; while (lt<rt && cmp) { md = (lt+rt)/2; @@ -3410,25 +3436,26 @@ H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id) } } if (cmp) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point"); + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") /* Unmount the child */ parent->mtab.nmounts -= 1; - H5G_close(parent->mtab.child[md].group); + if(H5G_close(parent->mtab.child[md].group)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close unmounted group") parent->mtab.child[md].file->mtab.parent = NULL; - H5F_close(parent->mtab.child[md].file); - HDmemmove(parent->mtab.child+md, - parent->mtab.child+md+1, - (parent->mtab.nmounts-md)*sizeof(parent->mtab.child[0])); + if(H5F_close(parent->mtab.child[md].file)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close unmounted file") + HDmemmove(parent->mtab.child+md, parent->mtab.child+md+1, + (parent->mtab.nmounts-md)*sizeof(parent->mtab.child[0])); ret_value = SUCCEED; } done: if (mounted) if(H5G_close(mounted)<0 && ret_value>=0) - HDONE_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "can't close group"); + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close group") - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -3454,11 +3481,12 @@ herr_t H5F_mountpoint(H5G_entry_t *find/*in,out*/) { H5F_t *parent = find->file; - int lt, rt, md=(-1), cmp; + unsigned lt, rt, md=0; + int cmp; H5G_entry_t *ent = NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5F_mountpoint, FAIL); + FUNC_ENTER_NOAPI(H5F_mountpoint, FAIL) assert(find); @@ -3491,7 +3519,8 @@ H5F_mountpoint(H5G_entry_t *find/*in,out*/) ent = H5G_entof(parent->mtab.child[md].file->shared->root_grp); /* Don't lose the user path of the group when we copy the root group's entry */ - H5G_ent_copy(find,ent,H5G_COPY_LIMITED); + if(H5G_ent_copy(find,ent,H5G_COPY_LIMITED)<0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "unable to copy group entry") /* Switch to child's file */ parent = ent->file; @@ -3499,7 +3528,7 @@ H5F_mountpoint(H5G_entry_t *find/*in,out*/) } while (!cmp); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -3523,7 +3552,7 @@ H5F_has_mount(const H5F_t *file) { htri_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5F_has_mount, FAIL); + FUNC_ENTER_NOAPI(H5F_has_mount, FAIL) assert(file); @@ -3533,7 +3562,7 @@ H5F_has_mount(const H5F_t *file) ret_value=FALSE; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_has_mount() */ @@ -3557,7 +3586,7 @@ H5F_is_mount(const H5F_t *file) { htri_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5F_is_mount, FAIL); + FUNC_ENTER_NOAPI(H5F_is_mount, FAIL) assert(file); @@ -3567,7 +3596,7 @@ H5F_is_mount(const H5F_t *file) ret_value=FALSE; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_is_mount() */ @@ -3593,28 +3622,28 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) H5F_t *child = NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Fmount, FAIL); + FUNC_ENTER_API(H5Fmount, FAIL) H5TRACE4("e","isii",loc_id,name,child_id,plist_id); /* Check arguments */ if (NULL==(loc=H5G_loc(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if (NULL==(child=H5I_object_verify(child_id,H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") if(H5P_DEFAULT == plist_id) plist_id = H5P_MOUNT_DEFAULT; else if(TRUE != H5P_isa_class(plist_id, H5P_MOUNT)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list") /* Do the mount */ if (H5F_mount(loc, name, child, plist_id, H5AC_dxpl_id)<0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file"); + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -3645,21 +3674,21 @@ H5Funmount(hid_t loc_id, const char *name) H5G_entry_t *loc = NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Funmount, FAIL); + FUNC_ENTER_API(H5Funmount, FAIL) H5TRACE2("e","is",loc_id,name); /* Check args */ if (NULL==(loc=H5G_loc(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Unmount */ if (H5F_unmount(loc, name, H5AC_dxpl_id)<0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file"); + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } @@ -3692,29 +3721,30 @@ H5Freopen(hid_t file_id) H5F_t *new_file=NULL; hid_t ret_value; - FUNC_ENTER_API(H5Freopen, FAIL); + FUNC_ENTER_API(H5Freopen, FAIL) H5TRACE1("i","i",file_id); if (NULL==(old_file=H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Get a new "top level" file struct, sharing the same "low level" file struct */ if (NULL==(new_file=H5F_new(old_file->shared, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT))) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file"); + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") /* Keep old file's read/write intent in new file */ new_file->intent=old_file->intent; if ((ret_value=H5I_register(H5I_FILE, new_file))<0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle"); + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") - /* Keep this ID in file object structure */ - new_file->file_id = ret_value; + /* Keep this ID in file object structure */ + new_file->file_id = ret_value; done: if (ret_value<0 && new_file) - H5F_close(new_file); - FUNC_LEAVE_API(ret_value); + if(H5F_close(new_file)<0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") + FUNC_LEAVE_API(ret_value) } @@ -3738,11 +3768,11 @@ unsigned H5F_get_intent(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_intent); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_intent) assert(f); - FUNC_LEAVE_NOAPI(f->intent); + FUNC_LEAVE_NOAPI(f->intent) } @@ -3769,12 +3799,12 @@ size_t H5F_sizeof_addr(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sizeof_addr); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sizeof_addr) assert(f); assert(f->shared); - FUNC_LEAVE_NOAPI(f->shared->sizeof_addr); + FUNC_LEAVE_NOAPI(f->shared->sizeof_addr) } @@ -3801,12 +3831,12 @@ size_t H5F_sizeof_size(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sizeof_size); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sizeof_size) assert(f); assert(f->shared); - FUNC_LEAVE_NOAPI(f->shared->sizeof_size); + FUNC_LEAVE_NOAPI(f->shared->sizeof_size) } @@ -3834,12 +3864,12 @@ H5F_sizeof_size(const H5F_t *f) unsigned H5F_sym_leaf_k(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sym_leaf_k); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_sym_leaf_k) assert(f); assert(f->shared); - FUNC_LEAVE_NOAPI(f->shared->sym_leaf_k); + FUNC_LEAVE_NOAPI(f->shared->sym_leaf_k) } @@ -3864,17 +3894,17 @@ unsigned H5F_sym_leaf_k(const H5F_t *f) * Added this header and removed unused ret_value variable. *------------------------------------------------------------------------- */ -int +unsigned H5F_Kvalue(const H5F_t *f, const H5B_class_t *type) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_Kvalue); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_Kvalue) assert(f); assert(f->shared); assert(type); - FUNC_LEAVE_NOAPI(f->shared->btree_k[type->id]); + FUNC_LEAVE_NOAPI(f->shared->btree_k[type->id]) } /* end H5F_Kvalue() */ @@ -3898,13 +3928,13 @@ hid_t H5F_get_driver_id(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_driver_id); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_get_driver_id) assert(f); assert(f->shared); assert(f->shared->lf); - FUNC_LEAVE_NOAPI(f->shared->lf->driver_id); + FUNC_LEAVE_NOAPI(f->shared->lf->driver_id) } @@ -3929,7 +3959,7 @@ H5F_get_fileno(const H5F_t *f, unsigned long *filenum) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5F_get_fileno, FAIL); + FUNC_ENTER_NOAPI(H5F_get_fileno, FAIL) assert(f); assert(f->shared); @@ -3938,10 +3968,10 @@ H5F_get_fileno(const H5F_t *f, unsigned long *filenum) /* Retrieve the file's serial number */ if(H5FD_get_fileno(f->shared->lf,filenum)<0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "can't retrieve fileno"); + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "can't retrieve fileno") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_fileno() */ @@ -4004,7 +4034,7 @@ H5F_get_base_addr(const H5F_t *f) *------------------------------------------------------------------------- */ herr_t -H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, +H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, void *buf/*out*/) { haddr_t abs_addr; @@ -4060,7 +4090,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, +H5F_block_write(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, const void *buf) { haddr_t abs_addr; @@ -4233,7 +4263,7 @@ H5F_addr_pack(H5F_t UNUSED *f, haddr_t *addr_p/*out*/, *------------------------------------------------------------------------- */ herr_t -H5F_sieve_overlap_clear(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t size) +H5F_sieve_overlap_clear(const H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t size) { herr_t ret_value=SUCCEED; /* Return value */ diff --git a/src/H5Fistore.c b/src/H5Fistore.c index 2775548..bf4cc66 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -944,7 +944,7 @@ H5F_istore_flush_entry(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, alloc = ent->alloc_size; /* Should the chunk be filtered before writing it to disk? */ - if (ent->pline.nfilters) { + if (ent->pline.nused) { if (!reset) { /* * Copy the chunk to a new buffer before running it through @@ -1350,7 +1350,7 @@ static void * H5F_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const H5O_layout_t *layout, const H5O_pline_t *pline, const H5O_fill_t *fill, H5D_fill_time_t fill_time, H5F_istore_ud1_t *udata, - const hssize_t offset[], hbool_t relax, + const H5D_storage_t *store, hbool_t relax, unsigned *idx_hint/*in,out*/) { int idx=0; /*hash index number */ @@ -1373,18 +1373,14 @@ H5F_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, con /* Search for the chunk in the cache */ if (rdcc->nslots>0) { - for (u=0, temp_idx=0; u<layout->u.chunk.ndims; u++) { - temp_idx += offset[u]; - temp_idx *= layout->u.chunk.dim[u]; - } - temp_idx += (hsize_t)(layout->u.chunk.addr); + temp_idx = store->chunk.index + (hsize_t)(layout->u.chunk.addr); idx=H5F_HASH(f,temp_idx); ent = rdcc->slot[idx]; if (ent && layout->u.chunk.ndims==ent->layout.u.chunk.ndims && H5F_addr_eq(layout->u.chunk.addr, ent->layout.u.chunk.addr)) { for (u=0, found=TRUE; u<ent->layout.u.chunk.ndims; u++) { - if (offset[u]!=ent->offset[u]) { + if (store->chunk.offset[u]!=ent->offset[u]) { found = FALSE; break; } @@ -1427,7 +1423,7 @@ H5F_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, con * 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. */ - chunk_addr = H5F_istore_get_addr(f, dxpl_id, layout, offset, udata); + chunk_addr = H5F_istore_get_addr(f, dxpl_id, layout, store->chunk.offset, udata); } /* end else */ if (H5F_addr_defined(chunk_addr)) { @@ -1444,7 +1440,7 @@ H5F_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, con if (H5F_block_read(f, H5FD_MEM_DRAW, chunk_addr, udata->key.nbytes, dxpl_id, chunk)<0) HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL, "unable to read raw data chunk"); - if (pline->nfilters) + if (pline->nused) if (H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &(udata->key.filter_mask), dxpl_cache->err_detect, dxpl_cache->filter_cb, &(udata->key.nbytes), &chunk_alloc, &chunk)<0) { HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL, "data pipeline read failed"); @@ -1512,7 +1508,7 @@ H5F_istore_lock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, con H5O_copy(H5O_LAYOUT_ID, layout, &ent->layout); H5O_copy(H5O_PLINE_ID, pline, &ent->pline); for (u=0; u<layout->u.chunk.ndims; u++) - ent->offset[u] = offset[u]; + ent->offset[u] = store->chunk.offset[u]; ent->rd_count = chunk_size; ent->wr_count = chunk_size; ent->chunk = chunk; @@ -1616,7 +1612,7 @@ done: static herr_t H5F_istore_unlock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const H5O_layout_t *layout, const H5O_pline_t *pline, hbool_t dirty, - const hssize_t offset[], unsigned *idx_hint, uint8_t *chunk, size_t naccessed) + const H5D_storage_t *store, unsigned idx_hint, uint8_t *chunk, size_t naccessed) { H5F_rdcc_t *rdcc = &(f->shared->rdcc); H5F_rdcc_ent_t *ent = NULL; @@ -1625,13 +1621,13 @@ H5F_istore_unlock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_istore_unlock); - if (UINT_MAX==*idx_hint) { + if (UINT_MAX==idx_hint) { /*not in cache*/ } else { - assert(*idx_hint<rdcc->nslots); - assert(rdcc->slot[*idx_hint]); - assert(rdcc->slot[*idx_hint]->chunk==chunk); - found = *idx_hint; + assert(idx_hint<rdcc->nslots); + assert(rdcc->slot[idx_hint]); + assert(rdcc->slot[idx_hint]->chunk==chunk); + found = idx_hint; } if (found<0) { @@ -1649,7 +1645,7 @@ H5F_istore_unlock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, H5O_copy (H5O_LAYOUT_ID, layout, &x.layout); H5O_copy (H5O_PLINE_ID, pline, &x.pline); for (u=0; u<layout->u.chunk.ndims; u++) - x.offset[u] = offset[u]; + x.offset[u] = store->chunk.offset[u]; assert(layout->u.chunk.size>0); H5_ASSIGN_OVERFLOW(x.chunk_size,layout->u.chunk.size,hsize_t,size_t); x.alloc_size = x.chunk_size; @@ -1696,7 +1692,7 @@ H5F_istore_unlock(H5F_t *f, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, */ ssize_t H5F_istore_readvv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, - const H5O_layout_t *layout, const struct H5D_dcpl_cache_t *dcpl_cache, hssize_t chunk_coords[], + const H5O_layout_t *layout, const struct H5D_dcpl_cache_t *dcpl_cache, const H5D_storage_t *store, size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], void *buf) @@ -1722,7 +1718,7 @@ H5F_istore_readvv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxp #ifndef NDEBUG for (u=0; u<layout->u.chunk.ndims; u++) - assert(chunk_coords[u]>=0); /*negative coordinates not supported (yet) */ + assert(store->chunk.offset[u]>=0); /*negative coordinates not supported (yet) */ #endif /* Get the address of this chunk on disk */ @@ -1731,7 +1727,7 @@ HDfprintf(stderr,"%s: chunk_coords={",FUNC); for(u=0; u<layout->u.chunk.ndims; u++) HDfprintf(stderr,"%Hd%s",chunk_coords[u],(u<(layout->u.chunk.ndims-1) ? ", " : "}\n")); #endif /* QAK */ - chunk_addr=H5F_istore_get_addr(f, dxpl_id, layout, chunk_coords, &udata); + chunk_addr=H5F_istore_get_addr(f, dxpl_id, layout, store->chunk.offset, &udata); #ifdef QAK HDfprintf(stderr,"%s: chunk_addr=%a, chunk_size=%Hu\n",FUNC,chunk_addr,layout->u.chunk.size); HDfprintf(stderr,"%s: chunk_len_arr[%Zu]=%Zu\n",FUNC,*chunk_curr_seq,chunk_len_arr[*chunk_curr_seq]); @@ -1746,7 +1742,7 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a * for the chunk has been defined, then don't load the chunk into the * cache, just write the data to it directly. */ - if (layout->u.chunk.size>f->shared->rdcc_nbytes && dcpl_cache->pline.nfilters==0 && + if (layout->u.chunk.size>f->shared->rdcc_nbytes && dcpl_cache->pline.nused==0 && chunk_addr!=HADDR_UNDEF) { if ((ret_value=H5F_contig_readvv(f, (hsize_t)layout->u.chunk.size, chunk_addr, chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, dxpl_id, buf))<0) HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "unable to read raw data to file"); @@ -1761,7 +1757,7 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a * chunk. */ if (NULL==(chunk=H5F_istore_lock(f, dxpl_cache, dxpl_id, layout, &dcpl_cache->pline, &dcpl_cache->fill, dcpl_cache->fill_time, - &udata, chunk_coords, FALSE, &idx_hint))) + &udata, store, FALSE, &idx_hint))) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk"); /* Use the vectorized memory copy routine to do actual work */ @@ -1770,7 +1766,7 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a H5_CHECK_OVERFLOW(naccessed,ssize_t,size_t); if (H5F_istore_unlock(f, dxpl_cache, dxpl_id, layout, &dcpl_cache->pline, FALSE, - chunk_coords, &idx_hint, chunk, (size_t)naccessed)<0) + store, idx_hint, chunk, (size_t)naccessed)<0) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to unlock raw data chunk"); /* Set return value */ @@ -1800,7 +1796,7 @@ done: ssize_t H5F_istore_writevv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const H5O_layout_t *layout, - const struct H5D_dcpl_cache_t *dcpl_cache, hssize_t chunk_coords[], + const struct H5D_dcpl_cache_t *dcpl_cache, const H5D_storage_t *store, size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], const void *buf) @@ -1826,7 +1822,7 @@ H5F_istore_writevv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, #ifndef NDEBUG for (u=0; u<layout->u.chunk.ndims; u++) - assert(chunk_coords[u]>=0); /*negative coordinates not supported (yet) */ + assert(store->chunk.offset[u]>=0); /*negative coordinates not supported (yet) */ #endif /* Get the address of this chunk on disk */ @@ -1835,7 +1831,7 @@ HDfprintf(stderr,"%s: chunk_coords={",FUNC); for(u=0; u<layout->u.chunk.ndims; u++) HDfprintf(stderr,"%Hd%s",chunk_coords[u],(u<(layout->u.chunk.ndims-1) ? ", " : "}\n")); #endif /* QAK */ - chunk_addr=H5F_istore_get_addr(f, dxpl_id, layout, chunk_coords, &udata); + chunk_addr=H5F_istore_get_addr(f, dxpl_id, layout, store->chunk.offset, &udata); #ifdef QAK HDfprintf(stderr,"%s: chunk_addr=%a, chunk_size=%Hu\n",FUNC,chunk_addr,layout->u.chunk.size); HDfprintf(stderr,"%s: chunk_len_arr[%Zu]=%Zu\n",FUNC,*chunk_curr_seq,chunk_len_arr[*chunk_curr_seq]); @@ -1855,11 +1851,11 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a * writing to other elements in the same chunk. Do a direct * write-through of only the elements requested. */ - if ((layout->u.chunk.size>f->shared->rdcc_nbytes && dcpl_cache->pline.nfilters==0 && chunk_addr!=HADDR_UNDEF) + if ((layout->u.chunk.size>f->shared->rdcc_nbytes && dcpl_cache->pline.nused==0 && chunk_addr!=HADDR_UNDEF) || (IS_H5FD_MPI(f) && (H5F_ACC_RDWR & f->shared->flags))) { #ifdef H5_HAVE_PARALLEL /* Additional sanity check when operating in parallel */ - if (chunk_addr==HADDR_UNDEF || dcpl_cache->pline.nfilters>0) + if (chunk_addr==HADDR_UNDEF || dcpl_cache->pline.nused>0) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to locate raw data chunk"); #endif /* H5_HAVE_PARALLEL */ if ((ret_value=H5F_contig_writevv(f, (hsize_t)layout->u.chunk.size, chunk_addr, chunk_max_nseq, chunk_curr_seq, chunk_len_arr, chunk_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, dxpl_id, buf))<0) @@ -1881,7 +1877,7 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a relax = FALSE; if (NULL==(chunk=H5F_istore_lock(f, dxpl_cache, dxpl_id, layout, &dcpl_cache->pline, &dcpl_cache->fill, dcpl_cache->fill_time, - &udata, chunk_coords, relax, &idx_hint))) + &udata, store, relax, &idx_hint))) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk"); /* Use the vectorized memory copy routine to do actual work */ @@ -1890,7 +1886,7 @@ HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_a H5_CHECK_OVERFLOW(naccessed,ssize_t,size_t); if (H5F_istore_unlock(f, dxpl_cache, dxpl_id, layout, &dcpl_cache->pline, TRUE, - chunk_coords, &idx_hint, chunk, (size_t)naccessed)<0) + store, idx_hint, chunk, (size_t)naccessed)<0) HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "uanble to unlock raw data chunk"); /* Set return value */ @@ -1971,16 +1967,33 @@ done: *------------------------------------------------------------------------- */ hsize_t -H5F_istore_allocated(H5F_t *f, hid_t dxpl_id, unsigned ndims, haddr_t addr) +H5F_istore_allocated(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout) { + H5F_rdcc_t *rdcc = &(f->shared->rdcc); /*raw data chunk cache */ + H5F_rdcc_ent_t *ent; /*cache entry */ + H5D_dxpl_cache_t dxpl_cache; /* Cached data transfer properties */ H5F_istore_ud1_t udata; hsize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5F_istore_allocated, 0); + /* Fill the DXPL cache values for later use */ + if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't fill dxpl cache") + + /* Search for cached chunks that haven't been written out */ + for(ent = rdcc->head; ent; ent = ent->next) { + /* Make certain we are dealing with the correct B-tree, etc */ + if (H5F_addr_eq(layout->u.chunk.addr, ent->layout.u.chunk.addr)) { + /* Flush the chunk out to disk, to make certain the size is correct later */ + if (H5F_istore_flush_entry(f, &dxpl_cache, dxpl_id, ent, FALSE)<0) + HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, 0, "cannot flush indexed storage buffer"); + } /* end if */ + } /* end for */ + HDmemset(&udata, 0, sizeof udata); - udata.mesg.u.chunk.ndims = ndims; - if (H5B_iterate(f, dxpl_id, H5B_ISTORE, H5F_istore_iter_allocated, addr, &udata)<0) + udata.mesg.u.chunk.ndims = layout->u.chunk.ndims; + if (H5B_iterate(f, dxpl_id, H5B_ISTORE, H5F_istore_iter_allocated, layout->u.chunk.addr, &udata)<0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree"); /* Set return value */ @@ -1988,7 +2001,7 @@ H5F_istore_allocated(H5F_t *f, hid_t dxpl_id, unsigned ndims, haddr_t addr) done: FUNC_LEAVE_NOAPI(ret_value); -} +} /* end H5F_istore_allocated() */ /*------------------------------------------------------------------------- @@ -2074,7 +2087,7 @@ H5F_istore_chunk_alloc(size_t size, const H5O_pline_t *pline) assert(size); assert(pline); - if(pline->nfilters>0) + if(pline->nused>0) ret_value=H5MM_malloc(size); else ret_value=H5FL_BLK_MALLOC(chunk,size); @@ -2107,7 +2120,7 @@ H5F_istore_chunk_xfree(void *chk, const H5O_pline_t *pline) assert(pline); if(chk) { - if(pline->nfilters>0) + if(pline->nused>0) H5MM_xfree(chk); else H5FL_BLK_FREE(chunk,chk); @@ -2297,7 +2310,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, } /* end else */ /* Check if there are filters which need to be applied to the chunk */ - if (pline.nfilters>0) { + if (pline.nused>0) { unsigned filter_mask=0; size_t buf_size=(size_t)chunk_size; size_t nbytes=(size_t)chunk_size; @@ -2517,7 +2530,7 @@ H5F_istore_prune_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, H5F_rdcc_t *rdcc = &(f->shared->rdcc); /*raw data chunk cache */ H5F_rdcc_ent_t *ent = NULL, *next = NULL; /*cache entry */ unsigned u; /*counters */ - int found = 0; /*remove this entry */ + int found; /*remove this entry */ H5F_istore_ud1_t udata; /*B-tree pass-through */ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */ herr_t ret_value=SUCCEED; /* Return value */ @@ -2540,13 +2553,12 @@ H5F_istore_prune_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, * and release them from the linked list raw data cache *------------------------------------------------------------------------- */ + found = 0; for(ent = rdcc->head; ent; ent = next) { next = ent->next; /* Make certain we are dealing with the correct B-tree, etc */ - if (layout->u.chunk.ndims==ent->layout.u.chunk.ndims && - H5F_addr_eq(layout->u.chunk.addr, ent->layout.u.chunk.addr)) { - found = 0; + if (H5F_addr_eq(layout->u.chunk.addr, ent->layout.u.chunk.addr)) { for(u = 0; u < ent->layout.u.chunk.ndims - 1; u++) { if((hsize_t)ent->offset[u] > curr_dims[u]) { found = 1; @@ -2556,17 +2568,18 @@ H5F_istore_prune_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, } /* end if */ if(found) { -#if defined (H5F_ISTORE_DEBUG) - HDfputs("cache:remove:[", stdout); - for(u = 0; u < ent->layout.u.chunk.ndims - 1; u++) { - HDfprintf(stdout, "%s%Hd", u ? ", " : "", ent->offset[u]); - } - HDfputs("]\n", stdout); +#ifdef H5F_ISTORE_DEBUG + HDfputs("cache:remove:[", stderr); + for(u = 0; u < ent->layout.u.chunk.ndims - 1; u++) + HDfprintf(stderr, "%s%Hd", u ? ", " : "", ent->offset[u]); + HDfputs("]\n", stderr); #endif /* Preempt the entry from the cache, but do not flush it to disk */ if(H5F_istore_preempt(f, dxpl_cache, dxpl_id, ent, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to preempt chunk"); + + found=0; } } @@ -2627,12 +2640,10 @@ H5F_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t UNUSED a /* Figure out what chunks are no longer in use for the specified extent and release them */ for(u = 0; u < bt_udata->mesg.u.chunk.ndims - 1; u++) if((hsize_t)lt_key->offset[u] > bt_udata->dims[u]) { -#if defined (H5F_ISTORE_DEBUG) +#ifdef H5F_ISTORE_DEBUG HDfputs("b-tree:remove:[", bt_udata->stream); - for(u = 0; u < bt_udata->mesg.u.chunk.ndims - 1; u++) { - HDfprintf(bt_udata->stream, "%s%Hd", u ? ", " : "", - lt_key->offset[u]); - } + for(u = 0; u < bt_udata->mesg.u.chunk.ndims - 1; u++) + HDfprintf(bt_udata->stream, "%s%Hd", u ? ", " : "", lt_key->offset[u]); HDfputs("]\n", bt_udata->stream); #endif @@ -2740,6 +2751,8 @@ H5F_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca H5S_t *space_chunk = NULL; /*dataspace for a chunk */ hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; /*current chunk dimensions */ hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */ + hsize_t chunks[H5O_LAYOUT_NDIMS]; /*current number of chunks in each dimension */ + hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of elements in each dimension */ int srank; /*current # of dimensions (signed) */ unsigned rank; /*current # of dimensions */ int i, carry; /*counters */ @@ -2748,6 +2761,7 @@ H5F_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca H5O_pline_t pline; /* I/O pipeline information */ H5O_fill_t fill; /* Fill value information */ H5D_fill_time_t fill_time; /* Fill time information */ + H5D_storage_t store; /* Dataset storage information */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5F_istore_initialize_by_extent, FAIL); @@ -2777,10 +2791,18 @@ H5F_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca H5_ASSIGN_OVERFLOW(rank,srank,int,unsigned); /* Copy current dimensions */ - for(u = 0; u < rank; u++) + for(u = 0; u < rank; u++) { size[u] = curr_dims[u]; + + /* Round up to the next integer # of chunks, to accomodate partial chunks */ + chunks[u] = ((curr_dims[u]+layout->u.chunk.dim[u])-1) / layout->u.chunk.dim[u]; + } /* end for */ size[u] = layout->u.chunk.dim[u]; + /* Get the "down" sizes for each dimension */ + if(H5V_array_down(rank,chunks,down_chunks)<0) + HGOTO_ERROR (H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute 'down' sizes") + /* Create a data space for a chunk & set the extent */ for(u = 0; u < rank; u++) chunk_dims[u] = layout->u.chunk.dim[u]; @@ -2822,8 +2844,13 @@ H5F_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca if(found) { + /* Calculate the index of this chunk */ + if(H5V_chunk_index(rank,chunk_offset,layout->u.chunk.dim,down_chunks,&store.chunk.index)<0) + HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") + + store.chunk.offset=chunk_offset; if(NULL == (chunk = H5F_istore_lock(f, dxpl_cache, dxpl_id, layout, &pline, &fill, fill_time, - NULL, chunk_offset, FALSE, &idx_hint))) + NULL, &store, FALSE, &idx_hint))) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk"); if(H5S_select_all(space_chunk,1) < 0) @@ -2832,7 +2859,7 @@ H5F_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca for(u = 0; u < rank; u++) count[u] = MIN((idx_cur[u] + 1) * layout->u.chunk.dim[u], size[u] - chunk_offset[u]); -#if defined (H5F_ISTORE_DEBUG) +#ifdef H5F_ISTORE_DEBUG HDfputs("cache:initialize:offset:[", stdout); for(u = 0; u < layout->u.chunk.ndims - 1; u++) HDfprintf(stdout, "%s%Hd", u ? ", " : "", chunk_offset[u]); @@ -2856,7 +2883,7 @@ H5F_istore_initialize_by_extent(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_ca HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed"); if(H5F_istore_unlock(f, dxpl_cache, dxpl_id, layout, &pline, TRUE, - chunk_offset, &idx_hint, chunk, (size_t)naccessed) < 0) + &store, idx_hint, chunk, (size_t)naccessed) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to unlock raw data chunk"); } /*found */ @@ -2917,8 +2944,8 @@ H5F_istore_delete(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout) /* Is the chunk to be deleted this cache entry? */ if(layout->u.chunk.addr==ent->layout.u.chunk.addr) /* Remove entry without flushing */ - if (H5F_istore_preempt(f, &dxpl_cache, dxpl_id, ent, FALSE )<0) - HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks"); + if (H5F_istore_preempt(f, &dxpl_cache, dxpl_id, ent, FALSE )<0) + HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks"); } /* end for */ /* Set up user data for B-tree deletion */ @@ -2936,6 +2963,111 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_istore_update_cache + * + * Purpose: Update any cached chunks index values after the dataspace + * size has changed + * + * Return: Success: Non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Saturday, May 29, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_istore_update_cache(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout, const H5S_t * space) +{ + H5F_rdcc_t *rdcc = &(f->shared->rdcc); /*raw data chunk cache */ + H5F_rdcc_ent_t *ent, *next; /*cache entry */ + H5F_rdcc_ent_t *old_ent; /* Old cache entry */ + H5D_dxpl_cache_t dxpl_cache; /* Cached data transfer properties */ + int srank; /*current # of dimensions (signed) */ + unsigned rank; /*current # of dimensions */ + hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */ + hsize_t chunks[H5O_LAYOUT_NDIMS]; /*current number of chunks in each dimension */ + hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of elements in each dimension */ + hsize_t idx; /* Chunk index */ + hsize_t temp_idx; /* temporary index number */ + unsigned old_idx; /* Previous index number */ + unsigned u; /*counters */ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5F_istore_update_cache, FAIL); + + /* Check args */ + assert(f); + assert(layout && H5D_CHUNKED == layout->type); + assert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); + assert(space); + + /* Go get the rank & dimensions */ + if((srank = H5S_get_simple_extent_dims(space, curr_dims, NULL)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions"); + H5_ASSIGN_OVERFLOW(rank,srank,int,unsigned); + + /* Copy current dimensions */ + for(u = 0; u < rank; u++) { + /* Round up to the next integer # of chunks, to accomodate partial chunks */ + chunks[u] = ((curr_dims[u]+layout->u.chunk.dim[u])-1) / layout->u.chunk.dim[u]; + } /* end for */ + + /* Get the "down" sizes for each dimension */ + if(H5V_array_down(rank,chunks,down_chunks)<0) + HGOTO_ERROR (H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute 'down' sizes") + + /* Fill the DXPL cache values for later use */ + if (H5D_get_dxpl_cache(dxpl_id,&dxpl_cache)<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") + + /* Recompute the index for each cached chunk that is in a dataset */ + for(ent = rdcc->head; ent; ent = next) { + next=ent->next; + + /* Make certain we are dealing with the correct B-tree, etc */ + if (H5F_addr_eq(layout->u.chunk.addr, ent->layout.u.chunk.addr)) { + /* Calculate the index of this chunk */ + if(H5V_chunk_index(rank,ent->offset,layout->u.chunk.dim,down_chunks,&idx)<0) + HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index") + + /* Compute the index for the chunk entry */ + temp_idx = idx + (hsize_t)(layout->u.chunk.addr); + old_idx=ent->idx; /* Save for later */ + ent->idx=H5F_HASH(f,temp_idx); + + if(old_idx!=ent->idx) { + /* Check if there is already a chunk at this chunk's new location */ + old_ent = rdcc->slot[ent->idx]; + if(old_ent!=NULL) { + assert(old_ent->locked==0); + + /* Check if we are removing the entry we would walk to next */ + if(old_ent==next) + next=old_ent->next; + + /* Remove the old entry from the cache */ + if (H5F_istore_preempt(f, &dxpl_cache, dxpl_id, old_ent, TRUE )<0) + HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks"); + } /* end if */ + + /* Insert this chunk into correct location in hash table */ + rdcc->slot[ent->idx]=ent; + + /* Null out previous location */ + rdcc->slot[old_idx]=NULL; + } /* end if */ + } /* end if */ + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5F_istore_update_cache() */ + + +/*------------------------------------------------------------------------- * Function: H5F_istore_dump_btree * * Purpose: Prints information about the storage B-tree to the specified diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index d33d553..c3169cd 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -117,7 +117,7 @@ typedef struct H5F_file_t { size_t sizeof_addr; /* Size of addresses in file */ size_t sizeof_size; /* Size of offsets in file */ unsigned sym_leaf_k; /* Size of leaves in symbol tables */ - int btree_k[H5B_NUM_BTREE_ID]; /* B-tree key values for each type */ + unsigned btree_k[H5B_NUM_BTREE_ID]; /* B-tree key values for each type */ haddr_t super_addr; /* Absolute address of super block */ haddr_t base_addr; /* Absolute base address for rel.addrs. */ @@ -189,6 +189,7 @@ struct H5F_t { /* Forward declarations for prototype arguments */ struct H5D_dxpl_cache_t; struct H5D_dcpl_cache_t; +union H5D_storage_t; /* Private functions, not part of the publicly documented API */ #ifdef NOT_YET @@ -197,7 +198,7 @@ H5_DLL void H5F_encode_length_unusual(const H5F_t *f, uint8_t **p, uint8_t *l); H5_DLL herr_t H5F_mountpoint(struct H5G_entry_t *find/*in,out*/); H5_DLL herr_t H5F_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth); -H5_DLL herr_t H5F_sieve_overlap_clear(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t size); +H5_DLL herr_t H5F_sieve_overlap_clear(const H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t size); /* Functions that operate on indexed storage */ H5_DLL herr_t H5F_istore_init (H5F_t *f); @@ -206,14 +207,14 @@ H5_DLL herr_t H5F_istore_dest (H5F_t *f, hid_t dxpl_id); H5_DLL ssize_t H5F_istore_readvv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const struct H5O_layout_t *layout, const struct H5D_dcpl_cache_t *dcpl_cache, - hssize_t chunk_coords[], + const union H5D_storage_t *store, size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], void *buf); H5_DLL ssize_t H5F_istore_writevv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const struct H5O_layout_t *layout, const struct H5D_dcpl_cache_t *dcpl_cache, - hssize_t chunk_coords[], + const union H5D_storage_t *store, size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[], const void *buf); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index d57e014..b8c7e2b 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -256,7 +256,7 @@ typedef struct H5F_t H5F_t; #define H5F_CRT_SYM_LEAF_DEF 4 /* Definitions for the 1/2 rank for btree internal nodes */ #define H5F_CRT_BTREE_RANK_NAME "btree_rank" -#define H5F_CRT_BTREE_RANK_SIZE sizeof(int[H5B_NUM_BTREE_ID]) +#define H5F_CRT_BTREE_RANK_SIZE sizeof(unsigned[H5B_NUM_BTREE_ID]) #define H5F_CRT_BTREE_RANK_DEF {HDF5_BTREE_SNODE_IK_DEF,HDF5_BTREE_ISTORE_IK_DEF} /* Definitions for byte number in an address */ #define H5F_CRT_ADDR_BYTE_NUM_NAME "addr_byte_num" @@ -268,19 +268,19 @@ typedef struct H5F_t H5F_t; #define H5F_CRT_OBJ_BYTE_NUM_DEF sizeof(hsize_t) /* Definitions for version number of the superblock */ #define H5F_CRT_SUPER_VERS_NAME "super_version" -#define H5F_CRT_SUPER_VERS_SIZE sizeof(int) +#define H5F_CRT_SUPER_VERS_SIZE sizeof(unsigned) #define H5F_CRT_SUPER_VERS_DEF HDF5_SUPERBLOCK_VERSION_DEF /* Definitions for free-space version number */ #define H5F_CRT_FREESPACE_VERS_NAME "free_space_version" -#define H5F_CRT_FREESPACE_VERS_SIZE sizeof(int) +#define H5F_CRT_FREESPACE_VERS_SIZE sizeof(unsigned) #define H5F_CRT_FREESPACE_VERS_DEF HDF5_FREESPACE_VERSION /* Definitions for object directory version number */ #define H5F_CRT_OBJ_DIR_VERS_NAME "obj_dir_version" -#define H5F_CRT_OBJ_DIR_VERS_SIZE sizeof(int) +#define H5F_CRT_OBJ_DIR_VERS_SIZE sizeof(unsigned) #define H5F_CRT_OBJ_DIR_VERS_DEF HDF5_OBJECTDIR_VERSION /* Definitions for shared-header format version */ #define H5F_CRT_SHARE_HEAD_VERS_NAME "share_head_version" -#define H5F_CRT_SHARE_HEAD_VERS_SIZE sizeof(int) +#define H5F_CRT_SHARE_HEAD_VERS_SIZE sizeof(unsigned) #define H5F_CRT_SHARE_HEAD_VERS_DEF HDF5_SHAREDHEADER_VERSION /* ========= File Access properties ============ */ @@ -297,7 +297,7 @@ typedef struct H5F_t H5F_t; /* Definition for size of raw data chunk cache(bytes) */ #define H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" #define H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t) -#define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF 1024*1024 +#define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF (1024*1024) /* Definition for preemption read chunks first */ #define H5F_ACS_PREEMPT_READ_CHUNKS_NAME "rdcc_w0" @@ -324,7 +324,7 @@ typedef struct H5F_t H5F_t; is allowed by file driver */ #define H5F_ACS_SIEVE_BUF_SIZE_NAME "sieve_buf_size" #define H5F_ACS_SIEVE_BUF_SIZE_SIZE sizeof(size_t) -#define H5F_ACS_SIEVE_BUF_SIZE_DEF 64*1024 +#define H5F_ACS_SIEVE_BUF_SIZE_DEF (64*1024) /* Definition for minimum "small data" allocation block size (when aggregating "small" raw data allocations. */ @@ -389,8 +389,8 @@ H5_DLL hid_t H5F_get_driver_id(const H5F_t *f); H5_DLL unsigned H5F_get_intent(const H5F_t *f); H5_DLL herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum); H5_DLL hid_t H5F_get_id(H5F_t *file); -H5_DLL int H5F_get_obj_count(H5F_t *f, unsigned types); -H5_DLL int H5F_get_obj_ids(H5F_t *f, unsigned types, int max_objs, hid_t *obj_id_list); +H5_DLL int H5F_get_obj_count(const H5F_t *f, unsigned types); +H5_DLL int H5F_get_obj_ids(const H5F_t *f, unsigned types, int max_objs, hid_t *obj_id_list); H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); /* Functions than check file mounting information */ @@ -401,12 +401,12 @@ H5_DLL htri_t H5F_has_mount(const H5F_t *file); H5_DLL size_t H5F_sizeof_addr(const H5F_t *f); H5_DLL size_t H5F_sizeof_size(const H5F_t *f); H5_DLL unsigned H5F_sym_leaf_k(const H5F_t *f); -H5_DLL int H5F_Kvalue(const H5F_t *f, const struct H5B_class_t *type); +H5_DLL unsigned H5F_Kvalue(const H5F_t *f, const struct H5B_class_t *type); /* Functions that operate on blocks of bytes wrt super block */ -H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, +H5_DLL herr_t H5F_block_read(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, void *buf/*out*/); -H5_DLL herr_t H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, +H5_DLL herr_t H5F_block_write(const H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_id, const void *buf); /* Functions that operate on byte sequences */ @@ -448,7 +448,7 @@ H5_DLL herr_t H5F_istore_create(H5F_t *f, hid_t dxpl_id, H5_DLL herr_t H5F_istore_allocate (H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, const hsize_t *space_dim, struct H5P_genplist_t *dc_plist, hbool_t full_overwrite); -H5_DLL hsize_t H5F_istore_allocated(H5F_t *f, hid_t dxpl_id, unsigned ndims, haddr_t addr); +H5_DLL hsize_t H5F_istore_allocated(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout); H5_DLL herr_t H5F_istore_dump_btree(H5F_t *f, hid_t dxpl_id, FILE *stream, unsigned ndims, haddr_t addr); H5_DLL herr_t H5F_istore_prune_by_extent( H5F_t *f, @@ -460,6 +460,8 @@ H5_DLL herr_t H5F_istore_initialize_by_extent( H5F_t *f, const struct H5S_t *space ); H5_DLL herr_t H5F_istore_delete(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout); +H5_DLL herr_t H5F_istore_update_cache(H5F_t *f, hid_t dxpl_id, const struct H5O_layout_t *layout, + const struct H5S_t * space); /* Address-related functions */ H5_DLL void H5F_addr_encode(H5F_t *, uint8_t** /*in,out*/, haddr_t); diff --git a/src/H5Fseq.c b/src/H5Fseq.c index 6fd583c..9bd9f72 100644 --- a/src/H5Fseq.c +++ b/src/H5Fseq.c @@ -241,7 +241,7 @@ H5F_seq_readvv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_i case H5D_CHUNKED: assert(store); - if((ret_value=H5F_istore_readvv(f, dxpl_cache, dxpl_id, layout, dcpl_cache, store->chunk_coords, + if((ret_value=H5F_istore_readvv(f, dxpl_cache, dxpl_id, layout, dcpl_cache, store, dset_max_nseq, dset_curr_seq, dset_len_arr, dset_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0) @@ -350,7 +350,7 @@ H5F_seq_writevv(H5F_t *f, const struct H5D_dxpl_cache_t *dxpl_cache, case H5D_CHUNKED: assert(store); - if((ret_value=H5F_istore_writevv(f, dxpl_cache, dxpl_id, layout, dcpl_cache, store->chunk_coords, + if((ret_value=H5F_istore_writevv(f, dxpl_cache, dxpl_id, layout, dcpl_cache, store, dset_max_nseq, dset_curr_seq, dset_len_arr, dset_offset_arr, mem_max_nseq, mem_curr_seq, mem_len_arr, mem_offset_arr, buf))<0) diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 061ba01..e77a691 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -90,8 +90,9 @@ static void * H5O_efl_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *sh) { H5O_efl_t *mesg = NULL; - int i, version; + int version; const char *s = NULL; + size_t u; /* Local index variable */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_efl_decode, NULL); @@ -130,19 +131,19 @@ H5O_efl_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *s mesg->slot = H5MM_calloc(mesg->nalloc*sizeof(H5O_efl_entry_t)); if (NULL==mesg->slot) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - for (i=0; i<mesg->nused; i++) { + for (u=0; u<mesg->nused; u++) { /* Name */ - H5F_DECODE_LENGTH (f, p, mesg->slot[i].name_offset); - s = H5HL_peek(f, dxpl_id, mesg->heap_addr, mesg->slot[i].name_offset); + H5F_DECODE_LENGTH (f, p, mesg->slot[u].name_offset); + s = H5HL_peek(f, dxpl_id, mesg->heap_addr, mesg->slot[u].name_offset); assert (s && *s); - mesg->slot[i].name = H5MM_xstrdup (s); + mesg->slot[u].name = H5MM_xstrdup (s); /* File offset */ - H5F_DECODE_LENGTH (f, p, mesg->slot[i].offset); + H5F_DECODE_LENGTH (f, p, mesg->slot[u].offset); /* Size */ - H5F_DECODE_LENGTH (f, p, mesg->slot[i].size); - assert (mesg->slot[i].size>0); + H5F_DECODE_LENGTH (f, p, mesg->slot[u].size); + assert (mesg->slot[u].size>0); } /* Set return value */ @@ -182,7 +183,7 @@ static herr_t H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg) { const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg; - int i; + size_t u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_efl_encode, FAIL); @@ -211,15 +212,15 @@ H5O_efl_encode(H5F_t *f, uint8_t *p, const void *_mesg) H5F_addr_encode(f, &p, mesg->heap_addr); /* Encode file list */ - for (i=0; i<mesg->nused; i++) { + for (u=0; u<mesg->nused; u++) { /* * The name should have been added to the heap when the dataset was * created. */ - assert(mesg->slot[i].name_offset); - H5F_ENCODE_LENGTH (f, p, mesg->slot[i].name_offset); - H5F_ENCODE_LENGTH (f, p, mesg->slot[i].offset); - H5F_ENCODE_LENGTH (f, p, mesg->slot[i].size); + assert(mesg->slot[u].name_offset); + H5F_ENCODE_LENGTH (f, p, mesg->slot[u].name_offset); + H5F_ENCODE_LENGTH (f, p, mesg->slot[u].offset); + H5F_ENCODE_LENGTH (f, p, mesg->slot[u].size); } done: @@ -249,7 +250,7 @@ H5O_efl_copy(const void *_mesg, void *_dest) { const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; H5O_efl_t *dest = (H5O_efl_t *) _dest; - int i; + size_t u; /* Local index variable */ void *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_efl_copy, NULL); @@ -271,9 +272,9 @@ H5O_efl_copy(const void *_mesg, void *_dest) dest->nalloc = mesg->nalloc; dest->nused = mesg->nused; - for (i = 0; i < mesg->nused; i++) { - dest->slot[i] = mesg->slot[i]; - dest->slot[i].name = H5MM_xstrdup (mesg->slot[i].name); + for (u = 0; u < mesg->nused; u++) { + dest->slot[u] = mesg->slot[u]; + dest->slot[u].name = H5MM_xstrdup (mesg->slot[u].name); } /* Set return value */ @@ -347,7 +348,7 @@ static herr_t H5O_efl_reset(void *_mesg) { H5O_efl_t *mesg = (H5O_efl_t *) _mesg; - int i; + size_t u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_efl_reset, FAIL); @@ -356,8 +357,8 @@ H5O_efl_reset(void *_mesg) assert(mesg); /* reset */ - for (i=0; i<mesg->nused; i++) - mesg->slot[i].name = H5MM_xfree (mesg->slot[i].name); + for (u=0; u<mesg->nused; u++) + mesg->slot[u].name = H5MM_xfree (mesg->slot[u].name); mesg->heap_addr = HADDR_UNDEF; mesg->nused = mesg->nalloc = 0; if(mesg->slot) @@ -388,7 +389,6 @@ done: hsize_t H5O_efl_total_size (H5O_efl_t *efl) { - int i; hsize_t ret_value = 0, tmp; FUNC_ENTER_NOAPI(H5O_efl_total_size, 0); @@ -397,8 +397,10 @@ H5O_efl_total_size (H5O_efl_t *efl) H5O_EFL_UNLIMITED==efl->slot[efl->nused-1].size) { ret_value = H5O_EFL_UNLIMITED; } else { - for (i=0; i<efl->nused; i++, ret_value=tmp) { - tmp = ret_value + efl->slot[i].size; + size_t u; /* Local index variable */ + + for (u=0; u<efl->nused; u++, ret_value=tmp) { + tmp = ret_value + efl->slot[u].size; if (tmp<=ret_value) HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, 0, "total external storage size overflowed"); } @@ -430,7 +432,7 @@ done: static herr_t H5O_efl_read (const H5O_efl_t *efl, haddr_t addr, size_t size, uint8_t *buf) { - int i, fd=-1; + int fd=-1; size_t to_read; #ifndef NDEBUG hsize_t tempto_read; @@ -438,6 +440,7 @@ H5O_efl_read (const H5O_efl_t *efl, haddr_t addr, size_t size, uint8_t *buf) hsize_t skip=0; haddr_t cur; ssize_t n; + size_t u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_efl_read, FAIL); @@ -449,31 +452,30 @@ H5O_efl_read (const H5O_efl_t *efl, haddr_t addr, size_t size, uint8_t *buf) assert (buf || 0==size); /* Find the first efl member from which to read */ - for (i=0, cur=0; i<efl->nused; i++) { - if (H5O_EFL_UNLIMITED==efl->slot[i].size || - addr < cur+efl->slot[i].size) { + for (u=0, cur=0; u<efl->nused; u++) { + if (H5O_EFL_UNLIMITED==efl->slot[u].size || addr < cur+efl->slot[u].size) { skip = addr - cur; break; } - cur += efl->slot[i].size; + cur += efl->slot[u].size; } /* Read the data */ while (size) { - if (i>=efl->nused) + if (u>=efl->nused) HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "read past logical end of file"); - if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[i].offset+skip)) + if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[u].offset+skip)) HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed"); - if ((fd=HDopen (efl->slot[i].name, O_RDONLY, 0))<0) + if ((fd=HDopen (efl->slot[u].name, O_RDONLY, 0))<0) HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file"); - if (HDlseek (fd, (off_t)(efl->slot[i].offset+skip), SEEK_SET)<0) + if (HDlseek (fd, (off_t)(efl->slot[u].offset+skip), SEEK_SET)<0) HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file"); #ifndef NDEBUG - tempto_read = MIN(efl->slot[i].size-skip,(hsize_t)size); + tempto_read = MIN(efl->slot[u].size-skip,(hsize_t)size); H5_CHECK_OVERFLOW(tempto_read,hsize_t,size_t); to_read = (size_t)tempto_read; #else /* NDEBUG */ - to_read = MIN((size_t)(efl->slot[i].size-skip), size); + to_read = MIN((size_t)(efl->slot[u].size-skip), size); #endif /* NDEBUG */ if ((n=HDread (fd, buf, to_read))<0) { HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "read error in external raw data file"); @@ -485,7 +487,7 @@ H5O_efl_read (const H5O_efl_t *efl, haddr_t addr, size_t size, uint8_t *buf) size -= to_read; buf += to_read; skip = 0; - i++; + u++; } done: @@ -517,13 +519,14 @@ done: static herr_t H5O_efl_write (const H5O_efl_t *efl, haddr_t addr, size_t size, const uint8_t *buf) { - int i, fd=-1; + int fd=-1; size_t to_write; #ifndef NDEBUG hsize_t tempto_write; #endif /* NDEBUG */ haddr_t cur; hsize_t skip=0; + size_t u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_efl_write, FAIL); @@ -535,36 +538,35 @@ H5O_efl_write (const H5O_efl_t *efl, haddr_t addr, size_t size, const uint8_t *b assert (buf || 0==size); /* Find the first efl member in which to write */ - for (i=0, cur=0; i<efl->nused; i++) { - if (H5O_EFL_UNLIMITED==efl->slot[i].size || - addr < cur+efl->slot[i].size) { + for (u=0, cur=0; u<efl->nused; u++) { + if (H5O_EFL_UNLIMITED==efl->slot[u].size || addr < cur+efl->slot[u].size) { skip = addr - cur; break; } - cur += efl->slot[i].size; + cur += efl->slot[u].size; } /* Write the data */ while (size) { - if (i>=efl->nused) + if (u>=efl->nused) HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "write past logical end of file"); - if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[i].offset+skip)) + if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[u].offset+skip)) HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed"); - if ((fd=HDopen (efl->slot[i].name, O_CREAT|O_RDWR, 0666))<0) { - if (HDaccess (efl->slot[i].name, F_OK)<0) { + if ((fd=HDopen (efl->slot[u].name, O_CREAT|O_RDWR, 0666))<0) { + if (HDaccess (efl->slot[u].name, F_OK)<0) { HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, "external raw data file does not exist"); } else { HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file"); } } - if (HDlseek (fd, (off_t)(efl->slot[i].offset+skip), SEEK_SET)<0) + if (HDlseek (fd, (off_t)(efl->slot[u].offset+skip), SEEK_SET)<0) HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file"); #ifndef NDEBUG - tempto_write = MIN(efl->slot[i].size-skip,(hsize_t)size); + tempto_write = MIN(efl->slot[u].size-skip,(hsize_t)size); H5_CHECK_OVERFLOW(tempto_write,hsize_t,size_t); to_write = (size_t)tempto_write; #else /* NDEBUG */ - to_write = MIN((size_t)(efl->slot[i].size-skip), size); + to_write = MIN((size_t)(efl->slot[u].size-skip), size); #endif /* NDEBUG */ if ((size_t)HDwrite (fd, buf, to_write)!=to_write) HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "write error in external raw data file"); @@ -573,7 +575,7 @@ H5O_efl_write (const H5O_efl_t *efl, haddr_t addr, size_t size, const uint8_t *b size -= to_write; buf += to_write; skip = 0; - i++; + u++; } done: @@ -762,7 +764,7 @@ H5O_efl_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * s { const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; char buf[64]; - int i; + size_t u; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5O_efl_debug, FAIL); @@ -781,25 +783,25 @@ H5O_efl_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * s "Slots used/allocated:", mesg->nused, mesg->nalloc); - for (i = 0; i < mesg->nused; i++) { - sprintf (buf, "File %d", i); + for (u = 0; u < mesg->nused; u++) { + sprintf (buf, "File %u", (unsigned)u); HDfprintf (stream, "%*s%s:\n", indent, "", buf); HDfprintf(stream, "%*s%-*s \"%s\"\n", indent+3, "", MAX (fwidth-3, 0), "Name:", - mesg->slot[i].name); + mesg->slot[u].name); HDfprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), "Name offset:", - (unsigned long)(mesg->slot[i].name_offset)); + (unsigned long)(mesg->slot[u].name_offset)); HDfprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), "Offset of data in file:", - (unsigned long)(mesg->slot[i].offset)); + (unsigned long)(mesg->slot[u].offset)); HDfprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (fwidth-3, 0), "Bytes reserved for data:", - (unsigned long)(mesg->slot[i].size)); + (unsigned long)(mesg->slot[u].size)); } done: diff --git a/src/H5Opline.c b/src/H5Opline.c index 972e5e0..5240f72 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -104,15 +104,15 @@ H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p, version = *p++; if (version!=H5O_PLINE_VERSION) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "bad version number for filter pipeline message"); - pline->nfilters = *p++; - if (pline->nfilters>H5Z_MAX_NFILTERS) + pline->nused = *p++; + if (pline->nused>H5Z_MAX_NFILTERS) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter pipeline message has too many filters"); p += 6; /*reserved*/ - pline->nalloc = pline->nfilters; + pline->nalloc = pline->nused; pline->filter = H5MM_calloc(pline->nalloc*sizeof(pline->filter[0])); if (NULL==pline->filter) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - for (i=0; i<pline->nfilters; i++) { + for (i=0; i<pline->nused; i++) { UINT16DECODE(p, pline->filter[i].id); UINT16DECODE(p, name_length); if (name_length % 8) @@ -150,7 +150,7 @@ H5O_pline_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const uint8_t *p, done: if (NULL==ret_value && pline) { if (pline->filter) { - for (i=0; i<pline->nfilters; i++) { + for (i=0; i<pline->nused; i++) { H5MM_xfree(pline->filter[i].name); H5MM_xfree(pline->filter[i].cd_values); } @@ -193,7 +193,7 @@ H5O_pline_encode (H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg) assert (mesg); *p++ = H5O_PLINE_VERSION; - *p++ = (uint8_t)(pline->nfilters); + *p++ = (uint8_t)(pline->nused); *p++ = 0; /*reserved 1*/ *p++ = 0; /*reserved 2*/ *p++ = 0; /*reserved 3*/ @@ -201,7 +201,7 @@ H5O_pline_encode (H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg) *p++ = 0; /*reserved 5*/ *p++ = 0; /*reserved 6*/ - for (i=0; i<pline->nfilters; i++) { + for (i=0; i<pline->nused; i++) { /* * Get the filter name. If the pipeline message has a name in it then * use that one. Otherwise try to look up the filter and get the name @@ -266,7 +266,7 @@ H5O_pline_copy (const void *_src, void *_dst/*out*/) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); *dst = *src; - dst->nalloc = dst->nfilters; + dst->nalloc = dst->nused; if (dst->nalloc>0) { dst->filter = H5MM_calloc(dst->nalloc * sizeof(dst->filter[0])); if (NULL==dst->filter) @@ -275,7 +275,7 @@ H5O_pline_copy (const void *_src, void *_dst/*out*/) dst->filter = NULL; } - for (i=0; i<src->nfilters; i++) { + for (i=0; i<src->nused; i++) { dst->filter[i] = src->filter[i]; if (src->filter[i].name) { dst->filter[i].name = H5MM_xstrdup(src->filter[i].name); @@ -296,7 +296,7 @@ H5O_pline_copy (const void *_src, void *_dst/*out*/) done: if (!ret_value && dst) { if (dst->filter) { - for (i=0; i<dst->nfilters; i++) { + for (i=0; i<dst->nused; i++) { H5MM_xfree(dst->filter[i].name); H5MM_xfree(dst->filter[i].cd_values); } @@ -342,7 +342,7 @@ H5O_pline_size (H5F_t UNUSED *f, const void *mesg) 1 + /*number of filters */ 6; /*reserved */ - for (i=0; i<pline->nfilters; i++) { + for (i=0; i<pline->nused; i++) { /* Get the name of the filter, same as done with H5O_pline_encode() */ if (NULL==(name=pline->filter[i].name) && (cls=H5Z_find(pline->filter[i].id))) @@ -395,7 +395,7 @@ H5O_pline_reset (void *mesg) assert (pline); - for (i=0; i<pline->nfilters; i++) { + for (i=0; i<pline->nused; i++) { H5MM_xfree(pline->filter[i].name); H5MM_xfree(pline->filter[i].cd_values); } @@ -473,10 +473,10 @@ H5O_pline_debug (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg, FILE * fprintf(stream, "%*s%-*s %lu/%lu\n", indent, "", fwidth, "Number of filters:", - (unsigned long)(pline->nfilters), + (unsigned long)(pline->nused), (unsigned long)(pline->nalloc)); - for (i=0; i<pline->nfilters; i++) { + for (i=0; i<pline->nused; i++) { char name[32]; sprintf(name, "Filter at position %lu", (unsigned long)i); fprintf(stream, "%*s%-*s\n", indent, "", fwidth, name); diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 574c516..7b39aed 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -38,7 +38,7 @@ #include "H5private.h" /* Generic functions */ #include "H5HGprivate.h" /* Global heap functions */ #include "H5Tprivate.h" /* Datatype functions */ -#include "H5Zprivate.h" /* I/O pipeline filters */ +#include "H5Zprivate.h" /* I/O pipeline filters */ /* Object header macros */ #define H5O_MIN_SIZE H5O_ALIGN(32) /*min obj header data size */ @@ -112,8 +112,8 @@ typedef struct H5O_efl_entry_t { typedef struct H5O_efl_t { haddr_t heap_addr; /*address of name heap */ - int nalloc; /*number of slots allocated */ - int nused; /*number of slots used */ + size_t nalloc; /*number of slots allocated */ + size_t nused; /*number of slots used */ H5O_efl_entry_t *slot; /*array of external file entries */ } H5O_efl_t; @@ -175,8 +175,8 @@ typedef struct H5O_bogus_t { * (Data structure in memory) */ typedef struct H5O_pline_t { - size_t nfilters; /*num filters defined */ size_t nalloc; /*num elements in `filter' array */ + size_t nused; /*num filters defined */ H5Z_filter_info_t *filter; /*array of filters */ } H5O_pline_t; diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index cafd036..8d71e0b 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -294,7 +294,7 @@ done: herr_t H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) { - int idx; + size_t idx; hsize_t total, tmp; H5O_efl_t efl; H5P_genplist_t *plist; /* Property list pointer */ @@ -331,7 +331,7 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) /* Add to the list */ if (efl.nused >= efl.nalloc) { - int na = efl.nalloc + H5O_EFL_ALLOC; + size_t na = efl.nalloc + H5O_EFL_ALLOC; H5O_efl_entry_t *x = H5MM_realloc (efl.slot, na*sizeof(H5O_efl_entry_t)); if (!x) @@ -394,7 +394,7 @@ H5Pget_external_count(hid_t plist_id) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list"); /* Set return value */ - ret_value=efl.nused; + ret_value=(int)efl.nused; done: FUNC_LEAVE_API(ret_value); @@ -451,7 +451,7 @@ H5Pget_external(hid_t plist_id, int idx, size_t name_size, char *name/*out*/, if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list"); - if (idx<0 || idx>=efl.nused) + if (idx<0 || (size_t)idx>=efl.nused) HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, "external file index is out of range"); /* Return values */ @@ -667,7 +667,7 @@ H5Pget_nfilters(hid_t plist_id) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline"); /* Set return value */ - ret_value=(int)(pline.nfilters); + ret_value=(int)(pline.nused); done: FUNC_LEAVE_API(ret_value); @@ -749,7 +749,7 @@ H5Pget_filter(hid_t plist_id, int idx, unsigned int *flags/*out*/, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline"); /* Check more args */ - if (idx<0 || (size_t)idx>=pline.nfilters) + if (idx<0 || (size_t)idx>=pline.nused) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5Z_FILTER_ERROR, "filter number is invalid"); /* Set pointer to particular filter to query */ @@ -1342,17 +1342,14 @@ H5P_is_fill_value_defined(const struct H5O_fill_t *fill, H5D_fill_value_t *statu assert(status); /* Check if the fill value was never set */ - if(fill->size == (size_t)-1 && !fill->buf) { + if(fill->size == (size_t)-1 && !fill->buf) *status = H5D_FILL_VALUE_UNDEFINED; - } /* Check if the fill value was set to the default fill value by the library */ - else if(fill->size == 0 && !fill->buf) { + else if(fill->size == 0 && !fill->buf) *status = H5D_FILL_VALUE_DEFAULT; - } /* Check if the fill value was set by the application */ - else if(fill->size > 0 && fill->buf) { + else if(fill->size > 0 && fill->buf) *status = H5D_FILL_VALUE_USER_DEFINED; - } else { *status = H5D_FILL_VALUE_ERROR; HGOTO_ERROR(H5E_PLIST, H5E_BADRANGE, FAIL, "invalid combination of fill-value info"); @@ -1645,6 +1642,3 @@ H5Premove_filter(hid_t plist_id, H5Z_filter_t filter) done: FUNC_LEAVE_API(ret_value); } - - - @@ -81,29 +81,29 @@ H5Z_init_interface (void) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5Z_init_interface); + FUNC_ENTER_NOAPI_NOINIT(H5Z_init_interface) #ifdef H5_HAVE_FILTER_DEFLATE if (H5Z_register (H5Z_DEFLATE)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register deflate filter"); + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register deflate filter") #endif /* H5_HAVE_FILTER_DEFLATE */ #ifdef H5_HAVE_FILTER_SHUFFLE if (H5Z_register (H5Z_SHUFFLE)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register shuffle filter"); + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register shuffle filter") #endif /* H5_HAVE_FILTER_SHUFFLE */ #ifdef H5_HAVE_FILTER_FLETCHER32 if (H5Z_register (H5Z_FLETCHER32)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register fletcher32 filter"); + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register fletcher32 filter") #endif /* H5_HAVE_FILTER_FLETCHER32 */ #ifdef H5_HAVE_FILTER_SZIP if (H5Z_register (H5Z_SZIP)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register szip filter"); + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register szip filter") #endif /* H5_HAVE_FILTER_SZIP */ #if (defined H5_HAVE_FILTER_DEFLATE | defined H5_HAVE_FILTER_FLETCHER32 | defined H5_HAVE_FILTER_SHUFFLE | defined H5_HAVE_FILTER_SZIP) done: #endif /* (defined H5_HAVE_FILTER_DEFLATE | defined H5_HAVE_FILTER_FLETCHER32 | defined H5_HAVE_FILTER_SHUFFLE | defined H5_HAVE_FILTER_SZIP) */ - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -262,24 +262,25 @@ H5Zregister(const H5Z_class_t *cls) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Zregister, FAIL); + FUNC_ENTER_API(H5Zregister, FAIL) + H5TRACE1("e","Zc",cls); /* Check args */ if (cls==NULL) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter class"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter class") if (cls->id<0 || cls->id>H5Z_FILTER_MAX) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") if (cls->id<H5Z_FILTER_RESERVED) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters") if (cls->filter==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no filter function specified"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no filter function specified") /* Do it */ if (H5Z_register (cls)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter"); + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } #endif /* H5_WANT_H5_V1_4_COMPAT */ @@ -305,7 +306,7 @@ H5Z_register (const H5Z_class_t *cls) size_t i; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5Z_register, FAIL); + FUNC_ENTER_NOAPI(H5Z_register, FAIL) assert (cls); assert (cls->id>=0 && cls->id<=H5Z_FILTER_MAX); @@ -326,11 +327,11 @@ H5Z_register (const H5Z_class_t *cls) n*sizeof(H5Z_stats_t)); #endif /* H5Z_DEBUG */ if (!table) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter table"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter table") H5Z_table_g = table; #ifdef H5Z_DEBUG if (!stat_table) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter statistics table"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter statistics table") H5Z_stat_table_g = stat_table; #endif /* H5Z_DEBUG */ H5Z_table_alloc_g = n; @@ -350,7 +351,7 @@ H5Z_register (const H5Z_class_t *cls) } /* end else */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -373,21 +374,21 @@ H5Zunregister(H5Z_filter_t id) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Zunregister, FAIL); + FUNC_ENTER_API(H5Zunregister, FAIL) H5TRACE1("e","Zf",id); /* Check args */ if (id<0 || id>H5Z_FILTER_MAX) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") if (id<H5Z_FILTER_RESERVED) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters") /* Do it */ if (H5Z_unregister (id)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to unregister filter"); + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to unregister filter") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Zunregister() */ @@ -412,7 +413,7 @@ H5Z_unregister (H5Z_filter_t id) size_t i; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5Z_unregister,FAIL); + FUNC_ENTER_NOAPI(H5Z_unregister,FAIL) assert (id>=0 && id<=H5Z_FILTER_MAX); @@ -423,7 +424,7 @@ H5Z_unregister (H5Z_filter_t id) /* Fail if filter not found */ if (i>=H5Z_table_used_g) - HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter is not registered"); + HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter is not registered") /* Remove filter from table */ /* Don't worry about shrinking table size (for now) */ @@ -434,7 +435,7 @@ H5Z_unregister (H5Z_filter_t id) H5Z_table_used_g--; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_unregister() */ @@ -458,12 +459,12 @@ H5Zfilter_avail(H5Z_filter_t id) size_t i; /* Local index variable */ htri_t ret_value=FALSE; /* Return value */ - FUNC_ENTER_API(H5Zfilter_avail, FAIL); + FUNC_ENTER_API(H5Zfilter_avail, FAIL) H5TRACE1("b","Zf",id); /* Check args */ if(id<0 || id>H5Z_FILTER_MAX) - HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") /* Is the filter already registered? */ for(i=0; i<H5Z_table_used_g; i++) @@ -473,7 +474,7 @@ H5Zfilter_avail(H5Z_filter_t id) } /* end if */ done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Zfilter_avail() */ @@ -502,7 +503,7 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5Z_prelude_callback); + FUNC_ENTER_NOAPI_NOINIT(H5Z_prelude_callback) assert (H5I_GENPROP_LST==H5I_get_type(dcpl_id)); assert (H5I_DATATYPE==H5I_get_type(type_id)); @@ -514,11 +515,11 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Get dataset creation property list object */ if (NULL == (dc_plist = H5I_object(dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") /* Get layout information */ if(H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, &dcpl_layout) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") /* Check if the dataset is chunked */ if(H5D_CHUNKED == dcpl_layout) { @@ -526,10 +527,10 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Get I/O pipeline information */ if(H5P_get(dc_plist, H5D_CRT_DATA_PIPELINE_NAME, &dcpl_pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve pipeline filter"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve pipeline filter") /* Check if the chunks have filters */ - if(dcpl_pline.nfilters > 0) { + if(dcpl_pline.nused > 0) { unsigned chunk_ndims; /* # of chunk dimensions */ size_t chunk_size[H5O_LAYOUT_NDIMS]; /* Size of chunk dimensions */ hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; /* Size of chunk dimensions */ @@ -539,9 +540,9 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Get chunk information */ if(H5P_get(dc_plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve chunk dimensions"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve chunk dimensions") if(H5P_get(dc_plist, H5D_CRT_CHUNK_SIZE_NAME, chunk_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve chunk size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve chunk size") /* Create a data space for a chunk & set the extent */ for(u=0; u<chunk_ndims; u++) @@ -551,12 +552,12 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Get ID for dataspace to pass to filter routines */ if ((space_id=H5I_register (H5I_DATASPACE, space))<0) { - H5S_close(space); - HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID"); + (void)H5S_close(space); + HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") } /* end if */ /* Iterate over filters */ - for (u=0; u<dcpl_pline.nfilters; u++) { + for (u=0; u<dcpl_pline.nused; u++) { H5Z_class_t *fclass; /* Individual filter information */ /* Get filter information */ @@ -565,7 +566,7 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty if (dcpl_pline.filter[u].flags & H5Z_FLAG_OPTIONAL) H5E_clear(); else - HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "required filter was not located"); + HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "required filter was not located") } /* end if */ else { /* Make correct callback */ @@ -580,15 +581,15 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty if(status<=0) { /* We're leaving, so close dataspace */ if(H5I_dec_ref(space_id)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace"); + HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") /* Indicate filter can't apply to this combination of parameters */ if(status==0) { - HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "filter parameters not appropriate"); + HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "filter parameters not appropriate") } /* end if */ /* Indicate error during filter callback */ else { - HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "error during user callback"); + HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "error during user callback") } /* end if */ } /* end if */ } /* end if */ @@ -601,10 +602,10 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty if((fclass->set_local)(dcpl_id, type_id, space_id)<0) { /* We're leaving, so close dataspace */ if(H5I_dec_ref(space_id)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace"); + HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") /* Indicate error during filter callback */ - HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "error during user callback"); + HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "error during user callback") } /* end if */ } /* end if */ break; @@ -617,13 +618,13 @@ H5Z_prelude_callback(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_ty /* Close dataspace */ if(H5I_dec_ref(space_id)<0) - HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace"); + HGOTO_ERROR (H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") } /* end if */ } /* end if */ } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_prelude_callback() */ @@ -653,17 +654,17 @@ H5Z_can_apply (hid_t dcpl_id, hid_t type_id) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5Z_can_apply,FAIL); + FUNC_ENTER_NOAPI(H5Z_can_apply,FAIL) assert (H5I_GENPROP_LST==H5I_get_type(dcpl_id)); assert (H5I_DATATYPE==H5I_get_type(type_id)); /* Make "can apply" callbacks for filters in pipeline */ if(H5Z_prelude_callback(dcpl_id, type_id, H5Z_PRELUDE_CAN_APPLY)<0) - HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "filter parameters not appropriate"); + HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "filter parameters not appropriate") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_can_apply() */ @@ -693,17 +694,17 @@ H5Z_set_local (hid_t dcpl_id, hid_t type_id) { herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5Z_set_local,FAIL); + FUNC_ENTER_NOAPI(H5Z_set_local,FAIL) assert (H5I_GENPROP_LST==H5I_get_type(dcpl_id)); assert (H5I_DATATYPE==H5I_get_type(type_id)); /* Make "set local" callbacks for filters in pipeline */ if(H5Z_prelude_callback(dcpl_id, type_id, H5Z_PRELUDE_SET_LOCAL)<0) - HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "local filter parameters not set"); + HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "local filter parameters not set") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_set_local() */ @@ -722,14 +723,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Z_modify(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, +H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) { size_t idx; /* Index of filter in pipeline */ size_t i; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5Z_modify, FAIL); + FUNC_ENTER_NOAPI(H5Z_modify, FAIL) assert(pline); assert(filter>=0 && filter<=H5Z_FILTER_MAX); @@ -737,13 +738,13 @@ H5Z_modify(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, assert(0==cd_nelmts || cd_values); /* Locate the filter in the pipeline */ - for(idx=0; idx<pline->nfilters; idx++) + for(idx=0; idx<pline->nused; idx++) if(pline->filter[idx].id==filter) break; /* Check if the filter was not already in the pipeline */ - if(idx>pline->nfilters) - HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline"); + if(idx>pline->nused) + HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline") /* Change parameters for filter */ pline->filter[idx].flags = flags; @@ -757,7 +758,7 @@ H5Z_modify(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, if (cd_nelmts>0) { pline->filter[idx].cd_values = H5MM_malloc(cd_nelmts*sizeof(unsigned)); if (NULL==pline->filter[idx].cd_values) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter parameters"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter parameters") for (i=0; i<cd_nelmts; i++) pline->filter[idx].cd_values[i] = cd_values[i]; } /* end if */ @@ -765,7 +766,7 @@ H5Z_modify(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, pline->filter[idx].cd_values = NULL; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_modify() */ @@ -790,7 +791,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t idx, i; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5Z_append, FAIL); + FUNC_ENTER_NOAPI(H5Z_append, FAIL) assert(pline); assert(filter>=0 && filter<=H5Z_FILTER_MAX); @@ -801,22 +802,22 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, * Check filter limit. We do it here for early warnings although we may * decide to relax this restriction in the future. */ - if (pline->nfilters>=H5Z_MAX_NFILTERS) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "too many filters in pipeline"); + if (pline->nused>=H5Z_MAX_NFILTERS) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "too many filters in pipeline") /* Allocate additional space in the pipeline if it's full */ - if (pline->nfilters>=pline->nalloc) { + if (pline->nused>=pline->nalloc) { H5O_pline_t x; x.nalloc = MAX(H5Z_MAX_NFILTERS, 2*pline->nalloc); x.filter = H5MM_realloc(pline->filter, x.nalloc*sizeof(x.filter[0])); if (NULL==x.filter) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter pipeline"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter pipeline") pline->nalloc = x.nalloc; pline->filter = x.filter; } /* Add the new filter to the pipeline */ - idx = pline->nfilters; + idx = pline->nused; pline->filter[idx].id = filter; pline->filter[idx].flags = flags; pline->filter[idx].name = NULL; /*we'll pick it up later*/ @@ -824,16 +825,16 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, if (cd_nelmts>0) { pline->filter[idx].cd_values = H5MM_malloc(cd_nelmts*sizeof(unsigned)); if (NULL==pline->filter[idx].cd_values) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter") for (i=0; i<cd_nelmts; i++) pline->filter[idx].cd_values[i] = cd_values[i]; } else { pline->filter[idx].cd_values = NULL; } - pline->nfilters++; + pline->nused++; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -859,14 +860,14 @@ H5Z_find_idx(H5Z_filter_t id) size_t i; /* Local index variable */ int ret_value=FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5Z_find_idx); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5Z_find_idx) for (i=0; i<H5Z_table_used_g; i++) if (H5Z_table_g[i].id == id) - HGOTO_DONE((int)i); + HGOTO_DONE((int)i) done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_find_idx() */ @@ -894,17 +895,17 @@ H5Z_find(H5Z_filter_t id) int idx; /* Filter index in global table */ H5Z_class_t *ret_value=NULL; /* Return value */ - FUNC_ENTER_NOAPI(H5Z_find, NULL); + FUNC_ENTER_NOAPI(H5Z_find, NULL) /* Get the index in the global table */ if((idx=H5Z_find_idx(id))<0) - HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, NULL, "required filter is not registered"); + HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, NULL, "required filter is not registered") /* Set return value */ ret_value=H5Z_table_g+idx; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* H5Z_find() */ @@ -953,17 +954,17 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, unsigned tmp_flags; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5Z_pipeline, FAIL); + FUNC_ENTER_NOAPI(H5Z_pipeline, FAIL) assert(0==(flags & ~((unsigned)H5Z_FLAG_INVMASK))); assert(filter_mask); assert(nbytes && *nbytes>0); assert(buf_size && *buf_size>0); assert(buf && *buf); - assert(!pline || pline->nfilters<H5Z_MAX_NFILTERS); + assert(!pline || pline->nused<H5Z_MAX_NFILTERS); if (pline && (flags & H5Z_FLAG_REVERSE)) { /* Read */ - for (i=pline->nfilters; i>0; --i) { + for (i=pline->nused; i>0; --i) { idx = i-1; if (*filter_mask & ((unsigned)1<<idx)) { @@ -971,7 +972,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, continue;/*filter excluded*/ } if ((fclass_idx=H5Z_find_idx(pline->filter[idx].id))<0) { - HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter is not registered"); + HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter is not registered") } fclass=&H5Z_table_g[fclass_idx]; #ifdef H5Z_DEBUG @@ -992,7 +993,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, if(0==new_nbytes) { if((cb_struct.func && (H5Z_CB_FAIL==cb_struct.func(pline->filter[idx].id, *buf, *buf_size, cb_struct.op_data))) || !cb_struct.func) - HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "filter returned failure during read"); + HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "filter returned failure during read") *nbytes = *buf_size; failed |= (unsigned)1 << idx; @@ -1002,7 +1003,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, } } } else if (pline) { /* Write */ - for (idx=0; idx<pline->nfilters; idx++) { + for (idx=0; idx<pline->nused; idx++) { if (*filter_mask & ((unsigned)1<<idx)) { failed |= (unsigned)1 << idx; continue; /*filter excluded*/ @@ -1010,8 +1011,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, if ((fclass_idx=H5Z_find_idx(pline->filter[idx].id))<0) { /* Check if filter is optional -- If it isn't, then error */ if ((pline->filter[idx].flags & H5Z_FLAG_OPTIONAL) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, - "required filter is not registered"); + HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "required filter is not registered") failed |= (unsigned)1 << idx; H5E_clear(); @@ -1033,7 +1033,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, if (0==(pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) { if((cb_struct.func && (H5Z_CB_FAIL==cb_struct.func(pline->filter[idx].id, *buf, *nbytes, cb_struct.op_data))) || !cb_struct.func) - HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "filter returned failure"); + HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "filter returned failure") *nbytes = *buf_size; } @@ -1049,7 +1049,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, *filter_mask = failed; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } @@ -1068,30 +1068,30 @@ done: *------------------------------------------------------------------------- */ H5Z_filter_info_t * -H5Z_filter_info(H5O_pline_t *pline, H5Z_filter_t filter) +H5Z_filter_info(const H5O_pline_t *pline, H5Z_filter_t filter) { size_t idx; /* Index of filter in pipeline */ H5Z_filter_info_t *ret_value; /* Return value */ - FUNC_ENTER_NOAPI(H5Z_filter_info, NULL); + FUNC_ENTER_NOAPI(H5Z_filter_info, NULL) assert(pline); assert(filter>=0 && filter<=H5Z_FILTER_MAX); /* Locate the filter in the pipeline */ - for(idx=0; idx<pline->nfilters; idx++) + for(idx=0; idx<pline->nused; idx++) if(pline->filter[idx].id==filter) break; /* Check if the filter was not already in the pipeline */ - if(idx>pline->nfilters) - HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, NULL, "filter not in pipeline"); + if(idx>pline->nused) + HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, NULL, "filter not in pipeline") /* Set return value */ ret_value=&pline->filter[idx]; done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_filter_info() */ @@ -1111,18 +1111,18 @@ done: *------------------------------------------------------------------------- */ htri_t -H5Z_all_filters_avail(H5O_pline_t *pline) +H5Z_all_filters_avail(const H5O_pline_t *pline) { size_t i,j; /* Local index variable */ htri_t ret_value=TRUE; /* Return value */ - FUNC_ENTER_NOAPI(H5Z_all_filters_avail, UFAIL); + FUNC_ENTER_NOAPI(H5Z_all_filters_avail, FAIL) /* Check args */ assert(pline); /* Iterate through all the filters in pipeline */ - for(i=0; i<pline->nfilters; i++) { + for(i=0; i<pline->nused; i++) { /* Look for each filter in the list of registered filters */ for(j=0; j<H5Z_table_used_g; j++) @@ -1131,11 +1131,11 @@ H5Z_all_filters_avail(H5O_pline_t *pline) /* Check if we didn't find the filter */ if(j==H5Z_table_used_g) - HGOTO_DONE(FALSE); + HGOTO_DONE(FALSE) } /* end for */ done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z_all_filters_avail() */ @@ -1167,7 +1167,7 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) assert(filter>=0 && filter<=H5Z_FILTER_MAX); /* if the pipeline has no filters, just return */ - if(pline->nfilters==0) + if(pline->nused==0) HGOTO_DONE(SUCCEED) /* Delete all filters */ @@ -1181,7 +1181,7 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) unsigned found=0; /* Indicate filter was found in pipeline */ /* Locate the filter in the pipeline */ - for(idx=0; idx<pline->nfilters; idx++) + for(idx=0; idx<pline->nused; idx++) if(pline->filter[idx].id==filter) { found=1; break; @@ -1196,15 +1196,15 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) H5MM_xfree(pline->filter[idx].cd_values); /* Remove filter from pipeline array */ - if((idx+1)<pline->nfilters) + if((idx+1)<pline->nused) HDmemcpy(&pline->filter[idx], &pline->filter[idx+1], - sizeof (H5Z_filter_info_t)*(pline->nfilters-(idx+1))); + sizeof (H5Z_filter_info_t)*(pline->nused-(idx+1))); /* Decrement number of used filters */ - pline->nfilters--; + pline->nused--; /* Reset information for previous last filter in pipeline */ - HDmemset(&pline->filter[pline->nfilters], 0, sizeof (H5Z_filter_info_t)); + HDmemset(&pline->filter[pline->nused], 0, sizeof (H5Z_filter_info_t)); } /* end else */ done: diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index 4ca0662..5ee02ec 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -19,6 +19,7 @@ #ifndef _H5Zprivate_H #define _H5Zprivate_H +/* Include package's public header */ #include "H5Zpublic.h" /* Structure to store information about each filter's parameters */ @@ -45,7 +46,7 @@ H5_DLL herr_t H5Z_register(const H5Z_class_t *cls); H5_DLL herr_t H5Z_unregister(H5Z_filter_t id); H5_DLL herr_t H5Z_append(struct H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, const unsigned int cd_values[]); -H5_DLL herr_t H5Z_modify(struct H5O_pline_t *pline, H5Z_filter_t filter, +H5_DLL herr_t H5Z_modify(const struct H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, const unsigned int cd_values[]); H5_DLL herr_t H5Z_pipeline(const struct H5O_pline_t *pline, unsigned flags, unsigned *filter_mask/*in,out*/, @@ -55,9 +56,9 @@ H5_DLL herr_t H5Z_pipeline(const struct H5O_pline_t *pline, H5_DLL H5Z_class_t *H5Z_find(H5Z_filter_t id); H5_DLL herr_t H5Z_can_apply(hid_t dcpl_id, hid_t type_id); H5_DLL herr_t H5Z_set_local(hid_t dcpl_id, hid_t type_id); -H5_DLL H5Z_filter_info_t *H5Z_filter_info(struct H5O_pline_t *pline, +H5_DLL H5Z_filter_info_t *H5Z_filter_info(const struct H5O_pline_t *pline, H5Z_filter_t filter); -H5_DLL htri_t H5Z_all_filters_avail(struct H5O_pline_t *pline); +H5_DLL htri_t H5Z_all_filters_avail(const struct H5O_pline_t *pline); H5_DLL herr_t H5Z_delete(struct H5O_pline_t *pline, H5Z_filter_t filter); #endif diff --git a/test/dsets.c b/test/dsets.c index 71379cb..707f858 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -582,6 +582,8 @@ test_compact_io(hid_t fapl) H5_FAILED(); printf(" Read different values than written.\n"); printf(" At index %d,%d\n", i, j); + printf(" wbuf[%d][%d]=%d\n", i, j, wbuf[i][j]); + printf(" rbuf[%d][%d]=%d\n", i, j, rbuf[i][j]); goto error; } } @@ -1282,6 +1284,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, { hid_t dataset; /* Dataset ID */ hid_t dxpl; /* Dataset xfer property list ID */ + hid_t write_dxpl; /* Dataset xfer property list ID for writing */ hid_t sid; /* Dataspace ID */ const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ const hssize_t hs_offset[2] = {FILTER_HS_OFFSET1, FILTER_HS_OFFSET2}; /* Hyperslab offset */ @@ -1304,6 +1307,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, #else /* H5_WANT_H5_V1_4_COMPAT */ if (H5Pset_buffer (dxpl, (size_t)1000, tconv_buf, NULL)<0) goto error; #endif /* H5_WANT_H5_V1_4_COMPAT */ + if ((write_dxpl = H5Pcopy (dxpl))<0) TEST_ERROR; if (if_fletcher32==DISABLE_FLETCHER32) { if(H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)<0) @@ -1361,10 +1365,10 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, } } - if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, points)<0) - goto error; + if (H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points)<0) + TEST_ERROR; - if((*dset_size=H5Dget_storage_size(dataset))==0) goto error; + if((*dset_size=H5Dget_storage_size(dataset))==0) TEST_ERROR; PASSED(); @@ -1377,25 +1381,27 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, /* Read the dataset back */ if(corrupted) { /* Default behavior is failure when data is corrupted. */ + /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); } H5E_END_TRY; - if(status>=0) goto error; + if(status>=0) TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ - if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) goto error; + if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) TEST_ERROR; if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) - goto error; + TEST_ERROR; /* Callback decides to fail when data is corrupted. */ - if(H5Pset_filter_callback(dxpl, filter_cb_fail, NULL)<0) goto error; + if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL)<0) TEST_ERROR; + /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); } H5E_END_TRY; - if(status>=0) goto error; + if(status>=0) TEST_ERROR; } else { if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) - goto error; + TEST_ERROR; /* Check that the values read are the same as the values written */ for (i=0; i<size[0]; i++) { @@ -1428,31 +1434,33 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, points[i][j] = (int)HDrandom (); } } - if (H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, points)<0) - goto error; + if (H5Dwrite (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, points)<0) + TEST_ERROR; if(corrupted) { /* Default behavior is failure when data is corrupted. */ + /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); } H5E_END_TRY; - if(status>=0) goto error; + if(status>=0) TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ - if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) goto error; + if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) TEST_ERROR; if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) - goto error; + TEST_ERROR; /* Callback decides to fail when data is corrupted. */ - if(H5Pset_filter_callback(dxpl, filter_cb_fail, NULL)<0) goto error; + if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL)<0) TEST_ERROR; + /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); } H5E_END_TRY; - if(status>=0) goto error; + if(status>=0) TEST_ERROR; } else { /* Read the dataset back and check it */ if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) - goto error; + TEST_ERROR; /* Check that the values read are the same as the values written */ for (i=0; i<size[0]; i++) { @@ -1468,7 +1476,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, } } - if((*dset_size=H5Dget_storage_size(dataset))==0) goto error; + if((*dset_size=H5Dget_storage_size(dataset))==0) TEST_ERROR; PASSED(); /*---------------------------------------------------------------------- @@ -1479,30 +1487,32 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, */ TESTING(" filters (re-open)"); - if (H5Dclose (dataset)<0) goto error; - if ((dataset = H5Dopen (fid, name))<0) goto error; + if (H5Dclose (dataset)<0) TEST_ERROR; + if ((dataset = H5Dopen (fid, name))<0) TEST_ERROR; if(corrupted) { /* Default behavior is failure when data is corrupted. */ + /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); } H5E_END_TRY; - if(status>=0) goto error; + if(status>=0) TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ - if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) goto error; + if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) TEST_ERROR; if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) - goto error; + TEST_ERROR; /* Callback decides to fail when data is corrupted. */ - if(H5Pset_filter_callback(dxpl, filter_cb_fail, NULL)<0) goto error; + if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL)<0) TEST_ERROR; + /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); } H5E_END_TRY; - if(status>=0) goto error; + if(status>=0) TEST_ERROR; } else { if (H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) - goto error; + TEST_ERROR; /* Check that the values read are the same as the values written */ for (i=0; i<size[0]; i++) { @@ -1535,31 +1545,34 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, } } if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, - NULL)<0) goto error; + NULL)<0) TEST_ERROR; + /* (Use the "read" DXPL because partial I/O on corrupted data test needs to ignore errors during writing) */ if (H5Dwrite (dataset, H5T_NATIVE_INT, sid, sid, dxpl, points)<0) - goto error; + TEST_ERROR; if(corrupted) { /* Default behavior is failure when data is corrupted. */ + /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); } H5E_END_TRY; - if(status>=0) goto error; + if(status>=0) TEST_ERROR; /* Callback decides to continue inspite data is corrupted. */ - if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) goto error; + if(H5Pset_filter_callback(dxpl, filter_cb_cont, NULL)<0) TEST_ERROR; if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check)<0) - goto error; + TEST_ERROR; /* Callback decides to fail when data is corrupted. */ - if(H5Pset_filter_callback(dxpl, filter_cb_fail, NULL)<0) goto error; + if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL)<0) TEST_ERROR; + /* (Use the "write" DXPL in order to make certain corruption is seen) */ H5E_BEGIN_TRY { - status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check); + status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check); } H5E_END_TRY; - if(status>=0) goto error; + if(status>=0) TEST_ERROR; } else { if (H5Dread (dataset, H5T_NATIVE_INT, sid, sid, dxpl, check)<0) - goto error; + TEST_ERROR; /* Check that the values read are the same as the values written */ for (i=0; i<hs_size[0]; i++) { @@ -1709,7 +1722,7 @@ test_filters(hid_t file) if (H5Zregister (H5Z_CORRUPT)<0) goto error; #endif /* H5_WANT_H5_V1_4_COMPAT */ if (H5Pset_filter (dc, H5Z_FILTER_CORRUPT, 0, 3, data_corrupt)<0) goto error; - if(test_filter_internal(file,DSET_FLETCHER32_NAME_3,dc,ENABLE_FLETCHER32,DATA_CORRUPTED,&fletcher32_size)<0) goto error; + if(test_filter_internal(file,DSET_FLETCHER32_NAME_3,dc,DISABLE_FLETCHER32,DATA_CORRUPTED,&fletcher32_size)<0) goto error; if(fletcher32_size<=null_size) { H5_FAILED(); puts(" Size after checksumming is incorrect."); @@ -3123,10 +3136,11 @@ error: static herr_t auxread_fdata(hid_t fid, const char *name) { - hid_t dset_id; /* dataset ID */ - hid_t space_id=(-1); /* space ID */ - hid_t ftype_id=(-1); /* file data type ID */ - hid_t mtype_id=(-1); /* memory data type ID */ + hid_t dset_id=-1; /* dataset ID */ + hid_t dcpl_id=-1; /* dataset creation property list ID */ + hid_t space_id=-1; /* space ID */ + hid_t ftype_id=-1; /* file data type ID */ + hid_t mtype_id=-1; /* memory data type ID */ size_t msize; /* memory size of memory type */ void *buf=NULL; /* data buffer */ hsize_t nelmts; /* number of elements in dataset */ @@ -3140,6 +3154,8 @@ auxread_fdata(hid_t fid, const char *name) goto error; if ((ftype_id=H5Dget_type (dset_id))<0) goto error; + if ((dcpl_id=H5Dget_create_plist(dset_id))<0) + goto error; if ( (rank=H5Sget_simple_extent_ndims(space_id))<0) goto error; HDmemset(dims, 0, sizeof dims); @@ -3164,6 +3180,8 @@ auxread_fdata(hid_t fid, const char *name) goto error; } + if (H5Pclose(dcpl_id)<0) + goto error; if (H5Sclose(space_id)<0) goto error; if (H5Dclose(dset_id)<0) @@ -3175,6 +3193,7 @@ auxread_fdata(hid_t fid, const char *name) error: H5E_BEGIN_TRY { + H5Pclose(dcpl_id); H5Sclose(space_id); H5Dclose(dset_id); H5Tclose(ftype_id); @@ -3204,10 +3223,10 @@ error: static herr_t test_filters_endianess(void) { - hid_t fid; /* file ID */ - hid_t dsid=(-1); /* dataset ID */ - hid_t sid; /* dataspace ID */ - hid_t dcpl=(-1); /* dataset creation property list ID */ + hid_t fid=-1; /* file ID */ + hid_t dsid=-1; /* dataset ID */ + hid_t sid=-1; /* dataspace ID */ + hid_t dcpl=-1; /* dataset creation property list ID */ hsize_t dims[1]={2}; /* dataspace dimensions */ hsize_t chunk_dims[1]={2}; /* chunk dimensions */ int buf[2]; @@ -3251,11 +3270,13 @@ test_filters_endianess(void) if (H5Dclose (dsid)<0) goto error; if (H5Sclose (sid)<0) goto error; if (H5Fclose (fid)<0) goto error; + /*------------------------------------------------------------------------- * step 2: open a file written on a little-endian machine in step 1 *------------------------------------------------------------------------- */ - /* compose the name of the file to open, using the srcdir, if appropriate */ + + /* compose the name of the file to open, using the srcdir, if appropriate */ strcpy(data_file, ""); if ( srcdir ) { @@ -3273,10 +3294,12 @@ test_filters_endianess(void) /* close */ if (H5Fclose(fid)<0) goto error; + /*------------------------------------------------------------------------- * step 3: open a file written on a big-endian machine in step 1 *------------------------------------------------------------------------- */ + /* compose the name of the file to open, using the srcdir, if appropriate */ strcpy(data_file, ""); if ( srcdir ) @@ -3330,25 +3353,26 @@ int main(void) { hid_t file, grp, fapl; + int mdc_nelmts; + size_t rdcc_nelmts; + size_t rdcc_nbytes; + double rdcc_w0; int nerrors=0; char filename[1024]; h5_reset(); fapl = h5_fileaccess(); -#if 0 - { - /* Turn off raw data cache */ - int mdc_nelmts; - if (H5Pget_cache(fapl, &mdc_nelmts, NULL, NULL, NULL)<0) goto error; - if (H5Pset_cache(fapl, mdc_nelmts, 0, 0, 0.0)<0) goto error; - } -#endif - /* Set the random # seed */ HDsrandom((unsigned long)HDtime(NULL)); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + + /* Turn off the chunk cache, so all the chunks are immediately written to disk */ + if(H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0)<0) goto error; + rdcc_nbytes=0; + if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0)<0) goto error; + if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) { goto error; } diff --git a/test/set_extent.c b/test/set_extent.c index 067dabc..845d621 100644 --- a/test/set_extent.c +++ b/test/set_extent.c @@ -67,17 +67,17 @@ int main( void ) /* Create a new file using default properties. */ - if ((file_id = H5Fcreate( "set_extent_create.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ))<0) goto out; + if ((file_id = H5Fcreate( "set_extent_create.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT ))<0) TEST_ERROR; TESTING("extend dataset create with fill value"); /* Create the data space with unlimited dimensions. */ - if ((space_id = H5Screate_simple( RANK, dims, maxdims ))<0) goto out; + if ((space_id = H5Screate_simple( RANK, dims, maxdims ))<0) TEST_ERROR; /* Modify dataset creation properties, i.e. enable chunking. */ - if ((plist_id = H5Pcreate (H5P_DATASET_CREATE ))<0) goto out; - if (H5Pset_chunk( plist_id, RANK, dims_chunk )<0) goto out; - if (H5Pset_fill_value( plist_id, H5T_NATIVE_INT, &fillvalue )<0) goto out; + if ((plist_id = H5Pcreate (H5P_DATASET_CREATE ))<0) TEST_ERROR; + if (H5Pset_chunk( plist_id, RANK, dims_chunk )<0) TEST_ERROR; + if (H5Pset_fill_value( plist_id, H5T_NATIVE_INT, &fillvalue )<0) TEST_ERROR; /*------------------------------------------------------------------------- @@ -86,10 +86,10 @@ int main( void ) */ /* Create a new dataset */ - if ((dataset_id = H5Dcreate( file_id , "Dataset1", H5T_NATIVE_INT, space_id, plist_id ))<0) goto out; + if ((dataset_id = H5Dcreate( file_id , "Dataset1", H5T_NATIVE_INT, space_id, plist_id ))<0) TEST_ERROR; /* Write the data. */ - if (H5Dwrite( dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data )<0) goto out; + if (H5Dwrite( dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data )<0) TEST_ERROR; /*------------------------------------------------------------------------- * Set new dimensions for the array; shrink it @@ -97,15 +97,16 @@ int main( void ) */ /* Set new dimensions for the array. */ - if (H5Dset_extent( dataset_id , dims_new )<0) goto out; + if (H5Dset_extent( dataset_id , dims_new )<0) TEST_ERROR; /* Get the space. */ - if ((space_id = H5Dget_space( dataset_id ))<0) goto out; + if ((space_id = H5Dget_space( dataset_id ))<0) TEST_ERROR; /* Get dimensions. */ - if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) goto out; + if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) TEST_ERROR; - if ( dims_out[0] != dims_new[0] ) goto out; + if ( dims_out[0] != dims_new[0] ) TEST_ERROR; + if ( dims_out[1] != dims_new[1] ) TEST_ERROR; /*------------------------------------------------------------------------- @@ -114,13 +115,17 @@ int main( void ) */ /* Read the new dataset. */ - if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 )<0) goto out; + if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 )<0) TEST_ERROR; /* Compare the read array with the original array */ for( i = 0; i < (int)dims_out[0]; i++ ) for( j = 0; j < (int)dims_out[1]; j++ ) - if ( buf1[i][j] != data[i][j] ) goto out; + if ( buf1[i][j] != data[i][j] ) { + printf("buf1[%d][%d]=%d\n",i,j,buf1[i][j]); + printf("data[%d][%d]=%d\n",i,j,data[i][j]); + TEST_ERROR; + } /* end if */ /*------------------------------------------------------------------------- @@ -129,15 +134,15 @@ int main( void ) */ /* Set new dimensions for the array. */ - if (H5Dset_extent( dataset_id , dims )<0) goto out; + if (H5Dset_extent( dataset_id , dims )<0) TEST_ERROR; /* Get the space. */ - if ((space_id = H5Dget_space( dataset_id ))<0) goto out; + if ((space_id = H5Dget_space( dataset_id ))<0) TEST_ERROR; /* Get dimensions. */ - if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) goto out; + if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) TEST_ERROR; - if ( dims_out[0] != dims[0] ) goto out; + if ( dims_out[0] != dims[0] ) TEST_ERROR; /*------------------------------------------------------------------------- @@ -146,16 +151,16 @@ int main( void ) */ /* Read the new dataset. */ - if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 )<0) goto out; + if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 )<0) TEST_ERROR; /* Compare the read array with the original array */ for( i = 0; i < (int)dims_out[0]; i++ ) { for( j = 0; j < (int)dims_out[1]; j++ ) { if ( i >= 70 || j >= 70 ) { - if ( buf2[i][j] != fillvalue ) goto out; + if ( buf2[i][j] != fillvalue ) TEST_ERROR; } else { - if ( buf2[i][j] != data[i][j] ) goto out; + if ( buf2[i][j] != data[i][j] ) TEST_ERROR; } } } @@ -174,12 +179,12 @@ int main( void ) TESTING("extend dataset create without fill value"); /* Create the data space with unlimited dimensions. */ - if ((space_id = H5Screate_simple( RANK, dims, maxdims ))<0) goto out; + if ((space_id = H5Screate_simple( RANK, dims, maxdims ))<0) TEST_ERROR; /* Modify dataset creation properties, i.e. enable chunking. */ - if ((plist_id = H5Pcreate (H5P_DATASET_CREATE ))<0) goto out; - if (H5Pset_chunk( plist_id, RANK, dims_chunk )<0) goto out; - if (H5Pset_fill_time( plist_id, H5D_FILL_TIME_ALLOC)<0) goto out; + if ((plist_id = H5Pcreate (H5P_DATASET_CREATE ))<0) TEST_ERROR; + if (H5Pset_chunk( plist_id, RANK, dims_chunk )<0) TEST_ERROR; + if (H5Pset_fill_time( plist_id, H5D_FILL_TIME_ALLOC)<0) TEST_ERROR; /*------------------------------------------------------------------------- * Create and write one dataset @@ -187,10 +192,10 @@ int main( void ) */ /* Create a new dataset */ - if ((dataset_id = H5Dcreate( file_id , "Dataset2", H5T_NATIVE_INT, space_id, plist_id ))<0) goto out; + if ((dataset_id = H5Dcreate( file_id , "Dataset2", H5T_NATIVE_INT, space_id, plist_id ))<0) TEST_ERROR; /* Write the data. */ - if (H5Dwrite( dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data )<0) goto out; + if (H5Dwrite( dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data )<0) TEST_ERROR; /*------------------------------------------------------------------------- * Set new dimensions for the array; shrink it @@ -198,15 +203,15 @@ int main( void ) */ /* Set new dimensions for the array. */ - if (H5Dset_extent( dataset_id , dims_new )<0) goto out; + if (H5Dset_extent( dataset_id , dims_new )<0) TEST_ERROR; /* Get the space. */ - if ((space_id = H5Dget_space( dataset_id ))<0) goto out; + if ((space_id = H5Dget_space( dataset_id ))<0) TEST_ERROR; /* Get dimensions. */ - if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) goto out; + if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) TEST_ERROR; - if ( dims_out[0] != dims_new[0] ) goto out; + if ( dims_out[0] != dims_new[0] ) TEST_ERROR; /*------------------------------------------------------------------------- @@ -215,13 +220,13 @@ int main( void ) */ /* Read the new dataset. */ - if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 )<0) goto out; + if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 )<0) TEST_ERROR; /* Compare the read array with the original array */ for( i = 0; i < (int)dims_out[0]; i++ ) for( j = 0; j < (int)dims_out[1]; j++ ) - if ( buf1[i][j] != data[i][j] ) goto out; + if ( buf1[i][j] != data[i][j] ) TEST_ERROR; /*------------------------------------------------------------------------- @@ -230,15 +235,15 @@ int main( void ) */ /* Set new dimensions for the array. */ - if (H5Dset_extent( dataset_id , dims )<0) goto out; + if (H5Dset_extent( dataset_id , dims )<0) TEST_ERROR; /* Get the space. */ - if ((space_id = H5Dget_space( dataset_id ))<0) goto out; + if ((space_id = H5Dget_space( dataset_id ))<0) TEST_ERROR; /* Get dimensions. */ - if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) goto out; + if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) TEST_ERROR; - if ( dims_out[0] != dims[0] ) goto out; + if ( dims_out[0] != dims[0] ) TEST_ERROR; /*------------------------------------------------------------------------- @@ -247,16 +252,16 @@ int main( void ) */ /* Read the new dataset. */ - if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 )<0) goto out; + if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 )<0) TEST_ERROR; /* Compare the read array with the original array */ for( i = 0; i < (int)dims_out[0]; i++ ) { for( j = 0; j < (int)dims_out[1]; j++ ) { if ( i >= 70 || j >= 70 ) { - if ( buf2[i][j] != 0 ) goto out; + if ( buf2[i][j] != 0 ) TEST_ERROR; } else { - if ( buf2[i][j] != data[i][j] ) goto out; + if ( buf2[i][j] != data[i][j] ) TEST_ERROR; } } } @@ -283,32 +288,32 @@ int main( void ) */ /* Create a file creation property list */ - if((fcpl = H5Pcreate(H5P_FILE_CREATE))<0) goto out; + if((fcpl = H5Pcreate(H5P_FILE_CREATE))<0) TEST_ERROR; /* Set non-default indexed storage B-tree internal 'K' value */ - if(H5Pset_istore_k(fcpl,ISTORE_IK)<0) goto out; + if(H5Pset_istore_k(fcpl,ISTORE_IK)<0) TEST_ERROR; /* Create a new file using properties. */ - if ((file_id = H5Fcreate( "set_extent_read.h5", H5F_ACC_TRUNC, fcpl, H5P_DEFAULT ))<0) goto out; + if ((file_id = H5Fcreate( "set_extent_read.h5", H5F_ACC_TRUNC, fcpl, H5P_DEFAULT ))<0) TEST_ERROR; /* Close property list */ - if(H5Pclose(fcpl)<0) goto out; + if(H5Pclose(fcpl)<0) TEST_ERROR; TESTING("extend dataset read with fill value"); /* Create the data space with unlimited dimensions. */ - if ((space_id = H5Screate_simple( RANK, dims, maxdims ))<0) goto out; + if ((space_id = H5Screate_simple( RANK, dims, maxdims ))<0) TEST_ERROR; /* Modify dataset creation properties, i.e. enable chunking. */ - if ((plist_id = H5Pcreate (H5P_DATASET_CREATE ))<0) goto out; - if (H5Pset_chunk( plist_id, RANK, dims_chunk )<0) goto out; - if (H5Pset_fill_value( plist_id, H5T_NATIVE_INT, &fillvalue )<0) goto out; + if ((plist_id = H5Pcreate (H5P_DATASET_CREATE ))<0) TEST_ERROR; + if (H5Pset_chunk( plist_id, RANK, dims_chunk )<0) TEST_ERROR; + if (H5Pset_fill_value( plist_id, H5T_NATIVE_INT, &fillvalue )<0) TEST_ERROR; /* Create a new dataset within the file using cparms creation properties. */ - if ((dataset_id = H5Dcreate( file_id , "Dataset1", H5T_NATIVE_INT, space_id, plist_id ))<0) goto out; + if ((dataset_id = H5Dcreate( file_id , "Dataset1", H5T_NATIVE_INT, space_id, plist_id ))<0) TEST_ERROR; /* Write the data. */ - if (H5Dwrite( dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data )<0) goto out; + if (H5Dwrite( dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data )<0) TEST_ERROR; /* Close/release resources. */ H5Dclose( dataset_id ); @@ -318,29 +323,29 @@ int main( void ) /* Open the file */ - if ((file_id = H5Fopen( "set_extent_read.h5", H5F_ACC_RDWR, H5P_DEFAULT ))<0) goto out; + if ((file_id = H5Fopen( "set_extent_read.h5", H5F_ACC_RDWR, H5P_DEFAULT ))<0) TEST_ERROR; /* Open the dataset */ - if ((dataset_id = H5Dopen( file_id , "Dataset1" ))<0) goto out; + if ((dataset_id = H5Dopen( file_id , "Dataset1" ))<0) TEST_ERROR; /* Set new dimensions for the array. */ - if (H5Dset_extent( dataset_id, dims_new )<0) goto out; + if (H5Dset_extent( dataset_id, dims_new )<0) TEST_ERROR; /* Get the space. */ - if ((space_id = H5Dget_space( dataset_id ))<0) goto out; + if ((space_id = H5Dget_space( dataset_id ))<0) TEST_ERROR; /* Get dimensions. */ - if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) goto out; + if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) TEST_ERROR; - if ( dims_out[0] != dims_new[0] ) goto out; + if ( dims_out[0] != dims_new[0] ) TEST_ERROR; /* Read the new dataset. */ - if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 )<0) goto out; + if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 )<0) TEST_ERROR; /* Compare the read array with the original array */ for( i = 0; i < (int)dims_out[0]; i++ ) for( j = 0; j < (int)dims_out[1]; j++ ) - if ( buf1[i][j] != data[i][j] ) goto out; + if ( buf1[i][j] != data[i][j] ) TEST_ERROR; /*------------------------------------------------------------------------- * Set new dimensions for the array; expand it again @@ -348,27 +353,27 @@ int main( void ) */ /* Set new dimensions for the array. */ - if (H5Dset_extent( dataset_id , dims )<0) goto out; + if (H5Dset_extent( dataset_id , dims )<0) TEST_ERROR; /* Get the space. */ - if ((space_id = H5Dget_space( dataset_id ))<0) goto out; + if ((space_id = H5Dget_space( dataset_id ))<0) TEST_ERROR; /* Get dimensions. */ - if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) goto out; + if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) TEST_ERROR; - if ( dims_out[0] != dims[0] ) goto out; + if ( dims_out[0] != dims[0] ) TEST_ERROR; /* Read the new dataset. */ - if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 )<0) goto out; + if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 )<0) TEST_ERROR; /* Compare the read array with the original array */ for( i = 0; i < (int)dims_out[0]; i++ ) { for( j = 0; j < (int)dims_out[1]; j++ ) { if ( i >= 70 || j >= 70 ) { - if ( buf2[i][j] != fillvalue ) goto out; + if ( buf2[i][j] != fillvalue ) TEST_ERROR; } else { - if ( buf2[i][j] != data[i][j] ) goto out; + if ( buf2[i][j] != data[i][j] ) TEST_ERROR; } } } @@ -388,18 +393,18 @@ int main( void ) TESTING("extend dataset read without fill value"); /* Create the data space with unlimited dimensions. */ - if ((space_id = H5Screate_simple( RANK, dims, maxdims ))<0) goto out; + if ((space_id = H5Screate_simple( RANK, dims, maxdims ))<0) TEST_ERROR; /* Modify dataset creation properties, i.e. enable chunking. */ - if ((plist_id = H5Pcreate (H5P_DATASET_CREATE ))<0) goto out; - if (H5Pset_chunk( plist_id, RANK, dims_chunk )<0) goto out; - if (H5Pset_fill_time( plist_id, H5D_FILL_TIME_ALLOC)<0) goto out; + if ((plist_id = H5Pcreate (H5P_DATASET_CREATE ))<0) TEST_ERROR; + if (H5Pset_chunk( plist_id, RANK, dims_chunk )<0) TEST_ERROR; + if (H5Pset_fill_time( plist_id, H5D_FILL_TIME_ALLOC)<0) TEST_ERROR; /* Create a new dataset within the file using cparms creation properties. */ - if ((dataset_id = H5Dcreate( file_id , "Dataset2", H5T_NATIVE_INT, space_id, plist_id ))<0) goto out; + if ((dataset_id = H5Dcreate( file_id , "Dataset2", H5T_NATIVE_INT, space_id, plist_id ))<0) TEST_ERROR; /* Write the data. */ - if (H5Dwrite( dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data )<0) goto out; + if (H5Dwrite( dataset_id , H5T_NATIVE_INT, space_id, H5S_ALL, H5P_DEFAULT, data )<0) TEST_ERROR; /* Close/release resources. */ H5Dclose( dataset_id ); @@ -409,29 +414,29 @@ int main( void ) /* Open the file */ - if ((file_id = H5Fopen( "set_extent_read.h5", H5F_ACC_RDWR, H5P_DEFAULT ))<0) goto out; + if ((file_id = H5Fopen( "set_extent_read.h5", H5F_ACC_RDWR, H5P_DEFAULT ))<0) TEST_ERROR; /* Open the dataset */ - if ((dataset_id = H5Dopen( file_id , "Dataset2" ))<0) goto out; + if ((dataset_id = H5Dopen( file_id , "Dataset2" ))<0) TEST_ERROR; /* Set new dimensions for the array. */ - if (H5Dset_extent( dataset_id, dims_new )<0) goto out; + if (H5Dset_extent( dataset_id, dims_new )<0) TEST_ERROR; /* Get the space. */ - if ((space_id = H5Dget_space( dataset_id ))<0) goto out; + if ((space_id = H5Dget_space( dataset_id ))<0) TEST_ERROR; /* Get dimensions. */ - if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) goto out; + if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) TEST_ERROR; - if ( dims_out[0] != dims_new[0] ) goto out; + if ( dims_out[0] != dims_new[0] ) TEST_ERROR; /* Read the new dataset. */ - if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 )<0) goto out; + if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1 )<0) TEST_ERROR; /* Compare the read array with the original array */ for( i = 0; i < (int)dims_out[0]; i++ ) for( j = 0; j < (int)dims_out[1]; j++ ) - if ( buf1[i][j] != data[i][j] ) goto out; + if ( buf1[i][j] != data[i][j] ) TEST_ERROR; /*------------------------------------------------------------------------- * Set new dimensions for the array; expand it again @@ -439,27 +444,27 @@ int main( void ) */ /* Set new dimensions for the array. */ - if (H5Dset_extent( dataset_id , dims )<0) goto out; + if (H5Dset_extent( dataset_id , dims )<0) TEST_ERROR; /* Get the space. */ - if ((space_id = H5Dget_space( dataset_id ))<0) goto out; + if ((space_id = H5Dget_space( dataset_id ))<0) TEST_ERROR; /* Get dimensions. */ - if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) goto out; + if (H5Sget_simple_extent_dims( space_id, dims_out, NULL )<0) TEST_ERROR; - if ( dims_out[0] != dims[0] ) goto out; + if ( dims_out[0] != dims[0] ) TEST_ERROR; /* Read the new dataset. */ - if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 )<0) goto out; + if (H5Dread( dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2 )<0) TEST_ERROR; /* Compare the read array with the original array */ for( i = 0; i < (int)dims_out[0]; i++ ) { for( j = 0; j < (int)dims_out[1]; j++ ) { if ( i >= 70 || j >= 70 ) { - if ( buf2[i][j] != 0 ) goto out; + if ( buf2[i][j] != 0 ) TEST_ERROR; } else { - if ( buf2[i][j] != data[i][j] ) goto out; + if ( buf2[i][j] != data[i][j] ) TEST_ERROR; } } } @@ -482,7 +487,7 @@ int main( void ) return 0; -out: +error: H5Dclose( dataset_id ); H5Sclose( space_id ); H5Pclose( plist_id ); diff --git a/test/tmisc.c b/test/tmisc.c index b60a0a7..9667e4f 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -229,8 +229,8 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset #define MISC20_DSET_NAME "Dataset" #define MISC20_DSET2_NAME "Dataset2" #define MISC20_SPACE_RANK 2 -#define MISC20_SPACE_DIM0 (8*1024*1024*1024ULL) -#define MISC20_SPACE_DIM1 ((4*1024*1024*1024ULL)+1ULL) +#define MISC20_SPACE_DIM0 (8*1024*1024*(uint64_t)1024) +#define MISC20_SPACE_DIM1 ((4*1024*1024*(uint64_t)1024)+1) #define MISC20_SPACE2_DIM0 8 #define MISC20_SPACE2_DIM1 4 |