summaryrefslogtreecommitdiffstats
path: root/hl/src/H5DS.c
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2022-04-25 06:20:52 (GMT)
committerGitHub <noreply@github.com>2022-04-25 06:20:52 (GMT)
commit63197e99f80b4c6d2aaf76f2d23c460ade1a5f5f (patch)
tree6c31237bf23d6720ea72718bd42bb03e56fd07b0 /hl/src/H5DS.c
parente8bda8f3a4cc4d64c99216decae9073beb7eaf3b (diff)
downloadhdf5-63197e99f80b4c6d2aaf76f2d23c460ade1a5f5f.zip
hdf5-63197e99f80b4c6d2aaf76f2d23c460ade1a5f5f.tar.gz
hdf5-63197e99f80b4c6d2aaf76f2d23c460ade1a5f5f.tar.bz2
Onion VFD: Sync with develop (#1685)
* Removes unused definitions from module headers (#1624) * Fix these Doxygen warnings #1581 (#1589) * Fixes a typo in H5.c (#1639) * free MPI_Group/MPI_Comm/MPI_Datatype objects (#1638) * free MPI_Group/MPI_Comm/MPI_Datatype objects * fix clang-format style * Adds build and license shields to README.md (#1641) * First stab at a Github status bar * Adds a .tokeignore file for counting lines of code accurately * Yanks lines of code calculation since it wildly overcounts * not depend on doIO to free an MPI_Comm object (#1642) * free MPI datatypes previously created (#1637) * Retrieve MPI-IO hints used by MPI library after file open (#1636) H5Pget_fapl_mpio() should return an MPI info object containing all the MPI-IO hints used by the MPI library underneath, after the file is opened. Some hints, such as cb_nodes (number of I/O aggregators), are useful for HDF5 applications and I/O libraries built on top of HDF5. * OESS-168: Remove clang warnings. (#1309) * OESS-168: Remove clang warnings. * OESS-168: Address @lrknox review. * OESS-168: Remove clang warnings. (#1376) * Remove H5_NO_ALIGNMENT_RESTRICTIONS (#1426) * Do not conditionally compile code that uses a pointer dereference and assignment to copy a potentially unaligned variable to aligned automatic storage, or vice versa. Instead, always use naked `memcpy(3)`s. Disassembling the generated code reveals that the `memcpy(3)`s optimize (`-O3`) to a single `mov` instruction for x86_64, which is not strict about alignment. This change reduces the size of code and scripts by 143 lines, eases our way to cross-compilation, and avoids invoking undefined behavior. * Committing clang-format changes * Per discussion, use HD and add comments. Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Cleans up some HL library code that inappropriately returns htri_t values cast to herr_t (#1651) * Cleans up some HL library code that inappropriately returns htri_t values cast to herr_t * Committing clang-format changes * Formatted source Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Mirror vfd test fixes (#1629) * Use the FAPL that was created earlier in the test (and delete an unused variable). This allows 'make check-vfd' to pass with --enable-mirror-vfd. * Check for testing directory before creating, to avoid warning from bash. Clean out .libs directory before re-using it (after a failed test), to remove any files generated by libtool. * Committing clang-format changes * Increment error count on failed file open and skip tests for VFDs that need modified filenames. * Skip the mirror VFD for 'make check-vfd' - the mirror VFD requires networking configuration parameters and can't be provided for an automated test that is configured with an environment variable. Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes HDF Group paths, adds shellcheck fixes (#1656) For more information: https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ... https://www.shellcheck.net/wiki/SC2230 -- which is non-standard. Use builti... https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le... * HDFFV-11306 Fixed (#1657) * HDFFV-11306, * Fixed it so both h5open_f and h5close_f can be called multiple times. * Fixed an issue with open objects remaining after h5close_f was called. * Added additional tests. * comments clean-up * Develop clang format java (#1653) * added HDFFV-11306 entry (#1662) * Adds the -q flag to all swmr test programs, quieting noisy output (#1665) * Adds paths-ignore to the Github pull request workflow (#1663) * Changes Github action `hdf5 dev CI` to `PR hdf5 dev CI` (#1666) So the PR action name is not the same as the one in main.yml * Replace H5detect's build-time detection of C99 integer properties with a (#1400) * Replace H5detect's build-time detection of C99 integer properties with a table-driven routine, `H5T__init_native_int()`, that is run at library initialization time. * Improve handling of copying of dynamic libraries and clean them up after (#1681) test finishes. Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: Wei-keng Liao <wkliao@users.noreply.github.com> Co-authored-by: H. Joe Lee <hyoklee@hdfgroup.org> Co-authored-by: David Young <dyoung@hdfgroup.org> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Quincey Koziol <koziol@lbl.gov> Co-authored-by: Scot Breitenfeld <brtnfld@hdfgroup.org>
Diffstat (limited to 'hl/src/H5DS.c')
-rw-r--r--hl/src/H5DS.c172
1 files changed, 80 insertions, 92 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c
index 387419b..d55512f 100644
--- a/hl/src/H5DS.c
+++ b/hl/src/H5DS.c
@@ -17,7 +17,7 @@
#include "H5TBprivate.h"
/* Local routines */
-static herr_t H5DS_is_reserved(hid_t did);
+static herr_t H5DS_is_reserved(hid_t did, hbool_t *is_reserved);
/*-------------------------------------------------------------------------
* Function: H5DSwith_new_ref
@@ -73,7 +73,7 @@ H5DSwith_new_ref(hid_t obj_id, hbool_t *with_new_ref)
herr_t
H5DSset_scale(hid_t dsid, const char *dimname)
{
- int has_dimlist;
+ htri_t has_dimlist;
H5I_type_t it;
/*-------------------------------------------------------------------------
@@ -92,11 +92,10 @@ H5DSset_scale(hid_t dsid, const char *dimname)
*-------------------------------------------------------------------------
*/
- /* try to find the attribute "DIMENSION_LIST" */
- if ((has_dimlist = H5LT_find_attribute(dsid, DIMENSION_LIST)) < 0)
+ /* Try to find the attribute "DIMENSION_LIST" */
+ if ((has_dimlist = H5Aexists(dsid, DIMENSION_LIST)) < 0)
return FAIL;
-
- if (has_dimlist == 1)
+ if (has_dimlist > 0)
return FAIL;
/*-------------------------------------------------------------------------
@@ -139,8 +138,8 @@ H5DSset_scale(hid_t dsid, const char *dimname)
herr_t
H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
{
- int has_dimlist;
- int has_reflist;
+ htri_t has_dimlist;
+ htri_t has_reflist;
int is_ds;
hssize_t nelmts;
hid_t sid, sid_w; /* space ID */
@@ -173,6 +172,7 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
size_t len;
int found_ds = 0;
htri_t is_scale;
+ hbool_t is_reserved;
/*-------------------------------------------------------------------------
* parameter checking
@@ -221,12 +221,14 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
if (H5I_DATASET != it1 || H5I_DATASET != it2)
return FAIL;
- /* the DS dataset cannot have dimension scales */
- if (H5LT_find_attribute(dsid, DIMENSION_LIST) == 1)
+ /* The DS dataset cannot have dimension scales */
+ if (H5Aexists(dsid, DIMENSION_LIST) > 0)
return FAIL;
- /* check if the dataset is a "reserved" dataset (image, table) */
- if (H5DS_is_reserved(did) == 1)
+ /* Check if the dataset is a "reserved" dataset (image, table) */
+ if (H5DS_is_reserved(did, &is_reserved) < 0)
+ return FAIL;
+ if (is_reserved == TRUE)
return FAIL;
/*-------------------------------------------------------------------------
@@ -279,8 +281,8 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
if (H5Rcreate(&dsl.ref, did, ".", H5R_OBJECT, (hid_t)-1) < 0)
return FAIL;
}
- /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
- if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
+ /* Try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
+ if ((has_dimlist = H5Aexists(did, DIMENSION_LIST)) < 0)
return FAIL;
/*-------------------------------------------------------------------------
@@ -354,7 +356,7 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
* and insert the new reference
*-------------------------------------------------------------------------
*/
- else if (has_dimlist == 1) {
+ else if (has_dimlist > 0) {
if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
goto out;
@@ -469,7 +471,7 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
*/
/* try to find the attribute "REFERENCE_LIST" on the >>DS<< dataset */
- if ((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0)
+ if ((has_reflist = H5Aexists(dsid, REFERENCE_LIST)) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -530,7 +532,7 @@ H5DSattach_scale(hid_t did, hid_t dsid, unsigned int idx)
* the "REFERENCE_LIST" array already exists, open it and extend it
*-------------------------------------------------------------------------
*/
- else if (has_reflist == 1) {
+ else if (has_reflist > 0) {
hid_t tmp_id; /* Temporary DS dataset ID to recreate reference */
int j;
@@ -727,8 +729,8 @@ out:
herr_t
H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
{
- int has_dimlist;
- int has_reflist;
+ htri_t has_dimlist;
+ htri_t has_reflist;
hssize_t nelmts;
hid_t dsid_j; /* DS dataset ID in DIMENSION_LIST */
hid_t did_i; /* dataset ID in REFERENCE_LIST */
@@ -804,10 +806,9 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
*-------------------------------------------------------------------------
*/
- /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
- if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
+ /* Try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
+ if ((has_dimlist = H5Aexists(did, DIMENSION_LIST)) < 0)
return FAIL;
-
if (has_dimlist == 0)
return FAIL;
@@ -833,9 +834,8 @@ H5DSdetach_scale(hid_t did, hid_t dsid, unsigned int idx)
*/
/* try to find the attribute "REFERENCE_LIST" on the >>DS<< dataset */
- if ((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0)
+ if ((has_reflist = H5Aexists(dsid, REFERENCE_LIST)) < 0)
return FAIL;
-
if (has_reflist == 0)
return FAIL;
@@ -1228,8 +1228,8 @@ out:
htri_t
H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
{
- int has_dimlist;
- int has_reflist;
+ htri_t has_dimlist;
+ htri_t has_reflist;
hssize_t nelmts;
hid_t sid; /* space ID */
hid_t tid = H5I_INVALID_HID; /* attribute type ID */
@@ -1319,7 +1319,7 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
return FAIL;
/* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
- if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
+ if ((has_dimlist = H5Aexists(did, DIMENSION_LIST)) < 0)
return FAIL;
/*-------------------------------------------------------------------------
@@ -1327,7 +1327,7 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
*-------------------------------------------------------------------------
*/
- if (has_dimlist == 1) {
+ if (has_dimlist > 0) {
if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
goto out;
@@ -1407,7 +1407,7 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
*/
/* try to find the attribute "REFERENCE_LIST" on the >>DS<< dataset */
- if ((has_reflist = H5LT_find_attribute(dsid, REFERENCE_LIST)) < 0)
+ if ((has_reflist = H5Aexists(dsid, REFERENCE_LIST)) < 0)
goto out;
/*-------------------------------------------------------------------------
@@ -1415,7 +1415,7 @@ H5DSis_attached(hid_t did, hid_t dsid, unsigned int idx)
*-------------------------------------------------------------------------
*/
- if (has_reflist == 1) {
+ if (has_reflist > 0) {
if ((aid = H5Aopen(dsid, REFERENCE_LIST, H5P_DEFAULT)) < 0)
goto out;
@@ -1610,7 +1610,7 @@ H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, H5DS_iterate_t visi
herr_t ret_value = 0;
int j_idx;
int nscales;
- int has_dimlist;
+ htri_t has_dimlist;
int i;
hbool_t is_new_ref;
@@ -1658,14 +1658,13 @@ H5DSiterate_scales(hid_t did, unsigned int dim, int *ds_idx, H5DS_iterate_t visi
if (dim >= (unsigned)rank)
return FAIL;
- /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
- if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
+ /* Try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
+ if ((has_dimlist = H5Aexists(did, DIMENSION_LIST)) < 0)
return FAIL;
-
if (has_dimlist == 0)
return SUCCEED;
- else if (has_dimlist == 1) {
+ else if (has_dimlist > 0) {
if ((aid = H5Aopen(did, DIMENSION_LIST, H5P_DEFAULT)) < 0)
goto out;
if ((tid = H5Aget_type(aid)) < 0)
@@ -1788,7 +1787,7 @@ out:
herr_t
H5DSset_label(hid_t did, unsigned int idx, const char *label)
{
- int has_labels;
+ htri_t has_labels;
hid_t sid = H5I_INVALID_HID; /* space ID */
hid_t tid = H5I_INVALID_HID; /* attribute type ID */
hid_t aid = H5I_INVALID_HID; /* attribute ID */
@@ -1838,7 +1837,7 @@ H5DSset_label(hid_t did, unsigned int idx, const char *label)
*/
/* try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */
- if ((has_labels = H5LT_find_attribute(did, DIMENSION_LABELS)) < 0)
+ if ((has_labels = H5Aexists(did, DIMENSION_LABELS)) < 0)
return FAIL;
/*-------------------------------------------------------------------------
@@ -1991,7 +1990,7 @@ out:
ssize_t
H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size)
{
- int has_labels;
+ htri_t has_labels;
hid_t sid = H5I_INVALID_HID; /* space ID */
hid_t tid = H5I_INVALID_HID; /* attribute type ID */
hid_t aid = H5I_INVALID_HID; /* attribute ID */
@@ -2033,11 +2032,11 @@ H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size)
*-------------------------------------------------------------------------
*/
- /* try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */
- if ((has_labels = H5LT_find_attribute(did, DIMENSION_LABELS)) < 0)
+ /* Try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */
+ if ((has_labels = H5Aexists(did, DIMENSION_LABELS)) < 0)
return FAIL;
- /* return 0 and NULL for label if no label found */
+ /* Return 0 and NULL for label if no label found */
if (has_labels == 0) {
if (label)
label[0] = 0;
@@ -2049,7 +2048,6 @@ H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size)
*-------------------------------------------------------------------------
*/
- assert(has_labels == 1);
if ((aid = H5Aopen(did, DIMENSION_LABELS, H5P_DEFAULT)) < 0)
goto out;
@@ -2146,7 +2144,7 @@ H5DSget_scale_name(hid_t did, char *name, size_t size)
H5I_type_t it; /* ID type */
size_t nbytes;
size_t copy_len;
- int has_name;
+ htri_t has_name;
char * buf = NULL;
/*-------------------------------------------------------------------------
@@ -2169,9 +2167,8 @@ H5DSget_scale_name(hid_t did, char *name, size_t size)
*/
/* try to find the attribute "NAME" on the >>DS<< dataset */
- if ((has_name = H5LT_find_attribute(did, "NAME")) < 0)
+ if ((has_name = H5Aexists(did, "NAME")) < 0)
return FAIL;
-
if (has_name == 0)
return 0;
@@ -2259,7 +2256,7 @@ H5DSis_scale(hid_t did)
{
hid_t tid = H5I_INVALID_HID; /* attribute type ID */
hid_t aid = H5I_INVALID_HID; /* attribute ID */
- herr_t attr_class; /* has the "CLASS" attribute */
+ htri_t attr_class; /* has the "CLASS" attribute */
htri_t is_ds = -1; /* set to "not a dimension scale" */
H5I_type_t it; /* type of identifier */
char * buf = NULL; /* buffer to read name of attribute */
@@ -2279,7 +2276,7 @@ H5DSis_scale(hid_t did)
goto out;
/* try to find the attribute "CLASS" on the dataset */
- if ((attr_class = H5LT_find_attribute(did, "CLASS")) < 0)
+ if ((attr_class = H5Aexists(did, "CLASS")) < 0)
goto out;
if (attr_class == 0) {
@@ -2370,7 +2367,7 @@ out:
int
H5DSget_num_scales(hid_t did, unsigned int idx)
{
- int has_dimlist;
+ htri_t has_dimlist;
hid_t sid; /* space ID */
hid_t tid = H5I_INVALID_HID; /* attribute type ID */
hid_t aid = H5I_INVALID_HID; /* attribute ID */
@@ -2410,11 +2407,11 @@ H5DSget_num_scales(hid_t did, unsigned int idx)
if (idx >= (unsigned int)rank)
return FAIL;
- /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
- if ((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0)
+ /* Try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */
+ if ((has_dimlist = H5Aexists(did, DIMENSION_LIST)) < 0)
return FAIL;
- /* it does not exist */
+ /* No scales */
if (has_dimlist == 0)
return 0;
@@ -2475,86 +2472,77 @@ out:
/*-------------------------------------------------------------------------
* Function: H5DS_is_reserved
*
- * Purpose: Verify that a dataset's CLASS is either an image, palette or table
- *
- * Return: true, false, fail
- *
- * Programmer: Pedro Vicente
- *
- * Date: March 19, 2005
+ * Purpose: Verify that a dataset's CLASS is either an image, palette or
+ * table
*
+ * Return: SUCCEED/FAIL
*-------------------------------------------------------------------------
*/
static herr_t
-H5DS_is_reserved(hid_t did)
+H5DS_is_reserved(hid_t did, hbool_t *is_reserved)
{
- int has_class;
+ htri_t has_class;
hid_t tid = H5I_INVALID_HID;
hid_t aid = H5I_INVALID_HID;
char * buf = NULL; /* Name of attribute */
size_t string_size; /* Size of storage for attribute */
- herr_t ret;
-
- /* try to find the attribute "CLASS" on the dataset */
- if ((has_class = H5LT_find_attribute(did, "CLASS")) < 0)
- return -1;
- if (has_class == 0)
- return 0;
+ /* Try to find the attribute "CLASS" on the dataset */
+ if ((has_class = H5Aexists(did, "CLASS")) < 0)
+ return FAIL;
+ if (has_class == 0) {
+ *is_reserved = FALSE;
+ return SUCCEED;
+ }
- assert(has_class == 1);
if ((aid = H5Aopen(did, "CLASS", H5P_DEFAULT)) < 0)
- goto out;
-
+ goto error;
if ((tid = H5Aget_type(aid)) < 0)
- goto out;
+ goto error;
- /* check to make sure attribute is a string */
+ /* Check to make sure attribute is a string */
if (H5T_STRING != H5Tget_class(tid))
- goto out;
+ goto error;
- /* check to make sure string is null-terminated */
+ /* Check to make sure string is null-terminated */
if (H5T_STR_NULLTERM != H5Tget_strpad(tid))
- goto out;
+ goto error;
- /* allocate buffer large enough to hold string */
+ /* Allocate buffer large enough to hold string */
if ((string_size = H5Tget_size(tid)) == 0)
- goto out;
-
- buf = (char *)HDmalloc((size_t)string_size * sizeof(char));
- if (buf == NULL)
- goto out;
+ goto error;
+ if (NULL == (buf = HDmalloc(string_size * sizeof(char))))
+ goto error;
/* Read the attribute */
if (H5Aread(aid, tid, buf) < 0)
- goto out;
+ goto error;
if (HDstrncmp(buf, IMAGE_CLASS, MIN(HDstrlen(IMAGE_CLASS), HDstrlen(buf))) == 0 ||
HDstrncmp(buf, PALETTE_CLASS, MIN(HDstrlen(PALETTE_CLASS), HDstrlen(buf))) == 0 ||
HDstrncmp(buf, TABLE_CLASS, MIN(HDstrlen(TABLE_CLASS), HDstrlen(buf))) == 0)
- ret = 1;
+ *is_reserved = TRUE;
else
- ret = 0;
+ *is_reserved = FALSE;
HDfree(buf);
if (H5Tclose(tid) < 0)
- goto out;
-
+ goto error;
if (H5Aclose(aid) < 0)
- goto out;
+ goto error;
- return ret;
+ return SUCCEED;
- /* error zone */
-out:
+error:
H5E_BEGIN_TRY
{
- if (buf)
- HDfree(buf);
H5Tclose(tid);
H5Aclose(aid);
}
H5E_END_TRY;
+
+ HDfree(buf);
+
return FAIL;
}