mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-01 16:28:09 +08:00
[svn-r7080] Purpose:
Bug fix (backward compatibility) Description: Changes we've made during development of the 1.5.x branch had broken the feature of allowing user's callbacks to H5Giterate to return a value through the library back to the application which called H5Giterate. Solution: Correctly pass along iterator callback return value and adjust internal library code to conform to this design. Platforms tested: FreeBSD 4.8 (sleipnir) h5committest
This commit is contained in:
parent
ff818d2d47
commit
403f1bac7c
18
src/H5B.c
18
src/H5B.c
@ -1517,8 +1517,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
|
||||
haddr_t *child = NULL;
|
||||
uint8_t *key = NULL;
|
||||
int i, nchildren;
|
||||
herr_t ret_value = SUCCEED;
|
||||
H5B_iterate_t ret_flag = H5B_ITER_CONT;
|
||||
herr_t ret_value;
|
||||
|
||||
FUNC_ENTER_NOAPI(H5B_iterate, FAIL);
|
||||
|
||||
@ -1535,7 +1534,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node");
|
||||
if (bt->level > 0) {
|
||||
/* Keep following the left-most child until we reach a leaf node. */
|
||||
if (H5B_iterate(f, dxpl_id, type, op, bt->child[0], udata)<0)
|
||||
if ((ret_value=H5B_iterate(f, dxpl_id, type, op, bt->child[0], udata))<0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node");
|
||||
} else {
|
||||
/*
|
||||
@ -1545,7 +1544,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
|
||||
if (NULL==(child=H5FL_ARR_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) ||
|
||||
NULL==(key=H5MM_malloc((2*H5F_KVALUE(f, type)+1)*type->sizeof_nkey)))
|
||||
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
|
||||
for (cur_addr=addr, ret_value=0; H5F_addr_defined(cur_addr); cur_addr=next_addr) {
|
||||
for (cur_addr=addr, ret_value=0; H5F_addr_defined(cur_addr) && !ret_value; cur_addr=next_addr) {
|
||||
|
||||
/*
|
||||
* Save all the child addresses and native keys since we can't
|
||||
@ -1570,16 +1569,11 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
|
||||
* Perform the iteration operator, which might invoke an
|
||||
* application callback.
|
||||
*/
|
||||
for (i=0; i<nchildren && ret_flag==H5B_ITER_CONT; i++) {
|
||||
ret_flag = (*op)(f, dxpl_id, key+i*type->sizeof_nkey,
|
||||
for (i=0, ret_value=H5B_ITER_CONT; i<nchildren && !ret_value; i++) {
|
||||
ret_value = (*op)(f, dxpl_id, key+i*type->sizeof_nkey,
|
||||
child[i], key+(i+1)*type->sizeof_nkey, udata);
|
||||
if (ret_flag==H5B_ITER_ERROR) {
|
||||
if (ret_value<0)
|
||||
HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iterator function failed");
|
||||
} else if(ret_flag==H5B_ITER_STOP) {
|
||||
HGOTO_DONE(SUCCEED);
|
||||
} else {
|
||||
;
|
||||
}
|
||||
} /* end for */
|
||||
} /* end for */
|
||||
} /* end else */
|
||||
|
@ -58,14 +58,15 @@ typedef enum H5B_ins_t {
|
||||
} H5B_ins_t;
|
||||
|
||||
/* Define return values from operator callback function for H5B_iterate */
|
||||
typedef enum H5B_iterate_t {
|
||||
H5B_ITER_ERROR = -1, /*error return value */
|
||||
H5B_ITER_CONT = 0, /*continue the loop */
|
||||
H5B_ITER_STOP = 1 /*stop and break the loop */
|
||||
} H5B_iterate_t;
|
||||
/* (Actually, any postive value will cause the iterator to stop and pass back
|
||||
* that positive value to the function that called the iterator)
|
||||
*/
|
||||
#define H5B_ITER_ERROR (-1)
|
||||
#define H5B_ITER_CONT (0)
|
||||
#define H5B_ITER_STOP (1)
|
||||
|
||||
/* Define the operator callback function pointer for H5B_iterate() */
|
||||
typedef H5B_iterate_t (*H5B_operator_t)(H5F_t *f, hid_t, void *_lt_key, haddr_t addr,
|
||||
typedef int (*H5B_operator_t)(H5F_t *f, hid_t, void *_lt_key, haddr_t addr,
|
||||
void *_rt_key, void *_udata);
|
||||
|
||||
/* Typedef for B-tree in memory (defined in H5Bpkg.h) */
|
||||
|
@ -123,11 +123,11 @@ static haddr_t H5F_istore_get_addr(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *
|
||||
const hssize_t offset[]);
|
||||
|
||||
/* B-tree iterator callbacks */
|
||||
static H5B_iterate_t H5F_istore_iter_allocated(H5F_t *f, hid_t dxpl_id, void *left_key, haddr_t addr,
|
||||
static int H5F_istore_iter_allocated(H5F_t *f, hid_t dxpl_id, void *left_key, haddr_t addr,
|
||||
void *right_key, void *_udata);
|
||||
static H5B_iterate_t H5F_istore_iter_dump(H5F_t *f, hid_t dxpl_id, void *left_key, haddr_t addr,
|
||||
static int H5F_istore_iter_dump(H5F_t *f, hid_t dxpl_id, void *left_key, haddr_t addr,
|
||||
void *right_key, void *_udata);
|
||||
static H5B_iterate_t H5F_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t addr,
|
||||
static int H5F_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t addr,
|
||||
void *_rt_key, void *_udata);
|
||||
|
||||
/* B-tree callbacks */
|
||||
@ -789,7 +789,7 @@ done:
|
||||
* Changed to callback from H5B_iterate
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5B_iterate_t
|
||||
static int
|
||||
H5F_istore_iter_allocated (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, haddr_t UNUSED addr,
|
||||
void UNUSED *_rt_key, void *_udata)
|
||||
{
|
||||
@ -825,7 +825,7 @@ H5F_istore_iter_allocated (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key,
|
||||
* Changed to callback from H5B_iterate
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5B_iterate_t
|
||||
static int
|
||||
H5F_istore_iter_dump (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, haddr_t UNUSED addr,
|
||||
void UNUSED *_rt_key, void *_udata)
|
||||
{
|
||||
@ -2600,7 +2600,7 @@ done:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5B_iterate_t
|
||||
static int
|
||||
H5F_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t UNUSED addr,
|
||||
void UNUSED *_rt_key, void *_udata)
|
||||
{
|
||||
@ -2608,7 +2608,7 @@ H5F_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t UNUSED a
|
||||
H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
|
||||
unsigned u;
|
||||
H5F_istore_ud1_t udata;
|
||||
H5B_iterate_t ret_value=H5B_ITER_CONT; /* Return value */
|
||||
int ret_value=H5B_ITER_CONT; /* Return value */
|
||||
|
||||
/* The LT_KEY is the left key (the one that describes the chunk). It points to a chunk of
|
||||
* storage that contains the beginning of the logical address space represented by UDATA.
|
||||
|
@ -123,11 +123,11 @@ static haddr_t H5F_istore_get_addr(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *
|
||||
const hssize_t offset[]);
|
||||
|
||||
/* B-tree iterator callbacks */
|
||||
static H5B_iterate_t H5F_istore_iter_allocated(H5F_t *f, hid_t dxpl_id, void *left_key, haddr_t addr,
|
||||
static int H5F_istore_iter_allocated(H5F_t *f, hid_t dxpl_id, void *left_key, haddr_t addr,
|
||||
void *right_key, void *_udata);
|
||||
static H5B_iterate_t H5F_istore_iter_dump(H5F_t *f, hid_t dxpl_id, void *left_key, haddr_t addr,
|
||||
static int H5F_istore_iter_dump(H5F_t *f, hid_t dxpl_id, void *left_key, haddr_t addr,
|
||||
void *right_key, void *_udata);
|
||||
static H5B_iterate_t H5F_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t addr,
|
||||
static int H5F_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t addr,
|
||||
void *_rt_key, void *_udata);
|
||||
|
||||
/* B-tree callbacks */
|
||||
@ -789,7 +789,7 @@ done:
|
||||
* Changed to callback from H5B_iterate
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5B_iterate_t
|
||||
static int
|
||||
H5F_istore_iter_allocated (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, haddr_t UNUSED addr,
|
||||
void UNUSED *_rt_key, void *_udata)
|
||||
{
|
||||
@ -825,7 +825,7 @@ H5F_istore_iter_allocated (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key,
|
||||
* Changed to callback from H5B_iterate
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5B_iterate_t
|
||||
static int
|
||||
H5F_istore_iter_dump (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, void *_lt_key, haddr_t UNUSED addr,
|
||||
void UNUSED *_rt_key, void *_udata)
|
||||
{
|
||||
@ -2600,7 +2600,7 @@ done:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static H5B_iterate_t
|
||||
static int
|
||||
H5F_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t UNUSED addr,
|
||||
void UNUSED *_rt_key, void *_udata)
|
||||
{
|
||||
@ -2608,7 +2608,7 @@ H5F_istore_prune_extent(H5F_t *f, hid_t dxpl_id, void *_lt_key, haddr_t UNUSED a
|
||||
H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
|
||||
unsigned u;
|
||||
H5F_istore_ud1_t udata;
|
||||
H5B_iterate_t ret_value=H5B_ITER_CONT; /* Return value */
|
||||
int ret_value=H5B_ITER_CONT; /* Return value */
|
||||
|
||||
/* The LT_KEY is the left key (the one that describes the chunk). It points to a chunk of
|
||||
* storage that contains the beginning of the logical address space represented by UDATA.
|
||||
|
@ -1243,7 +1243,7 @@ done:
|
||||
* Changed to callback from H5B_iterate
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5B_iterate_t
|
||||
int
|
||||
H5G_node_iterate (H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
void UNUSED *_rt_key, void *_udata)
|
||||
{
|
||||
@ -1253,7 +1253,7 @@ H5G_node_iterate (H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
size_t n, *name_off=NULL;
|
||||
const char *name;
|
||||
char buf[1024], *s;
|
||||
H5B_iterate_t ret_value = H5B_ITER_ERROR;
|
||||
int ret_value;
|
||||
|
||||
FUNC_ENTER_NOAPI(H5G_node_iterate, H5B_ITER_ERROR);
|
||||
|
||||
@ -1280,7 +1280,7 @@ H5G_node_iterate (H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
/*
|
||||
* Iterate over the symbol table node entries.
|
||||
*/
|
||||
for (i=0, ret_value=H5B_ITER_CONT; i<nsyms && H5B_ITER_CONT==ret_value; i++) {
|
||||
for (i=0, ret_value=H5B_ITER_CONT; i<nsyms && !ret_value; i++) {
|
||||
if (bt_udata->skip>0) {
|
||||
--bt_udata->skip;
|
||||
} else {
|
||||
@ -1305,7 +1305,7 @@ H5G_node_iterate (H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
bt_udata->final_ent++;
|
||||
}
|
||||
if (ret_value<0)
|
||||
HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed");
|
||||
HERROR (H5E_SYM, H5E_CANTNEXT, "iteration operator failed");
|
||||
|
||||
done:
|
||||
name_off = H5MM_xfree (name_off);
|
||||
@ -1328,13 +1328,13 @@ done:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5B_iterate_t
|
||||
int
|
||||
H5G_node_sumup(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
void UNUSED *_rt_key, void *_udata)
|
||||
{
|
||||
hsize_t *num_objs = (hsize_t *)_udata;
|
||||
H5G_node_t *sn = NULL;
|
||||
H5B_iterate_t ret_value = H5B_ITER_CONT;
|
||||
int ret_value = H5B_ITER_CONT;
|
||||
|
||||
FUNC_ENTER_NOAPI(H5G_node_sumup, H5B_ITER_ERROR);
|
||||
|
||||
@ -1371,7 +1371,7 @@ done:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5B_iterate_t
|
||||
int
|
||||
H5G_node_name(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
void UNUSED *_rt_key, void *_udata)
|
||||
{
|
||||
@ -1380,7 +1380,7 @@ H5G_node_name(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
hsize_t loc_idx;
|
||||
const char *name;
|
||||
H5G_node_t *sn = NULL;
|
||||
H5B_iterate_t ret_value = H5B_ITER_CONT;
|
||||
int ret_value = H5B_ITER_CONT;
|
||||
|
||||
FUNC_ENTER_NOAPI(H5G_node_name, H5B_ITER_ERROR);
|
||||
|
||||
@ -1397,12 +1397,12 @@ H5G_node_name(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
|
||||
/* Find the node, locate the object symbol table entry and retrieve the name */
|
||||
if(bt_udata->idx >= bt_udata->num_objs && bt_udata->idx < (bt_udata->num_objs+sn->nsyms)) {
|
||||
loc_idx = bt_udata->idx - bt_udata->num_objs;
|
||||
name_off = sn->entry[loc_idx].name_off;
|
||||
name = H5HL_peek (f, dxpl_id, bt_udata->group->ent.cache.stab.heap_addr, name_off);
|
||||
assert (name);
|
||||
bt_udata->name = H5MM_strdup (name);
|
||||
HGOTO_DONE(H5B_ITER_STOP);
|
||||
loc_idx = bt_udata->idx - bt_udata->num_objs;
|
||||
name_off = sn->entry[loc_idx].name_off;
|
||||
name = H5HL_peek (f, dxpl_id, bt_udata->group->ent.cache.stab.heap_addr, name_off);
|
||||
assert (name);
|
||||
bt_udata->name = H5MM_strdup (name);
|
||||
HGOTO_DONE(H5B_ITER_STOP);
|
||||
}
|
||||
|
||||
bt_udata->num_objs += sn->nsyms;
|
||||
@ -1427,14 +1427,14 @@ done:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5B_iterate_t
|
||||
int
|
||||
H5G_node_type(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
void UNUSED *_rt_key, void *_udata)
|
||||
{
|
||||
H5G_bt_ud3_t *bt_udata = (H5G_bt_ud3_t*)_udata;
|
||||
hsize_t loc_idx;
|
||||
H5G_node_t *sn = NULL;
|
||||
H5B_iterate_t ret_value = H5B_ITER_CONT;
|
||||
int ret_value = H5B_ITER_CONT;
|
||||
|
||||
FUNC_ENTER_NOAPI(H5G_node_name, H5B_ITER_ERROR);
|
||||
|
||||
@ -1448,9 +1448,9 @@ H5G_node_type(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node");
|
||||
|
||||
if(bt_udata->idx >= bt_udata->num_objs && bt_udata->idx < (bt_udata->num_objs+sn->nsyms)) {
|
||||
loc_idx = bt_udata->idx - bt_udata->num_objs;
|
||||
bt_udata->type = H5G_get_type(&(sn->entry[loc_idx]), dxpl_id);
|
||||
HGOTO_DONE(H5B_ITER_STOP);
|
||||
loc_idx = bt_udata->idx - bt_udata->num_objs;
|
||||
bt_udata->type = H5G_get_type(&(sn->entry[loc_idx]), dxpl_id);
|
||||
HGOTO_DONE(H5B_ITER_STOP);
|
||||
}
|
||||
|
||||
bt_udata->num_objs += sn->nsyms;
|
||||
|
@ -142,12 +142,12 @@ H5_DLL herr_t H5G_ent_encode_vec(H5F_t *f, uint8_t **pp,
|
||||
const H5G_entry_t *ent, int n);
|
||||
|
||||
/* Functions that understand symbol table nodes */
|
||||
H5_DLL H5B_iterate_t H5G_node_iterate (H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
H5_DLL int H5G_node_iterate (H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
void UNUSED *_rt_key, void *_udata);
|
||||
H5_DLL H5B_iterate_t H5G_node_sumup(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
H5_DLL int H5G_node_sumup(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
void UNUSED *_rt_key, void *_udata);
|
||||
H5_DLL H5B_iterate_t H5G_node_name(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
H5_DLL int H5G_node_name(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
void UNUSED *_rt_key, void *_udata);
|
||||
H5_DLL H5B_iterate_t H5G_node_type(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
H5_DLL int H5G_node_type(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
|
||||
void UNUSED *_rt_key, void *_udata);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user