Skip to content

Commit

Permalink
Replace non-VOL calls with VOL calls - part 3
Browse files Browse the repository at this point in the history
This PR switches H5I_object_verify() to H5VL_vol_object_verify() in the H5G API
and removes unnecessary casts.
  • Loading branch information
bmribler committed Aug 26, 2024
1 parent a03203a commit 33f761a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/H5G.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id)
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 @@ -507,7 +507,7 @@ H5Gget_create_plist(hid_t group_id)
FUNC_ENTER_API(H5I_INVALID_HID)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP)))
if (NULL == (vol_obj = H5VL_vol_object_verify(group_id, H5I_GROUP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group ID");

/* Set up VOL callback arguments */
Expand Down Expand Up @@ -960,7 +960,7 @@ H5Gflush(hid_t group_id)
FUNC_ENTER_API(FAIL)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP)))
if (NULL == (vol_obj = H5VL_vol_object_verify(group_id, H5I_GROUP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID");

/* Set up collective metadata if appropriate */
Expand Down Expand Up @@ -998,7 +998,7 @@ H5Grefresh(hid_t group_id)
FUNC_ENTER_API(FAIL)

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP)))
if (NULL == (vol_obj = H5VL_vol_object_verify(group_id, H5I_GROUP)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID");

/* Set up collective metadata if appropriate */
Expand Down
4 changes: 2 additions & 2 deletions src/H5L.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,11 @@ H5L__create_hard_api_common(hid_t cur_loc_id, const char *cur_name, hid_t link_l

if (H5L_SAME_LOC != cur_loc_id)
/* Get the current location object */
if (NULL == (curr_vol_obj = (H5VL_object_t *)H5VL_vol_object(cur_loc_id)))
if (NULL == (curr_vol_obj = H5VL_vol_object(cur_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier");
if (H5L_SAME_LOC != link_loc_id)
/* Get the new location object */
if (NULL == (link_vol_obj = (H5VL_object_t *)H5VL_vol_object(link_loc_id)))
if (NULL == (link_vol_obj = H5VL_vol_object(link_loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier");

/* Make sure that the VOL connectors are the same */
Expand Down
12 changes: 6 additions & 6 deletions src/H5Ldeprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ H5Literate1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified");

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

/* Check if the VOL object is a native VOL connector object */
Expand Down Expand Up @@ -248,7 +248,7 @@ H5Literate_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "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, FAIL, "invalid location identifier");

/* Check if the VOL object is a native VOL connector object */
Expand Down Expand Up @@ -325,7 +325,7 @@ H5Lget_info1(hid_t loc_id, const char *name, H5L_info1_t *linfo /*out*/, hid_t l
loc_params.loc_data.loc_by_name.lapl_id = lapl_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, FAIL, "invalid location identifier");

/* Check if the VOL object is a native VOL connector object */
Expand Down Expand Up @@ -416,7 +416,7 @@ H5Lget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H
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, FAIL, "invalid location identifier");

/* Check if the VOL object is a native VOL connector object */
Expand Down Expand Up @@ -515,7 +515,7 @@ H5Lvisit1(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterat
loc_params.obj_type = H5I_get_type(group_id);

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

/* Check if the VOL object is a native VOL connector object */
Expand Down Expand Up @@ -604,7 +604,7 @@ H5Lvisit_by_name1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "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, FAIL, "invalid location identifier");

/* Check if the VOL object is a native VOL connector object */
Expand Down
9 changes: 9 additions & 0 deletions test/th5o.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ test_h5o_plist(void)
hid_t grp, dset, dtype, dspace; /* Object identifiers */
hid_t fapl; /* File access property list */
hid_t gcpl, dcpl, tcpl; /* Object creation properties */
hid_t bad_pl=H5I_INVALID_HID; /* Invalid property list dues to invalid arg */
char filename[1024];
unsigned def_max_compact, def_min_dense; /* Default phase change parameters */
unsigned max_compact, min_dense; /* Actual phase change parameters */
Expand Down Expand Up @@ -854,6 +855,14 @@ test_h5o_plist(void)
dcpl = H5Dget_create_plist(dset);
CHECK(dcpl, FAIL, "H5Dget_create_plist");

/* Test passing in a non-group identifier to the H5G API */
H5E_BEGIN_TRY
{
bad_pl = H5Gget_create_plist(dtype);
}
H5E_END_TRY
VERIFY(bad_pl, H5I_INVALID_HID, "H5Gget_create_plist");

/* Retrieve attribute phase change values on each creation property list and verify */
ret = H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
Expand Down

0 comments on commit 33f761a

Please sign in to comment.