From 0db6cc4d275c73f8c1e02bc39e73d236060c8646 Mon Sep 17 00:00:00 2001 From: Binh-Minh Date: Thu, 29 Aug 2024 11:39:36 -0400 Subject: [PATCH 1/3] Replace non-VOL calls with VOL calls - part 5 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 GH-4730. --- src/H5Gdeprec.c | 26 +++++++++++++------------- src/H5M.c | 24 ++++++++++++------------ src/H5Mpublic.h | 22 ++++++++++++++++++++-- 3 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 72b328c730e..6871283ed03 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ diff --git a/src/H5M.c b/src/H5M.c index b196f0930b8..99984ea4fb1 100644 --- a/src/H5M.c +++ b/src/H5M.c @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ @@ -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 */ diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h index 44c78fe064f..7676d372b16 100644 --- a/src/H5Mpublic.h +++ b/src/H5Mpublic.h @@ -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 * From 07fabed94efb7262ace327252a92f6235aa184a5 Mon Sep 17 00:00:00 2001 From: Binh-Minh Date: Thu, 29 Aug 2024 13:30:59 -0400 Subject: [PATCH 2/3] Fix typo --- src/H5M.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/H5M.c b/src/H5M.c index 99984ea4fb1..bb8b4d9882b 100644 --- a/src/H5M.c +++ b/src/H5M.c @@ -359,8 +359,7 @@ H5Mcreate_async(const char *app_file, const char *app_func, unsigned app_line, h * the in-file datatype for values is defined by VAL_TYPE_ID. * 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 LCPL_ID, MCPL_ID, and - * MAPL_ID. + * specified through the property lists MCPL_ID and MAPL_ID. * * The resulting ID should be linked into the file with * H5Olink or it will be deleted when closed. From 5fea711a889bc2bee226a580d9f1af1a6b50e577 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Tue, 3 Sep 2024 11:20:43 -0500 Subject: [PATCH 3/3] Apply suggestions from code review --- src/H5Mpublic.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h index 7676d372b16..3d8a8c7f7c8 100644 --- a/src/H5Mpublic.h +++ b/src/H5Mpublic.h @@ -264,8 +264,8 @@ H5_DLL hid_t H5Mcreate_async(hid_t loc_id, const char *name, hid_t key_type_id, * 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. + * closed or it will be deleted. The map should be closed when the + * caller no longer requires it. * * \since 1.12.0 *