From a67ba27a071668592677b5794c8fbeb18e11f22e Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 17 Oct 2024 15:57:36 -0500 Subject: [PATCH] Remove another couple of H5E_clear_stack calls Also clean up links test. Signed-off-by: Quincey Koziol --- src/H5Dvirtual.c | 23 +- src/H5Gloc.c | 5 +- src/H5Gtraverse.c | 13 +- test/links.c | 666 ++++++++++++++++++++++++++-------------------- 4 files changed, 401 insertions(+), 306 deletions(-) diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index d10f4af8520..01ca405a6eb 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -890,6 +890,7 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, H5O_storage_virtual_ent_t *vir if (src_file) { H5G_loc_t src_root_loc; /* Object location of source file root group */ + bool exists = false; /* Set up the root group in the destination file */ if (NULL == (src_root_loc.oloc = H5G_oloc(H5G_rootof(src_file)))) @@ -897,18 +898,17 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, H5O_storage_virtual_ent_t *vir if (NULL == (src_root_loc.path = H5G_nameof(H5G_rootof(src_file)))) HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to get path for root group"); - /* Try opening the source dataset */ - source_dset->dset = H5D__open_name(&src_root_loc, source_dset->dset_name, - vdset->shared->layout.storage.u.virt.source_dapl); + /* Check if the source dataset exists */ + if (H5G_loc_exists(&src_root_loc, source_dset->dset_name, &exists /*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFIND, FAIL, "can't check object's existence"); - /* Dataset does not exist */ - if (NULL == source_dset->dset) { - /* Reset the error stack */ - H5E_clear_stack(); + /* Dataset exists */ + if (exists) { + /* Try opening the source dataset */ + if (NULL == (source_dset->dset = H5D__open_name(&src_root_loc, source_dset->dset_name, + vdset->shared->layout.storage.u.virt.source_dapl))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open source dataset"); - source_dset->dset_exists = false; - } /* end if */ - else { /* Dataset exists */ source_dset->dset_exists = true; @@ -919,6 +919,9 @@ H5D__virtual_open_source_dset(const H5D_t *vdset, H5O_storage_virtual_ent_t *vir virtual_ent->source_space_status = H5O_VIRTUAL_STATUS_CORRECT; } /* end if */ } /* end else */ + else + /* Dataset does not exist */ + source_dset->dset_exists = false; } /* end if */ done: diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 7bb59ea9e2f..2bbca9ce7e5 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -588,10 +588,7 @@ H5G__loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_ /* Check if the name in this group resolved to a valid object */ if (obj_loc == NULL) - if (lnk) - *exists = false; - else - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no object or link info?"); + *exists = false; else *exists = true; diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index d113b576b18..7c2a7d08d13 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -180,7 +180,11 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc /*in,out*/, const H5O_link_t *lnk, H5G if ((cur_grp = H5VL_wrap_register(H5I_GROUP, grp, false)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "unable to register group"); - /* User-defined callback function */ + /* Pause recording errors, if we are just checking for object's existance */ + if (target & H5G_TARGET_EXISTS) + H5E_pause_stack(); + + /* Invoke user-defined callback function */ #ifndef H5_NO_DEPRECATED_SYMBOLS /* (Backwardly compatible with v0 H5L_class_t traversal callback) */ if (link_class->version == H5L_LINK_CLASS_T_VERS_0) @@ -194,13 +198,14 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc /*in,out*/, const H5O_link_t *lnk, H5G H5CX_get_dxpl()); #endif /* H5_NO_DEPRECATED_SYMBOLS */ + /* Resume recording errors, if we were just checking for object's existance */ + if (target & H5G_TARGET_EXISTS) + H5E_resume_stack(); + /* Check for failing to locate the object */ if (cb_return < 0) { /* Check if we just needed to know if the object exists */ if (target & H5G_TARGET_EXISTS) { - /* Clear any errors from the stack */ - H5E_clear_stack(); - /* Indicate that the object doesn't exist */ *obj_exists = false; diff --git a/test/links.c b/test/links.c index ad9948af04d..db804134f14 100644 --- a/test/links.c +++ b/test/links.c @@ -495,6 +495,7 @@ new_links(hid_t fapl, bool new_format) hid_t dset1 = (H5I_INVALID_HID), dset2 = (H5I_INVALID_HID); char filename[NAME_BUF_SIZE]; hsize_t size[1] = {1}; + herr_t status; /* Generic return value */ if (new_format) TESTING("H5Lcreate functions (w/new group format)"); @@ -535,24 +536,27 @@ new_links(hid_t fapl, bool new_format) * H5L_SAME_LOC. Both hard and soft links should fail. */ H5E_BEGIN_TRY { - if (H5Lcreate_hard(H5L_SAME_LOC, "dataset1", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT) != FAIL) - TEST_ERROR; + status = H5Lcreate_hard(H5L_SAME_LOC, "dataset1", H5L_SAME_LOC, "hard", H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; H5E_BEGIN_TRY { - if (H5Lcreate_soft("dataset1", H5L_SAME_LOC, "soft", H5P_DEFAULT, H5P_DEFAULT) != FAIL) - TEST_ERROR; + status = H5Lcreate_soft("dataset1", H5L_SAME_LOC, "soft", H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Create links across files with hard link. Should fail. */ H5E_BEGIN_TRY { - if (H5Lcreate_hard(file_a, "dataset1", file_b, "hard", H5P_DEFAULT, H5P_DEFAULT) != FAIL) - TEST_ERROR; + status = H5Lcreate_hard(file_a, "dataset1", file_b, "hard", H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Create hard link to test H5L_SAME_LOC */ if (H5Lcreate_hard(grp1_a, "dataset2", H5L_SAME_LOC, "hard1", H5P_DEFAULT, H5P_DEFAULT) < 0) @@ -1361,6 +1365,7 @@ test_move(hid_t fapl, bool new_format) hid_t grp_1 = H5I_INVALID_HID, grp_2 = H5I_INVALID_HID, grp_move = H5I_INVALID_HID, moved_grp = H5I_INVALID_HID; char filename[1024]; + herr_t status; /* Generic return value */ if (new_format) TESTING("H5Lmove (w/new group format)"); @@ -1395,19 +1400,20 @@ test_move(hid_t fapl, bool new_format) * H5L_SAME_LOC. Should fail. */ H5E_BEGIN_TRY { - if (H5Lmove(H5L_SAME_LOC, "group_move", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != - FAIL) - TEST_ERROR; + status = H5Lmove(H5L_SAME_LOC, "group_move", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Move a group across files. Should fail. */ H5E_BEGIN_TRY { - if (H5Lmove(grp_1, "group_move", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != FAIL) - TEST_ERROR; + status = H5Lmove(grp_1, "group_move", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Move a soft link across files. Should succeed. */ if (H5Lmove(grp_2, "soft", file_b, "soft_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) @@ -1478,16 +1484,44 @@ test_move(hid_t fapl, bool new_format) /* Verify that the group is in no previous locations */ H5E_BEGIN_TRY { - if ((moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT)) >= 0) - FAIL_STACK_ERROR; - if ((moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT)) >= 0) - FAIL_STACK_ERROR; - if ((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) >= 0) - FAIL_STACK_ERROR; - if ((moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT)) >= 0) - FAIL_STACK_ERROR; + moved_grp = H5Gopen2(grp_1, "group_newer_name", H5P_DEFAULT); } H5E_END_TRY + if (moved_grp >= 0) { + H5_FAILED(); + puts(" Group still in earlier location?"); + TEST_ERROR; + } /* end if */ + H5E_BEGIN_TRY + { + moved_grp = H5Gopen2(grp_2, "group_newer_name", H5P_DEFAULT); + } + H5E_END_TRY + if (moved_grp >= 0) { + H5_FAILED(); + puts(" Group still in earlier location?"); + TEST_ERROR; + } /* end if */ + H5E_BEGIN_TRY + { + moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT); + } + H5E_END_TRY + if (moved_grp >= 0) { + H5_FAILED(); + puts(" Group still in earlier location?"); + TEST_ERROR; + } /* end if */ + H5E_BEGIN_TRY + { + moved_grp = H5Gopen2(grp_1, "group_copy", H5P_DEFAULT); + } + H5E_END_TRY + if (moved_grp >= 0) { + H5_FAILED(); + puts(" Group still in earlier location?"); + TEST_ERROR; + } /* end if */ H5Gclose(grp_1); H5Gclose(grp_2); @@ -1529,6 +1563,7 @@ test_copy(hid_t fapl, bool new_format) hid_t grp_1 = H5I_INVALID_HID, grp_2 = H5I_INVALID_HID, grp_move = H5I_INVALID_HID, moved_grp = H5I_INVALID_HID; char filename[1024]; + herr_t status; /* Generic return value */ if (new_format) TESTING("H5Lcopy (w/new group format)"); @@ -1563,19 +1598,20 @@ test_copy(hid_t fapl, bool new_format) * H5L_SAME_LOC. Should fail. */ H5E_BEGIN_TRY { - if (H5Lcopy(H5L_SAME_LOC, "group_copy", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != - FAIL) - TEST_ERROR; + status = H5Lcopy(H5L_SAME_LOC, "group_copy", H5L_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Copy a group across files. Should fail. */ H5E_BEGIN_TRY { - if (H5Lcopy(grp_1, "group_copy", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != FAIL) - TEST_ERROR; + status = H5Lcopy(grp_1, "group_copy", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Copy a soft link across files. Should succeed. */ if (H5Lcopy(grp_2, "soft", file_b, "soft_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) @@ -1946,12 +1982,14 @@ test_deprec(hid_t fapl, bool new_format) hid_t group1_id = H5I_INVALID_HID; hid_t group2_id = H5I_INVALID_HID; hid_t group3_id = H5I_INVALID_HID; + hid_t group4_id = H5I_INVALID_HID; H5G_stat_t sb_hard1, sb_hard2, sb_soft1, sb_soft2; H5G_obj_t obj_type; /* Object type */ hsize_t num_objs; /* Number of objects in a group */ char filename[1024]; char tmpstr[1024]; int len = 0; /* Length of comment */ + herr_t status; /* Generic return value */ if (new_format) TESTING("backwards compatibility (w/new group format)"); @@ -2006,10 +2044,11 @@ test_deprec(hid_t fapl, bool new_format) TEST_ERROR; H5E_BEGIN_TRY { - if (H5Gget_objname_by_idx(group1_id, (hsize_t)1, tmpstr, sizeof(tmpstr)) >= 0) - TEST_ERROR; + len = (int)H5Gget_objname_by_idx(group1_id, (hsize_t)1, tmpstr, sizeof(tmpstr)); } H5E_END_TRY + if (len >= 0) + TEST_ERROR; /* Test getting the type for objects */ if ((obj_type = H5Gget_objtype_by_idx(group1_id, (hsize_t)0)) < 0) @@ -2018,10 +2057,11 @@ test_deprec(hid_t fapl, bool new_format) TEST_ERROR; H5E_BEGIN_TRY { - if (H5Gget_objtype_by_idx(group1_id, (hsize_t)1) >= 0) - TEST_ERROR; + status = H5Gget_objtype_by_idx(group1_id, (hsize_t)1); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Test getting the number of objects in a group */ if (H5Gget_num_objs(file_id, &num_objs) < 0) @@ -2097,10 +2137,11 @@ test_deprec(hid_t fapl, bool new_format) /* Test non-existing links with H5Gget_objinfo */ H5E_BEGIN_TRY { - if (H5Gget_objinfo(file_id, "/group2/soft_link_no_exist", true, NULL) >= 0) - FAIL_STACK_ERROR; + status = H5Gget_objinfo(file_id, "/group2/soft_link_no_exist", true, NULL); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Test the dangling soft link */ if (H5Gget_objinfo(file_id, "/group2/dangle_soft_link", false, &sb_soft2) < 0) @@ -2140,20 +2181,20 @@ test_deprec(hid_t fapl, bool new_format) /* Test passing in invalid ID */ H5E_BEGIN_TRY { - hid_t bad_id = H5I_BADID; - if (H5Gmove2(bad_id, "group2", group1_id, "moved_group2") >= 0) - TEST_ERROR; + status = H5Gmove2(H5I_BADID, "group2", group1_id, "moved_group2"); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Test passing in invalid ID */ H5E_BEGIN_TRY { - hid_t bad_id = H5I_BADID; - if (H5Gmove2(file_id, "group2", bad_id, "moved_group2") >= 0) - TEST_ERROR; + status = H5Gmove2(H5I_BADID, "group2", H5I_BADID, "moved_group2"); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Ensure that both groups can be opened */ if (H5Gclose(group2_id) < 0) @@ -2180,10 +2221,11 @@ test_deprec(hid_t fapl, bool new_format) H5E_BEGIN_TRY { - if (H5Gopen2(file_id, "moved_group1/moved_group2", H5P_DEFAULT) >= 0) - TEST_ERROR; + group4_id = H5Gopen2(file_id, "moved_group1/moved_group2", H5P_DEFAULT); } H5E_END_TRY + if (group4_id >= 0) + TEST_ERROR; if (H5Fclose(file_id) < 0) FAIL_STACK_ERROR; @@ -3073,6 +3115,7 @@ external_link_query_deprec(hid_t fapl, bool new_format) H5L_info1_t li; /* Link information */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], /* Names of files to externally link across */ query_buf[NAME_BUF_SIZE]; /* Buffer to hold query result */ + herr_t status; /* Generic return value */ if (new_format) TESTING("query aspects of external link using deprecated routines (w/new group format)"); @@ -3170,28 +3213,32 @@ external_link_query_deprec(hid_t fapl, bool new_format) /* Make sure that bogus cases trigger errors in H5Lunpack_elink_val */ H5E_BEGIN_TRY { - if (H5Lunpack_elink_val(query_buf, li.u.val_size - 1, NULL, NULL, NULL) >= 0) - TEST_ERROR; + status = H5Lunpack_elink_val(query_buf, li.u.val_size - 1, NULL, NULL, NULL); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; H5E_BEGIN_TRY { - if (H5Lunpack_elink_val(query_buf, (size_t)0, NULL, NULL, NULL) >= 0) - TEST_ERROR; + status = H5Lunpack_elink_val(query_buf, (size_t)0, NULL, NULL, NULL); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; H5E_BEGIN_TRY { - if (H5Lunpack_elink_val(NULL, (size_t)0, NULL, NULL, NULL) >= 0) - TEST_ERROR; + status = H5Lunpack_elink_val(NULL, (size_t)0, NULL, NULL, NULL); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; H5E_BEGIN_TRY { - if (H5Lunpack_elink_val(NULL, (size_t)1000, NULL, NULL, NULL) >= 0) - TEST_ERROR; + status = H5Lunpack_elink_val(NULL, (size_t)1000, NULL, NULL, NULL); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; PASSED(); return SUCCEED; @@ -3231,6 +3278,7 @@ external_link_closing_deprec(hid_t fapl, bool new_format) H5L_info1_t li; H5O_info1_t oi; hobj_ref_t obj_ref; + herr_t status; /* Generic return value */ if (new_format) TESTING("that external files are closed during traversal (w/new group format)"); @@ -3390,12 +3438,18 @@ external_link_closing_deprec(hid_t fapl, bool new_format) TEST_ERROR; H5E_BEGIN_TRY { - if (H5Fmount(fid1, "elink/elink/elink/mnt", fid1, H5P_DEFAULT) >= 0) - TEST_ERROR; - if (H5Funmount(fid1, "elink/elink/elink/mnt") >= 0) - TEST_ERROR; + status = H5Fmount(fid1, "elink/elink/elink/mnt", fid1, H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Funmount(fid1, "elink/elink/elink/mnt"); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Test H5Rcreate */ if (H5Rcreate(&obj_ref, fid1, "elink/elink/elink/type1_moved", H5R_OBJECT, (hid_t)(-1)) < 0) @@ -3856,6 +3910,7 @@ ud_link_reregister_deprec(hid_t fapl) char objname[NAME_BUF_SIZE]; /* Object name */ char filename[NAME_BUF_SIZE]; h5_stat_size_t empty_size; /* Size of an empty file */ + herr_t status; /* Generic return value */ TESTING("registering a new class for existing UD links using deprecated routines (w/new group format)"); @@ -3915,19 +3970,20 @@ ud_link_reregister_deprec(hid_t fapl) /* Verify that we can't traverse the ud link anymore */ H5E_BEGIN_TRY { - if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) >= 0) - TEST_ERROR; + gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT); } H5E_END_TRY + if (gid >= 0) + TEST_ERROR; /* Verify that we can't create any new links of this type */ H5E_BEGIN_TRY { - if (H5Lcreate_ud(fid, "ud_link2", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), sizeof(li.u.address), - H5P_DEFAULT, H5P_DEFAULT) >= 0) - TEST_ERROR; + status = H5Lcreate_ud(fid, "ud_link2", (H5L_type_t)UD_HARD_TYPE, &(li.u.address), sizeof(li.u.address), H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Register a new kind of link with the same ID number */ if (H5Lregister(UD_rereg_class) < 0) @@ -4041,6 +4097,7 @@ ud_callbacks_deprec(hid_t fapl, bool new_format) char ud_target_name[] = UD_CB_TARGET; /* Link target name */ char filename[NAME_BUF_SIZE]; char query_buf[NAME_BUF_SIZE]; + herr_t status; /* Generic return value */ if (new_format) TESTING("user-defined link callbacks using deprecated routines (w/new group format)"); @@ -4154,19 +4211,39 @@ ud_callbacks_deprec(hid_t fapl, bool new_format) /* Now test that each of the callbacks fails */ H5E_BEGIN_TRY { - if (H5Lcreate_ud(fid, NEW_UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, - (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) >= 0) - FAIL_STACK_ERROR; - if (H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) >= 0) - FAIL_STACK_ERROR; - if (H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) - FAIL_STACK_ERROR; - if ((gid = H5Gopen2(gid, UD_CB_LINK_NAME, H5P_DEFAULT)) >= 0) - FAIL_STACK_ERROR; - if (H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) - FAIL_STACK_ERROR; + status = H5Lcreate_ud(fid, NEW_UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + gid = H5Gopen2(gid, UD_CB_LINK_NAME, H5P_DEFAULT); + } + H5E_END_TRY + if (gid >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* The query callback should NOT fail, but should be unable to give a linklen */ if (H5Lget_info1(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) @@ -4427,14 +4504,25 @@ lapl_nlinks_deprec(hid_t fapl, bool new_format) /* Try to open the objects using too many symlinks with default *APLs */ H5E_BEGIN_TRY { - if ((gid = H5Gopen2(fid, "soft17", H5P_DEFAULT)) >= 0) - FAIL_PUTS_ERROR(" Should have failed for too many nested links."); - if ((tid = H5Topen2(fid, "soft17/datatype", H5P_DEFAULT)) >= 0) - FAIL_PUTS_ERROR(" Should have failed for too many nested links."); - if ((did = H5Dopen2(fid, "soft17/dataset", H5P_DEFAULT)) >= 0) - FAIL_PUTS_ERROR(" Should have failed for too many nested links."); + gid = H5Gopen2(fid, "soft17", H5P_DEFAULT); + } + H5E_END_TRY + if (gid >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + tid = H5Topen2(fid, "soft17/datatype", H5P_DEFAULT); + } + H5E_END_TRY + if (tid >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + did = H5Dopen2(fid, "soft17/dataset", H5P_DEFAULT); } H5E_END_TRY + if (did >= 0) + TEST_ERROR; /* Create property lists with nlinks set */ if ((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) @@ -5205,16 +5293,14 @@ link_info_by_idx_deprec(hid_t fapl) /* Check for query on empty group */ H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &linfo, - H5P_DEFAULT); + ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &linfo, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) TEST_ERROR; H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, - tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY if (name_len >= 0) @@ -5257,24 +5343,21 @@ link_info_by_idx_deprec(hid_t fapl) /* Check for out of bound offset queries */ H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, - H5P_DEFAULT); + ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) TEST_ERROR; H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, - H5P_DEFAULT); + ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) TEST_ERROR; H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, - tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY if (name_len >= 0) @@ -5317,8 +5400,7 @@ link_info_by_idx_deprec(hid_t fapl) /* Check for out of bound offset queries */ H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, - H5P_DEFAULT); + ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) @@ -5533,16 +5615,14 @@ link_info_by_idx_old_deprec(hid_t fapl) /* Check for creation order index queries */ H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, - H5P_DEFAULT); + ret = H5Lget_info_by_idx1(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) TEST_ERROR; H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, - (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY if (name_len >= 0) @@ -6997,8 +7077,7 @@ link_iterate_old_check_deprec(hid_t group_id, H5_iter_order_t order, unsigned ma skip = 0; H5E_BEGIN_TRY { - ret = H5Literate1((hid_t)(H5I_INVALID_HID), H5_INDEX_NAME, order, &skip, link_iterate_fail_deprec_cb, - NULL); + ret = H5Literate1((hid_t)(H5I_INVALID_HID), H5_INDEX_NAME, order, &skip, link_iterate_fail_deprec_cb, NULL); } H5E_END_TRY if (ret >= 0) @@ -9016,11 +9095,7 @@ external_link_chdir(hid_t fapl, bool new_format) TEST_ERROR; /* Open object through external link */ - H5E_BEGIN_TRY - { - gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } - H5E_END_TRY + gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); if (HDchdir("..") < 0) TEST_ERROR; @@ -10461,12 +10536,11 @@ external_link_win1(hid_t fapl, bool new_format) /* Open object through external link */ H5E_BEGIN_TRY { - gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); } H5E_END_TRY /* should be able to find the target file via main file's CWD*/ - if (gid < 0) { + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { H5_FAILED(); puts(" Should have found the file in CWD."); goto error; @@ -10555,14 +10629,8 @@ external_link_win2(hid_t fapl, bool new_format) TEST_ERROR; /* Open object through external link */ - H5E_BEGIN_TRY - { - gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } - H5E_END_TRY - /* should be able to find the target file directly */ - if (gid < 0) { + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { H5_FAILED(); puts(" Should have found the file in tmp_links."); goto error; @@ -10649,14 +10717,8 @@ external_link_win3(hid_t fapl, bool new_format) TEST_ERROR; /* Open object through external link */ - H5E_BEGIN_TRY - { - gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } - H5E_END_TRY - /* should be able to find the target file directly */ - if (gid < 0) { + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { H5_FAILED(); puts(" Should have found the file in tmp_links."); goto error; @@ -10740,14 +10802,8 @@ external_link_win4(hid_t fapl, bool new_format) TEST_ERROR; /* Open object through external link */ - H5E_BEGIN_TRY - { - gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } - H5E_END_TRY - /* should be able to find the target file via main file's absolute drive/relative path */ - if (gid < 0) { + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { H5_FAILED(); puts(" Should have found the file in CWD."); goto error; @@ -10841,14 +10897,8 @@ external_link_win5(hid_t fapl, bool new_format) TEST_ERROR; /* Open object through external link */ - H5E_BEGIN_TRY - { - gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } - H5E_END_TRY - /* should be able to find the target file via main file's rel drive/abs path */ - if (gid < 0) { + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { H5_FAILED(); puts(" Should have found the file in CWD."); goto error; @@ -10939,14 +10989,8 @@ external_link_win6(hid_t fapl, bool new_format) TEST_ERROR; /* Open object through external link */ - H5E_BEGIN_TRY - { - gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } - H5E_END_TRY - /* should be able to find the target file via target file's rel path in current drive */ - if (gid < 0) { + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { H5_FAILED(); puts(" Should have found the file in tmp_links."); goto error; @@ -11034,14 +11078,8 @@ external_link_win7(hid_t fapl, bool new_format) TEST_ERROR; /* Open object through external link */ - H5E_BEGIN_TRY - { - gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } - H5E_END_TRY - /* should be able to find the target file via main file's local host/main drive*/ - if (gid < 0) { + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { H5_FAILED(); puts(" Should have found the file in local host/main drive."); goto error; @@ -11134,14 +11172,8 @@ external_link_win8(hid_t fapl, bool new_format) TEST_ERROR; /* Open object through external link */ - H5E_BEGIN_TRY - { - gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } - H5E_END_TRY - /* should be able to find the target file directly */ - if (gid < 0) { + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { H5_FAILED(); puts(" Should have found the file in tmp_links."); goto error; @@ -11229,14 +11261,8 @@ external_link_win9(hid_t fapl, bool new_format) TEST_ERROR; /* Open object through external link */ - H5E_BEGIN_TRY - { - gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT); - } - H5E_END_TRY - /* should be able to find the target file via main file's local host/main drive*/ - if (gid < 0) { + if ((gid = H5Gopen2(fid, "ext_link", H5P_DEFAULT)) < 0) { H5_FAILED(); puts(" Should have found the file in local host/main drive."); goto error; @@ -11353,6 +11379,7 @@ external_link_query(hid_t fapl, bool new_format) H5L_info2_t li; /* Link information */ char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], /* Names of files to externally link across */ query_buf[NAME_BUF_SIZE]; /* Buffer to hold query result */ + herr_t status; /* Generic return value */ if (new_format) TESTING("query aspects of external link (w/new group format)"); @@ -11450,28 +11477,32 @@ external_link_query(hid_t fapl, bool new_format) /* Make sure that bogus cases trigger errors in H5Lunpack_elink_val */ H5E_BEGIN_TRY { - if (H5Lunpack_elink_val(query_buf, li.u.val_size - 1, NULL, NULL, NULL) >= 0) - TEST_ERROR; + status = H5Lunpack_elink_val(query_buf, li.u.val_size - 1, NULL, NULL, NULL); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; H5E_BEGIN_TRY { - if (H5Lunpack_elink_val(query_buf, (size_t)0, NULL, NULL, NULL) >= 0) - TEST_ERROR; + status = H5Lunpack_elink_val(query_buf, (size_t)0, NULL, NULL, NULL); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; H5E_BEGIN_TRY { - if (H5Lunpack_elink_val(NULL, (size_t)0, NULL, NULL, NULL) >= 0) - TEST_ERROR; + status = H5Lunpack_elink_val(NULL, (size_t)0, NULL, NULL, NULL); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; H5E_BEGIN_TRY { - if (H5Lunpack_elink_val(NULL, (size_t)1000, NULL, NULL, NULL) >= 0) - TEST_ERROR; + status = H5Lunpack_elink_val(NULL, (size_t)1000, NULL, NULL, NULL); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; PASSED(); return SUCCEED; @@ -12247,6 +12278,7 @@ external_link_closing(hid_t fapl, bool new_format) H5L_info2_t li; H5O_info2_t oi; hobj_ref_t obj_ref; + herr_t status; /* Generic return value */ if (new_format) TESTING("that external files are closed during traversal (w/new group format)"); @@ -12405,12 +12437,18 @@ external_link_closing(hid_t fapl, bool new_format) TEST_ERROR; H5E_BEGIN_TRY { - if (H5Fmount(fid1, "elink/elink/elink/mnt", fid1, H5P_DEFAULT) >= 0) - TEST_ERROR; - if (H5Funmount(fid1, "elink/elink/elink/mnt") >= 0) - TEST_ERROR; + status = H5Fmount(fid1, "elink/elink/elink/mnt", fid1, H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Funmount(fid1, "elink/elink/elink/mnt"); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Test H5Rcreate */ if (H5Rcreate(&obj_ref, fid1, "elink/elink/elink/type1_moved", H5R_OBJECT, (hid_t)(-1)) < 0) @@ -14496,6 +14534,7 @@ ud_link_reregister(hid_t fapl) char objname[NAME_BUF_SIZE]; /* Object name */ char filename[NAME_BUF_SIZE]; h5_stat_size_t empty_size; /* Size of an empty file */ + herr_t status; /* Generic return value */ TESTING("registering a new class for existing UD links (w/new group format)"); @@ -14555,19 +14594,20 @@ ud_link_reregister(hid_t fapl) /* Verify that we can't traverse the ud link anymore */ H5E_BEGIN_TRY { - if ((gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT)) >= 0) - TEST_ERROR; + gid = H5Gopen2(fid, "ud_link", H5P_DEFAULT); } H5E_END_TRY + if (gid >= 0) + TEST_ERROR; /* Verify that we can't create any new links of this type */ H5E_BEGIN_TRY { - if (H5Lcreate_ud(fid, "ud_link2", (H5L_type_t)UD_HARD_TYPE, &(li.u.token), sizeof(H5O_token_t), - H5P_DEFAULT, H5P_DEFAULT) >= 0) - TEST_ERROR; + status = H5Lcreate_ud(fid, "ud_link2", (H5L_type_t)UD_HARD_TYPE, &(li.u.token), sizeof(H5O_token_t), H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Register a new kind of link with the same ID number */ if (H5Lregister(UD_rereg_class) < 0) @@ -14825,6 +14865,7 @@ ud_callbacks(hid_t fapl, bool new_format) char ud_target_name[] = UD_CB_TARGET; /* Link target name */ char filename[NAME_BUF_SIZE]; char query_buf[NAME_BUF_SIZE]; + herr_t status; /* Generic return value */ if (new_format) TESTING("user-defined link callbacks (w/new group format)"); @@ -14938,19 +14979,39 @@ ud_callbacks(hid_t fapl, bool new_format) /* Now test that each of the callbacks fails */ H5E_BEGIN_TRY { - if (H5Lcreate_ud(fid, NEW_UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, - (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT) >= 0) - FAIL_STACK_ERROR; - if (H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) >= 0) - FAIL_STACK_ERROR; - if (H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) - FAIL_STACK_ERROR; - if ((gid = H5Gopen2(gid, UD_CB_LINK_NAME, H5P_DEFAULT)) >= 0) - FAIL_STACK_ERROR; - if (H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT) >= 0) - FAIL_STACK_ERROR; + status = H5Lcreate_ud(fid, NEW_UD_CB_LINK_NAME, (H5L_type_t)UD_CB_TYPE, ud_target_name, (size_t)UD_CB_TARGET_LEN, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Lmove(fid, UD_CB_LINK_NAME, H5L_SAME_LOC, NEW_UD_CB_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + gid = H5Gopen2(gid, UD_CB_LINK_NAME, H5P_DEFAULT); + } + H5E_END_TRY + if (gid >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Ldelete(fid, UD_CB_LINK_NAME, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* The query callback should NOT fail, but should be unable to give a linklen */ if (H5Lget_info2(fid, UD_CB_LINK_NAME, &li, H5P_DEFAULT) < 0) @@ -15349,6 +15410,7 @@ ud_link_errors(hid_t fapl, bool new_format) char filename[NAME_BUF_SIZE]; char query_buf[NAME_BUF_SIZE]; H5L_info2_t li; /* Link information */ + herr_t status; /* Generic return value */ if (new_format) TESTING("user-defined link error conditions (w/new group format)"); @@ -15363,16 +15425,32 @@ ud_link_errors(hid_t fapl, bool new_format) /* Try to register some invalid link classes */ H5E_BEGIN_TRY { - if (H5Lregister(UD_error1_class) >= 0) - TEST_ERROR; - if (H5Lregister(UD_error2_class) >= 0) - TEST_ERROR; - if (H5Lregister(UD_error3_class) >= 0) - TEST_ERROR; - if (H5Lregister(UD_error4_class) >= 0) - TEST_ERROR; + status = H5Lregister(UD_error1_class); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Lregister(UD_error2_class); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Lregister(UD_error3_class); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Lregister(UD_error4_class); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Register the UD plist class. */ if (H5Lregister(UD_plist_class) < 0) @@ -15391,21 +15469,28 @@ ud_link_errors(hid_t fapl, bool new_format) /* Try to create internally defined links with H5Lcreate_ud */ H5E_BEGIN_TRY { - if (H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_HARD, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) >= 0) - TEST_ERROR; - if (H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_SOFT, "str", (size_t)4, H5P_DEFAULT, H5P_DEFAULT) >= 0) - TEST_ERROR; + status = H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_HARD, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Lcreate_ud(fid, "/ud_link", H5L_TYPE_SOFT, "str", (size_t)4, H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Try to create a link with H5Lcreate_ud that has a NULL udata pointer, but a non-zero udata_size value */ H5E_BEGIN_TRY { - if (H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, NULL, 1, H5P_DEFAULT, H5P_DEFAULT) >= 0) - TEST_ERROR; + status = H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, NULL, 1, H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Create a user-defined link to the group. */ strcpy(group_name, "/group"); @@ -15423,31 +15508,56 @@ ud_link_errors(hid_t fapl, bool new_format) H5E_BEGIN_TRY { /* The create callback will fail if we pass in no udata */ - if (H5Lcreate_ud(fid, "fail", (H5L_type_t)UD_CBFAIL_TYPE, NULL, (size_t)0, H5P_DEFAULT, - H5P_DEFAULT) >= 0) - TEST_ERROR; + status = H5Lcreate_ud(fid, "fail", (H5L_type_t)UD_CBFAIL_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { /* The move and copy callbacks will fail */ - if (H5Lmove(fid, "ud_link", H5L_SAME_LOC, "move_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) - TEST_ERROR; - if (H5Lcopy(fid, "ud_link", fid, "copy_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) - TEST_ERROR; + status = H5Lmove(fid, "ud_link", H5L_SAME_LOC, "move_fail", H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + status = H5Lcopy(fid, "ud_link", fid, "copy_fail", H5P_DEFAULT, H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; - /* The traversal callback will fail if we remove its target */ - if (H5Ldelete(fid, "group", H5P_DEFAULT) < 0) - TEST_ERROR; - if ((gid = H5Gopen2(gid, "ud_link", H5P_DEFAULT)) >= 0) - TEST_ERROR; + /* The traversal callback will fail (when opening the object) if we remove its target */ + if (H5Ldelete(fid, "group", H5P_DEFAULT) < 0) + FAIL_STACK_ERROR; + H5E_BEGIN_TRY + { + gid = H5Gopen2(gid, "ud_link", H5P_DEFAULT); + } + H5E_END_TRY + if (gid >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { /* The deletion callback will always fail */ - if (H5Ldelete(fid, "ud_link", H5P_DEFAULT) >= 0) - TEST_ERROR; + status = H5Ldelete(fid, "ud_link", H5P_DEFAULT); + } + H5E_END_TRY + if (status >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { /* The query callback will fail */ - if (H5Lget_info2(fid, "ud_link", &li, H5P_DEFAULT) >= 0) - TEST_ERROR; + status = H5Lget_info2(fid, "ud_link", &li, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Now use a class with different callback functions */ if (H5Lregister(UD_cbfail_class2) < 0) @@ -15456,10 +15566,11 @@ ud_link_errors(hid_t fapl, bool new_format) /* Moving should still fail, but copying will succeed */ H5E_BEGIN_TRY { - if (H5Lmove(fid, "ud_link", H5L_SAME_LOC, "move_fail", H5P_DEFAULT, H5P_DEFAULT) >= 0) - TEST_ERROR; + status = H5Lmove(fid, "ud_link", H5L_SAME_LOC, "move_fail", H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; if (H5Lcopy(fid, "ud_link", fid, "copy_succ", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; @@ -15471,10 +15582,11 @@ ud_link_errors(hid_t fapl, bool new_format) /* ...but fail when we try to write data to the buffer itself*/ H5E_BEGIN_TRY { - if (H5Lget_val(fid, "ud_link", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) >= 0) - TEST_ERROR; + status = H5Lget_val(fid, "ud_link", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY + if (status >= 0) + TEST_ERROR; /* Register a new class */ if (H5Lregister(UD_cbfail_class3) < 0) @@ -15745,14 +15857,25 @@ lapl_nlinks(hid_t fapl, bool new_format) /* Try to open the objects using too many symlinks with default *APLs */ H5E_BEGIN_TRY { - if ((gid = H5Gopen2(fid, "soft17", H5P_DEFAULT)) >= 0) - FAIL_PUTS_ERROR(" Should have failed for too many nested links."); - if ((tid = H5Topen2(fid, "soft17/datatype", H5P_DEFAULT)) >= 0) - FAIL_PUTS_ERROR(" Should have failed for too many nested links."); - if ((did = H5Dopen2(fid, "soft17/dataset", H5P_DEFAULT)) >= 0) - FAIL_PUTS_ERROR(" Should have failed for too many nested links."); + gid = H5Gopen2(fid, "soft17", H5P_DEFAULT); + } + H5E_END_TRY + if (gid >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + tid = H5Topen2(fid, "soft17/datatype", H5P_DEFAULT); } H5E_END_TRY + if (tid >= 0) + TEST_ERROR; + H5E_BEGIN_TRY + { + did = H5Dopen2(fid, "soft17/dataset", H5P_DEFAULT); + } + H5E_END_TRY + if (did >= 0) + TEST_ERROR; /* Create property lists with nlinks set */ if ((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) @@ -17089,7 +17212,7 @@ obj_exists(hid_t fapl, bool new_format) char filename[NAME_BUF_SIZE]; /* Buffer for file name */ hid_t fid = H5I_INVALID_HID; /* File ID */ hid_t gid = H5I_INVALID_HID; /* Group ID */ - herr_t status; /* Generic return value */ + htri_t status; /* Generic return value */ if (new_format) TESTING("object exists (w/new group format)"); @@ -17104,12 +17227,9 @@ obj_exists(hid_t fapl, bool new_format) /* Hard links */ /* Verify that H5Oexists_by_name() returns false for non-existent link in root group */ - H5E_BEGIN_TRY - { - status = H5Oexists_by_name(fid, "foo", H5P_DEFAULT); - } - H5E_END_TRY - if (status >= 0) + if ((status = H5Oexists_by_name(fid, "foo", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + if (status != 0) TEST_ERROR; /* Create a group, as a destination for testing */ @@ -17123,12 +17243,9 @@ obj_exists(hid_t fapl, bool new_format) TEST_ERROR; /* Verify that H5Oexists_by_name() returns false for non-existent object in non-root group */ - H5E_BEGIN_TRY - { - status = H5Oexists_by_name(fid, "group/foo", H5P_DEFAULT); - } - H5E_END_TRY - if (status >= 0) + if ((status = H5Oexists_by_name(fid, "group/foo", H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + if (status != 0) TEST_ERROR; /* Soft links */ @@ -17445,7 +17562,7 @@ corder_create_empty(hid_t fapl) ret = H5Pset_link_creation_order(gcpl_id, H5P_CRT_ORDER_INDEXED); } H5E_END_TRY - if (ret > 0) { + if (ret >= 0) { H5_FAILED(); puts( " H5Pset_link_create_order() should have failed for a creation order index with no tracking."); @@ -18561,16 +18678,14 @@ link_info_by_idx(hid_t fapl) /* Check for query on empty group */ H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &linfo, - H5P_DEFAULT); + ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, &linfo, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) TEST_ERROR; H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, - tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY if (name_len >= 0) @@ -18613,24 +18728,21 @@ link_info_by_idx(hid_t fapl) /* Check for out of bound offset queries */ H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, - H5P_DEFAULT); + ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) TEST_ERROR; H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, - H5P_DEFAULT); + ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) TEST_ERROR; H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, - tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY if (name_len >= 0) @@ -18673,24 +18785,21 @@ link_info_by_idx(hid_t fapl) /* Check for out of bound offset queries */ H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, - H5P_DEFAULT); + ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) TEST_ERROR; H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, - H5P_DEFAULT); + ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_DEC, (hsize_t)u, &linfo, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) TEST_ERROR; H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, - tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY if (name_len >= 0) @@ -18897,16 +19006,14 @@ link_info_by_idx_old(hid_t fapl) /* Check for creation order index queries */ H5E_BEGIN_TRY { - ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, - H5P_DEFAULT); + ret = H5Lget_info_by_idx2(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, &linfo, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) TEST_ERROR; H5E_BEGIN_TRY { - name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, - (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY if (name_len >= 0) @@ -21402,14 +21509,11 @@ object_info(hid_t fapl) TEST_ERROR; /* Set creation order tracking & indexing on group */ - if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | - (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < - 0) + if (H5Pset_link_creation_order(gcpl_id, (H5P_CRT_ORDER_TRACKED | (use_index ? H5P_CRT_ORDER_INDEXED : (unsigned)0))) < 0) TEST_ERROR; /* Create group with creation order tracking on */ - if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < - 0) + if ((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create group with creation order tracking on for soft links */ @@ -21420,8 +21524,7 @@ object_info(hid_t fapl) /* Check for out of bound query by index on empty group */ H5E_BEGIN_TRY { - ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &oinfo, - H5O_INFO_BASIC, H5P_DEFAULT); + ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) @@ -21436,8 +21539,7 @@ object_info(hid_t fapl) snprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < - 0) + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Retrieve group's address on disk */ @@ -21451,8 +21553,7 @@ object_info(hid_t fapl) snprintf(attrname, sizeof(attrname), "attr %02u", v); /* Create attribute */ - if ((attr_id = H5Acreate2(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT, - H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Close attribute */ @@ -21477,8 +21578,7 @@ object_info(hid_t fapl) /* Check for out of bound query by index */ H5E_BEGIN_TRY { - ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &oinfo, - H5O_INFO_BASIC, H5P_DEFAULT); + ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) @@ -21497,8 +21597,7 @@ object_info(hid_t fapl) snprintf(objname, sizeof(objname), "filler %02u", u); /* Create hard link, with group object */ - if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < - 0) + if ((group_id2 = H5Gcreate2(group_id, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Retrieve group's address on disk */ @@ -21512,8 +21611,7 @@ object_info(hid_t fapl) snprintf(attrname, sizeof(attrname), "attr %02u", v); /* Create attribute */ - if ((attr_id = H5Acreate2(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT, - H5P_DEFAULT)) < 0) + if ((attr_id = H5Acreate2(group_id2, attrname, H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Close attribute */ @@ -21538,8 +21636,7 @@ object_info(hid_t fapl) /* Check for out of bound query by index */ H5E_BEGIN_TRY { - ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &oinfo, - H5O_INFO_BASIC, H5P_DEFAULT); + ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) @@ -21738,8 +21835,7 @@ object_info_old(hid_t fapl) /* Check for out of bound query by index on empty group */ H5E_BEGIN_TRY { - ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &oinfo, H5O_INFO_BASIC, - H5P_DEFAULT); + ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) @@ -21794,8 +21890,7 @@ object_info_old(hid_t fapl) /* Check for out of bound query by index */ H5E_BEGIN_TRY { - ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &oinfo, H5O_INFO_BASIC, - H5P_DEFAULT); + ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) @@ -21804,8 +21899,7 @@ object_info_old(hid_t fapl) /* Check for creation order index query */ H5E_BEGIN_TRY { - ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_CRT_ORDER, order, (hsize_t)(u - 1), &oinfo, - H5O_INFO_BASIC, H5P_DEFAULT); + ret = H5Oget_info_by_idx3(group_id, ".", H5_INDEX_CRT_ORDER, order, (hsize_t)(u - 1), &oinfo, H5O_INFO_BASIC, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) @@ -21971,8 +22065,7 @@ group_info(hid_t fapl) /* Check for out of bound query by index on empty group */ H5E_BEGIN_TRY { - ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &grp_info, - H5P_DEFAULT); + ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, &grp_info, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) @@ -22163,8 +22256,7 @@ group_info(hid_t fapl) /* Check for out of bound query by index */ H5E_BEGIN_TRY { - ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &grp_info, - H5P_DEFAULT); + ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) @@ -22355,8 +22447,7 @@ group_info(hid_t fapl) /* Check for out of bound query by index */ H5E_BEGIN_TRY { - ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &grp_info, - H5P_DEFAULT); + ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)u, &grp_info, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0) @@ -22651,8 +22742,7 @@ group_info_old(hid_t fapl) /* Check for bad index query by index group */ H5E_BEGIN_TRY { - ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, order, (hsize_t)0, &grp_info, - H5P_DEFAULT); + ret = H5Gget_info_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, order, (hsize_t)0, &grp_info, H5P_DEFAULT); } H5E_END_TRY if (ret >= 0)