summaryrefslogtreecommitdiffstats
path: root/src/H5Rdeprec.c
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-05-28 14:10:51 (GMT)
committerGitHub <noreply@github.com>2021-05-28 14:10:51 (GMT)
commit2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8 (patch)
tree40975e0846d101360a838d42e16f4687fed77f4a /src/H5Rdeprec.c
parente22687912dbc6fcf4fff57e86e2cd5d75c81f81e (diff)
downloadhdf5-2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8.zip
hdf5-2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8.tar.gz
hdf5-2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8.tar.bz2
Much normalization with develop (#701)
* Brings CMake updates from develop * Brings reduction in pedantic casts from develop * Purges UFAIL from the library (#637) * Committing clang-format changes * Purges UFAIL from the library * H5HL_insert change requested in PR Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Removes gratuitous (double)x.yF casts (#632) * Committing clang-format changes * Removes gratuitous (double)x.yF casts * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Committing clang-format changes * Cleans up a const warning left over from previous constification (#633) * Committing clang-format changes * Adds consts to a few global variables * Cleans up a const warning left over from previous constification Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> * Formatted source * Bring over some VOL registration changes * VOL cleanup * H5VL_request_status_t substitutions * H5F.c cleanup * Minor API tweaks from develop * Moves H5G package init/teardown to H5Gint.c * H5G cleanup * H5M cleanup * H5SM cleanup * H5T cleanup * H5R cleanup * H5Lpublic.h cleanup * H5L cleanup * H5O cleanup * H5A, H5CS, and H5AC cleanup * Moved H5A init/teardown code to H5Aint.c * Moves H5D I/O functions to H5D.c * H5D cleanup * Misc minor cleanup * H5P close cleanup * H5Tpublic.h cleanup * Fixes err_compat test * H5PLpublic.h cleanup * Updates H5Ppublic.h * H5Fpublic.h updates * H5A.c cleanup * Brings over H5Aexists and related changes * Brings CMake shell testing changes from develop * Close callback changes * H5R and H5Tcommit normalization * err_compat test works now * H5O tweaks * Updates VOL registration code * Brings over H5VL_create_object * H5Tconv.c reformatting * H5T.c tweaks * Brings datatype and reference updates from develop * Brings VOL plugin loading changes from develop * Brings event sets from develop * Brings async functions over * Tools changes * Brings over many tools changes from develop * Brings VOL flags from develop * Fixes h5dump double/float tests * Updates h5repack tests * Brings h5diff test changes from develop * Last h5dump changes * Brings test changes from develop * Committing clang-format changes * Tidied h5_testing() * Brings chunk iteration code + misc from develop * Updates vds test * Enables external link parallel test * Brings updated property lists from develop * H5G changes from develop * H5MF cleanup * Brings vfd_swmr test back into CMake * Updates threadsafe test * Updates plist test * Brings recent changes from develop Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/H5Rdeprec.c')
-rw-r--r--src/H5Rdeprec.c167
1 files changed, 159 insertions, 8 deletions
diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c
index c66ae7c..d5f5a7d 100644
--- a/src/H5Rdeprec.c
+++ b/src/H5Rdeprec.c
@@ -61,6 +61,10 @@
/********************/
/* Local Prototypes */
/********************/
+static herr_t H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, size_t token_size,
+ H5S_t *space, unsigned char *buf, size_t *nalloc);
+static herr_t H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref_type,
+ const unsigned char *buf, H5O_token_t *obj_token);
/*********************/
/* Package Variables */
@@ -74,8 +78,155 @@
/* Local Variables */
/*******************/
-#ifndef H5_NO_DEPRECATED_SYMBOLS
+/*-------------------------------------------------------------------------
+ * Function: H5R__decode_token_compat
+ *
+ * Purpose: Decode an object token. (native only)
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref_type,
+ const unsigned char *buf, H5O_token_t *obj_token)
+{
+ hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */
+ H5VL_object_t * vol_obj_file = NULL;
+ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0};
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_STATIC
+
+#ifndef NDEBUG
+ {
+ hbool_t is_native = FALSE; /* Whether the src file is using the native VOL connector */
+
+ /* Check if using native VOL connector */
+ if (H5VL_object_is_native(vol_obj, &is_native) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't query if file uses native VOL connector")
+
+ /* Must use native VOL connector for this operation */
+ HDassert(is_native);
+ }
+#endif /* NDEBUG */
+
+ /* Get the file for the object */
+ if ((file_id = H5F_get_file_id(vol_obj, type, FALSE)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+
+ /* Retrieve VOL object */
+ if (NULL == (vol_obj_file = H5VL_vol_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+
+ /* Get container info */
+ if (H5VL_file_get((const H5VL_object_t *)vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT,
+ H5_REQUEST_NULL, &cont_info) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info")
+ if (ref_type == H5R_OBJECT1) {
+ size_t buf_size = H5R_OBJ_REF_BUF_SIZE;
+
+ /* Get object address */
+ if (H5R__decode_token_obj_compat(buf, &buf_size, obj_token, cont_info.token_size) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object token")
+ } /* end if */
+ else {
+ size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE;
+ H5F_t *f = NULL;
+
+ /* Retrieve file from VOL object */
+ if (NULL == (f = (H5F_t *)H5VL_object_data((const H5VL_object_t *)vol_obj_file)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object")
+
+ /* Get object address */
+ if (H5R__decode_token_region_compat(f, buf, &buf_size, obj_token, cont_info.token_size, NULL) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address")
+ } /* end else */
+
+done:
+ if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0)
+ HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file")
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5R__decode_token_compat() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5R__encode_token_region_compat
+ *
+ * Purpose: Encode dataset selection and insert data into heap
+ * (native only).
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token, size_t token_size, H5S_t *space,
+ unsigned char *buf, size_t *nalloc)
+{
+ size_t buf_size;
+ unsigned char *data = NULL;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_STATIC
+
+ HDassert(f);
+ HDassert(obj_token);
+ HDassert(token_size);
+ HDassert(space);
+ HDassert(nalloc);
+
+ /* Get required buffer size */
+ if (H5R__encode_heap(f, NULL, &buf_size, NULL, (size_t)0) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+
+ if (buf && *nalloc >= buf_size) {
+ ssize_t data_size;
+ uint8_t *p;
+
+ /* Pass the correct encoding version for the selection depending on the
+ * file libver bounds, this is later retrieved in H5S hyper encode */
+ H5CX_set_libver_bounds(f);
+
+ /* Zero the heap ID out, may leak heap space if user is re-using
+ * reference and doesn't have garbage collection turned on
+ */
+ HDmemset(buf, 0, buf_size);
+
+ /* Get the amount of space required to serialize the selection */
+ if ((data_size = H5S_SELECT_SERIAL_SIZE(space)) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL,
+ "Invalid amount of space for serializing selection")
+
+ /* Increase buffer size to allow for the dataset token */
+ data_size += (hssize_t)token_size;
+
+ /* Allocate the space to store the serialized information */
+ H5_CHECK_OVERFLOW(data_size, hssize_t, size_t);
+ if (NULL == (data = (uint8_t *)H5MM_malloc((size_t)data_size)))
+ HGOTO_ERROR(H5E_REFERENCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ /* Serialize information for dataset OID into heap buffer */
+ p = (uint8_t *)data;
+ H5MM_memcpy(p, obj_token, token_size);
+ p += token_size;
+
+ /* Serialize the selection into heap buffer */
+ if (H5S_SELECT_SERIALIZE(space, &p) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection")
+
+ /* Write to heap */
+ if (H5R__encode_heap(f, buf, nalloc, data, (size_t)data_size) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+ }
+ *nalloc = buf_size;
+
+done:
+ H5MM_free(data);
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5R__encode_token_region_compat() */
+
+#ifndef H5_NO_DEPRECATED_SYMBOLS
/*-------------------------------------------------------------------------
* Function: H5Rget_obj_type1
*
@@ -298,7 +449,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t
size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE;
/* Retrieve space */
- if (space_id == H5I_BADID)
+ if (space_id == H5I_INVALID_HID)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid")
if (NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
@@ -330,7 +481,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type)
+H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type /*out*/)
{
H5VL_object_t * vol_obj = NULL; /* Object of loc_id */
H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */
@@ -340,7 +491,7 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE4("e", "iRt*x*Ot", id, ref_type, ref, obj_type);
+ H5TRACE4("e", "iRt*xx", id, ref_type, ref, obj_type);
/* Check args */
if (buf == NULL)
@@ -520,9 +671,9 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref)
if (H5R__decode_token_region_compat(f, buf, &buf_size, NULL, cont_info.token_size, &space) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace")
- /* Atomize */
+ /* Register */
if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom")
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace ID")
done:
if (file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0)
@@ -542,7 +693,7 @@ done:
*-------------------------------------------------------------------------
*/
ssize_t
-H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name, size_t size)
+H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name /*out*/, size_t size)
{
H5VL_object_t * vol_obj = NULL; /* Object of loc_id */
H5I_type_t vol_obj_type = H5I_BADID; /* Object type of loc_id */
@@ -552,7 +703,7 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name, size_t s
ssize_t ret_value = -1; /* Return value */
FUNC_ENTER_API((-1))
- H5TRACE5("Zs", "iRt*x*sz", id, ref_type, ref, name, size);
+ H5TRACE5("Zs", "iRt*xxz", id, ref_type, ref, name, size);
/* Check args */
if (buf == NULL)