diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2018-12-15 01:06:25 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2018-12-15 01:06:25 (GMT) |
commit | 22bc8ba7bfb2c82b6cea6b5f5d1da2f2119c348b (patch) | |
tree | a15437bcf06df4a5c30b924fbcd7be135c992037 /src | |
parent | 1cffc3ff0f3454fedf6edcdb93dcde5ed1b910d6 (diff) | |
download | hdf5-22bc8ba7bfb2c82b6cea6b5f5d1da2f2119c348b.zip hdf5-22bc8ba7bfb2c82b6cea6b5f5d1da2f2119c348b.tar.gz hdf5-22bc8ba7bfb2c82b6cea6b5f5d1da2f2119c348b.tar.bz2 |
Addressed HDFFV-10661
Description:
- Fixed a bug triggered by tests in chunk_info.c. The returned value
from a callback function was not checked in H5EA_iterate(), H5FA_iterate(),
and H5D__none_idx_iterate(). This oversight caused a callback function
to continue iterating even though it's supposed to stop. Vailin confirmed.
- Addressed review comments and made various improvements on the tests.
Platforms tested:
Linux/64 (jelly)
Linux/64 (platypus)
Darwin (osx1010test)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5D.c | 10 | ||||
-rw-r--r-- | src/H5Dnone.c | 4 | ||||
-rw-r--r-- | src/H5Dpkg.h | 2 | ||||
-rw-r--r-- | src/H5Dpublic.h | 2 | ||||
-rw-r--r-- | src/H5EA.c | 13 | ||||
-rw-r--r-- | src/H5FA.c | 9 |
6 files changed, 18 insertions, 22 deletions
@@ -1190,7 +1190,7 @@ done: * Parameters: * hid_t dset_id; IN: Chunked dataset ID * hid_t fspace_id; IN: File dataspace ID - * hsize_t index; IN: Index of written chunk + * hsize_t chk_idx; IN: Index of allocated/written chunk * hsize_t *offset OUT: Offset coordinates of the chunk * unsigned *filter_mask OUT: Filter mask * haddr_t *addr OUT: Address of the chunk @@ -1204,14 +1204,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t index, hsize_t *offset, unsigned *filter_mask, haddr_t *addr, hsize_t *size) +H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_idx, hsize_t *offset, unsigned *filter_mask, haddr_t *addr, hsize_t *size) { H5D_t *dset = NULL; const H5S_t *space; /* Dataspace for dataset */ herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE7("e", "iih*h*Iu*a*h", dset_id, fspace_id, index, offset, filter_mask, + H5TRACE7("e", "iih*h*Iu*a*h", dset_id, fspace_id, chk_idx, offset, filter_mask, addr, size); /* Check arguments */ @@ -1226,7 +1226,7 @@ H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t index, hsize_t *offset HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") /* Call private function to get the chunk info given the chunk's index */ - if(H5D__get_chunk_info(dset, space, index, offset, filter_mask, addr, size) < 0) + if(H5D__get_chunk_info(dset, space, chk_idx, offset, filter_mask, addr, size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk info") done: @@ -1242,7 +1242,7 @@ done: * * Parameters: * hid_t dset_id IN: Chunked dataset ID - * hsize_t *offset IN: Coordinates of the chunk + * hsize_t *offset IN: Offset coordinates of the chunk * unsigned *filter_mask OUT: Filter mask * haddr_t *addr OUT: Address of the chunk * hsize_t *size OUT: Size of the chunk diff --git a/src/H5Dnone.c b/src/H5Dnone.c index be421b6..09e781e 100644 --- a/src/H5Dnone.c +++ b/src/H5Dnone.c @@ -242,7 +242,7 @@ H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, unsigned u; /* Local index variable */ int curr_dim; /* Current rank */ hsize_t idx; /* Array index of chunk */ - int ret_value = -1; /* Return value */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -266,7 +266,7 @@ H5D__none_idx_iterate(const H5D_chk_idx_info_t *idx_info, HDassert(ndims > 0); /* Iterate over all the chunks in the dataset's dataspace */ - for(u = 0; u < idx_info->layout->nchunks; u++) { + for(u = 0; u < idx_info->layout->nchunks && ret_value == H5_ITER_CONT; u++) { /* Calculate the index of this chunk */ idx = H5VM_array_offset_pre(ndims, idx_info->layout->max_down_chunks, chunk_rec.scaled); diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index ee70bae..9bd0616 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -567,7 +567,7 @@ H5_DLL herr_t H5D__get_storage_size(const H5D_t *dset, hsize_t *storage_size); H5_DLL herr_t H5D__get_chunk_storage_size(H5D_t *dset, const hsize_t *offset, hsize_t *storage_size); H5_DLL herr_t H5D__get_num_chunks(const H5D_t *dset, const H5S_t *space, hsize_t *nchunks); -H5_DLL herr_t H5D__get_chunk_info(const H5D_t *dset, const H5S_t *space, hsize_t index, hsize_t *coord, unsigned *filter_mask, haddr_t *offset, hsize_t *size); +H5_DLL herr_t H5D__get_chunk_info(const H5D_t *dset, const H5S_t *space, hsize_t chk_idx, hsize_t *coord, unsigned *filter_mask, haddr_t *offset, hsize_t *size); H5_DLL herr_t H5D__get_chunk_info_by_coord(const H5D_t *dset, const hsize_t *coord, unsigned *filter_mask, haddr_t *addr, hsize_t *size); H5_DLL haddr_t H5D__get_offset(const H5D_t *dset); H5_DLL void *H5D__vlen_get_buf_size_alloc(size_t size, void *info); diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index fcc76ee..2dcbeae 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -143,7 +143,7 @@ H5_DLL hsize_t H5Dget_storage_size(hid_t dset_id); H5_DLL herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_bytes); H5_DLL herr_t H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks); H5_DLL herr_t H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *coord, unsigned *filter_mask, haddr_t *addr, hsize_t *size); -H5_DLL herr_t H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t index, hsize_t *coord, unsigned *filter_mask, haddr_t *addr, hsize_t *size); +H5_DLL herr_t H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_idx, hsize_t *coord, unsigned *filter_mask, haddr_t *addr, hsize_t *size); H5_DLL haddr_t H5Dget_offset(hid_t dset_id); H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf/*out*/); @@ -999,10 +999,9 @@ H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata)) /* Local variables */ uint8_t *elmt = NULL; hsize_t u; + int ret_value = H5_ITER_CONT; /* Return value from callback */ - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(op); HDassert(udata); @@ -1012,17 +1011,15 @@ H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata)) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array element") /* Iterate over all elements in array */ - for(u = 0; u < ea->hdr->stats.stored.max_idx_set; u++) { - int cb_ret; /* Return value from callback */ - + for(u = 0; u < ea->hdr->stats.stored.max_idx_set && ret_value == H5_ITER_CONT; u++) { /* Get array element */ if(H5EA_get(ea, u, elmt) < 0) H5E_THROW(H5E_CANTGET, "unable to delete fixed array") /* Make callback */ - if((cb_ret = (*op)(u, elmt, udata)) < 0) { + if((ret_value = (*op)(u, elmt, udata)) < 0) { H5E_PRINTF(H5E_BADITER, "iterator function failed"); - H5_LEAVE(cb_ret) + H5_LEAVE(ret_value) } /* end if */ } /* end for */ @@ -699,6 +699,7 @@ H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata)) /* Local variables */ uint8_t *elmt = NULL; hsize_t u; + int ret_value = H5_ITER_CONT; /* Return value from callback */ /* * Check arguments. @@ -712,17 +713,15 @@ H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata)) H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array element") /* Iterate over all elements in array */ - for(u = 0; u < fa->hdr->stats.nelmts; u++) { - int cb_ret; /* Return value from callback */ - + for(u = 0; u < fa->hdr->stats.nelmts && ret_value == H5_ITER_CONT; u++) { /* Get array element */ if(H5FA_get(fa, u, elmt) < 0) H5E_THROW(H5E_CANTGET, "unable to delete fixed array") /* Make callback */ - if((cb_ret = (*op)(u, elmt, udata)) < 0) { + if((ret_value = (*op)(u, elmt, udata)) < 0) { H5E_PRINTF(H5E_BADITER, "iterator function failed"); - H5_LEAVE(cb_ret) + H5_LEAVE(ret_value) } /* end if */ } /* end for */ |