summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-12-19 04:30:12 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-12-19 04:30:12 (GMT)
commit1aafde9a46a31dd4a8dffb0cb07d3709f06dc8c3 (patch)
tree630fa724b7384340a203177a57c3236538eebd96
parent113a60aac235b9c4fed65c952eda79bdbfbf9d8b (diff)
downloadhdf5-1aafde9a46a31dd4a8dffb0cb07d3709f06dc8c3.zip
hdf5-1aafde9a46a31dd4a8dffb0cb07d3709f06dc8c3.tar.gz
hdf5-1aafde9a46a31dd4a8dffb0cb07d3709f06dc8c3.tar.bz2
[svn-r18036] Description:
Code cleanups to remove compile warnings and improve the style of changes. Tested on: Mac OS X/32 10.6.2 (amazon) debug & production (h5committest not required on this branch)
-rw-r--r--src/H5B.c898
-rw-r--r--src/H5Dtest.c6
-rw-r--r--src/H5FLprivate.h4
-rw-r--r--src/H5Fsuper.c70
-rw-r--r--src/H5HL.c32
-rw-r--r--src/H5L.c2
-rw-r--r--src/H5Ofill.c4
-rw-r--r--src/H5RS.c2
-rwxr-xr-xsrc/H5SM.c23
-rw-r--r--src/H5SMtest.c2
-rw-r--r--src/H5Sall.c19
-rw-r--r--src/H5Snone.c21
-rw-r--r--src/H5Tconv.c12
-rw-r--r--test/gen_deflate.c2
-rw-r--r--test/gen_noencoder.c2
15 files changed, 475 insertions, 624 deletions
diff --git a/src/H5B.c b/src/H5B.c
index 3536c96..2567fb6 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -205,19 +205,6 @@ H5FL_SEQ_DEFINE_STATIC(size_t);
* matzke@llnl.gov
* Jun 23 1997
*
- * Modifications:
- * Robb Matzke, 1999-07-28
- * Changed the name of the ADDR argument to ADDR_P to make it
- * obvious that the address is passed by reference unlike most
- * other functions that take addresses.
- *
- * John Mainzer 6/9/05
- * Removed code setting the is_dirty field of the cache info.
- * This is no longer pemitted, as the cache code is now
- * manageing this field. Since this function uses a call to
- * H5AC2_set() (which marks the entry dirty automaticly), no
- * other change is required.
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -233,30 +220,30 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata,
/*
* Check arguments.
*/
- assert(f);
- assert(type);
- assert(addr_p);
+ HDassert(f);
+ HDassert(type);
+ HDassert(addr_p);
/*
* Allocate file and memory data structures.
*/
- if (NULL==(bt = H5FL_MALLOC(H5B_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node")
+ if(NULL == (bt = H5FL_MALLOC(H5B_t)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node")
HDmemset(&bt->cache_info, 0, sizeof(H5AC2_info_t));
bt->level = 0;
bt->left = HADDR_UNDEF;
bt->right = HADDR_UNDEF;
bt->nchildren = 0;
- if((bt->rc_shared=(type->get_shared)(f, udata))==NULL)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree node buffer")
+ if(NULL == (bt->rc_shared = (type->get_shared)(f, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree node buffer")
H5RC_INC(bt->rc_shared);
shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
HDassert(shared);
- if (NULL==(bt->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) ||
- NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node")
- if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)shared->sizeof_rnode)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree root node")
+ if(NULL == (bt->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) ||
+ NULL == (bt->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for B-tree root node")
+ if(HADDR_UNDEF == (*addr_p = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)shared->sizeof_rnode)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "file allocation failed for B-tree root node")
/*
* Cache the new B-tree node.
@@ -268,14 +255,14 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata,
#endif
done:
- if (ret_value<0) {
+ if(ret_value < 0) {
if(shared && shared->sizeof_rnode>0) {
H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t);
(void)H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, *addr_p, (hsize_t)shared->sizeof_rnode);
} /* end if */
- if (bt)
+ if(bt)
(void)H5B_dest(bt);
- }
+ } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B_create() */ /*lint !e818 Can't make udata a pointer to const */
@@ -302,9 +289,6 @@ done:
* matzke@llnl.gov
* Jun 23 1997
*
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
@@ -323,16 +307,16 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u
/*
* Check arguments.
*/
- assert(f);
- assert(type);
- assert(type->decode);
- assert(type->cmp3);
- assert(type->found);
- assert(H5F_addr_defined(addr));
+ HDassert(f);
+ HDassert(type);
+ HDassert(type->decode);
+ HDassert(type->cmp3);
+ HDassert(type->found);
+ HDassert(H5F_addr_defined(addr));
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
HDassert(shared);
@@ -344,19 +328,18 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u
cache_udata.type = type;
cache_udata.rc_shared = rc_shared;
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node")
rt = bt->nchildren;
- while (lt < rt && cmp) {
+ while(lt < rt && cmp) {
idx = (lt + rt) / 2;
/* compare */
- if ((cmp = (type->cmp3)(H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1))) < 0) {
+ if((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0)
rt = idx;
- } else {
- lt = idx+1;
- }
- }
- if (cmp)
+ else
+ lt = idx + 1;
+ } /* end while */
+ if(cmp)
/* Note: don't push error on stack, leave that to next higher level,
* since many times the B-tree is searched in order to determine
* if an object exists in the B-tree or not. -QAK
@@ -370,10 +353,10 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u
/*
* Follow the link to the subtree or to the data node.
*/
- assert(idx < bt->nchildren);
+ HDassert(idx < bt->nchildren);
- if (bt->level > 0) {
- if (H5B_find(f, dxpl_id, type, bt->child[idx], udata) < 0)
+ if(bt->level > 0) {
+ if(H5B_find(f, dxpl_id, type, bt->child[idx], udata) < 0)
/* Note: don't push error on stack, leave that to next higher level,
* since many times the B-tree is searched in order to determine
* if an object exists in the B-tree or not. -QAK
@@ -384,7 +367,7 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u
HGOTO_DONE(FAIL)
#endif /* OLD_WAY */
} else {
- if ((type->found) (f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx), udata) < 0)
+ if((type->found)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt, shared, idx), udata) < 0)
/* Note: don't push error on stack, leave that to next higher level,
* since many times the B-tree is searched in order to determine
* if an object exists in the B-tree or not. -QAK
@@ -398,7 +381,7 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u
done:
if(bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node")
+ HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release node")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B_find() */
@@ -424,20 +407,6 @@ done:
* matzke@llnl.gov
* Jul 3 1997
*
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The OLD_ADDR argument is passed by value. The NEW_ADDR
- * argument has been renamed to NEW_ADDR_P
- *
- * John Mainzer, 6/9/05
- * Modified the function to use the new dirtied parameter of
- * of H5AC2_unprotect() instead of modifying the is_dirty
- * field of the cache info.
- *
- * In this case, that required adding the new
- * old_bt_dirtied_ptr parameter to the function's argument
- * list.
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -458,39 +427,38 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags,
/*
* Check arguments.
*/
- assert(f);
- assert(old_bt);
- assert(old_bt_flags);
- assert(H5F_addr_defined(old_addr));
+ HDassert(f);
+ HDassert(old_bt);
+ HDassert(old_bt_flags);
+ HDassert(H5F_addr_defined(old_addr));
/*
* Initialize variables.
*/
- shared=(H5B_shared_t *)H5RC_GET_OBJ(old_bt->rc_shared);
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(old_bt->rc_shared);
HDassert(shared);
- assert(old_bt->nchildren == shared->two_k);
+ HDassert(old_bt->nchildren == shared->two_k);
/* Get the dataset transfer property list */
- if (NULL == (dx_plist = (H5P_genplist_t *)H5I_object(dxpl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list")
+ if(NULL == (dx_plist = (H5P_genplist_t *)H5I_object(dxpl_id)))
+ HGOTO_ERROR(H5E_BTREE, H5E_BADTYPE, FAIL, "not a dataset transfer property list")
/* Get B-tree split ratios */
- if(H5P_get(dx_plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &split_ratios[0])<0)
- HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve B-tree split ratios")
+ if(H5P_get(dx_plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &split_ratios[0]) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree split ratios")
#ifdef H5B_DEBUG
- if (H5DEBUG(B)) {
+ if(H5DEBUG(B)) {
const char *side;
- if (!H5F_addr_defined(old_bt->left) &&
- !H5F_addr_defined(old_bt->right)) {
+
+ if(!H5F_addr_defined(old_bt->left) && !H5F_addr_defined(old_bt->right))
side = "ONLY";
- } else if (!H5F_addr_defined(old_bt->right)) {
+ else if(!H5F_addr_defined(old_bt->right))
side = "RIGHT";
- } else if (!H5F_addr_defined(old_bt->left)) {
+ else if(!H5F_addr_defined(old_bt->left))
side = "LEFT";
- } else {
+ else
side = "MIDDLE";
- }
fprintf(H5DEBUG(B), "H5B_split: %3u {%5.3f,%5.3f,%5.3f} %6s",
shared->two_k, split_ratios[0], split_ratios[1], split_ratios[2], side);
}
@@ -500,40 +468,38 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags,
* Decide how to split the children of the old node among the old node
* and the new node.
*/
- if (!H5F_addr_defined(old_bt->right)) {
+ if(!H5F_addr_defined(old_bt->right))
nleft = (unsigned)((double)shared->two_k * split_ratios[2]); /*right*/
- } else if (!H5F_addr_defined(old_bt->left)) {
+ else if(!H5F_addr_defined(old_bt->left))
nleft = (unsigned)((double)shared->two_k * split_ratios[0]); /*left*/
- } else {
+ else
nleft = (unsigned)((double)shared->two_k * split_ratios[1]); /*middle*/
- }
/*
* Keep the new child in the same node as the child that split. This can
* result in nodes that have an unused child when data is written
* sequentially, but it simplifies stuff below.
*/
- if (idx<nleft && nleft==shared->two_k) {
+ if(idx < nleft && nleft == shared->two_k)
--nleft;
- } else if (idx>=nleft && 0==nleft) {
+ else if(idx >= nleft && 0 == nleft)
nleft++;
- }
nright = shared->two_k - nleft;
#ifdef H5B_DEBUG
- if (H5DEBUG(B))
+ if(H5DEBUG(B))
fprintf(H5DEBUG(B), " split %3d/%-3d\n", nleft, nright);
#endif
/*
* Create the new B-tree node.
*/
- if (H5B_create(f, dxpl_id, shared->type, udata, new_addr_p/*out*/) < 0)
+ if(H5B_create(f, dxpl_id, shared->type, udata, new_addr_p/*out*/) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create B-tree")
cache_udata.f = f;
cache_udata.type = shared->type;
cache_udata.rc_shared = old_bt->rc_shared;
if(NULL == (new_bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, *new_addr_p, shared->sizeof_rnode, &cache_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to protect B-tree")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree")
new_bt->level = old_bt->level;
/*
@@ -550,10 +516,10 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags,
new_bt_flags |= H5AC2__DIRTIED_FLAG;
HDmemcpy(new_bt->native,
old_bt->native + nleft * shared->type->sizeof_nkey,
- (nright+1) * shared->type->sizeof_nkey);
+ (nright + 1) * shared->type->sizeof_nkey);
HDmemcpy(new_bt->child,
&old_bt->child[nleft],
- nright*sizeof(haddr_t));
+ nright * sizeof(haddr_t));
new_bt->nchildren = nright;
@@ -577,19 +543,19 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags,
cache_udata2.type = shared->type;
cache_udata2.rc_shared = old_bt->rc_shared;
if(NULL == (tmp_bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, old_bt->right, shared->sizeof_rnode, &cache_udata2, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load right sibling")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load right sibling")
tmp_bt->left = *new_addr_p;
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, old_bt->right, (size_t)0, tmp_bt, H5AC2__DIRTIED_FLAG) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
} /* end if */
old_bt->right = *new_addr_p;
done:
if(new_bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, *new_addr_p, (size_t)0, new_bt, new_bt_flags) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
+ HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B_split() */
@@ -607,25 +573,6 @@ done:
* matzke@llnl.gov
* Jun 23 1997
*
- * Modifications:
- * Robb Matzke, 28 Sep 1998
- * The optional SPLIT_RATIOS[] indicates what percent of the child
- * pointers should go in the left node when a node splits. There are
- * three possibilities and a separate split ratio can be specified for
- * each: [0] The node that split is the left-most node at its level of
- * the tree, [1] the node that split has left and right siblings, [2]
- * the node that split is the right-most node at its level of the tree.
- * When a node is an only node at its level then we use the right-most
- * rule. If SPLIT_RATIOS is null then default values are used.
- *
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
- *
- * John Mainzer, 6/9/05
- * Modified the function to use the new dirtied parameter of
- * of H5AC2_unprotect() instead of modifying the is_dirty
- * field of the cache info.
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -654,21 +601,21 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
FUNC_ENTER_NOAPI(H5B_insert, FAIL)
/* Check arguments. */
- assert(f);
- assert(type);
- assert(type->sizeof_nkey <= sizeof _lt_key);
- assert(H5F_addr_defined(addr));
+ HDassert(f);
+ HDassert(type);
+ HDassert(type->sizeof_nkey <= sizeof _lt_key);
+ HDassert(H5F_addr_defined(addr));
- if ((int)(my_ins = H5B_insert_helper(f, dxpl_id, addr, type, lt_key,
- &lt_key_changed, md_key, udata, rt_key, &rt_key_changed, &child/*out*/))<0)
+ if((int)(my_ins = H5B_insert_helper(f, dxpl_id, addr, type, lt_key,
+ &lt_key_changed, md_key, udata, rt_key, &rt_key_changed, &child/*out*/)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to insert key")
- if (H5B_INS_NOOP == my_ins)
+ if(H5B_INS_NOOP == my_ins)
HGOTO_DONE(SUCCEED)
HDassert(H5B_INS_RIGHT == my_ins);
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
HDassert(shared);
@@ -677,26 +624,26 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
cache_udata.type = type;
cache_udata.rc_shared = rc_shared;
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to locate root of B-tree")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to locate root of B-tree")
level = bt->level;
- if (!lt_key_changed)
+ if(!lt_key_changed)
HDmemcpy(lt_key, H5B_NKEY(bt,shared,0), type->sizeof_nkey);
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release new child")
bt = NULL;
/* the new node */
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, child, shared->sizeof_rnode, &cache_udata, H5AC2_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load new node")
- if (!rt_key_changed)
+ if(!rt_key_changed)
HDmemcpy(rt_key, H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey);
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, child, (size_t)0, bt, H5AC2__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release new child")
bt = NULL;
/*
@@ -705,17 +652,17 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
* from "moving".
*/
H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t);
- if (HADDR_UNDEF==(old_root=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)shared->sizeof_rnode)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space to move root")
+ if(HADDR_UNDEF == (old_root = H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)shared->sizeof_rnode)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "unable to allocate file space to move root")
/* update the new child's left pointer */
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, child, shared->sizeof_rnode, &cache_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load new child")
bt->left = old_root;
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, child, (size_t)0, bt, H5AC2__DIRTIED_FLAG) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release new child")
bt = NULL; /* Make certain future references will be caught */
/*
@@ -724,23 +671,23 @@ 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 = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, 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 */
/* Make a copy of the old root information */
- if (NULL == (new_bt = H5B_copy(bt))) {
- HCOMMON_ERROR(H5E_BTREE, H5E_CANTLOAD, "unable to copy old root");
+ if(NULL == (new_bt = H5B_copy(bt))) {
+ HCOMMON_ERROR(H5E_BTREE, H5E_CANTCOPY, "unable to copy old root");
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__DIRTIED_FLAG) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release new child")
HGOTO_DONE(FAIL)
- }
+ } /* end if */
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__DIRTIED_FLAG) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release new child")
bt = NULL; /* Make certain future references will be caught */
/* Move the location of the old root on the disk */
@@ -789,18 +736,6 @@ done:
* matzke@llnl.gov
* Jul 8 1997
*
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The CHILD argument is passed by value.
- *
- * John Mainzer, 6/9/05
- * Modified the function to use the new dirtied parameter of
- * of H5AC2_unprotect() instead of modifying the is_dirty
- * field of the cache info.
- *
- * In this case, that required adding the new dirtied_ptr
- * parameter to the function's argument list.
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -812,28 +747,28 @@ H5B_insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx,
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5B_insert_child)
- assert(bt);
- assert(bt_flags);
- shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
+ HDassert(bt);
+ HDassert(bt_flags);
+ shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
HDassert(shared);
- assert(bt->nchildren<shared->two_k);
+ HDassert(bt->nchildren < shared->two_k);
/* Check for inserting right-most key into node (common when just appending
* records to an unlimited dimension chunked dataset)
*/
- base=H5B_NKEY(bt,shared,(idx+1));
- if((idx+1)==bt->nchildren) {
+ base = H5B_NKEY(bt, shared, (idx + 1));
+ if((idx + 1) == bt->nchildren) {
/* Make room for the new key */
HDmemcpy(base + shared->type->sizeof_nkey, base,
shared->type->sizeof_nkey); /* No overlap possible - memcpy() OK */
HDmemcpy(base, md_key, shared->type->sizeof_nkey);
/* The MD_KEY is the left key of the new node */
- if (H5B_INS_RIGHT == anchor)
+ if(H5B_INS_RIGHT == anchor)
idx++; /* Don't have to memmove() child addresses down, just add new child */
else
/* Make room for the new child address */
- bt->child[idx+1] = bt->child[idx];
+ bt->child[idx + 1] = bt->child[idx];
} /* end if */
else {
/* Make room for the new key */
@@ -842,7 +777,7 @@ H5B_insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx,
HDmemcpy(base, md_key, shared->type->sizeof_nkey);
/* The MD_KEY is the left key of the new node */
- if (H5B_INS_RIGHT == anchor)
+ if(H5B_INS_RIGHT == anchor)
idx++;
/* Make room for the new child address */
@@ -889,27 +824,6 @@ H5B_insert_child(H5B_t *bt, unsigned *bt_flags, unsigned idx,
* matzke@llnl.gov
* Jul 9 1997
*
- * Modifications:
- *
- * Robb Matzke, 28 Sep 1998
- * The optional SPLIT_RATIOS[] indicates what percent of the child
- * pointers should go in the left node when a node splits. There are
- * three possibilities and a separate split ratio can be specified for
- * each: [0] The node that split is the left-most node at its level of
- * the tree, [1] the node that split has left and right siblings, [2]
- * the node that split is the right-most node at its level of the tree.
- * When a node is an only node at its level then we use the right-most
- * rule. If SPLIT_RATIOS is null then default values are used.
- *
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value. The NEW_NODE argument is
- * renamed NEW_NODE_P
- *
- * John Mainzer, 6/9/05
- * Modified the function to use the new dirtied parameter of
- * of H5AC2_unprotect() instead of modifying the is_dirty
- * field of the cache info.
- *
*-------------------------------------------------------------------------
*/
static H5B_ins_t
@@ -935,24 +849,24 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
/*
* Check arguments
*/
- assert(f);
- assert(H5F_addr_defined(addr));
- assert(type);
- assert(type->decode);
- assert(type->cmp3);
- assert(type->new_node);
- assert(lt_key);
- assert(lt_key_changed);
- assert(rt_key);
- assert(rt_key_changed);
- assert(new_node_p);
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(type);
+ HDassert(type->decode);
+ HDassert(type->cmp3);
+ HDassert(type->new_node);
+ HDassert(lt_key);
+ HDassert(lt_key_changed);
+ HDassert(rt_key);
+ HDassert(rt_key_changed);
+ HDassert(new_node_p);
*lt_key_changed = FALSE;
*rt_key_changed = FALSE;
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5B_INS_ERROR, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, H5B_INS_ERROR, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
HDassert(shared);
@@ -965,61 +879,59 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
cache_udata.type = type;
cache_udata.rc_shared = rc_shared;
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node")
rt = bt->nchildren;
- while (lt < rt && cmp) {
+ while(lt < rt && cmp) {
idx = (lt + rt) / 2;
- if ((cmp = (type->cmp3)(H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1))) < 0) {
+ if((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0)
rt = idx;
- } else {
+ else
lt = idx + 1;
- }
- }
+ } /* end while */
- if (0 == bt->nchildren) {
+ if(0 == bt->nchildren) {
/*
* The value being inserted will be the only value in this tree. We
* must necessarily be at level zero.
*/
- assert(0 == bt->level);
- if ((type->new_node)(f, dxpl_id, H5B_INS_FIRST, H5B_NKEY(bt,shared,0), udata,
- H5B_NKEY(bt,shared,1), bt->child + 0/*out*/) < 0)
+ HDassert(0 == bt->level);
+ if((type->new_node)(f, dxpl_id, H5B_INS_FIRST, H5B_NKEY(bt, shared, 0), udata,
+ H5B_NKEY(bt, shared, 1), bt->child + 0/*out*/) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR, "unable to create leaf node")
bt->nchildren = 1;
bt_flags |= H5AC2__DIRTIED_FLAG;
idx = 0;
- if (type->follow_min) {
- if ((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx),
- lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1),
+ if(type->follow_min) {
+ if((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt, shared, idx),
+ lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1),
rt_key_changed, &child_addr/*out*/)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert first leaf node")
- } else {
+ } /* end if */
+ 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.
*/
- if ((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type,
+ if((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type,
H5B_NKEY(bt,shared,idx), lt_key_changed, md_key,
- udata, H5B_NKEY(bt,shared,idx+1), rt_key_changed,
- &child_addr/*out*/))<0)
+ udata, H5B_NKEY(bt, shared, idx + 1), 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) {
+ } 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.
*/
- if ((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx),
- lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1),
+ if((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt, shared, idx),
+ lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1),
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) {
+ } 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
@@ -1027,33 +939,32 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
*/
my_ins = H5B_INS_LEFT;
HDmemcpy(md_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey);
- if ((type->new_node)(f, dxpl_id, H5B_INS_LEFT, H5B_NKEY(bt,shared,idx), udata,
- md_key, &child_addr/*out*/) < 0)
+ if((type->new_node)(f, dxpl_id, H5B_INS_LEFT, H5B_NKEY(bt, shared, idx), udata,
+ md_key, &child_addr/*out*/) < 0)
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) {
+ } else if(cmp > 0 && idx + 1 >= bt->nchildren && bt->level > 0) {
/*
* The value being inserted is larger than any value in this tree.
* Follow the maximum branch out of this node to a subtree.
*/
idx = bt->nchildren - 1;
- if ((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type,
- H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, udata,
- H5B_NKEY(bt,shared,idx+1), rt_key_changed, &child_addr/*out*/)) < 0)
+ if((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type,
+ H5B_NKEY(bt, shared, idx), lt_key_changed, md_key, udata,
+ H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &child_addr/*out*/)) < 0)
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) {
+ } else if(cmp > 0 && idx + 1 >= bt->nchildren && type->follow_max) {
/*
* The value being inserted is larger than any leaf node out of the
* current node. Follow the maximum branch to a leaf node and let the
* subclass handle the problem.
*/
idx = bt->nchildren - 1;
- if ((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx),
- lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1),
+ if((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt, shared, idx),
+ lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1),
rt_key_changed, &child_addr/*out*/)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node")
- } else if (cmp > 0 && idx + 1 >= bt->nchildren) {
+ } else if(cmp > 0 && idx + 1 >= bt->nchildren) {
/*
* The value being inserted is larger than any leaf node out of the
* current node. Create a new maximum leaf node out of this B-tree
@@ -1061,80 +972,78 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
*/
idx = bt->nchildren - 1;
my_ins = H5B_INS_RIGHT;
- HDmemcpy(md_key, H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey);
- if ((type->new_node)(f, dxpl_id, H5B_INS_RIGHT, md_key, udata,
- H5B_NKEY(bt,shared,idx+1), &child_addr/*out*/) < 0)
+ HDmemcpy(md_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey);
+ if((type->new_node)(f, dxpl_id, H5B_INS_RIGHT, md_key, udata,
+ H5B_NKEY(bt, shared, idx + 1), &child_addr/*out*/) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node")
*rt_key_changed = TRUE;
-
- } else if (cmp) {
+ } else if(cmp) {
/*
* We couldn't figure out which branch to follow out of this node. THIS
* IS A MAJOR PROBLEM THAT NEEDS TO BE FIXED --rpm.
*/
- assert("INTERNAL HDF5 ERROR (contact rpm)" && 0);
+ HDassert("INTERNAL HDF5 ERROR (contact rpm)" && 0);
#ifdef NDEBUG
HDabort();
#endif /* NDEBUG */
- } else if (bt->level > 0) {
+ } else if(bt->level > 0) {
/*
* Follow a branch out of this node to another subtree.
*/
- assert(idx < bt->nchildren);
- if ((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type,
- H5B_NKEY(bt,shared,idx), lt_key_changed, md_key, udata,
- H5B_NKEY(bt,shared,idx+1), rt_key_changed, &child_addr/*out*/)) < 0)
+ HDassert(idx < bt->nchildren);
+ if((int)(my_ins = H5B_insert_helper(f, dxpl_id, bt->child[idx], type,
+ H5B_NKEY(bt, shared, idx), lt_key_changed, md_key, udata,
+ H5B_NKEY(bt, shared, idx + 1), rt_key_changed, &child_addr/*out*/)) < 0)
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 < bt->nchildren);
- if ((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt,shared,idx),
- lt_key_changed, md_key, udata, H5B_NKEY(bt,shared,idx+1),
+ HDassert(idx < bt->nchildren);
+ if((int)(my_ins = (type->insert)(f, dxpl_id, bt->child[idx], H5B_NKEY(bt, shared, idx),
+ lt_key_changed, md_key, udata, H5B_NKEY(bt, shared, idx + 1),
rt_key_changed, &child_addr/*out*/)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert leaf node")
}
- assert((int)my_ins >= 0);
+ HDassert((int)my_ins >= 0);
/*
* Update the left and right keys of the current node.
*/
- if (*lt_key_changed) {
+ if(*lt_key_changed) {
bt_flags |= H5AC2__DIRTIED_FLAG;
- if (idx > 0)
+ if(idx > 0)
*lt_key_changed = FALSE;
else
- HDmemcpy(lt_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey);
- }
- if (*rt_key_changed) {
+ HDmemcpy(lt_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey);
+ } /* end if */
+ if(*rt_key_changed) {
bt_flags |= H5AC2__DIRTIED_FLAG;
- if (idx+1 < bt->nchildren)
+ if(idx + 1 < bt->nchildren)
*rt_key_changed = FALSE;
else
- HDmemcpy(rt_key, H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey);
- }
- if (H5B_INS_CHANGE == my_ins) {
+ HDmemcpy(rt_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey);
+ } /* end if */
+ if(H5B_INS_CHANGE == my_ins) {
/*
* The insertion simply changed the address for the child.
*/
bt->child[idx] = child_addr;
bt_flags |= H5AC2__DIRTIED_FLAG;
ret_value = H5B_INS_NOOP;
-
- } else if (H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins) {
+ } else if(H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins) {
hbool_t *tmp_bt_flags_ptr = NULL;
H5B_t *tmp_bt;
/*
* If this node is full then split it before inserting the new child.
*/
- if (bt->nchildren == shared->two_k) {
- if (H5B_split(f, dxpl_id, bt, &bt_flags, addr, idx, udata, new_node_p/*out*/)<0)
+ if(bt->nchildren == shared->two_k) {
+ if(H5B_split(f, dxpl_id, bt, &bt_flags, addr, idx, udata, new_node_p/*out*/) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node")
if(NULL == (twin = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, *new_node_p, shared->sizeof_rnode, &cache_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node")
- if (idx<bt->nchildren) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node")
+ if(idx < bt->nchildren) {
tmp_bt = bt;
tmp_bt_flags_ptr = &bt_flags;
} else {
@@ -1142,13 +1051,14 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
tmp_bt = twin;
tmp_bt_flags_ptr = &twin_flags;
}
- } else {
+ } /* end if */
+ else {
tmp_bt = bt;
tmp_bt_flags_ptr = &bt_flags;
- }
+ } /* end else */
/* Insert the child */
- if (H5B_insert_child(tmp_bt, tmp_bt_flags_ptr, idx, child_addr, my_ins, md_key) < 0)
+ if(H5B_insert_child(tmp_bt, tmp_bt_flags_ptr, idx, child_addr, my_ins, md_key) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert child")
}
@@ -1156,28 +1066,28 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
* If this node split, return the mid key (the one that is shared
* by the left and right node).
*/
- if (twin) {
- HDmemcpy(md_key, H5B_NKEY(twin,shared,0), type->sizeof_nkey);
+ if(twin) {
+ HDmemcpy(md_key, H5B_NKEY(twin, shared, 0), type->sizeof_nkey);
ret_value = H5B_INS_RIGHT;
#ifdef H5B_DEBUG
/*
* The max key in the original left node must be equal to the min key
* in the new node.
*/
- cmp = (type->cmp2)(H5B_NKEY(bt,shared,bt->nchildren), udata,
- H5B_NKEY(twin,shared,0));
- assert(0 == cmp);
+ cmp = (type->cmp2)(H5B_NKEY(bt, shared, bt->nchildren), udata,
+ H5B_NKEY(twin, shared, 0));
+ HDassert(0 == cmp);
#endif
- } else {
+ } /* end if */
+ else
ret_value = H5B_INS_NOOP;
- }
done:
{
herr_t e1 = (bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, bt_flags) < 0);
herr_t e2 = (twin && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, *new_node_p, (size_t)0, twin, twin_flags) < 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)")
+ if(e1 || e2) /*use vars to prevent short-circuit of side effects */
+ HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node(s)")
}
FUNC_LEAVE_NOAPI(ret_value)
@@ -1223,7 +1133,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
HDassert(shared);
@@ -1232,14 +1142,14 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add
cache_udata.type = type;
cache_udata.rc_shared = rc_shared;
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5_ITER_ERROR, "unable to load B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5_ITER_ERROR, "unable to load B-tree node")
if(bt->level > 0) {
haddr_t left_child = bt->child[0]; /* Address of left-most child in node */
/* Release current node */
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5_ITER_ERROR, "unable to release B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node")
bt = NULL;
/* Keep following the left-most child until we reach a leaf node. */
@@ -1252,9 +1162,9 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add
/* Allocate space for a copy of the native records & child pointers */
if(NULL == (native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)))
- HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for shared B-tree native records")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, H5_ITER_ERROR, "memory allocation failed for shared B-tree native records")
if(NULL == (child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k)))
- HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for shared B-tree child addresses")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, H5_ITER_ERROR, "memory allocation failed for shared B-tree child addresses")
/* Cache information from this node */
nchildren = bt->nchildren;
@@ -1266,7 +1176,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add
/* Release current node */
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5_ITER_ERROR, "unable to release B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node")
bt = NULL;
/*
@@ -1296,7 +1206,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add
/* Protect the next node to the right */
addr = next_addr;
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5_ITER_ERROR, "B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5_ITER_ERROR, "B-tree node")
/* Cache information from this node */
nchildren = bt->nchildren;
@@ -1308,7 +1218,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add
/* Unprotect node */
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5_ITER_ERROR, "unable to release B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node")
bt = NULL;
} /* end if */
else
@@ -1320,7 +1230,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add
done:
if(bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5_ITER_ERROR, "unable to release B-tree node")
+ HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5_ITER_ERROR, "unable to release B-tree node")
if(native)
(void)H5FL_BLK_FREE(native_block, native);
if(child)
@@ -1391,15 +1301,6 @@ H5B_iterate(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
* Programmer: Robb Matzke
* Wednesday, September 16, 1998
*
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
- *
- * John Mainzer, 6/10/05
- * Modified the function to use the new dirtied parameter of
- * of H5AC2_unprotect() instead of modifying the is_dirty
- * field of the cache info.
- *
*-------------------------------------------------------------------------
*/
static H5B_ins_t
@@ -1413,24 +1314,24 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
H5RC_t *rc_shared; /* Ref-counted shared info */
H5B_shared_t *shared; /* Pointer to shared B-tree info */
H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
- unsigned idx=0, lt=0, rt; /* Final, left & right indices */
- int cmp=1; /* Key comparison value */
+ unsigned idx = 0, lt = 0, rt; /* Final, left & right indices */
+ int cmp = 1; /* Key comparison value */
H5B_ins_t ret_value = H5B_INS_ERROR;
FUNC_ENTER_NOAPI(H5B_remove_helper, H5B_INS_ERROR)
- assert(f);
- assert(H5F_addr_defined(addr));
- assert(type);
- assert(type->decode);
- assert(type->cmp3);
- assert(lt_key && lt_key_changed);
- assert(udata);
- assert(rt_key && rt_key_changed);
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(type);
+ HDassert(type->decode);
+ HDassert(type->cmp3);
+ HDassert(lt_key && lt_key_changed);
+ HDassert(udata);
+ HDassert(rt_key && rt_key_changed);
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5B_INS_ERROR, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, H5B_INS_ERROR, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
HDassert(shared);
@@ -1442,41 +1343,40 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
cache_udata.type = type;
cache_udata.rc_shared = rc_shared;
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load B-tree node")
rt = bt->nchildren;
- while (lt<rt && cmp) {
- idx = (lt+rt)/2;
- if ((cmp=(type->cmp3)(H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1)))<0) {
+ while(lt < rt && cmp) {
+ idx = (lt + rt) / 2;
+ if((cmp = (type->cmp3)(H5B_NKEY(bt, shared, idx), udata, H5B_NKEY(bt, shared, idx + 1))) < 0)
rt = idx;
- } else {
- lt = idx+1;
- }
- }
- if (cmp)
+ else
+ lt = idx + 1;
+ } /* end while */
+ if(cmp)
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<bt->nchildren);
- if (bt->level>0) {
+ HDassert(idx < bt->nchildren);
+ if(bt->level > 0) {
/* We're at an internal node -- call recursively */
- if ((int)(ret_value=H5B_remove_helper(f, dxpl_id,
- bt->child[idx], type, level+1, H5B_NKEY(bt,shared,idx)/*out*/,
- lt_key_changed/*out*/, udata, H5B_NKEY(bt,shared,idx+1)/*out*/,
- rt_key_changed/*out*/))<0)
+ if((int)(ret_value = H5B_remove_helper(f, dxpl_id,
+ bt->child[idx], type, level + 1, H5B_NKEY(bt, shared, idx)/*out*/,
+ lt_key_changed/*out*/, udata, H5B_NKEY(bt, shared, idx + 1)/*out*/,
+ rt_key_changed/*out*/)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in subtree")
- } else if (type->remove) {
+ } else if(type->remove) {
/*
* We're at a leaf node but the leaf node points to an object that
* has a removal method. Pass the removal request to the pointed-to
* object and let it decide how to progress.
*/
- if ((int)(ret_value=(type->remove)(f, dxpl_id,
- bt->child[idx], H5B_NKEY(bt,shared,idx), lt_key_changed, udata,
- H5B_NKEY(bt,shared,idx+1), rt_key_changed))<0)
+ if((int)(ret_value = (type->remove)(f, dxpl_id,
+ bt->child[idx], H5B_NKEY(bt, shared, idx), lt_key_changed, udata,
+ H5B_NKEY(bt, shared, idx + 1), rt_key_changed)) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in leaf node")
} else {
/*
@@ -1497,48 +1397,49 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
* key changed and it's the right most key of this node we must update
* our right key and indicate that it changed.
*/
- if (*lt_key_changed) {
+ if(*lt_key_changed) {
bt_flags |= H5AC2__DIRTIED_FLAG;
- if (idx>0)
+ if(idx > 0)
/* Don't propagate change out of this B-tree node */
*lt_key_changed = FALSE;
else
- HDmemcpy(lt_key, H5B_NKEY(bt,shared,idx), type->sizeof_nkey);
- }
- if (*rt_key_changed) {
+ HDmemcpy(lt_key, H5B_NKEY(bt, shared, idx), type->sizeof_nkey);
+ } /* end if */
+ if(*rt_key_changed) {
bt_flags |= H5AC2__DIRTIED_FLAG;
- if (idx+1<bt->nchildren) {
+ if(idx + 1 < bt->nchildren) {
/* Don't propagate change out of this B-tree node */
*rt_key_changed = FALSE;
- } else {
- HDmemcpy(rt_key, H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey);
+ } /* end if */
+ else {
+ HDmemcpy(rt_key, H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey);
/* Since our right key was changed, we must check for a right
* sibling and change it's left-most key as well.
* (Handle the ret_value==H5B_INS_REMOVE case below)
*/
- if (ret_value!=H5B_INS_REMOVE && level>0) {
- if (H5F_addr_defined(bt->right)) {
+ if(ret_value != H5B_INS_REMOVE && level > 0) {
+ if(H5F_addr_defined(bt->right)) {
if(NULL == (sibling = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, bt->right, shared->sizeof_rnode, &cache_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to unlink node from tree")
/* Make certain the native key for the right sibling is set up */
- HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,idx+1), type->sizeof_nkey);
+ HDmemcpy(H5B_NKEY(sibling, shared, 0), H5B_NKEY(bt, shared, idx + 1), type->sizeof_nkey);
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, bt->right, (size_t)0, sibling, H5AC2__DIRTIED_FLAG) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
- sibling=NULL; /* Make certain future references will be caught */
- }
- }
- }
- }
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree")
+ sibling = NULL; /* Make certain future references will be caught */
+ } /* end if */
+ } /* end if */
+ } /* end else */
+ } /* end if */
/*
* If the subtree returned H5B_INS_REMOVE then we should remove the
* subtree entry from the current node. There are four cases:
*/
- if (H5B_INS_REMOVE==ret_value && 1==bt->nchildren) {
+ if(H5B_INS_REMOVE == ret_value && 1 == bt->nchildren) {
/*
* The subtree is the only child of this node. Discard both
* keys and the subtree pointer. Free this node (unless it's the
@@ -1546,44 +1447,43 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
*/
bt_flags |= H5AC2__DIRTIED_FLAG;
bt->nchildren = 0;
- if (level>0) {
- if (H5F_addr_defined(bt->left)) {
+ if(level > 0) {
+ if(H5F_addr_defined(bt->left)) {
if(NULL == (sibling = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, bt->left, shared->sizeof_rnode, &cache_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node from tree")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to load node from tree")
sibling->right = bt->right;
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, bt->left, (size_t)0, sibling, H5AC2__DIRTIED_FLAG) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
- sibling=NULL; /* Make certain future references will be caught */
- }
- if (H5F_addr_defined(bt->right)) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree")
+ sibling = NULL; /* Make certain future references will be caught */
+ } /* end if */
+ if(H5F_addr_defined(bt->right)) {
if(NULL == (sibling = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, bt->right, shared->sizeof_rnode, &cache_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, 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 */
- HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,0), type->sizeof_nkey);
+ HDmemcpy(H5B_NKEY(sibling, shared, 0), H5B_NKEY(bt, shared, 0), type->sizeof_nkey);
sibling->left = bt->left;
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, bt->right, (size_t)0, sibling, H5AC2__DIRTIED_FLAG) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
- sibling=NULL; /* Make certain future references will be caught */
- }
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree")
+ sibling = NULL; /* Make certain future references will be caught */
+ } /* end if */
bt->left = HADDR_UNDEF;
bt->right = HADDR_UNDEF;
- H5_CHECK_OVERFLOW(shared->sizeof_rnode,size_t,hsize_t);
- if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)shared->sizeof_rnode)<0
+ H5_CHECK_OVERFLOW(shared->sizeof_rnode, size_t, hsize_t);
+ if(H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)shared->sizeof_rnode) < 0
|| H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, bt_flags | H5C__DELETED_FLAG) < 0) {
bt = NULL;
bt_flags = H5AC2__NO_FLAGS_SET;
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to free B-tree node")
- }
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to free B-tree node")
+ } /* end if */
bt = NULL;
bt_flags = H5AC2__NO_FLAGS_SET;
- }
-
- } else if (H5B_INS_REMOVE==ret_value && 0==idx) {
+ } /* end if */
+ } else if(H5B_INS_REMOVE == ret_value && 0 == idx) {
/*
* The subtree is the left-most child of this node. We discard the
* left-most key and the left-most child (the child has already been
@@ -1596,15 +1496,14 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
HDmemmove(bt->native,
bt->native + type->sizeof_nkey,
- (bt->nchildren+1) * type->sizeof_nkey);
+ (bt->nchildren + 1) * type->sizeof_nkey);
HDmemmove(bt->child,
- bt->child+1,
+ bt->child + 1,
bt->nchildren * sizeof(haddr_t));
- HDmemcpy(lt_key, H5B_NKEY(bt,shared,0), type->sizeof_nkey);
+ HDmemcpy(lt_key, H5B_NKEY(bt, shared, 0), type->sizeof_nkey);
*lt_key_changed = TRUE;
ret_value = H5B_INS_NOOP;
-
- } else if (H5B_INS_REMOVE==ret_value && idx+1==bt->nchildren) {
+ } else if(H5B_INS_REMOVE == ret_value && idx + 1 == bt->nchildren) {
/*
* The subtree is the right-most child of this node. We discard the
* right-most key and the right-most child (the child has already been
@@ -1613,29 +1512,28 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
*/
bt_flags |= H5AC2__DIRTIED_FLAG;
bt->nchildren -= 1;
- HDmemcpy(rt_key, H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey);
+ HDmemcpy(rt_key, H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey);
*rt_key_changed = TRUE;
/* Since our right key was changed, we must check for a right
* sibling and change it's left-most key as well.
* (Handle the ret_value==H5B_INS_REMOVE case below)
*/
- if (level>0) {
- if (H5F_addr_defined(bt->right)) {
+ if(level > 0) {
+ if(H5F_addr_defined(bt->right)) {
if(NULL == (sibling = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, bt->right, shared->sizeof_rnode, &cache_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to unlink node from tree")
- HDmemcpy(H5B_NKEY(sibling,shared,0), H5B_NKEY(bt,shared,bt->nchildren), type->sizeof_nkey);
+ HDmemcpy(H5B_NKEY(sibling, shared, 0), H5B_NKEY(bt, shared, bt->nchildren), type->sizeof_nkey);
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, bt->right, (size_t)0, sibling, H5AC2__DIRTIED_FLAG) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
- sibling=NULL; /* Make certain future references will be caught */
- }
- }
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node from tree")
+ sibling = NULL; /* Make certain future references will be caught */
+ } /* end if */
+ } /* end if */
ret_value = H5B_INS_NOOP;
-
- } else if (H5B_INS_REMOVE==ret_value) {
+ } else if(H5B_INS_REMOVE == ret_value) {
/*
* There are subtrees out of this node to both the left and right of
* the subtree being removed. The key to the left of the subtree and
@@ -1647,20 +1545,18 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
bt->nchildren -= 1;
HDmemmove(bt->native + idx * type->sizeof_nkey,
- bt->native + (idx+1) * type->sizeof_nkey,
- (bt->nchildren+1-idx) * type->sizeof_nkey);
- HDmemmove(bt->child+idx,
- bt->child+idx+1,
- (bt->nchildren-idx) * sizeof(haddr_t));
+ bt->native + (idx + 1) * type->sizeof_nkey,
+ (bt->nchildren + 1 - idx) * type->sizeof_nkey);
+ HDmemmove(bt->child + idx,
+ bt->child + idx + 1,
+ (bt->nchildren - idx) * sizeof(haddr_t));
ret_value = H5B_INS_NOOP;
-
- } else {
+ } else
ret_value = H5B_INS_NOOP;
- }
done:
if(bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, bt_flags) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node")
+ HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release node")
FUNC_LEAVE_NOAPI(ret_value)
}
@@ -1680,15 +1576,6 @@ done:
* Programmer: Robb Matzke
* Wednesday, September 16, 1998
*
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
- *
- * John Mainzer, 6/8/05
- * Modified the function to use the new dirtied parameter of
- * of H5AC2_unprotect() instead of modifying the is_dirty
- * field of the cache info.
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -1710,19 +1597,19 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
FUNC_ENTER_NOAPI(H5B_remove, FAIL)
/* Check args */
- assert(f);
- assert(type);
- assert(type->sizeof_nkey <= sizeof _lt_key);
- assert(H5F_addr_defined(addr));
+ HDassert(f);
+ HDassert(type);
+ HDassert(type->sizeof_nkey <= sizeof _lt_key);
+ HDassert(H5F_addr_defined(addr));
/* The actual removal */
- if (H5B_remove_helper(f, dxpl_id, addr, type, 0, lt_key, &lt_key_changed,
- udata, rt_key, &rt_key_changed)==H5B_INS_ERROR)
+ if(H5B_remove_helper(f, dxpl_id, addr, type, 0, lt_key, &lt_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")
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
HDassert(shared);
@@ -1734,16 +1621,16 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
cache_udata.type = type;
cache_udata.rc_shared = rc_shared;
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree root node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree root node")
- if (0==bt->nchildren && 0!=bt->level) {
+ if(0 == bt->nchildren && 0 != bt->level) {
bt->level = 0;
bt_flags |= H5AC2__DIRTIED_FLAG;
- }
+ } /* end if */
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, bt_flags) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node")
- bt=NULL; /* Make certain future references will be caught */
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release node")
+ bt = NULL; /* Make certain future references will be caught */
#ifdef H5B_DEBUG
H5B_assert(f, dxpl_id, addr, type, udata);
@@ -1764,13 +1651,6 @@ done:
* Programmer: Quincey Koziol
* Thursday, March 20, 2003
*
- * Modifications:
- *
- * John Mainzer, 6/10/05
- * Modified the function to use the new dirtied parameter of
- * of H5AC2_unprotect() instead of modifying the is_dirty
- * field of the cache info.
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -1781,18 +1661,18 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
H5B_shared_t *shared; /* Pointer to shared B-tree info */
H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */
unsigned u; /* Local index variable */
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5B_delete, FAIL)
/* Check args */
- assert(f);
- assert(type);
- assert(H5F_addr_defined(addr));
+ HDassert(f);
+ HDassert(type);
+ HDassert(H5F_addr_defined(addr));
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
HDassert(shared);
@@ -1801,38 +1681,39 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
cache_udata.type = type;
cache_udata.rc_shared = rc_shared;
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node")
/* Iterate over all children in tree, deleting them */
- if (bt->level > 0) {
+ if(bt->level > 0) {
/* Iterate over all children in node, deleting them */
- for (u=0; u<bt->nchildren; u++)
- if (H5B_delete(f, dxpl_id, type, bt->child[u], udata)<0)
+ 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 {
+ } /* end if */
+ else {
hbool_t lt_key_changed, rt_key_changed; /* Whether key changed (unused here, just for callback) */
/* Check for removal callback */
if(type->remove) {
/* Iterate over all entries in node, calling callback */
- for (u=0; u<bt->nchildren; u++) {
+ for(u = 0; u < bt->nchildren; u++) {
/* Call user's callback for each entry */
- if ((type->remove)(f, dxpl_id,
- bt->child[u], H5B_NKEY(bt,shared,u), &lt_key_changed, udata,
- H5B_NKEY(bt,shared,u+1), &rt_key_changed)<H5B_INS_NOOP)
+ if((type->remove)(f, dxpl_id,
+ bt->child[u], H5B_NKEY(bt, shared, u), &lt_key_changed, udata,
+ H5B_NKEY(bt, shared, u + 1), &rt_key_changed) < H5B_INS_NOOP)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "can't remove B-tree node")
} /* end for */
} /* end if */
} /* end else */
/* Delete this node from disk */
- if (H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)shared->sizeof_rnode)<0)
+ if(H5MF_xfree(f, H5FD_MEM_BTREE, dxpl_id, addr, (hsize_t)shared->sizeof_rnode) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTFREE, FAIL, "unable to free B-tree node")
done:
if(bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5C__DELETED_FLAG) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node in cache")
+ HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node in cache")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B_delete() */
@@ -1868,7 +1749,7 @@ H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey)
/* Allocate space for the shared structure */
if(NULL == (shared = H5FL_MALLOC(H5B_shared_t)))
- HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for shared B-tree info")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for shared B-tree info")
/* Set up the "global" information for this file's groups */
shared->type = type;
@@ -1885,12 +1766,12 @@ H5B_shared_new(const H5F_t *f, const H5B_class_t *type, size_t sizeof_rkey)
/* Allocate shared buffers */
if(NULL == (shared->page = H5FL_BLK_MALLOC(page, shared->sizeof_rnode)))
- HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree page")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree page")
#ifdef H5_CLEAR_MEMORY
HDmemset(shared->page, 0, shared->sizeof_rnode);
#endif /* H5_CLEAR_MEMORY */
if(NULL == (shared->nkey = H5FL_SEQ_MALLOC(size_t, (size_t)(2 * H5F_KVALUE(f, type) + 1))))
- HGOTO_ERROR(H5E_BTREE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree page")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree page")
/* Initialize the offsets into the native key buffer */
for(u = 0; u < (2 * H5F_KVALUE(f, type) + 1); u++)
@@ -1949,8 +1830,6 @@ H5B_shared_free(void *_shared)
* koziol@ncsa.uiuc.edu
* Apr 18 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static H5B_t *
@@ -1965,13 +1844,13 @@ H5B_copy(const H5B_t *old_bt)
/*
* Check arguments.
*/
- assert(old_bt);
+ HDassert(old_bt);
shared=(H5B_shared_t *)H5RC_GET_OBJ(old_bt->rc_shared);
HDassert(shared);
/* 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")
+ if(NULL == (new_node = H5FL_MALLOC(H5B_t)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree root node")
/* Copy the main structure */
HDmemcpy(new_node, old_bt, sizeof(H5B_t));
@@ -1979,19 +1858,19 @@ H5B_copy(const H5B_t *old_bt)
/* Reset cache info */
HDmemset(&new_node->cache_info, 0, sizeof(H5AC2_info_t));
- if ( NULL==(new_node->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) ||
- NULL==(new_node->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node")
+ if(NULL == (new_node->native = H5FL_BLK_MALLOC(native_block, shared->sizeof_keys)) ||
+ NULL == (new_node->child = H5FL_SEQ_MALLOC(haddr_t, (size_t)shared->two_k)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for B-tree root node")
/* Copy the other structures */
- HDmemcpy(new_node->native,old_bt->native,shared->sizeof_keys);
- HDmemcpy(new_node->child,old_bt->child,(sizeof(haddr_t)*shared->two_k));
+ HDmemcpy(new_node->native, old_bt->native, shared->sizeof_keys);
+ HDmemcpy(new_node->child, old_bt->child, (sizeof(haddr_t) * shared->two_k));
/* Increment the ref-count on the raw page */
H5RC_INC(new_node->rc_shared);
/* Set return value */
- ret_value=new_node;
+ ret_value = new_node;
done:
if(ret_value == NULL) {
@@ -2047,7 +1926,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, info_udata->udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
HDassert(shared);
@@ -2059,7 +1938,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad
cache_udata.type = type;
cache_udata.rc_shared = rc_shared;
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node")
/* Cache information from this node */
left_child = bt->child[0];
@@ -2072,7 +1951,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad
/* Release current node */
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
bt = NULL;
/*
@@ -2083,7 +1962,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad
/* Protect the next node to the right */
addr = next_addr;
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "B-tree node")
/* Cache information from this node */
next_addr = bt->right;
@@ -2094,7 +1973,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad
/* Unprotect node */
if(H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
bt = NULL;
} /* end while */
@@ -2107,7 +1986,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad
done:
if(bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
+ HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5B_get_info_helper() */
@@ -2208,9 +2087,6 @@ H5B_dest(H5B_t *bt)
* matzke@llnl.gov
* Aug 4 1997
*
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
*-------------------------------------------------------------------------
*/
herr_t
@@ -2229,16 +2105,16 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
/*
* Check arguments.
*/
- assert(f);
- assert(H5F_addr_defined(addr));
- assert(stream);
- assert(indent >= 0);
- assert(fwidth >= 0);
- assert(type);
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+ HDassert(stream);
+ HDassert(indent >= 0);
+ HDassert(fwidth >= 0);
+ HDassert(type);
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
HDassert(shared);
@@ -2249,7 +2125,7 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
cache_udata.type = type;
cache_udata.rc_shared = rc_shared;
if(NULL == (bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_READ)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node")
/*
* Print the values.
@@ -2286,32 +2162,32 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
/*
* Print the child addresses
*/
- for (u = 0; u < bt->nchildren; u++) {
+ 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[u]);
/* If there is a key debugging routine, use it to display the left & right keys */
- if (type->debug_key) {
+ if(type->debug_key) {
/* Decode the 'left' key & print it */
HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3),
"Left Key:");
- assert(H5B_NKEY(bt,shared,u));
- (void)(type->debug_key)(stream, indent+6, MAX (0, fwidth-6),
- H5B_NKEY(bt,shared,u), udata);
+ HDassert(H5B_NKEY(bt, shared, u));
+ (void)(type->debug_key)(stream, indent + 6, MAX(0, fwidth - 6),
+ H5B_NKEY(bt, shared, u), udata);
/* Decode the 'right' key & print it */
HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3),
"Right Key:");
- assert(H5B_NKEY(bt,shared,u+1));
- (void)(type->debug_key)(stream, indent+6, MAX (0, fwidth-6),
- H5B_NKEY(bt,shared,u+1), udata);
- }
- }
+ HDassert(H5B_NKEY(bt, shared, u + 1));
+ (void)(type->debug_key)(stream, indent + 6, MAX(0, fwidth - 6),
+ H5B_NKEY(bt, shared, u + 1), udata);
+ } /* end if */
+ } /* end for */
done:
if(bt && H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
+ HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
}
@@ -2329,15 +2205,6 @@ done:
* Programmer: Robb Matzke
* Tuesday, November 4, 1997
*
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
- *
- * John Mainzer, 6/8/05
- * Modified the function to use the new dirtied parameter of
- * of H5AC2_unprotect() instead of modifying the is_dirty
- * field of the cache info.
- *
*-------------------------------------------------------------------------
*/
#ifdef H5B_DEBUG
@@ -2351,7 +2218,7 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void
int i, ncell, cmp;
static int ncalls = 0;
herr_t status;
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
/* A queue of child data */
struct child_t {
@@ -2362,15 +2229,14 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void
FUNC_ENTER_NOAPI(H5B_assert, FAIL)
- if (0==ncalls++) {
- if (H5DEBUG(B)) {
+ if(0 == ncalls++) {
+ if(H5DEBUG(B))
fprintf(H5DEBUG(B), "H5B: debugging B-trees (expensive)\n");
- }
- }
+ } /* end if */
/* Get shared info for B-tree */
if(NULL == (rc_shared = (type->get_shared)(f, udata)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't retrieve B-tree's shared ref. count object")
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "can't retrieve B-tree's shared ref. count object")
shared = (H5B_shared_t *)H5RC_GET_OBJ(rc_shared);
HDassert(shared);
@@ -2379,18 +2245,18 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void
cache_udata.type = type;
cache_udata.rc_shared = rc_shared;
bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, addr, shared->sizeof_rnode, &cache_udata, H5AC2_READ);
- assert(bt);
+ HDassert(bt);
shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared);
HDassert(shared);
cur = H5MM_calloc(sizeof(struct child_t));
- assert (cur);
+ HDassert(cur);
cur->addr = addr;
cur->level = bt->level;
head = tail = cur;
status = H5AC2_unprotect(f, dxpl_id, H5AC2_BT, addr, (size_t)0, bt, H5AC2__NO_FLAGS_SET);
- assert(status >= 0);
- bt=NULL; /* Make certain future references will be caught */
+ HDassert(status >= 0);
+ bt = NULL; /* Make certain future references will be caught */
/*
* Do a breadth-first search of the tree. New nodes are added to the end
@@ -2398,64 +2264,62 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void
* remove any nodes from the queue because we need them in the uniqueness
* test.
*/
- for (ncell = 0; cur; ncell++) {
+ for(ncell = 0; cur; ncell++) {
bt = (H5B_t *)H5AC2_protect(f, dxpl_id, H5AC2_BT, cur->addr, shared->sizeof_rnode, &cache_udata, H5AC2_READ);
- assert(bt);
+ HDassert(bt);
/* Check node header */
- assert(bt->level == cur->level);
- if (cur->next && cur->next->level == bt->level) {
- assert(H5F_addr_eq(bt->right, cur->next->addr));
- } else {
- assert(!H5F_addr_defined(bt->right));
- }
- if (prev && prev->level == bt->level) {
- assert(H5F_addr_eq(bt->left, prev->addr));
- } else {
- assert(!H5F_addr_defined(bt->left));
- }
-
- if (cur->level > 0) {
- for (i = 0; i < bt->nchildren; i++) {
+ HDassert(bt->level == cur->level);
+ if(cur->next && cur->next->level == bt->level)
+ HDassert(H5F_addr_eq(bt->right, cur->next->addr));
+ else
+ HDassert(!H5F_addr_defined(bt->right));
+ if(prev && prev->level == bt->level)
+ HDassert(H5F_addr_eq(bt->left, prev->addr));
+ else
+ HDassert(!H5F_addr_defined(bt->left));
+
+ if(cur->level > 0) {
+ for(i = 0; i < bt->nchildren; i++) {
/*
* Check that child nodes haven't already been seen. If they
* have then the tree has a cycle.
*/
- for (tmp = head; tmp; tmp = tmp->next) {
- assert(H5F_addr_ne(tmp->addr, bt->child[i]));
- }
+ for(tmp = head; tmp; tmp = tmp->next)
+ HDassert(H5F_addr_ne(tmp->addr, bt->child[i]));
/* Add the child node to the end of the queue */
tmp = H5MM_calloc(sizeof(struct child_t));
- assert (tmp);
+ HDassert(tmp);
tmp->addr = bt->child[i];
tmp->level = bt->level - 1;
tail->next = tmp;
tail = tmp;
/* Check that the keys are monotonically increasing */
- cmp = (type->cmp2)(H5B_NKEY(bt,shared,i), udata,
- H5B_NKEY(bt,shared,i+1));
- assert(cmp < 0);
- }
- }
+ cmp = (type->cmp2)(H5B_NKEY(bt, shared, i), udata,
+ H5B_NKEY(bt, shared, i + 1));
+ HDassert(cmp < 0);
+ } /* end for */
+ } /* end if */
+
/* Release node */
status = H5AC2_unprotect(f, dxpl_id, H5AC2_BT, cur->addr, (size_t)0, bt, H5AC2__NO_FLAGS_SET);
- assert(status >= 0);
- bt=NULL; /* Make certain future references will be caught */
+ HDassert(status >= 0);
+ bt = NULL; /* Make certain future references will be caught */
/* Advance current location in queue */
prev = cur;
cur = cur->next;
- }
+ } /* end for */
/* Free all entries from queue */
- while (head) {
+ while(head) {
tmp = head->next;
H5MM_xfree(head);
head = tmp;
- }
+ } /* end while */
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Dtest.c b/src/H5Dtest.c
index cf4d5b6..2198ff4 100644
--- a/src/H5Dtest.c
+++ b/src/H5Dtest.c
@@ -35,26 +35,32 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
+
/****************/
/* Local Macros */
/****************/
+
/******************/
/* Local Typedefs */
/******************/
+
/********************/
/* Local Prototypes */
/********************/
+
/*********************/
/* Package Variables */
/*********************/
+
/*******************/
/* Local Variables */
/*******************/
+
/*--------------------------------------------------------------------------
NAME
diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h
index 1dcced6..446c852 100644
--- a/src/H5FLprivate.h
+++ b/src/H5FLprivate.h
@@ -130,7 +130,7 @@ typedef struct H5FL_reg_head_t {
#define H5FL_CALLOC(t) (t *)H5FL_reg_calloc(&(H5FL_REG_NAME(t)) H5FL_TRACK_INFO)
/* Free an object of type 't' */
-#define H5FL_FREE(t,obj) H5FL_reg_free(&(H5FL_REG_NAME(t)),obj)
+#define H5FL_FREE(t,obj) (t *)H5FL_reg_free(&(H5FL_REG_NAME(t)),obj)
/* Re-allocating an object of type 't' is not defined, because these free-lists
* only support fixed sized types, like structs, etc..
@@ -331,7 +331,7 @@ typedef struct H5FL_seq_head_t {
#define H5FL_SEQ_CALLOC(t,elem) (t *)H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)),elem H5FL_TRACK_INFO)
/* Free a sequence of type 't' */
-#define H5FL_SEQ_FREE(t,obj) H5FL_seq_free(&(H5FL_SEQ_NAME(t)),obj)
+#define H5FL_SEQ_FREE(t,obj) (t *)H5FL_seq_free(&(H5FL_SEQ_NAME(t)),obj)
/* Re-allocate a sequence of type 't' */
#define H5FL_SEQ_REALLOC(t,obj,new_elem) (t *)H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)),obj,new_elem H5FL_TRACK_INFO)
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index 8cdca20..aa87842 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -110,9 +110,7 @@
/* Local Prototypes */
/********************/
-herr_t H5F_super_create_extension(H5F_t *f,
- hid_t dxpl_id,
- H5O_loc_t * ext_loc_ptr);
+static herr_t H5F_super_create_extension(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_loc_ptr);
/*********************/
@@ -239,15 +237,10 @@ done:
* Programmer: John Mainzer
* 2/29/08
*
- * Changes: None.
- *
*-------------------------------------------------------------------------
*/
-
-herr_t
-H5F_super_create_extension(H5F_t *f,
- hid_t dxpl_id,
- H5O_loc_t * ext_loc_ptr)
+static herr_t
+H5F_super_create_extension(H5F_t *f, hid_t dxpl_id, H5O_loc_t *ext_loc_ptr)
{
H5O_loc_t ext_loc; /* Superblock extension object location */
H5O_loc_t *elp;
@@ -255,31 +248,19 @@ H5F_super_create_extension(H5F_t *f,
FUNC_ENTER_NOAPI(H5F_super_create_extension, FAIL)
- HDassert( f != NULL );
- HDassert( f->shared != NULL );
-
- if ( ext_loc_ptr != NULL ) {
+ HDassert(f != NULL);
+ HDassert(f->shared != NULL);
+ if(ext_loc_ptr != NULL)
elp = ext_loc_ptr;
-
- } else {
-
+ else
elp = &ext_loc;
- }
-
-
- if ( ! f->shared->extension_ok ) {
-
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL,
- "superblock extension not permitted?!?!")
-
- } else if ( f->shared->extension_addr != HADDR_UNDEF ) {
-
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL,
- "superblock extension already exists?!?!")
-
- } else {
+ if(!f->shared->extension_ok)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension not permitted?!?!")
+ else if(f->shared->extension_addr != HADDR_UNDEF)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "superblock extension already exists?!?!")
+ else {
/* The superblock extension isn't actually a group, but the
* default group creation list should work fine.
* If we don't supply a size for the object header, HDF5 will
@@ -289,20 +270,15 @@ H5F_super_create_extension(H5F_t *f,
* extension.
*/
H5O_loc_reset(elp);
- if( H5O_create(f, dxpl_id, 0, H5P_GROUP_CREATE_DEFAULT, elp) < 0 )
- {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, \
- "unable to create superblock extension")
- }
+ if(H5O_create(f, dxpl_id, 0, H5P_GROUP_CREATE_DEFAULT, elp) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create superblock extension")
/* Record the address of the superblock extension */
f->shared->extension_addr = elp->addr;
- }
+ } /* end else */
done:
-
FUNC_LEAVE_NOAPI(ret_value)
-
} /* end H5F_super_create_extension() */
@@ -673,7 +649,7 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
/* Open the superblock extension */
if(H5O_open(&ext_loc) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENFILE, FAIL, "unable to open superblock extension")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open superblock extension")
/* Read in the shared OH message information if there is any */
if(H5SM_get_info(&ext_loc, c_plist, dxpl_id) < 0)
@@ -766,7 +742,7 @@ H5F_super_read(H5F_t *f, hid_t dxpl_id, H5G_loc_t *root_loc)
*/
f->nopen_objs++;
if(H5O_close(&ext_loc) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENFILE, FAIL, "unable to close superblock extension")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to close superblock extension")
f->nopen_objs--;
} /* end if */
@@ -904,7 +880,7 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
* extension.
*/
if(H5F_super_create_extension(f, dxpl_id, &ext_loc) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create superblock extension")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create superblock extension")
/* Create the Shared Object Header Message table and register it with
* the metadata cache, if this file supports shared messages.
@@ -980,7 +956,7 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id)
*/
f->nopen_objs++;
if(H5O_close(&ext_loc) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close superblock extension")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to close superblock extension")
f->nopen_objs--;
} /* end if */
@@ -1180,7 +1156,7 @@ H5F_super_write_mdj_msg(H5F_t *f, hid_t dxpl_id)
/* Open the superblock extension, or create it if it doesn't exist */
if(!H5F_addr_defined(f->shared->extension_addr)) {
if(H5F_super_create_extension(f, dxpl_id, &ext_loc) < 0)
- HGOTO_ERROR(H5E_SYSTEM, H5E_SYSERRSTR, FAIL, "unable to create superblock extension?!?!")
+ HGOTO_ERROR(H5E_FILE, H5E_SYSERRSTR, FAIL, "unable to create superblock extension?!?!")
} /* end if */
else {
/* Set up "fake" object location for superblock extension */
@@ -1190,7 +1166,7 @@ H5F_super_write_mdj_msg(H5F_t *f, hid_t dxpl_id)
/* Open the superblock extension */
if(H5O_open(&ext_loc) < 0)
- HGOTO_ERROR(H5E_SYSTEM, H5E_SYSERRSTR, FAIL, "unable to open superblock extension?!?!")
+ HGOTO_ERROR(H5E_FILE, H5E_SYSERRSTR, FAIL, "unable to open superblock extension?!?!")
} /* end else */
/* The metadata journaling message is a variable length message.
@@ -1250,7 +1226,7 @@ H5F_super_write_mdj_msg(H5F_t *f, hid_t dxpl_id)
/* Store the metadata journaling message in the superblock extension */
if(H5O_msg_create(&ext_loc, H5O_MDJ_MSG_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &mdj_msg, dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYSTEM, H5E_SYSERRSTR, FAIL, "unable to add mdj_msg to superblock extension?!?!")
+ HGOTO_ERROR(H5E_FILE, H5E_SYSERRSTR, FAIL, "unable to add mdj_msg to superblock extension?!?!")
} /* end if */
/* Close the extension. Twiddle the number of open objects to avoid
@@ -1258,7 +1234,7 @@ H5F_super_write_mdj_msg(H5F_t *f, hid_t dxpl_id)
*/
f->nopen_objs++;
if(H5O_close(&ext_loc) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENFILE, FAIL, "unable to close superblock extension")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to close superblock extension")
f->nopen_objs--;
done:
diff --git a/src/H5HL.c b/src/H5HL.c
index 69f79ec..4465232 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -154,7 +154,7 @@ H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr_p/*out*/)
/* Allocate file space */
total_size = heap->prfx_size + size_hint;
if(HADDR_UNDEF == (heap->prfx_addr = H5MF_alloc(f, H5FD_MEM_LHEAP, dxpl_id, total_size)))
- HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "unable to allocate file memory")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "unable to allocate file memory")
/* Initialize info */
heap->single_cache_obj = TRUE;
@@ -488,7 +488,7 @@ H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5AC2_protect_t rw)
/* Protect the local heap prefix */
if(NULL == (prfx = (H5HL_prfx_t *)H5AC2_protect(f, dxpl_id, H5AC2_LHEAP_PRFX, addr, H5HL_SPEC_READ_SIZE, &prfx_udata, rw)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap prefix")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to load heap prefix")
/* Get the pointer to the heap */
heap = prfx->heap;
@@ -513,7 +513,7 @@ H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5AC2_protect_t rw)
/* Protect the local heap data block */
if(NULL == (dblk = (H5HL_dblk_t *)H5AC2_protect(f, dxpl_id, H5AC2_LHEAP_DBLK, heap->dblk_addr, heap->dblk_size, &dblk_udata, rw)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap data block")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to load heap data block")
/* Pin the prefix, if the data block was loaded from file */
if(dblk_udata.loaded)
@@ -810,13 +810,13 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void *
/* Check if current heap is extendible */
can_extend = H5MF_can_extend(f, H5FD_MEM_LHEAP, heap->dblk_addr, (hsize_t)(heap->dblk_size), (hsize_t)need_more);
if(can_extend < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "unable to check whether heap can be extended")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, UFAIL, "unable to check whether heap can be extended")
/* Check if we can extend heap in file */
if(can_extend == TRUE) {
/* Extend file space allocation */
if(H5MF_extend(f, H5FD_MEM_LHEAP, heap->dblk_addr, (hsize_t)(heap->dblk_size), (hsize_t)need_more) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "can't extend heap on disk")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTEXTEND, UFAIL, "can't extend heap on disk")
/* Check for prefix & data block contiguous */
if(heap->single_cache_obj) {
@@ -868,7 +868,7 @@ H5HL_insert(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t buf_size, const void *
offset = old_dblk_size;
if(need_more - need_size >= H5HL_SIZEOF_FREE(f)) {
if(NULL == (fl = H5FL_MALLOC(H5HL_free_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, UFAIL, "memory allocation failed")
fl->offset = old_dblk_size + need_size;
fl->size = need_more - need_size;
HDassert(fl->offset == H5HL_ALIGN(fl->offset));
@@ -991,7 +991,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size)
if(((fl->offset + fl->size) == heap->dblk_size) &&
((2 * fl->size) > heap->dblk_size)) {
if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed")
}
HGOTO_DONE(SUCCEED);
}
@@ -1000,7 +1000,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size)
if(((fl->offset + fl->size) == heap->dblk_size) &&
((2 * fl->size) > heap->dblk_size)) {
if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed")
}
HGOTO_DONE(SUCCEED);
} else if(fl->offset + fl->size == offset) {
@@ -1015,7 +1015,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size)
if(((fl->offset + fl->size) == heap->dblk_size) &&
((2 * fl->size) > heap->dblk_size)) {
if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed")
} /* end if */
HGOTO_DONE(SUCCEED);
} /* end if */
@@ -1024,7 +1024,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size)
if(((fl->offset + fl->size) == heap->dblk_size) &&
((2 * fl->size) > heap->dblk_size)) {
if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed")
} /* end if */
HGOTO_DONE(SUCCEED);
} /* end if */
@@ -1050,7 +1050,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size)
* Add an entry to the free list.
*/
if(NULL == (fl = H5FL_MALLOC(H5HL_free_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed")
fl->offset = offset;
fl->size = size;
HDassert(fl->offset == H5HL_ALIGN(fl->offset));
@@ -1064,7 +1064,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size)
if(((fl->offset + fl->size) == heap->dblk_size) &&
((2 * fl->size) > heap->dblk_size)) {
if(H5HL_minimize_heap_space(f, dxpl_id, heap) < 0)
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "heap size minimization failed")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "heap size minimization failed")
} /* end if */
done:
@@ -1109,7 +1109,7 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr)
/* Protect the local heap prefix */
if(NULL == (prfx = (H5HL_prfx_t *)H5AC2_protect(f, dxpl_id, H5AC2_LHEAP_PRFX, addr, H5HL_SPEC_READ_SIZE, &prfx_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap prefix")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix")
/* Get the pointer to the heap */
heap = prfx->heap;
@@ -1127,7 +1127,7 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr)
/* Protect the local heap data block */
if(NULL == (dblk = (H5HL_dblk_t *)H5AC2_protect(f, dxpl_id, H5AC2_LHEAP_DBLK, heap->dblk_addr, heap->dblk_size, &dblk_udata, H5AC2_WRITE)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap data block")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap data block")
/* Pin the prefix, if the data block was loaded from file */
if(dblk_udata.loaded) {
@@ -1207,7 +1207,7 @@ H5HL_get_size(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t *size)
/* Protect the local heap prefix */
if(NULL == (prfx = (H5HL_prfx_t *)H5AC2_protect(f, dxpl_id, H5AC2_LHEAP_PRFX, addr, H5HL_SPEC_READ_SIZE, &prfx_udata, H5AC2_READ)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap prefix")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix")
/* Get the pointer to the heap */
heap = prfx->heap;
@@ -1259,7 +1259,7 @@ H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size)
/* Protect the local heap prefix */
if(NULL == (prfx = (H5HL_prfx_t *)H5AC2_protect(f, dxpl_id, H5AC2_LHEAP_PRFX, addr, H5HL_SPEC_READ_SIZE, &prfx_udata, H5AC2_READ)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap prefix")
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap prefix")
/* Get the pointer to the heap */
heap = prfx->heap;
diff --git a/src/H5L.c b/src/H5L.c
index 608d76d..97f5656 100644
--- a/src/H5L.c
+++ b/src/H5L.c
@@ -2736,7 +2736,7 @@ H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id)
HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "path doesn't exist")
/* Set return value */
- ret_value = exists;
+ ret_value = (htri_t)exists;
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 4cc2807..9f7a0fc 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -555,7 +555,7 @@ H5O_fill_copy(const void *_src, void *_dst)
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
if(bkg_buf)
- H5FL_BLK_FREE(type_conv, bkg_buf);
+ bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf);
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, NULL, "datatype conversion failed")
} /* end if */
@@ -563,7 +563,7 @@ H5O_fill_copy(const void *_src, void *_dst)
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
if(bkg_buf)
- H5FL_BLK_FREE(type_conv, bkg_buf);
+ bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf);
} /* end if */
} /* end if */
} /* end if */
diff --git a/src/H5RS.c b/src/H5RS.c
index 065d05f..550e326 100644
--- a/src/H5RS.c
+++ b/src/H5RS.c
@@ -63,7 +63,7 @@ H5RS_xstrdup(const char *s)
{
char *ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5RS_xstrdup)
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5RS_xstrdup)
if(s) {
ret_value = (char *)H5FL_BLK_MALLOC(str_buf, HDstrlen(s) + 1);
diff --git a/src/H5SM.c b/src/H5SM.c
index d77918f..a2d5bbb 100755
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -343,7 +343,6 @@ htri_t
H5SM_type_shared(H5F_t *f, unsigned type_id, hid_t dxpl_id)
{
H5SM_master_table_t *table = NULL; /* Shared object master table */
- hsize_t table_size; /* Size of SOHM master table in file */
unsigned type_flag; /* Flag corresponding to message type */
size_t u; /* Local index variable */
htri_t ret_value = FALSE; /* Return value */
@@ -354,11 +353,13 @@ H5SM_type_shared(H5F_t *f, unsigned type_id, hid_t dxpl_id)
if(H5SM_type_to_flag(type_id, &type_flag) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't map message type to flag")
- /* Determine size of table in file */
- table_size = (hsize_t) H5SM_TABLE_SIZE(f) + (hsize_t)(f->shared->sohm_nindexes * H5SM_INDEX_HEADER_SIZE(f));
-
/* Look up the master SOHM table */
if(H5F_addr_defined(f->shared->sohm_addr)) {
+ hsize_t table_size; /* Size of SOHM master table in file */
+
+ /* Determine size of table in file */
+ table_size = (hsize_t) H5SM_TABLE_SIZE(f) + (hsize_t)(f->shared->sohm_nindexes * H5SM_INDEX_HEADER_SIZE(f));
+
if(NULL == (table = (H5SM_master_table_t *)H5AC2_protect(f, dxpl_id, H5AC2_SOHM_TABLE, f->shared->sohm_addr, (size_t)table_size, f, H5AC2_READ)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table")
} /* end if */
@@ -1609,7 +1610,6 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
H5SM_mesg_key_t key;
H5SM_sohm_t message; /* Deleted message returned from index */
H5SM_sohm_t *message_ptr; /* Pointer to deleted message returned from index */
- H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */
H5HF_t *fheap = NULL; /* Fractal heap that contains the message */
size_t buf_size; /* Size of the encoded message (out) */
void *encoding_buf = NULL; /* The encoded message (out) */
@@ -1661,6 +1661,7 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
/* Try to find the message in the index */
if(header->index_type == H5SM_LIST) {
+ H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */
size_t list_pos; /* Position of the message in the list */
/* Set up user data for metadata cache callback */
@@ -1786,7 +1787,6 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist, hid_t dxpl_id)
H5F_file_t *shared = f->shared; /* Shared file info (convenience variable) */
H5O_shmesg_table_t sohm_table; /* SOHM message from superblock extension */
H5SM_master_table_t *table = NULL; /* SOHM master table */
- hsize_t table_size; /* Size of SOHM master table in file */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5SM_get_info, FAIL)
@@ -1811,6 +1811,7 @@ H5SM_get_info(const H5O_loc_t *ext_loc, H5P_genplist_t *fc_plist, hid_t dxpl_id)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set number of SOHM indexes")
} /* end if */
else {
+ hsize_t table_size; /* Size of SOHM master table in file */
unsigned index_flags[H5O_SHMESG_MAX_NINDEXES]; /* Message flags for each index */
unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Minimum message size for each index */
unsigned sohm_l2b; /* SOHM list-to-btree cutoff */
@@ -2045,7 +2046,6 @@ H5SM_get_refcount(H5F_t *f, hid_t dxpl_id, unsigned type_id,
H5SM_index_header_t *header=NULL; /* Index header for message type */
H5SM_mesg_key_t key; /* Key for looking up message */
H5SM_sohm_t message; /* Shared message returned from callback */
- H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */
hsize_t table_size; /* Size of SOHM master table in file */
ssize_t index_num; /* Table index for message type */
size_t buf_size; /* Size of the encoded message */
@@ -2071,10 +2071,6 @@ H5SM_get_refcount(H5F_t *f, hid_t dxpl_id, unsigned type_id,
HGOTO_ERROR(H5E_SOHM, H5E_NOTFOUND, FAIL, "unable to find correct SOHM index")
header = &(table->indexes[index_num]);
- /* Set up user data for metadata cache callback */
- cache_udata.f = f;
- cache_udata.header = header;
-
/* Open the heap for this message type */
if(NULL == (fheap = H5HF_open(f, dxpl_id, header->heap_addr)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open fractal heap")
@@ -2098,8 +2094,13 @@ H5SM_get_refcount(H5F_t *f, hid_t dxpl_id, unsigned type_id,
/* Try to find the message in the index */
if(header->index_type == H5SM_LIST) {
+ H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */
size_t list_pos; /* Position of the message in the list */
+ /* Set up user data for metadata cache callback */
+ cache_udata.f = f;
+ cache_udata.header = header;
+
/* If the index is stored as a list, get it from the cache */
if(NULL == (list = (H5SM_list_t *)H5AC2_protect(f, dxpl_id, H5AC2_SOHM_LIST, header->index_addr, H5SM_LIST_SIZE(f, header->list_max), &cache_udata, H5AC2_READ)))
HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index")
diff --git a/src/H5SMtest.c b/src/H5SMtest.c
index b72aabb..d2afe6c 100644
--- a/src/H5SMtest.c
+++ b/src/H5SMtest.c
@@ -80,7 +80,6 @@ H5SM_get_mesg_count_test(H5F_t *f, hid_t dxpl_id, unsigned type_id,
size_t *mesg_count)
{
H5SM_master_table_t *table = NULL; /* SOHM master table */
- hsize_t table_size; /* Size of SOHM master table in file */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5SM_get_mesg_count_test)
@@ -92,6 +91,7 @@ H5SM_get_mesg_count_test(H5F_t *f, hid_t dxpl_id, unsigned type_id,
/* Check for shared messages being enabled */
if(H5F_addr_defined(f->shared->sohm_addr)) {
H5SM_index_header_t *header; /* Index header for message type */
+ hsize_t table_size; /* Size of SOHM master table in file */
ssize_t index_num; /* Table index for message type */
/* Determine size of table in file */
diff --git a/src/H5Sall.c b/src/H5Sall.c
index c603251..07043f2 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -630,7 +630,7 @@ H5S_all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_all_offset(const H5S_t *space, hsize_t *offset)
+H5S_all_offset(const H5S_t UNUSED *space, hsize_t *offset)
{
FUNC_ENTER_NOAPI_NOFUNC(H5S_all_offset)
@@ -825,23 +825,24 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-herr_t H5Sselect_all (hid_t spaceid)
+herr_t
+H5Sselect_all(hid_t spaceid)
{
- H5S_t *space = NULL; /* Dataspace to modify selection of */
- herr_t ret_value=SUCCEED; /* return value */
+ H5S_t *space; /* Dataspace to modify selection of */
+ herr_t ret_value = SUCCEED; /* return value */
- FUNC_ENTER_API(H5Sselect_all, FAIL);
+ FUNC_ENTER_API(H5Sselect_all, FAIL)
/* Check args */
- if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
/* Call internal routine to do the work */
- if((ret_value = H5S_select_all(space, TRUE)) < 0)
+ if(H5S_select_all(space, TRUE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
done:
- FUNC_LEAVE_API(ret_value);
+ FUNC_LEAVE_API(ret_value)
} /* H5Sselect_all() */
diff --git a/src/H5Snone.c b/src/H5Snone.c
index 88ab67f..50e685a 100644
--- a/src/H5Snone.c
+++ b/src/H5Snone.c
@@ -586,7 +586,7 @@ H5S_none_bounds(const H5S_t UNUSED *space, hsize_t UNUSED *start, hsize_t UNUSED
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_none_offset(const H5S_t *space, hsize_t *offset)
+H5S_none_offset(const H5S_t UNUSED *space, hsize_t UNUSED *offset)
{
FUNC_ENTER_NOAPI_NOFUNC(H5S_none_offset)
@@ -775,23 +775,24 @@ done:
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-herr_t H5Sselect_none (hid_t spaceid)
+herr_t
+H5Sselect_none(hid_t spaceid)
{
- H5S_t *space = NULL; /* Dataspace to modify selection of */
- herr_t ret_value; /* return value */
+ H5S_t *space; /* Dataspace to modify selection of */
+ herr_t ret_value = SUCCEED; /* return value */
- FUNC_ENTER_API(H5Sselect_none, FAIL);
+ FUNC_ENTER_API(H5Sselect_none, FAIL)
/* Check args */
- if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ if(NULL == (space = (H5S_t *)H5I_object_verify(spaceid, H5I_DATASPACE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
/* Change to "none" selection */
- if((ret_value=H5S_select_none(space))<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
+ if(H5S_select_none(space) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
done:
- FUNC_LEAVE_API(ret_value);
+ FUNC_LEAVE_API(ret_value)
} /* H5Sselect_none() */
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 7803d07..a91c09a 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -3086,13 +3086,13 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
done:
/* If the conversion buffer doesn't need to be freed, reset its pointer */
if(write_to_file && noop_conv)
- conv_buf=NULL;
+ conv_buf = NULL;
/* Release the conversion buffer (always allocated, except on errors) */
- if(conv_buf!=NULL)
- H5FL_BLK_FREE(vlen_seq,conv_buf);
+ if(conv_buf)
+ conv_buf = H5FL_BLK_FREE(vlen_seq, conv_buf);
/* Release the background buffer, if we have one */
- if(tmp_buf!=NULL)
- H5FL_BLK_FREE(vlen_seq,tmp_buf);
+ if(tmp_buf)
+ tmp_buf = H5FL_BLK_FREE(vlen_seq, tmp_buf);
FUNC_LEAVE_NOAPI(ret_value);
}
@@ -3238,7 +3238,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
done:
/* Release the background buffer, if we have one */
if(bkg_buf)
- H5FL_BLK_FREE(array_seq, bkg_buf);
+ bkg_buf = H5FL_BLK_FREE(array_seq, bkg_buf);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_conv_array() */
diff --git a/test/gen_deflate.c b/test/gen_deflate.c
index 16de92e..2d0b746 100644
--- a/test/gen_deflate.c
+++ b/test/gen_deflate.c
@@ -66,7 +66,7 @@ main(void)
/* (Try for something easily compressible) */
for(i=0; i<SPACE_DIM1; i++)
for(j=0; j<SPACE_DIM2; j++)
- data[i][j]=j%5;
+ data[i][j] = (int)(j % 5);
/* Create the file */
file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
diff --git a/test/gen_noencoder.c b/test/gen_noencoder.c
index 3266374..46a2036 100644
--- a/test/gen_noencoder.c
+++ b/test/gen_noencoder.c
@@ -79,5 +79,7 @@ main(void)
H5Dclose(dset_id);
H5Sclose(space_id);
H5Fclose(file_id);
+
+ return(0);
}