diff options
author | Larry Knox <lrknox@hdfgroup.org> | 2021-08-12 18:26:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 18:26:15 (GMT) |
commit | e2c47ffb01b42a3da930e2b175b40810d4bcfbca (patch) | |
tree | 7b6f0410430d29d09342106afae0f886a9b45963 /src/H5FA.c | |
parent | c2e61724aa19f84bda9fd730236d80f4af1e4e74 (diff) | |
download | hdf5-e2c47ffb01b42a3da930e2b175b40810d4bcfbca.zip hdf5-e2c47ffb01b42a3da930e2b175b40810d4bcfbca.tar.gz hdf5-e2c47ffb01b42a3da930e2b175b40810d4bcfbca.tar.bz2 |
Merge1 issue 839 PRs to hdf5 1 12 (#904)
* Fixes for a couple of trivial warnings (#676)
* Committing clang-format changes
* Trivial warning fixes:
* Removes an unused done target in H5Tbit.c
* Add (void) to quiet "ignored return value" warnings in the generators
(which generally ignore errors)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Removes alternative function enter/leave macro scheme (#678)
* Committing clang-format changes
* Converted BEGIN_FUNC, etc. macros to FUNC_ENTER
* Rips out the BEGIN_FUNC, etc. macros
* Removes 'end if', etc. comments from H5HL package
* Committing clang-format changes
* Fixes an H5EA iterate issue
* Fixes an issue in the H5FA iterator code
* Further cleanup in bin/trace after macro removal
* Iterator changes in H5EA and H5FA
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Various CMake changes (#679)
* Committing clang-format changes
* Several CMake updates:
* Removes unused HDF5_ENABLE_HSIZET
* Switches TEST_SHELL_SCRIPTS to ON
* Sets SH_PROGRAM to bash instead of sh
* Set default build type back to RelWithDebInfo
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* err_compat test cleanup (#681)
* Committing clang-format changes
* Cleans up err_compat test and output
* Formatted source
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* CMake fix for sporadic flush2 failures (#692)
* Committing clang-format changes
* Runs the flush1/flush2 tests in their own directory
Avoids file deletions by other tests.
* Revert "Runs the flush1/flush2 tests in their own directory"
This reverts commit 746c04882434cb502e4231de8f7dd5acb4949f54.
Also pulls the flush files from the clean list, which is a simpler fix.
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Ubsan fixes (#498)
* Fixed use of null pointer identified by UBSan
UBSan warned:
runtime error: member access within null pointer of type 'named_dt_t' (aka 'struct named_dt_t')
with these two tests:
H5REPACK-committed_dt_DFF
H5REPACK-committed_dt
Reformulated per @gnuoyd suggestion.
* Fixed undefined float -> unsigned char conversion in HL_test_image
* Removed dead skip_overflow_tests_g global
The global `skip_overflow_tests_g` was being set but never read.
* Don't treat 2d array as 1d array, fixing UBSan complaint in `CPP_testhdf5`
* Committing clang-format changes
* Remove extra ']' in line 730.
* Committing clang-format changes
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
* BUG: DataSet assignment operator is missing (#503)
* BUG: DataSet assignment operator is missing
* Some compilers complain if the copy constructor is given explicitly
but the assignment operator is implicitly set to default.
* Explicitly defining the assignment operator allows us to properly
handle reference counters for shared resources.
* BUG: DataSet assignment operator is missing.
* Mimicking code of H5DataType::operator() as suggested by @bmribler.
* Added test
Description:
Added test for DataSet::operator= that Leengit added
Platform tested:
Linux/64 (jelly)
* Removed Author field.
* Commit clang format changes.
* Entry for Leengit's github PR #503
* Removed lines left by mistake
Co-authored-by: Binh-Minh Ribler <bmribler@hdfgroup.org>
Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
* Hdf5 merge pr7 (#516)
* Modify temporary rpath for testing in java example scripts.
* Update URL in source file Copyright headers for web copy of COPYING (license) file.
* Add release_docs/code-conventions.md file.
* Add script to test h5py.
* Fix script error.
* Add file h5pytest.yml.
* Test declaration of counter variables in for loops.
* Committing clang-format changes
* Committing clang-format changes
* Added [] to line 126 of H5LTanalyze.l.
Ran bin/genparser with flex v2.6.4 and Bison v3.0.4 on jelly.
* Revert "Added [] to line 126 of H5LTanalyze.l."
This reverts commit e4a9cee441efa75b16a8ee030c86189e186dd266.
* Revert extra commits to match canonical develop.
* Add cmake variable HDF5_LIB_INFIX (#7)
* Add cmake variable HDF5_LIB_INFIX
This infix is added to all library names after 'hdf5'.
e.g. the infix '_openmpi' results in the library name 'libhdf5_openmpi.so'
This name is used in packages on debian based systems.
(see https://packages.debian.org/jessie/amd64/libhdf5-openmpi-8/filelist)
This option is useful when testing projects on debian based systems with
custom builds of hdf5 while trying to minimize differences between the
custom setup and the environment created by installing system packages.
* Added RELEASE.txt entry for HDF5_LIB_INFIX.
Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Raphael Grimm <barcode@users.noreply.github.com>
* Fixes a segfault when H5Pset_mdc_log_options is called multiple times on a fapl (#601)
* Committing clang-format changes
* Fixes a segfault when H5Pset_mdc_log_options() is called multiple times
An internal string is incorrectly freed when the API call is invoked
multiple times on a property list, which will usually cause a segfault
to occur. On the first call the log location is NULL so the problem
doesn't occur.
Fixes HDFFV-11239
* Fixes typos
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Fix for a segfault when H5Pset_fapl_log is passed an invalid fapl ID (#607)
* Committing clang-format changes
* Fixes an issue where H5Pset_fapl_log sefaults when passed an invalid
fapl ID
This was due to a pointer-containing struct being memset after the first
internal API call. If the first call failed, the error condition would
check if the pointer was not NULL and then attempt to free it if not.
This would lead to the freeing of a wild pointer if an invalid fapl ID
were passed in.
This was fixed by reordering the memset and adding a test to ensure the
problem stays fixed.
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Fixes crashes when size_hint > UINT32_MAX is passed to H5Gcreate1 (#611)
* Committing clang-format changes
* Fixes incorrect size_hint handling in H5Gcreate1
* Updates the size hint type for group creation
* Updates the RELEASE.txt note
* Revert "Updates the RELEASE.txt note"
This reverts commit 3df386acca806d652bbe2209f7c4503b30f068ff.
* Reverts previous behavior to use a uint32_t struct field
* Updates RELEASE.txt
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sean McBride <sean@rogue-research.com>
Co-authored-by: Lee Newberg <35611400+Leengit@users.noreply.github.com>
Co-authored-by: Binh-Minh Ribler <bmribler@hdfgroup.org>
Co-authored-by: Raphael Grimm <barcode@users.noreply.github.com>
Diffstat (limited to 'src/H5FA.c')
-rw-r--r-- | src/H5FA.c | 337 |
1 files changed, 177 insertions, 160 deletions
@@ -105,39 +105,40 @@ H5FL_BLK_DEFINE(fa_native_elmt); * *------------------------------------------------------------------------- */ -BEGIN_FUNC(STATIC, ERR, H5FA_t *, NULL, NULL, - H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata)) +static H5FA_t * +H5FA__new(H5F_t *f, haddr_t fa_addr, hbool_t from_open, void *ctx_udata) +{ + H5FA_t * fa = NULL; /* Pointer to new fixed array */ + H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + H5FA_t * ret_value = NULL; - /* Local variables */ - H5FA_t * fa = NULL; /* Pointer to new fixed array */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + FUNC_ENTER_STATIC - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(fa_addr)); /* Allocate fixed array wrapper */ if (NULL == (fa = H5FL_CALLOC(H5FA_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array info") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, NULL, "memory allocation failed for fixed array info") /* Lock the array header into memory */ if (NULL == (hdr = H5FA__hdr_protect(f, fa_addr, ctx_udata, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, NULL, "unable to load fixed array header") /* Check for pending array deletion */ if (from_open && hdr->pending_delete) - H5E_THROW(H5E_CANTOPENOBJ, "can't open fixed array pending deletion") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTOPENOBJ, NULL, "can't open fixed array pending deletion") /* Point fixed array wrapper at header and bump it's ref count */ fa->hdr = hdr; if (H5FA__hdr_incr(fa->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, "can't increment reference count on shared array header") /* Increment # of files using this array header */ if (H5FA__hdr_fuse_incr(fa->hdr) < 0) - H5E_THROW(H5E_CANTINC, "can't increment file reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINC, NULL, + "can't increment file reference count on shared array header") /* Set file pointer for this array open context */ fa->f = f; @@ -145,15 +146,15 @@ BEGIN_FUNC(STATIC, ERR, H5FA_t *, NULL, NULL, /* Set the return value */ ret_value = fa; - CATCH - +done: if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, NULL, "unable to release fixed array header") if (!ret_value) if (fa && H5FA_close(fa) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") -END_FUNC(STATIC) /* end H5FA__new() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA__new() */ /*------------------------------------------------------------------------- * Function: H5FA_create @@ -168,16 +169,16 @@ END_FUNC(STATIC) /* end H5FA__new() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, - H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata)) - - /* Local variables */ +H5FA_t * +H5FA_create(H5F_t *f, const H5FA_create_t *cparam, void *ctx_udata) +{ H5FA_t *fa = NULL; /* Pointer to new fixed array */ haddr_t fa_addr; /* Fixed array header address */ + H5FA_t *ret_value = NULL; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(NULL) + + /* Check arguments */ HDassert(f); HDassert(cparam); @@ -186,22 +187,23 @@ BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, /* Create fixed array header */ if (HADDR_UNDEF == (fa_addr = H5FA__hdr_create(f, cparam, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "can't create fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, "can't create fixed array header") /* Allocate and initialize new fixed array wrapper */ if (NULL == (fa = H5FA__new(f, fa_addr, FALSE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; - CATCH - +done: if (!ret_value) if (fa && H5FA_close(fa) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") -END_FUNC(PRIV) /* end H5FA_create() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_create() */ /*------------------------------------------------------------------------- * Function: H5FA_open @@ -216,31 +218,33 @@ END_FUNC(PRIV) /* end H5FA_create() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, H5FA_t *, NULL, NULL, H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) +H5FA_t * +H5FA_open(H5F_t *f, haddr_t fa_addr, void *ctx_udata) +{ + H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ + H5FA_t *ret_value = NULL; - /* Local variables */ - H5FA_t *fa = NULL; /* Pointer to new fixed array wrapper */ + FUNC_ENTER_NOAPI(NULL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(fa_addr)); /* Allocate and initialize new fixed array wrapper */ if (NULL == (fa = H5FA__new(f, fa_addr, TRUE, ctx_udata))) - H5E_THROW(H5E_CANTINIT, "allocation and/or initialization failed for fixed array wrapper") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTINIT, NULL, + "allocation and/or initialization failed for fixed array wrapper") /* Set the return value */ ret_value = fa; - CATCH - +done: if (!ret_value) if (fa && H5FA_close(fa) < 0) - H5E_THROW(H5E_CLOSEERROR, "unable to close fixed array") + HDONE_ERROR(H5E_FARRAY, H5E_CLOSEERROR, NULL, "unable to close fixed array") -END_FUNC(PRIV) /* end H5FA_open() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_open() */ /*------------------------------------------------------------------------- * Function: H5FA_get_nelmts @@ -254,20 +258,20 @@ END_FUNC(PRIV) /* end H5FA_open() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts)) - - /* Local variables */ +herr_t +H5FA_get_nelmts(const H5FA_t *fa, hsize_t *nelmts) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(nelmts); /* Retrieve the current number of elements in the fixed array */ *nelmts = fa->hdr->stats.nelmts; -END_FUNC(PRIV) /* end H5FA_get_nelmts() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_get_nelmts() */ /*------------------------------------------------------------------------- * Function: H5FA_get_addr @@ -281,13 +285,12 @@ END_FUNC(PRIV) /* end H5FA_get_nelmts() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_addr(const H5FA_t *fa, haddr_t *addr)) - - /* Local variables */ +herr_t +H5FA_get_addr(const H5FA_t *fa, haddr_t *addr) +{ + FUNC_ENTER_NOAPI_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(fa->hdr); HDassert(addr); @@ -295,7 +298,8 @@ BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_get_addr(const H5FA_t *fa, hadd /* Retrieve the address of the fixed array's header */ *addr = fa->hdr->addr; -END_FUNC(PRIV) /* end H5FA_get_addr() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_get_addr() */ /*------------------------------------------------------------------------- * Function: H5FA_set @@ -309,9 +313,9 @@ END_FUNC(PRIV) /* end H5FA_get_addr() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt)) - - /* Local variables */ +herr_t +H5FA_set(const H5FA_t *fa, hsize_t idx, const void *elmt) +{ H5FA_hdr_t * hdr = fa->hdr; /* Header for fixed array */ H5FA_dblock_t * dblock = NULL; /* Pointer to fixed array Data block */ H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to fixed array Data block page */ @@ -319,10 +323,11 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t unsigned dblk_page_cache_flags = H5AC__NO_FLAGS_SET; /* Flags to unprotecting FIxed Array Data block page */ hbool_t hdr_dirty = FALSE; /* Whether header information changed */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(fa); HDassert(fa->hdr); @@ -334,15 +339,16 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t /* Create the data block */ hdr->dblk_addr = H5FA__dblock_create(hdr, &hdr_dirty); if (!H5F_addr_defined(hdr->dblk_addr)) - H5E_THROW(H5E_CANTCREATE, "unable to create fixed array data block") - } /* end if */ + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, FAIL, "unable to create fixed array data block") + } HDassert(idx < hdr->cparam.nelmts); /* Protect data block */ if (NULL == (dblock = H5FA__dblock_protect(hdr, hdr->dblk_addr, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)hdr->dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", + (unsigned long long)hdr->dblk_addr) /* Check for paging data block */ if (!dblock->npages) { @@ -375,7 +381,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t if (!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { /* Create the data block page */ if (H5FA__dblk_page_create(hdr, dblk_page_addr, dblk_page_nelmts) < 0) - H5E_THROW(H5E_CANTCREATE, "unable to create data block page") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTCREATE, FAIL, "unable to create data block page") /* Mark data block page as initialized in data block */ H5VM_bit_set(dblock->dblk_page_init, page_idx, TRUE); @@ -385,8 +391,9 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t /* Protect the data block page */ if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Set the element in the data block page */ H5MM_memcpy(((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), elmt, @@ -394,19 +401,20 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_set(const H5FA_t *fa, hsize_t dblk_page_cache_flags |= H5AC__DIRTIED_FLAG; } /* end else */ - CATCH +done: /* Check for header modified */ if (hdr_dirty) if (H5FA__hdr_modified(hdr) < 0) - H5E_THROW(H5E_CANTMARKDIRTY, "unable to mark fixed array header as modified") + HDONE_ERROR(H5E_FARRAY, H5E_CANTMARKDIRTY, FAIL, "unable to mark fixed array header as modified") /* Release resources */ if (dblock && H5FA__dblock_unprotect(dblock, dblock_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") if (dblk_page && H5FA__dblk_page_unprotect(dblk_page, dblk_page_cache_flags) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block page") -END_FUNC(PRIV) /* end H5FA_set() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_set() */ /*------------------------------------------------------------------------- * Function: H5FA_get @@ -420,16 +428,17 @@ END_FUNC(PRIV) /* end H5FA_set() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt)) - - /* Local variables */ +herr_t +H5FA_get(const H5FA_t *fa, hsize_t idx, void *elmt) +{ H5FA_hdr_t * hdr = fa->hdr; /* Header for FA */ H5FA_dblock_t * dblock = NULL; /* Pointer to data block for FA */ H5FA_dblk_page_t *dblk_page = NULL; /* Pointer to data block page for FA */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(fa); HDassert(fa->hdr); @@ -440,14 +449,15 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t if (!H5F_addr_defined(hdr->dblk_addr)) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") } /* end if */ else { /* Get the data block */ HDassert(H5F_addr_defined(hdr->dblk_addr)); if (NULL == (dblock = H5FA__dblock_protect(hdr, hdr->dblk_addr, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array data block, address = %llu", - (unsigned long long)hdr->dblk_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block, address = %llu", + (unsigned long long)hdr->dblk_addr) /* Check for paged data block */ if (!dblock->npages) @@ -464,10 +474,10 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t if (!H5VM_bit_get(dblock->dblk_page_init, page_idx)) { /* Call the class's 'fill' callback */ if ((hdr->cparam.cls->fill)(elmt, (size_t)1) < 0) - H5E_THROW(H5E_CANTSET, "can't set element to class's fill value") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "can't set element to class's fill value") /* We've retrieved the value, leave now */ - H5_LEAVE(SUCCEED) + HGOTO_DONE(SUCCEED) } /* end if */ else { /* get the page */ size_t dblk_page_nelmts; /* # of elements in a data block page */ @@ -490,9 +500,9 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t /* Protect the data block page */ if (NULL == (dblk_page = H5FA__dblk_page_protect(hdr, dblk_page_addr, dblk_page_nelmts, H5AC__READ_ONLY_FLAG))) - H5E_THROW(H5E_CANTPROTECT, - "unable to protect fixed array data block page, address = %llu", - (unsigned long long)dblk_page_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, + "unable to protect fixed array data block page, address = %llu", + (unsigned long long)dblk_page_addr) /* Retrieve element from data block */ H5MM_memcpy(elmt, ((uint8_t *)dblk_page->elmts) + (hdr->cparam.cls->nat_elmt_size * elmt_idx), @@ -501,13 +511,14 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_get(const H5FA_t *fa, hsize_t } /* end else */ } /* end else */ - CATCH +done: if (dblock && H5FA__dblock_unprotect(dblock, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block") if (dblk_page && H5FA__dblk_page_unprotect(dblk_page, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array data block page") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array data block page") -END_FUNC(PRIV) /* end H5FA_get() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_get() */ /*------------------------------------------------------------------------- * Function: H5FA_close @@ -521,18 +532,19 @@ END_FUNC(PRIV) /* end H5FA_get() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) - - /* Local variables */ +herr_t +H5FA_close(H5FA_t *fa) +{ hbool_t pending_delete = FALSE; /* Whether the array is pending deletion */ haddr_t fa_addr = HADDR_UNDEF; /* Address of array (for deletion) */ + herr_t ret_value = SUCCEED; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ HDassert(fa); - /* Close the header, if it was set */ + /* Close the header if it was set */ if (fa->hdr) { /* Decrement file reference & check if this is the last open fixed array using the shared array header */ @@ -562,7 +574,8 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) /* Check the header's status in the metadata cache */ if (H5AC_get_entry_status(fa->f, fa_addr, &hdr_status) < 0) - H5E_THROW(H5E_CANTGET, "unable to check metadata cache status for fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, FAIL, + "unable to check metadata cache status for fixed array header") /* Sanity checks on header */ HDassert(hdr_status & H5AC_ES__IN_CACHE); @@ -574,7 +587,7 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) /* Lock the array header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ if (NULL == (hdr = H5FA__hdr_protect(fa->f, fa_addr, NULL, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTLOAD, "unable to load fixed array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTLOAD, FAIL, "unable to load fixed array header") /* Set the shared array header's file context for this operation */ hdr->f = fa->f; @@ -584,11 +597,12 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) * immediately -QAK) */ if (H5FA__hdr_decr(fa->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") /* Delete array, starting with header (unprotects header) */ if (H5FA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDELETE, FAIL, "unable to delete fixed array") } /* end if */ else { /* Decrement the reference count on the array header */ @@ -596,16 +610,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_close(H5FA_t *fa)) * immediately -QAK) */ if (H5FA__hdr_decr(fa->hdr) < 0) - H5E_THROW(H5E_CANTDEC, "can't decrement reference count on shared array header") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDEC, FAIL, + "can't decrement reference count on shared array header") } /* end else */ } /* end if */ /* Release the fixed array wrapper */ fa = H5FL_FREE(H5FA_t, fa); - CATCH - -END_FUNC(PRIV) /* end H5FA_close() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_close() */ /*------------------------------------------------------------------------- * Function: H5FA_delete @@ -619,21 +634,22 @@ END_FUNC(PRIV) /* end H5FA_close() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata)) +herr_t +H5FA_delete(H5F_t *f, haddr_t fa_addr, void *ctx_udata) +{ + H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_hdr_t *hdr = NULL; /* The fixed array header information */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(fa_addr)); /* Lock the array header into memory */ if (NULL == (hdr = H5FA__hdr_protect(f, fa_addr, ctx_udata, H5AC__NO_FLAGS_SET))) - H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", - (unsigned long long)fa_addr) + HGOTO_ERROR(H5E_FARRAY, H5E_CANTPROTECT, FAIL, "unable to protect fixed array header, address = %llu", + (unsigned long long)fa_addr) /* Check for files using shared array header */ if (hdr->file_rc) @@ -644,17 +660,17 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_delete(H5F_t *f, haddr_t fa_ad /* Delete array now, starting with header (unprotects header) */ if (H5FA__hdr_delete(hdr) < 0) - H5E_THROW(H5E_CANTDELETE, "unable to delete fixed array") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTDELETE, FAIL, "unable to delete fixed array") hdr = NULL; - } /* end if */ - - CATCH + } - /* Unprotect the header, if an error occurred */ +done: + /* Unprotect the header if an error occurred */ if (hdr && H5FA__hdr_unprotect(hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTUNPROTECT, "unable to release fixed array header") + HDONE_ERROR(H5E_FARRAY, H5E_CANTUNPROTECT, FAIL, "unable to release fixed array header") -END_FUNC(PRIV) /* end H5FA_delete() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_delete() */ /*------------------------------------------------------------------------- * Function: H5FA_iterate @@ -671,44 +687,44 @@ END_FUNC(PRIV) /* end H5FA_delete() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, int, H5_ITER_CONT, H5_ITER_ERROR, - H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata)) - - /* Local variables */ +int +H5FA_iterate(H5FA_t *fa, H5FA_operator_t op, void *udata) +{ uint8_t *elmt = NULL; hsize_t u; - int cb_ret = H5_ITER_CONT; /* Return value from callback */ + int ret_value = H5_ITER_CONT; - /* - * Check arguments. - */ + FUNC_ENTER_NOAPI(H5_ITER_ERROR) + + /* Check arguments */ HDassert(fa); HDassert(op); HDassert(udata); /* Allocate space for a native array element */ if (NULL == (elmt = H5FL_BLK_MALLOC(fa_native_elmt, fa->hdr->cparam.cls->nat_elmt_size))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for fixed array element") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTALLOC, H5_ITER_ERROR, + "memory allocation failed for fixed array element") /* Iterate over all elements in array */ - for (u = 0; u < fa->hdr->stats.nelmts && cb_ret == H5_ITER_CONT; u++) { + 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") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTGET, H5_ITER_ERROR, "unable to delete fixed array") - /* Make callback */ - if ((cb_ret = (*op)(u, elmt, udata)) < 0) { - H5E_PRINTF(H5E_BADITER, "iterator function failed"); - H5_LEAVE(cb_ret) - } /* end if */ - } /* end for */ - - CATCH + /* Invoke callback */ + if ((ret_value = (*op)(u, elmt, udata)) < 0) { + HERROR(H5E_FARRAY, H5E_BADITER, "iteration callback error"); + break; + } + } +done: if (elmt) elmt = H5FL_BLK_FREE(fa_native_elmt, elmt); -END_FUNC(PRIV) /* end H5FA_iterate() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_iterate() */ /*------------------------------------------------------------------------- * Function: H5FA_depend @@ -723,14 +739,15 @@ END_FUNC(PRIV) /* end H5FA_iterate() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent)) +herr_t +H5FA_depend(H5FA_t *fa, H5AC_proxy_entry_t *parent) +{ + H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ + herr_t ret_value = SUCCEED; - /* Local variables */ - H5FA_hdr_t *hdr = fa->hdr; /* Header for FA */ + FUNC_ENTER_NOAPI(FAIL) - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(hdr); HDassert(parent); @@ -749,13 +766,13 @@ BEGIN_FUNC(PRIV, ERR, herr_t, SUCCEED, FAIL, H5FA_depend(H5FA_t *fa, H5AC_proxy_ /* Add the fixed array as a child of the parent (proxy) */ if (H5AC_proxy_entry_add_child(parent, hdr->f, hdr->top_proxy) < 0) - H5E_THROW(H5E_CANTSET, "unable to add fixed array as child of proxy") + HGOTO_ERROR(H5E_FARRAY, H5E_CANTSET, FAIL, "unable to add fixed array as child of proxy") hdr->parent = parent; - } /* end if */ - - CATCH + } -END_FUNC(PRIV) /* end H5FA_depend() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FA_depend() */ /*------------------------------------------------------------------------- * Function: H5FA_patch_file @@ -769,17 +786,17 @@ END_FUNC(PRIV) /* end H5FA_depend() */ * *------------------------------------------------------------------------- */ -BEGIN_FUNC(PRIV, NOERR, herr_t, SUCCEED, -, H5FA_patch_file(H5FA_t *fa, H5F_t *f)) +herr_t +H5FA_patch_file(H5FA_t *fa, H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOERR - /* Local variables */ - - /* - * Check arguments. - */ + /* Check arguments */ HDassert(fa); HDassert(f); if (fa->f != f || fa->hdr->f != f) fa->f = fa->hdr->f = f; -END_FUNC(PRIV) /* end H5FA_patch_file() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5FA_patch_file() */ |