diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2019-01-02 20:28:40 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2019-01-02 20:28:40 (GMT) |
commit | 2713fb12b12c7d9c9a418494ac8c8c2b4ce93b88 (patch) | |
tree | 0521ea7663998496259b38c68cabd5bd0af9f34e /src | |
parent | 600d44292bfbce3f6d6226260a654555278ef24b (diff) | |
parent | 74a3710a996fca5ed7fcb4dd8919a7a8521de1de (diff) | |
download | hdf5-2713fb12b12c7d9c9a418494ac8c8c2b4ce93b88.zip hdf5-2713fb12b12c7d9c9a418494ac8c8c2b4ce93b88.tar.gz hdf5-2713fb12b12c7d9c9a418494ac8c8c2b4ce93b88.tar.bz2 |
Merge pull request #1380 in HDFFV/hdf5 from ~BMRIBLER/hdf5_1_10_bmr:hdf5_1_10 to hdf5_1_10
This is merged now so it can be tested.
* commit '74a3710a996fca5ed7fcb4dd8919a7a8521de1de':
Revised per review. Description: Changed H5EA_iterate and H5FA_iterate as suggested. Platforms tested: Linux/64 (jelly) Linux/64 (platypus) Darwin (osx1010test)
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 | 18 | ||||
-rw-r--r-- | src/H5FA.c | 14 |
6 files changed, 28 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 4409142..da74d11 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -565,7 +565,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*/); @@ -986,23 +986,27 @@ END_FUNC(PRIV) /* end H5EA_delete() */ * Purpose: Iterate over the elements of an extensible array * (copied and modified from FA_iterate() in H5FA.c) * - * Return: SUCCEED/FAIL + * Return: H5_ITER_CONT/H5_ITER_ERROR * * Programmer: Vailin Choi; Feb 2015 * + * Modification: + * Prototype changed (HDFFV-10661) + * - herr_t to int + * - SUCCEED/FAIL to H5_ITER_CONT/H5_ITER_ERROR + * December 24, 2018 -BMR *------------------------------------------------------------------------- */ BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, +int, H5_ITER_CONT, H5_ITER_ERROR, H5EA_iterate(H5EA_t *ea, H5EA_operator_t op, void *udata)) /* Local variables */ uint8_t *elmt = NULL; hsize_t u; + int cb_ret = H5_ITER_CONT; /* Return value from callback */ - /* - * Check arguments. - */ + /* Check arguments */ HDassert(ea); HDassert(op); HDassert(udata); @@ -1012,9 +1016,7 @@ 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 && cb_ret == H5_ITER_CONT; u++) { /* Get array element */ if(H5EA_get(ea, u, elmt) < 0) H5E_THROW(H5E_CANTGET, "unable to delete fixed array") @@ -685,20 +685,26 @@ END_FUNC(PRIV) /* end H5FA_delete() */ * Note: This is not very efficient, we should be iterating directly * over the fixed array's direct block [pages]. * - * Return: SUCCEED/FAIL + * Return: H5_ITER_CONT/H5_ITER_ERROR * * Programmer: Vailin Choi * Thursday, April 30, 2009 * + * Modification: + * Prototype changed (HDFFV-10661) + * - herr_t to int + * - SUCCEED/FAIL to H5_ITER_CONT/H5_ITER_ERROR + * December 24, 2018 -BMR *------------------------------------------------------------------------- */ BEGIN_FUNC(PRIV, ERR, -herr_t, SUCCEED, FAIL, +int, H5_ITER_CONT, H5_ITER_ERROR, H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata)) /* Local variables */ uint8_t *elmt = NULL; hsize_t u; + int cb_ret = H5_ITER_CONT; /* Return value from callback */ /* * Check arguments. @@ -712,9 +718,7 @@ 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 && cb_ret == H5_ITER_CONT; u++) { /* Get array element */ if(H5FA_get(fa, u, elmt) < 0) H5E_THROW(H5E_CANTGET, "unable to delete fixed array") |