Skip to content

Commit

Permalink
Replace non-VOL calls with VOL calls - part 1 (HDFGroup#4745)
Browse files Browse the repository at this point in the history
This PR is part of the incremental switching H5I_object() and H5I_object_verify()
to their VOL counterpart, H5VL_object() and H5VL_vol_object_verify(), a newly addedinternal function.

Fixes HDFGroupGH-4730 partially.
  • Loading branch information
bmribler authored and lrknox committed Aug 27, 2024
1 parent 77444b8 commit 2c89149
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 31 deletions.
14 changes: 7 additions & 7 deletions src/H5A.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ H5A__read_api_common(hid_t attr_id, hid_t dtype_id, void *buf, void **token_ptr,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf parameter can't be NULL");

/* Get attribute object pointer */
if (NULL == (*vol_obj_ptr = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR)))
if (NULL == (*vol_obj_ptr = H5VL_vol_object_verify(attr_id, H5I_ATTR)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");

/* Read the attribute data */
Expand Down Expand Up @@ -1090,7 +1090,7 @@ H5Aget_space(hid_t attr_id)
FUNC_ENTER_API(H5I_INVALID_HID)

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR)))
if (NULL == (vol_obj = H5VL_vol_object_verify(attr_id, H5I_ATTR)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -1134,7 +1134,7 @@ H5Aget_type(hid_t attr_id)
FUNC_ENTER_API(H5I_INVALID_HID)

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR)))
if (NULL == (vol_obj = H5VL_vol_object_verify(attr_id, H5I_ATTR)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -1183,7 +1183,7 @@ H5Aget_create_plist(hid_t attr_id)
assert(H5P_LST_ATTRIBUTE_CREATE_ID_g != -1);

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR)))
if (NULL == (vol_obj = H5VL_vol_object_verify(attr_id, H5I_ATTR)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -1234,7 +1234,7 @@ H5Aget_name(hid_t attr_id, size_t buf_size, char *buf /*out*/)
FUNC_ENTER_API((-1))

/* check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR)))
if (NULL == (vol_obj = H5VL_vol_object_verify(attr_id, H5I_ATTR)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not an attribute");
if (!buf && buf_size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "buf cannot be NULL if buf_size is non-zero");
Expand Down Expand Up @@ -1352,7 +1352,7 @@ H5Aget_storage_size(hid_t attr_id)
FUNC_ENTER_API(0)

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR)))
if (NULL == (vol_obj = H5VL_vol_object_verify(attr_id, H5I_ATTR)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an attribute");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -1390,7 +1390,7 @@ H5Aget_info(hid_t attr_id, H5A_info_t *ainfo /*out*/)
FUNC_ENTER_API(FAIL)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR)))
if (NULL == (vol_obj = H5VL_vol_object_verify(attr_id, H5I_ATTR)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
if (!ainfo)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "attribute_info parameter cannot be NULL");
Expand Down
46 changes: 23 additions & 23 deletions src/H5D.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info");

/* get the location object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
if (NULL == (vol_obj = H5VL_vol_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier");

/* Set location parameters */
Expand Down Expand Up @@ -559,7 +559,7 @@ H5D__get_space_api_common(hid_t dset_id, void **token_ptr, H5VL_object_t **_vol_
FUNC_ENTER_PACKAGE

/* Check args */
if (NULL == (*vol_obj_ptr = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (*vol_obj_ptr = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -671,7 +671,7 @@ H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation /*out*/)
FUNC_ENTER_API(FAIL)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -709,7 +709,7 @@ H5Dget_type(hid_t dset_id)
FUNC_ENTER_API(H5I_INVALID_HID)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -750,7 +750,7 @@ H5Dget_create_plist(hid_t dset_id)
FUNC_ENTER_API(H5I_INVALID_HID)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -808,7 +808,7 @@ H5Dget_access_plist(hid_t dset_id)
FUNC_ENTER_API(H5I_INVALID_HID)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -852,7 +852,7 @@ H5Dget_storage_size(hid_t dset_id)
FUNC_ENTER_API(0)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid dataset identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -893,7 +893,7 @@ H5Dget_offset(hid_t dset_id)
FUNC_ENTER_API(HADDR_UNDEF)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "invalid dataset identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -957,7 +957,7 @@ H5D__read_api_common(size_t count, hid_t dset_id[], hid_t mem_type_id[], hid_t m
HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate space for object array");

/* Get vol_obj_ptr (return just the first dataset to caller if requested) */
if (NULL == (*vol_obj_ptr = (H5VL_object_t *)H5I_object_verify(dset_id[0], H5I_DATASET)))
if (NULL == (*vol_obj_ptr = H5VL_vol_object_verify(dset_id[0], H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID");

/* Save the connector of the first dataset. Unpack the connector and call
Expand All @@ -969,7 +969,7 @@ H5D__read_api_common(size_t count, hid_t dset_id[], hid_t mem_type_id[], hid_t m
obj[0] = (*vol_obj_ptr)->data;
for (i = 1; i < count; i++) {
/* Get the object */
if (NULL == (tmp_vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id[i], H5I_DATASET)))
if (NULL == (tmp_vol_obj = H5VL_vol_object_verify(dset_id[i], H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID");
obj[i] = tmp_vol_obj->data;

Expand Down Expand Up @@ -1181,7 +1181,7 @@ H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fil
FUNC_ENTER_API(FAIL)

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID");
if (!buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf cannot be NULL");
Expand Down Expand Up @@ -1487,7 +1487,7 @@ H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *of
FUNC_ENTER_API(FAIL)

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset ID");
if (!buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf cannot be NULL");
Expand Down Expand Up @@ -1874,7 +1874,7 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *s
FUNC_ENTER_API(FAIL)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dataset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dataset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier");
if (H5I_DATATYPE != H5I_get_type(type_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype identifier");
Expand Down Expand Up @@ -1935,7 +1935,7 @@ H5D__set_extent_api_common(hid_t dset_id, const hsize_t size[], void **token_ptr
FUNC_ENTER_PACKAGE

/* Check args */
if (NULL == (*vol_obj_ptr = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (*vol_obj_ptr = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier");
if (!size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size array cannot be NULL");
Expand Down Expand Up @@ -2040,7 +2040,7 @@ H5Dflush(hid_t dset_id)
FUNC_ENTER_API(FAIL)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier");

/* Set up collective metadata if appropriate */
Expand Down Expand Up @@ -2081,7 +2081,7 @@ H5Drefresh(hid_t dset_id)
FUNC_ENTER_API(FAIL)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier");

/* Set up collective metadata if appropriate */
Expand Down Expand Up @@ -2124,7 +2124,7 @@ H5Dformat_convert(hid_t dset_id)
FUNC_ENTER_API(FAIL)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier");

/* Set up collective metadata if appropriate */
Expand Down Expand Up @@ -2163,7 +2163,7 @@ H5Dget_chunk_index_type(hid_t dset_id, H5D_chunk_index_t *idx_type /*out*/)
FUNC_ENTER_API(FAIL)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier");
if (NULL == idx_type)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "idx_type parameter cannot be NULL");
Expand Down Expand Up @@ -2204,7 +2204,7 @@ H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_n
FUNC_ENTER_API(FAIL)

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier");
if (NULL == offset)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset parameter cannot be NULL");
Expand Down Expand Up @@ -2254,7 +2254,7 @@ H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks /*out*/)
FUNC_ENTER_API(FAIL)

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier");
if (NULL == nchunks)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument (null)");
Expand Down Expand Up @@ -2308,7 +2308,7 @@ H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_index, hsize_t *of
if (NULL == offset && NULL == filter_mask && NULL == addr && NULL == size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
"invalid arguments, must have at least one non-null output argument");
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -2373,7 +2373,7 @@ H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filte
FUNC_ENTER_API(FAIL)

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier");
if (NULL == filter_mask && NULL == addr && NULL == size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
Expand Down Expand Up @@ -2423,7 +2423,7 @@ H5Dchunk_iter(hid_t dset_id, hid_t dxpl_id, H5D_chunk_iter_op_t op, void *op_dat
FUNC_ENTER_API(FAIL)

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier");
if (NULL == op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid callback to chunk iteration");
Expand Down
2 changes: 1 addition & 1 deletion src/H5Ddeprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ H5Dextend(hid_t dset_id, const hsize_t size[])
FUNC_ENTER_API(FAIL)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
if (NULL == (vol_obj = H5VL_vol_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier");
if (!size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified");
Expand Down
35 changes: 35 additions & 0 deletions src/H5VLint.c
Original file line number Diff line number Diff line change
Expand Up @@ -1761,6 +1761,41 @@ H5VL_vol_object(hid_t id)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_vol_object() */

/*-------------------------------------------------------------------------
* Function: H5VL_vol_object_verify
*
* Purpose: Utility function to return the object pointer associated with
* an ID of the specified type. This routine is the same as
* H5VL_vol_object except it takes the additional argument
* obj_type to verify the ID's type against.
*
* Return: Success: object pointer
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
H5VL_object_t *
H5VL_vol_object_verify(hid_t id, H5I_type_t obj_type)
{
void *obj = NULL;
H5VL_object_t *ret_value = NULL;

FUNC_ENTER_NOAPI(NULL)

if (NULL == (obj = H5I_object_verify(id, obj_type)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "identifier is not of specified type");

/* If this is a datatype, get the VOL object attached to the H5T_t struct */
if (H5I_DATATYPE == obj_type)
if (NULL == (obj = H5T_get_named_type((H5T_t *)obj)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype");

ret_value = (H5VL_object_t *)obj;

done:
FUNC_LEAVE_NOAPI(ret_value)
}

/*-------------------------------------------------------------------------
* Function: H5VL_object_data
*
Expand Down
1 change: 1 addition & 0 deletions src/H5VLprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ H5_DLL void *H5VL_object_data(const H5VL_object_t *vol_obj);
H5_DLL void *H5VL_object_unwrap(const H5VL_object_t *vol_obj);
H5_DLL void *H5VL_object_verify(hid_t id, H5I_type_t obj_type);
H5_DLL H5VL_object_t *H5VL_vol_object(hid_t id);
H5_DLL H5VL_object_t *H5VL_vol_object_verify(hid_t id, H5I_type_t obj_type);
H5_DLL H5VL_object_t *H5VL_create_object(void *object, H5VL_t *vol_connector);
H5_DLL H5VL_object_t *H5VL_create_object_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id);
H5_DLL hsize_t H5VL_object_inc_rc(H5VL_object_t *obj);
Expand Down

0 comments on commit 2c89149

Please sign in to comment.