diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5B.c | 898 | ||||
-rw-r--r-- | src/H5B2cache.c | 4 | ||||
-rw-r--r-- | src/H5B2int.c | 4 | ||||
-rw-r--r-- | src/H5Bcache.c | 11 | ||||
-rw-r--r-- | src/H5Bpkg.h | 1 | ||||
-rw-r--r-- | src/H5Defl.c | 2 | ||||
-rw-r--r-- | src/H5Dint.c | 2 | ||||
-rw-r--r-- | src/H5Dtest.c | 24 | ||||
-rw-r--r-- | src/H5FLprivate.h | 4 | ||||
-rw-r--r-- | src/H5FScache.c | 3 | ||||
-rw-r--r-- | src/H5Fsuper.c | 8 | ||||
-rw-r--r-- | src/H5HFcache.c | 3 | ||||
-rw-r--r-- | src/H5HFdblock.c | 6 | ||||
-rw-r--r-- | src/H5HFiblock.c | 4 | ||||
-rw-r--r-- | src/H5HG.c | 53 | ||||
-rw-r--r-- | src/H5HL.c | 78 | ||||
-rw-r--r-- | src/H5HLdbg.c | 2 | ||||
-rw-r--r-- | src/H5I.c | 26 | ||||
-rw-r--r-- | src/H5L.c | 2 | ||||
-rw-r--r-- | src/H5O.c | 22 | ||||
-rw-r--r-- | src/H5Oalloc.c | 10 | ||||
-rw-r--r-- | src/H5Ocopy.c | 13 | ||||
-rw-r--r-- | src/H5Omessage.c | 2 | ||||
-rw-r--r-- | src/H5Oprivate.h | 2 | ||||
-rwxr-xr-x | src/H5SM.c | 11 | ||||
-rw-r--r-- | src/H5Sall.c | 4 | ||||
-rw-r--r-- | src/H5Snone.c | 6 | ||||
-rw-r--r-- | src/H5T.c | 4 |
28 files changed, 476 insertions, 733 deletions
@@ -206,19 +206,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 - * H5AC_set() (which marks the entry dirty automaticly), no - * other change is required. - * *------------------------------------------------------------------------- */ herr_t @@ -234,29 +221,29 @@ 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(H5AC_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") 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) - (void)H5B_dest(f,bt); - } + if(bt) + (void)H5B_dest(f, bt); + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5B_create() */ /*lint !e818 Can't make udata a pointer to const */ @@ -302,17 +289,14 @@ done: * matzke@llnl.gov * Jun 23 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata) { H5B_t *bt = NULL; - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - unsigned idx=0, lt = 0, rt; /* Final, left & right key indices */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ + unsigned idx=0, lt = 0, rt; /* Final, left & right key indices */ int cmp = 1; /* Key comparison value */ int ret_value = SUCCEED; /* Return value */ @@ -321,33 +305,32 @@ 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)); /* * Perform a binary search to locate the child which contains * the thing for which we're searching. */ - if (NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") + if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); rt = bt->nchildren; - while (lt < rt && cmp) { + while(lt < rt && cmp) { idx = (lt + rt) / 2; /* compare */ - if ((cmp = (type->cmp3)(f, dxpl_id, H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1))) < 0) { + if((cmp = (type->cmp3)(f, dxpl_id, 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 @@ -361,10 +344,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 @@ -375,7 +358,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 @@ -389,7 +372,7 @@ H5B_find(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *u done: if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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() */ @@ -415,20 +398,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 H5AC_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 @@ -448,39 +417,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); } @@ -490,37 +458,35 @@ 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") if(NULL == (new_bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, *new_addr_p, shared->type, udata, H5AC_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; /* @@ -537,10 +503,10 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags, new_bt_flags |= H5AC__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; @@ -560,19 +526,19 @@ H5B_split(H5F_t *f, hid_t dxpl_id, H5B_t *old_bt, unsigned *old_bt_flags, H5B_t *tmp_bt; if(NULL == (tmp_bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, old_bt->right, shared->type, udata, H5AC_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(H5AC_unprotect(f, dxpl_id, H5AC_BT, old_bt->right, tmp_bt, H5AC__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 && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_addr_p, 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() */ @@ -590,25 +556,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 H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ herr_t @@ -635,42 +582,42 @@ 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, - <_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, + <_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); /* the current root */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_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") shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); level = bt->level; - if (!lt_key_changed) + if(!lt_key_changed) HDmemcpy(lt_key, H5B_NKEY(bt,shared,0), type->sizeof_nkey); if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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 *)H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_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(H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, H5AC__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; /* @@ -679,17 +626,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 *)H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata, H5AC_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(H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, H5AC__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 */ /* @@ -698,23 +645,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 *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_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(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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 */ @@ -763,18 +710,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 H5AC_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 @@ -786,28 +721,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 */ @@ -816,7 +751,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 */ @@ -863,27 +798,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 H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ static H5B_ins_t @@ -907,17 +821,17 @@ 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; @@ -928,63 +842,61 @@ H5B_insert_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type * should get the new data. */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_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") shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); rt = bt->nchildren; - while (lt < rt && cmp) { + while(lt < rt && cmp) { idx = (lt + rt) / 2; - if ((cmp = (type->cmp3)(f, dxpl_id, H5B_NKEY(bt,shared,idx), udata, H5B_NKEY(bt,shared,idx+1))) < 0) { + if((cmp = (type->cmp3)(f, dxpl_id, 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 |= H5AC__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 @@ -992,33 +904,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 @@ -1026,80 +937,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 |= H5AC__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 |= H5AC__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 |= H5AC__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 *)H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, type, udata, H5AC_WRITE))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node") - if (idx<bt->nchildren) { + if(NULL == (twin = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, *new_node_p, type, udata, H5AC_WRITE))) + 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 { @@ -1107,13 +1016,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") } @@ -1121,28 +1031,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)(f, dxpl_id, H5B_NKEY(bt,shared,bt->nchildren), udata, - H5B_NKEY(twin,shared,0)); - assert(0 == cmp); + cmp = (type->cmp2)(f, dxpl_id, 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 && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags) < 0); herr_t e2 = (twin && H5AC_unprotect(f, dxpl_id, H5AC_BT, *new_node_p, 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) @@ -1185,14 +1095,14 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add /* Protect the initial/current node */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_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(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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. */ @@ -1210,9 +1120,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; @@ -1224,7 +1134,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add /* Release current node */ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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; /* @@ -1254,7 +1164,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 *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_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; @@ -1266,7 +1176,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add /* Unprotect node */ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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 @@ -1278,7 +1188,7 @@ H5B_iterate_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t add done: if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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) @@ -1349,15 +1259,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 H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ static H5B_ins_t @@ -1368,64 +1269,63 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type { H5B_t *bt = NULL, *sibling = NULL; unsigned bt_flags = H5AC__NO_FLAGS_SET; - H5B_shared_t *shared; /* Pointer to shared B-tree info */ - unsigned idx=0, lt=0, rt; /* Final, left & right indices */ - int cmp=1; /* Key comparison value */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ + 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); /* * Perform a binary search to locate the child which contains the thing * for which we're searching. */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_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") shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); rt = bt->nchildren; - while (lt<rt && cmp) { - idx = (lt+rt)/2; - if ((cmp=(type->cmp3)(f, dxpl_id, 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)(f, dxpl_id, 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 { /* @@ -1446,48 +1346,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 |= H5AC__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 |= H5AC__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 *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_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(H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling, H5AC__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 @@ -1495,44 +1396,43 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ bt_flags |= H5AC__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 *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->left, type, udata, H5AC_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(H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->left, sibling, H5AC__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 *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_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(H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling, H5AC__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 || H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, bt_flags | H5C__DELETED_FLAG) < 0) { bt = NULL; bt_flags = H5AC__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 = H5AC__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 @@ -1545,15 +1445,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 @@ -1562,29 +1461,28 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type */ bt_flags |= H5AC__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 *)H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata, H5AC_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(H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling, H5AC__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 @@ -1596,20 +1494,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 && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, 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) } @@ -1629,15 +1525,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 H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ herr_t @@ -1656,14 +1543,14 @@ 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, <_key_changed, - udata, rt_key, &rt_key_changed)==H5B_INS_ERROR) + if(H5B_remove_helper(f, dxpl_id, addr, type, 0, lt_key, <_key_changed, + udata, rt_key, &rt_key_changed) == H5B_INS_ERROR) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to remove entry from B-tree") /* @@ -1671,16 +1558,16 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void * being at level zero */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_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 |= H5AC__DIRTIED_FLAG; - } + } /* end if */ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, 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); @@ -1701,66 +1588,60 @@ 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 H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ herr_t H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void *udata) { H5B_t *bt = NULL; /* B-tree node being operated on */ - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ 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)); /* Lock this B-tree node into memory for now */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_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") shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); /* 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), <_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), <_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 && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, 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() */ @@ -1796,7 +1677,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; @@ -1811,12 +1692,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++) @@ -1875,8 +1756,6 @@ H5B_shared_free(void *_shared) * koziol@ncsa.uiuc.edu * Apr 18 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ static H5B_t * @@ -1891,13 +1770,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)); @@ -1905,22 +1784,22 @@ H5B_copy(const H5B_t *old_bt) /* Reset cache info */ HDmemset(&new_node->cache_info, 0, sizeof(H5AC_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) { + if(ret_value == NULL) { if(new_node) { new_node->native = H5FL_BLK_FREE(native_block, new_node->native); new_node->child = H5FL_SEQ_FREE(haddr_t, new_node->child); @@ -1971,7 +1850,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad /* Protect the initial/current node */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, info_udata->udata, H5AC_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") /* Get the shared B-tree information */ shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); @@ -1991,7 +1870,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad /* Release current node */ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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; /* @@ -2002,7 +1881,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 *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, info_udata->udata, H5AC_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; @@ -2013,7 +1892,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad /* Unprotect node */ if(H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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 */ @@ -2026,7 +1905,7 @@ H5B_get_info_helper(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t ad done: if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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() */ @@ -2095,9 +1974,6 @@ done: * matzke@llnl.gov * Aug 4 1997 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ herr_t @@ -2105,7 +1981,7 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f const H5B_class_t *type, void *udata) { H5B_t *bt = NULL; - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ unsigned u; /* Local index variable */ herr_t ret_value=SUCCEED; /* Return value */ @@ -2114,19 +1990,19 @@ 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); /* * Load the tree node. */ if(NULL == (bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_READ))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node") - shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to load B-tree node") + shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); /* @@ -2164,32 +2040,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, f, dxpl_id, indent+6, MAX (0, fwidth-6), - H5B_NKEY(bt,shared,u), udata); + HDassert(H5B_NKEY(bt, shared, u)); + (void)(type->debug_key)(stream, f, dxpl_id, 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, f, dxpl_id, 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, f, dxpl_id, indent + 6, MAX(0, fwidth - 6), + H5B_NKEY(bt, shared, u + 1), udata); + } /* end if */ + } /* end for */ done: if(bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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) } @@ -2207,15 +2083,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 H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ #ifdef H5B_DEBUG @@ -2227,7 +2094,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 { @@ -2238,25 +2105,24 @@ 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 */ /* Initialize the queue */ bt = (H5B_t *)H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata, H5AC_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 = H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, H5AC__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 @@ -2264,64 +2130,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 *)H5AC_protect(f, dxpl_id, H5AC_BT, cur->addr, type, udata, H5AC_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)(f, dxpl_id, H5B_NKEY(bt,shared,i), udata, - H5B_NKEY(bt,shared,i+1)); - assert(cmp < 0); - } - } + cmp = (type->cmp2)(f, dxpl_id, H5B_NKEY(bt, shared, i), udata, + H5B_NKEY(bt, shared, i + 1)); + HDassert(cmp < 0); + } /* end for */ + } /* end if */ + /* Release node */ status = H5AC_unprotect(f, dxpl_id, H5AC_BT, cur->addr, bt, H5AC__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/H5B2cache.c b/src/H5B2cache.c index 3c96fa5..bdb9b26 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -506,7 +506,7 @@ H5B2_cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_uda H5RC_INC(internal->shared); /* Get the pointer to the shared B-tree info */ - shared=(H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); + shared = (H5B2_shared_t *)H5RC_GET_OBJ(internal->shared); HDassert(shared); /* Read header from disk */ @@ -915,7 +915,7 @@ H5B2_cache_leaf_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_nrec, v done: if(!ret_value && leaf) - (void)H5B2_cache_leaf_dest(f,leaf); + (void)H5B2_cache_leaf_dest(f, leaf); FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_cache_leaf_load() */ /*lint !e818 Can't make udata a pointer to const */ diff --git a/src/H5B2int.c b/src/H5B2int.c index c192c65..e27bb84 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -1974,7 +1974,7 @@ HDmemset(leaf->leaf_native, 0, shared->type->nrec_size * shared->node_info[0].ma done: if(ret_value < 0) { if(leaf) - (void)H5B2_cache_leaf_dest(f,leaf); + (void)H5B2_cache_leaf_dest(f, leaf); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -2055,7 +2055,7 @@ HDmemset(internal->node_ptrs, 0, sizeof(H5B2_node_ptr_t) * (shared->node_info[de done: if(ret_value < 0) { if(internal) - (void)H5B2_cache_internal_dest(f,internal); + (void)H5B2_cache_internal_dest(f, internal); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Bcache.c b/src/H5Bcache.c index 9f7444b..01dc737 100644 --- a/src/H5Bcache.c +++ b/src/H5Bcache.c @@ -224,8 +224,8 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) UINT16DECODE(p, bt->nchildren); /* sibling pointers */ - H5F_addr_decode(f, (const uint8_t **) &p, &(bt->left)); - H5F_addr_decode(f, (const uint8_t **) &p, &(bt->right)); + H5F_addr_decode(f, (const uint8_t **)&p, &(bt->left)); + H5F_addr_decode(f, (const uint8_t **)&p, &(bt->right)); /* the child/key pairs */ native = bt->native; @@ -237,7 +237,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) native += type->sizeof_nkey; /* Decode address value */ - H5F_addr_decode(f, (const uint8_t **) &p, bt->child + u); + H5F_addr_decode(f, (const uint8_t **)&p, bt->child + u); } /* end for */ /* Decode final key */ @@ -274,7 +274,7 @@ done: static herr_t H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt, unsigned UNUSED * flags_ptr) { - H5B_shared_t *shared; /* Pointer to shared B-tree info */ + H5B_shared_t *shared; /* Pointer to shared B-tree info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5B_flush) @@ -408,7 +408,7 @@ H5B_compute_size(const H5F_t UNUSED *f, const H5B_t *bt, size_t *size_ptr) HDassert(f); HDassert(bt); HDassert(bt->rc_shared); - shared=(H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); + shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); HDassert(shared->type); HDassert(size_ptr); @@ -418,3 +418,4 @@ H5B_compute_size(const H5F_t UNUSED *f, const H5B_t *bt, size_t *size_ptr) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5B_compute_size() */ + diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index 755488c..f70ecc2 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -34,6 +34,7 @@ /* Other private headers needed by this file */ #include "H5RCprivate.h" /* Reference counted objects */ + /**************************/ /* Package Private Macros */ /**************************/ diff --git a/src/H5Defl.c b/src/H5Defl.c index 647f02c..15bcd60 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -108,7 +108,7 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{ */ static herr_t H5D_efl_new(H5F_t *f, hid_t UNUSED dxpl_id, H5D_t *dset, - const H5P_genplist_t UNUSED *dc_plist) + const H5P_genplist_t *dc_plist) { const H5T_t *type = dset->shared->type; /* Convenience pointer to dataset's datatype */ hsize_t dim[H5O_LAYOUT_NDIMS]; /* Current size of data in elements */ diff --git a/src/H5Dint.c b/src/H5Dint.c index 839ea93..3b2faf2 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -2414,7 +2414,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5D_flush_real(H5D_t *dataset, hid_t dxpl_id, unsigned flags) { H5O_t *oh = NULL; /* Pointer to dataset's object header */ diff --git a/src/H5Dtest.c b/src/H5Dtest.c index 2fb3c10..2198ff4 100644 --- a/src/H5Dtest.c +++ b/src/H5Dtest.c @@ -84,20 +84,20 @@ herr_t H5D_layout_version_test(hid_t did, unsigned *version) { - H5D_t *dset; /* Pointer to dataset to query */ - herr_t ret_value = SUCCEED; /* return value */ + H5D_t *dset; /* Pointer to dataset to query */ + herr_t ret_value=SUCCEED; /* return value */ - FUNC_ENTER_NOAPI(H5D_layout_version_test, FAIL) + FUNC_ENTER_NOAPI(H5D_layout_version_test, FAIL); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if (NULL==(dset=H5I_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(version) - *version = dset->shared->layout.version; + *version=dset->shared->layout.version; done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value); } /* H5D_layout_version_test() */ @@ -124,20 +124,20 @@ herr_t H5D_layout_contig_size_test(hid_t did, hsize_t *size) { H5D_t *dset; /* Pointer to dataset to query */ - herr_t ret_value = SUCCEED; /* return value */ + herr_t ret_value=SUCCEED; /* return value */ - FUNC_ENTER_NOAPI(H5D_layout_contig_size_test, FAIL) + FUNC_ENTER_NOAPI(H5D_layout_contig_size_test, FAIL); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if (NULL==(dset=H5I_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(size) { - HDassert(dset->shared->layout.type == H5D_CONTIGUOUS); - *size = dset->shared->layout.u.contig.size; + assert(dset->shared->layout.type==H5D_CONTIGUOUS); + *size=dset->shared->layout.u.contig.size; } /* end if */ done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(ret_value); } /* H5D_layout_contig_size_test() */ 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/H5FScache.c b/src/H5FScache.c index 8ace571..7d0aad1 100644 --- a/src/H5FScache.c +++ b/src/H5FScache.c @@ -531,9 +531,6 @@ H5FS_cache_sinfo_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * H5FS_sinfo_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5FS_cache_sinfo_load) -#ifdef QAK -HDfprintf(stderr, "%s: Load free space sections, addr = %a\n", FUNC, addr); -#endif /* QAK */ /* Check arguments */ HDassert(f); diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 12a2d81..9261152 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -567,7 +567,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) @@ -623,7 +623,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 */ @@ -756,7 +756,7 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) */ H5O_loc_reset(&ext_loc); if(H5O_create(f, dxpl_id, 0, H5P_GROUP_CREATE_DEFAULT, &ext_loc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create superblock extension") + HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL, "unable to create superblock extension") /* Record the address of the superblock extension */ f->shared->extension_addr = ext_loc.addr; @@ -808,7 +808,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 */ diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 908188e..e4b5418 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -244,7 +244,6 @@ H5HF_dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dtable) * Purpose: Loads a fractal heap header from the disk. * * Return: Success: Pointer to a new fractal heap - * * Failure: NULL * * Programmer: Quincey Koziol @@ -392,7 +391,7 @@ H5HF_cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *ud /* Release the space allocated for the I/O pipeline filters */ H5O_msg_free(H5O_PLINE_ID, pline); } /* end if */ - else + else /* Set the heap header's size */ hdr->heap_size = size; diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index f173ed0..ae5938d 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -427,9 +427,9 @@ H5HF_man_dblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr, size_t dblock_size, H5HF_indirect_t *par_iblock, unsigned par_entry, H5AC_protect_t rw) { - H5HF_parent_t par_info; /* Parent info for loading block */ - H5HF_direct_t *dblock; /* Direct block from cache */ - H5HF_direct_t *ret_value; /* Return value */ + H5HF_parent_t par_info; /* Parent info for loading block */ + H5HF_direct_t *dblock; /* Direct block from cache */ + H5HF_direct_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5HF_man_dblock_protect) diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index 030d1ea..9733a0f 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -1032,7 +1032,7 @@ done: /*------------------------------------------------------------------------- * Function: H5HF_man_iblock_protect * - * Purpose: Convenience wrapper around H5AC_protect on a indirect block + * Purpose: Convenience wrapper around H5AC_protect on an indirect block * * Return: Pointer to indirect block on success, NULL on failure * @@ -1123,7 +1123,7 @@ done: /*------------------------------------------------------------------------- * Function: H5HF_man_iblock_unprotect * - * Purpose: Convenience wrapper around H5AC_unprotect on a indirect block + * Purpose: Convenience wrapper around H5AC_unprotect on an indirect block * * Return: SUCCEED/FAIL * @@ -171,24 +171,6 @@ H5FL_BLK_DEFINE_STATIC(heap_chunk); * Programmer: Robb Matzke * Friday, March 27, 1998 * - * Modifications: - * - * John Mainzer 5/26/04 - * Modified function to return the disk address of the new - * global heap collection, or HADDR_UNDEF on failure. This - * is necessary, as in some cases (i.e. flexible parallel) - * H5AC_set() will imediately flush and destroy the in memory - * version of the new collection. For the same reason, I - * moved the code which places the new collection on the cwfs - * list to just before the call to H5AC_set(). - * - * John Mainzer 6/8/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 - * H5AC_set() (which marks the entry dirty automaticly), no - * other change is required. - * *------------------------------------------------------------------------- */ static haddr_t @@ -668,16 +650,6 @@ H5HG_compute_size(const H5F_t UNUSED *f, const H5HG_heap_t *heap, size_t *size_p * Programmer: Robb Matzke * Friday, March 27, 1998 * - * Modifications: - * - * John Mainzer, 6/8/05 - * Modified the function to use the new dirtied parameter of - * of H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * - * In this case, that required adding the new heap_dirtied_ptr - * parameter to the function's argument list. - * *------------------------------------------------------------------------- */ static size_t @@ -899,30 +871,6 @@ done: * Programmer: Robb Matzke * Friday, March 27, 1998 * - * Modifications: - * - * John Mainzer -- 5/24/04 - * The function used to modify the heap without protecting - * the relevant collection first. I did a half assed job - * of fixing the problem, which should hold until we try to - * support multi-threading. At that point it will have to - * be done right. - * - * See in line comment of this date for more details. - * - * John Mainzer - 5/26/04 - * Modified H5HG_create() to return the disk address of the - * new collection, instead of the address of its - * representation in core. This was necessary as in FP - * mode, the cache will immediately flush and destroy any - * entry inserted in it via H5AC_set(). I then modified - * this function to account for the change in H5HG_create(). - * - * John Mainzer - 6/8/05 - * Modified function to use the dirtied parameter of - * H5AC_unprotect() instead of modifying the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ herr_t @@ -1030,7 +978,6 @@ H5HG_insert (H5F_t *f, hid_t dxpl_id, size_t size, void *obj, H5HG_t *hobj/*out* --cwfsno; } /* end if */ } /* end else */ - HDassert(H5F_addr_defined(addr)); if(NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL, H5AC_WRITE))) @@ -22,11 +22,6 @@ * Purpose: Heap functions for the local heaps used by symbol * tables to store names (among other things). * - * Modifications: - * - * Robb Matzke, 5 Aug 1997 - * Added calls to H5E. - * *------------------------------------------------------------------------- */ @@ -335,22 +330,6 @@ done: * wendling@ncsa.uiuc.edu * Sept. 16, 2003 * - * Modifications: - * - * John Mainzer, 8/10/05 - * Reworked this function for a different role. - * - * It used to be called during cache eviction, where it - * attempted to size the disk space allocation for the - * actual size of the heap. However, this causes problems - * in the parallel case, as the reuslting disk allocations - * may not be synchronized. - * - * It is now called from H5HL_remove(), where it is used to - * reduce heap size in response to an entry deletion. This - * means that the function should either do nothing, or - * reduce the size of the disk allocation. - * *------------------------------------------------------------------------- */ static herr_t @@ -491,8 +470,6 @@ done: * wendling@ncsa.uiuc.edu * Sept. 16, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -551,32 +528,6 @@ H5HL_serialize(H5F_t *f, H5HL_t *heap, uint8_t *buf) * matzke@llnl.gov * Jul 17 1997 * - * Modifications: - * rky, 1998-08-28 - * Only p0 writes metadata to disk. - * - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. - * - * Quincey Koziol, 2002-7-180 - * Added dxpl parameter to allow more control over I/O from metadata - * cache. - * - * Bill Wendling, 2003-09-16 - * Separated out the bit that serializes the heap. - * - * John Mainzer, 2005-08-10 - * Removed call to H5HL_minimize_heap_space(). It does disk space - * allocation, which can cause problems if done at flush time. - * Instead, disk space allocation/deallocation is now done at - * insert/remove time. - * - * John Mainzer, 2006-08-21 - * Added the flags_ptr parameter. This parameter exists to - * allow the flush routine to report to the cache if the - * entry is resized or renamed as a result of the flush. - * *flags_ptr is set to H5C_CALLBACK__NO_FLAGS_SET on entry. - * *------------------------------------------------------------------------- */ static herr_t @@ -641,8 +592,6 @@ done: * koziol@ncsa.uiuc.edu * Jan 15 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -682,8 +631,6 @@ H5HL_dest(H5F_t UNUSED *f, H5HL_t *heap) * koziol@ncsa.uiuc.edu * Mar 20 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -720,7 +667,6 @@ done: * Programmer: John Mainzer * 5/13/04 * - * Modifications: *------------------------------------------------------------------------- */ static herr_t @@ -846,8 +792,8 @@ H5HL_unprotect(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, haddr_t addr) HDassert(heap); HDassert(H5F_addr_defined(addr)); - if(H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, (void *)heap, H5AC__NO_FLAGS_SET) != SUCCEED) - HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header") + if(H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, (void *)heap, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1130,7 +1076,7 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size) H5HL_free_t *fl = NULL; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5HL_remove, FAIL); + FUNC_ENTER_NOAPI(H5HL_remove, FAIL) /* check arguments */ HDassert(f); @@ -1177,7 +1123,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->heap_alloc ) && ((2 * fl->size) > heap->heap_alloc )) { 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); } @@ -1186,7 +1132,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->heap_alloc) && ((2 * fl->size) > heap->heap_alloc)) { 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) { @@ -1201,7 +1147,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->heap_alloc) && ((2 * fl->size) > heap->heap_alloc)) { 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 */ @@ -1210,7 +1156,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->heap_alloc) && ((2 * fl->size) > heap->heap_alloc)) { 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 */ @@ -1236,7 +1182,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)); @@ -1250,7 +1196,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->heap_alloc) && ((2 * fl->size) > heap->heap_alloc)) { 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: @@ -1320,7 +1266,7 @@ H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) done: if(heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release local heap") + HDONE_ERROR(H5E_HEAP, H5E_CANTUNPROTECT, FAIL, "unable to release local heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5HL_delete() */ @@ -1396,11 +1342,11 @@ H5HL_heapsize(H5F_t *f, hid_t dxpl_id, haddr_t addr, hsize_t *heap_size) /* Get heap pointer */ if(NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap") + HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to load heap") /* Get the total size of the local heap */ if(H5HL_size(f, heap, &local_heap_size) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to compute size of local heap") + HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "unable to compute size of local heap") /* Accumulate the size of the local heap */ *heap_size += (hsize_t)local_heap_size; diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index d33bf0a..28fe277 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -70,7 +70,7 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int HDassert(indent >= 0); HDassert(fwidth >= 0); - if (NULL == (h = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) + if(NULL == (h = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap") fprintf(stream, "%*sLocal Heap...\n", indent, ""); @@ -1251,8 +1251,6 @@ done: * Programmer: Quincey Koziol * Dec 7, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1260,19 +1258,19 @@ H5Idec_ref(hid_t id) { int ret_value; /* Return value */ - FUNC_ENTER_API(H5Idec_ref, FAIL); + FUNC_ENTER_API(H5Idec_ref, FAIL) H5TRACE1("Is", "i", id); /* Check arguments */ - if (id<0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID"); + if(id < 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") /* Do actual decrement operation */ - if((ret_value = H5I_dec_ref(id))<0) - HGOTO_ERROR (H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count"); + if((ret_value = H5I_dec_ref(id)) < 0) + HGOTO_ERROR (H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Idec_ref() */ @@ -1385,19 +1383,19 @@ H5Iinc_ref(hid_t id) { int ret_value; /* Return value */ - FUNC_ENTER_API(H5Iinc_ref, FAIL); + FUNC_ENTER_API(H5Iinc_ref, FAIL) H5TRACE1("Is", "i", id); /* Check arguments */ - if (id<0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID"); + if(id < 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") /* Do actual increment operation */ - if((ret_value = H5I_inc_ref(id))<0) + if((ret_value = H5I_inc_ref(id)) < 0) HGOTO_ERROR (H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count"); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Iinc_ref() */ @@ -1997,7 +1995,7 @@ H5I_find_id(hid_t id) ssize_t H5Iget_name(hid_t id, char *name/*out*/, size_t size) { - ssize_t ret_value; + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(H5Iget_name, FAIL) H5TRACE3("Zs", "ixz", id, name, size); @@ -563,7 +563,7 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* end H5Lcreate_ud() */ @@ -1181,7 +1181,8 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id, /* Cache object header */ if(H5AC_set(f, dxpl_id, H5AC_OHDR, oh_addr, oh, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to cache object header") + HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") + oh = NULL; /* Set up object location */ loc->file = f; @@ -1408,10 +1409,10 @@ done: int H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id) { - H5O_t *oh = NULL; + H5O_t *oh = NULL; /* Object header to query/modify */ H5AC_protect_t oh_acc; /* Access mode for protecting object header */ unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Whether the object was deleted */ - int ret_value; /* Return value */ + int ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_link, FAIL) @@ -1431,7 +1432,11 @@ H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id) /* Check for too large of an adjustment */ if((unsigned)(-adjust) > oh->nlink) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative") + + /* Adjust the link count for the object header */ oh->nlink += adjust; + + /* Mark object header as dirty in cache */ oh_flags |= H5AC__DIRTIED_FLAG; /* Check if the object should be deleted */ @@ -1464,7 +1469,8 @@ H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id) /* Adjust the link count for the object header */ oh->nlink += adjust; - /* Mark the object header for deletion */ + + /* Mark object header as dirty in cache */ oh_flags |= H5AC__DIRTIED_FLAG; } /* end if */ @@ -1531,7 +1537,7 @@ done: H5O_t * H5O_protect(H5O_loc_t *loc, hid_t dxpl_id) { - H5O_t *ret_value; /* Return value */ + H5O_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5O_protect, NULL) @@ -1558,7 +1564,7 @@ H5O_protect(H5O_loc_t *loc, hid_t dxpl_id) /* Release the object header from the cache */ if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, ret_value, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_PROTECT, NULL, "unable to release object header") + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_protect() */ @@ -1701,7 +1707,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_touch(H5O_loc_t *loc, hbool_t force, hid_t dxpl_id) +H5O_touch(const H5O_loc_t *loc, hbool_t force, hid_t dxpl_id) { H5O_t *oh = NULL; /* Object header to modify */ unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ @@ -2482,7 +2488,7 @@ H5O_get_nlinks(const H5O_loc_t *loc, hid_t dxpl_id, hsize_t *nlinks) /* Get the object header */ if(NULL == (oh = H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Retrieve the # of link messages seen when the object header was loaded */ *nlinks = oh->link_msgs_seen; diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 29c057d..ec93d9b 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -70,7 +70,7 @@ static unsigned H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size); static htri_t H5O_move_msgs_forward(H5O_t *oh); static htri_t H5O_merge_null(H5O_t *oh); -static htri_t H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh, hid_t dxpl_id); +static htri_t H5O_remove_empty_chunks(H5F_t *f, hid_t dxpl_id, H5O_t *oh); /*********************/ @@ -600,7 +600,7 @@ H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, if(oh->mesg[u].chunkno == chunkno) { oh->mesg[u].raw = oh->chunk[chunkno].image + extra_prfx_size + (oh->mesg[u].raw - old_image); - /* Flag message as dirty */ + /* Flag message as dirty directly */ oh->mesg[u].dirty = TRUE; } /* endif */ @@ -609,7 +609,7 @@ H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, * it's size is directly encoded in the object header) */ if(chunkno > 0 && (H5O_CONT_ID == oh->mesg[u].type->id) && (((H5O_cont_t *)(oh->mesg[u].native))->chunkno == chunkno)) { - /* Adjust size of continuation message */ + /* Adjust size in continuation message */ HDassert(((H5O_cont_t *)(oh->mesg[u].native))->size == old_size); ((H5O_cont_t *)(oh->mesg[u].native))->size = oh->chunk[chunkno].size; @@ -1450,7 +1450,7 @@ H5O_merge_null(H5O_t *oh) *------------------------------------------------------------------------- */ static htri_t -H5O_remove_empty_chunks(H5F_t *f, H5O_t *oh, hid_t dxpl_id) +H5O_remove_empty_chunks(H5F_t *f, hid_t dxpl_id, H5O_t *oh) { hbool_t deleted_chunk; /* Whether to a chunk was deleted */ hbool_t did_deleting = FALSE; /* Whether any chunks were deleted */ @@ -1630,7 +1630,7 @@ H5O_condense_header(H5F_t *f, H5O_t *oh, hid_t dxpl_id) rescan_header = TRUE; /* Scan for empty chunks to remove */ - result = H5O_remove_empty_chunks(f, oh, dxpl_id); + result = H5O_remove_empty_chunks(f, dxpl_id, oh); if(result < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPACK, FAIL, "can't remove empty chunk") if(result > 0) diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 14280b3..8b31f9b 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -730,17 +730,12 @@ done: HDfree(deleted); /* Release pointer to source object header and its derived objects */ - if(oh_src != NULL) { - /* Unprotect the source object header */ - if(H5AC_unprotect(oloc_src->file, dxpl_id, H5AC_OHDR, oloc_src->addr, oh_src, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - } /* end if */ + if(oh_src && H5AC_unprotect(oloc_src->file, dxpl_id, H5AC_OHDR, oloc_src->addr, oh_src, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") /* Release pointer to destination object header */ - if(ret_value < 0 && oh_dst) { - if(H5O_dest(oloc_dst->file, oh_dst) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") - } /* end if */ + if(ret_value < 0 && oh_dst && H5O_dest(oloc_dst->file, oh_dst) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") /* Release user data for particular type of object to copy */ if(udata) { diff --git a/src/H5Omessage.c b/src/H5Omessage.c index 3e3a87a..6c6dfb1 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -493,7 +493,7 @@ H5O_msg_read(const H5O_loc_t *loc, unsigned type_id, void *mesg, done: if(oh && H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to release object header") + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_read() */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index a6e81f8..fa779bf 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -548,7 +548,7 @@ H5_DLL herr_t H5O_close(H5O_loc_t *loc); H5_DLL int H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id); H5_DLL H5O_t *H5O_protect(H5O_loc_t *loc, hid_t dxpl_id); H5_DLL herr_t H5O_unprotect(H5O_loc_t *loc, H5O_t *oh); -H5_DLL herr_t H5O_touch(H5O_loc_t *loc, hbool_t force, hid_t dxpl_id); +H5_DLL herr_t H5O_touch(const H5O_loc_t *loc, hbool_t force, hid_t dxpl_id); H5_DLL herr_t H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force); #ifdef H5O_ENABLE_BOGUS @@ -1582,8 +1582,6 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, 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) */ - H5O_loc_t oloc; /* Object location for message in object header */ - H5O_t *oh = NULL; /* Object header for message in object header */ unsigned type_id; /* Message type to operate on */ herr_t ret_value = SUCCEED; @@ -1716,15 +1714,6 @@ H5SM_delete_from_index(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, } /* end if */ done: - /* Unprotect & close the object header if we opened one */ - if(oh && oh != open_oh) { - if(H5AC_unprotect(oloc.file, dxpl_id, H5AC_OHDR, oloc.addr, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - - if(H5O_close(&oloc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object header") - } /* end if */ - /* Release the SOHM list */ if(list && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_LIST, header->index_addr, list, H5AC__DIRTIED_FLAG) < 0) HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") diff --git a/src/H5Sall.c b/src/H5Sall.c index e8ed337..07043f2 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -828,7 +828,7 @@ done: herr_t H5Sselect_all(hid_t spaceid) { - H5S_t *space = NULL; /* Dataspace to modify selection of */ + H5S_t *space; /* Dataspace to modify selection of */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(H5Sselect_all, FAIL) @@ -838,7 +838,7 @@ H5Sselect_all(hid_t spaceid) 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: diff --git a/src/H5Snone.c b/src/H5Snone.c index 8ed3c0a..50e685a 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -778,8 +778,8 @@ done: herr_t H5Sselect_none(hid_t spaceid) { - H5S_t *space; /* 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) @@ -788,7 +788,7 @@ H5Sselect_none(hid_t spaceid) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") /* Change to "none" selection */ - if((ret_value = H5S_select_none(space)) < 0) + if(H5S_select_none(space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") done: @@ -1699,7 +1699,7 @@ H5Tclose(hid_t type_id) H5T_t *dt = NULL; herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Tclose, FAIL); + FUNC_ENTER_API(H5Tclose, FAIL) H5TRACE1("e", "i", type_id); /* Check args */ @@ -1713,7 +1713,7 @@ H5Tclose(hid_t type_id) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id"); done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } |