Skip to content

Commit

Permalink
Replace non-VOL calls with VOL calls - part 5
Browse files Browse the repository at this point in the history
This PR switches H5I_object() and H5I_object_verify() to H5VL_vol_object() and          H5VL_vol_object_verify(), respectively, in the H5M APIs and H5Gdeprec (was left         out by mistake).  This completes the fixes of issue HDFGroupGH-4730.
  • Loading branch information
bmribler committed Aug 29, 2024
1 parent d2be618 commit 0db6cc4
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 27 deletions.
26 changes: 13 additions & 13 deletions src/H5Gdeprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint)
loc_params.obj_type = H5I_get_type(loc_id);

/* 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");

/* Create the group */
Expand Down Expand Up @@ -262,7 +262,7 @@ H5Gopen1(hid_t loc_id, const char *name)
loc_params.obj_type = H5I_get_type(loc_id);

/* 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");

/* Open the group */
Expand Down Expand Up @@ -320,7 +320,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new
new_loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT;

/* Get the location object */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id)))
if (NULL == (vol_obj = H5VL_vol_object(cur_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier");

/* Construct a temporary VOL object */
Expand Down Expand Up @@ -351,7 +351,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new
loc_params.obj_type = H5I_get_type(cur_loc_id);

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

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -409,9 +409,9 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_
new_loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT;

/* Get the location objects */
if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(cur_loc_id)))
if (NULL == (vol_obj1 = H5VL_vol_object(cur_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier");
if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(new_loc_id)))
if (NULL == (vol_obj2 = H5VL_vol_object(new_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -443,7 +443,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_
loc_params.obj_type = H5I_get_type(new_loc_id);

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

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -493,7 +493,7 @@ H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name)
loc_params2.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT;

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

/* Move the link */
Expand Down Expand Up @@ -541,11 +541,11 @@ H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *d

if (H5L_SAME_LOC != src_loc_id)
/* get the location object */
if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id)))
if (NULL == (vol_obj1 = H5VL_vol_object(src_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier");
if (H5L_SAME_LOC != dst_loc_id)
/* get the location object */
if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id)))
if (NULL == (vol_obj2 = H5VL_vol_object(dst_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier");

/* Move the link */
Expand Down Expand Up @@ -588,7 +588,7 @@ H5Gunlink(hid_t loc_id, const char *name)
loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT;

/* 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, FAIL, "invalid location identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -635,7 +635,7 @@ H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf /*out*/)
loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT;

/* 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, FAIL, "invalid location identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -1167,7 +1167,7 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name /*out*/, size_t size
loc_params.obj_type = H5I_get_type(loc_id);

/* 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, (-1), "invalid location identifier");

/* Set up VOL callback arguments */
Expand Down
24 changes: 12 additions & 12 deletions src/H5M.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ H5Mcreate_anon(hid_t loc_id, hid_t key_type_id, hid_t val_type_id, hid_t mcpl_id
HGOTO_ERROR(H5E_MAP, 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 @@ -693,7 +693,7 @@ H5Mget_key_type(hid_t map_id)
FUNC_ENTER_API(H5I_INVALID_HID)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP)))
if (NULL == (vol_obj = H5VL_vol_object_verify(map_id, H5I_MAP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -737,7 +737,7 @@ H5Mget_val_type(hid_t map_id)
FUNC_ENTER_API(H5I_INVALID_HID)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP)))
if (NULL == (vol_obj = H5VL_vol_object_verify(map_id, H5I_MAP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -781,7 +781,7 @@ H5Mget_create_plist(hid_t map_id)
FUNC_ENTER_API(H5I_INVALID_HID)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP)))
if (NULL == (vol_obj = H5VL_vol_object_verify(map_id, H5I_MAP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -828,7 +828,7 @@ H5Mget_access_plist(hid_t map_id)
FUNC_ENTER_API(H5I_INVALID_HID)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP)))
if (NULL == (vol_obj = H5VL_vol_object_verify(map_id, H5I_MAP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -871,7 +871,7 @@ H5Mget_count(hid_t map_id, hsize_t *count /*out*/, hid_t dxpl_id)
FUNC_ENTER_API(H5I_INVALID_HID)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP)))
if (NULL == (vol_obj = H5VL_vol_object_verify(map_id, H5I_MAP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid map identifier");

/* Get the default dataset transfer property list if the user didn't provide one */
Expand Down Expand Up @@ -927,7 +927,7 @@ H5M__put_api_common(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid value memory datatype ID");

/* Get map pointer */
if (NULL == (*vol_obj_ptr = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP)))
if (NULL == (*vol_obj_ptr = H5VL_vol_object_verify(map_id, H5I_MAP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID");

/* Get the default dataset transfer property list if the user didn't provide one */
Expand Down Expand Up @@ -1056,7 +1056,7 @@ H5M__get_api_common(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid value memory datatype ID");

/* Get map pointer */
if (NULL == (*vol_obj_ptr = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP)))
if (NULL == (*vol_obj_ptr = H5VL_vol_object_verify(map_id, H5I_MAP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID");

/* Get the default dataset transfer property list if the user didn't provide one */
Expand Down Expand Up @@ -1187,7 +1187,7 @@ H5Mexists(hid_t map_id, hid_t key_mem_type_id, const void *key, hbool_t *exists,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID");

/* Get map pointer */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP)))
if (NULL == (vol_obj = H5VL_vol_object_verify(map_id, H5I_MAP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID");

/* Get the default dataset transfer property list if the user didn't provide one */
Expand Down Expand Up @@ -1263,7 +1263,7 @@ H5Miterate(hid_t map_id, hsize_t *idx, hid_t key_mem_type_id, H5M_iterate_t op,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified");

/* Get map pointer */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP)))
if (NULL == (vol_obj = H5VL_vol_object_verify(map_id, H5I_MAP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID");

/* Get the default dataset transfer property list if the user didn't provide one */
Expand Down Expand Up @@ -1348,7 +1348,7 @@ H5Miterate_by_name(hid_t loc_id, const char *map_name, hsize_t *idx, hid_t key_m
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified");

/* 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, FAIL, "invalid location identifier");

/* Get the default dataset transfer property list if the user didn't provide one */
Expand Down Expand Up @@ -1412,7 +1412,7 @@ H5Mdelete(hid_t map_id, hid_t key_mem_type_id, const void *key, hid_t dxpl_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid key memory datatype ID");

/* Get map pointer */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(map_id, H5I_MAP)))
if (NULL == (vol_obj = H5VL_vol_object_verify(map_id, H5I_MAP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "map_id is not a map ID");

/* Get the default dataset transfer property list if the user didn't provide one */
Expand Down
22 changes: 20 additions & 2 deletions src/H5Mpublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,27 @@ H5_DLL hid_t H5Mcreate_async(hid_t loc_id, const char *name, hid_t key_type_id,
/**
* \ingroup H5M
*
* \brief
* \brief Creates a map object without linking it into a file
*
* \details
* \fgdta_loc_id
* \type_id{key_type_id}
* \type_id{val_type_id}
* \mcpl_id
* \mapl_id
* \return \hid_t{map object}
* The resulting ID should be linked into the file with H5Olink or it
* will be deleted when closed.
*
* \details H5Mcreate_anon() creates a new map object for storing key-value
* pairs. The in-file datatype for keys is defined by \p key_type_id
* and the in-file datatype for values is defined by \p val_type_id. \p
* loc_id specifies the file to create the map object, but no link to
* the object is created. Other options can be specified through the
* property lists \p mcpl_id and \p mapl_id.
*
* The new map should be linked into the group hierarchy before being
* closed or it will be deleted. The dataset should be closed when the
* caller is no longer interested in it.
*
* \since 1.12.0
*
Expand Down

0 comments on commit 0db6cc4

Please sign in to comment.