diff options
author | David Young <dyoung@hdfgroup.org> | 2020-03-31 18:13:39 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2020-03-31 18:13:39 (GMT) |
commit | 69fcb52eca6ec15f366c069fb9beb29190d58ba1 (patch) | |
tree | 22f4cc0752bf362e75d4e99b7c134bb4b3e25531 /test/genall5.c | |
parent | 817756a0e0a84a376e3c399f13ff495fde7a10a4 (diff) | |
download | hdf5-69fcb52eca6ec15f366c069fb9beb29190d58ba1.zip hdf5-69fcb52eca6ec15f366c069fb9beb29190d58ba1.tar.gz hdf5-69fcb52eca6ec15f366c069fb9beb29190d58ba1.tar.bz2 |
Prepare for reuse in vfd_swmr_zoo_{reader,writer}: in
validate_zoo()/check_zoo(), instead of checking/modifying the global
variable `pass`, just return `false` on failure, `true` on success.
Update test `cache_image` to match.
Diffstat (limited to 'test/genall5.c')
-rw-r--r-- | test/genall5.c | 2830 |
1 files changed, 1090 insertions, 1740 deletions
diff --git a/test/genall5.c b/test/genall5.c index 0904e9a..d9064d8 100644 --- a/test/genall5.c +++ b/test/genall5.c @@ -34,12 +34,10 @@ * Purpose: Create an empty "new style" group at the specified location * in the specified file. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 @@ -47,65 +45,50 @@ *------------------------------------------------------------------------- */ -void -ns_grp_0(hid_t fid, const char *group_name) { +bool +ns_grp_0(hid_t fid, const char *group_name) +{ hid_t gid = -1; hid_t gcpl = -1; herr_t ret; - if (pass) { - gcpl = H5Pcreate(H5P_GROUP_CREATE); + gcpl = H5Pcreate(H5P_GROUP_CREATE); - if (gcpl <= 0) { - pass = FALSE; - failure_mssg = "ns_grp_0: H5Pcreate() failed"; - } - HDassert(gcpl > 0); + if (gcpl <= 0) { + failure_mssg = "ns_grp_0: H5Pcreate() failed"; + return false; } - if (pass) { - ret = H5Pset_link_creation_order(gcpl, H5P_CRT_ORDER_TRACKED); + ret = H5Pset_link_creation_order(gcpl, H5P_CRT_ORDER_TRACKED); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ns_grp_0: H5Pset_link_creation_order() failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ns_grp_0: H5Pset_link_creation_order() failed"; + return false; } - if (pass) { - gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, gcpl, H5P_DEFAULT); + gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, gcpl, H5P_DEFAULT); - if (gid <= 0) { - pass = FALSE; - failure_mssg = "ns_grp_0: H5Gcreate2() failed"; - } - HDassert(gid > 0); + if (gid <= 0) { + failure_mssg = "ns_grp_0: H5Gcreate2() failed"; + return false; } - if (pass) { - ret = H5Pclose(gcpl); + ret = H5Pclose(gcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ns_grp_0: H5Pclose(gcpl) failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ns_grp_0: H5Pclose(gcpl) failed"; + return false; } - if (pass) { - ret = H5Gclose(gid); + ret = H5Gclose(gid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ns_grp_0: H5Gclose(gid) failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ns_grp_0: H5Gclose(gid) failed"; + return false; } - return; - -} /* ns_grp_0 */ + return true; +} /*------------------------------------------------------------------------- @@ -114,12 +97,10 @@ ns_grp_0(hid_t fid, const char *group_name) { * Purpose: verify an empty "new style" group at the specified location * in the specified file. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 @@ -127,103 +108,76 @@ ns_grp_0(hid_t fid, const char *group_name) { *------------------------------------------------------------------------- */ -void vrfy_ns_grp_0(hid_t fid, const char *group_name) { +bool +vrfy_ns_grp_0(hid_t fid, const char *group_name) +{ hid_t gid = -1; hid_t gcpl = -1; H5G_info_t grp_info; unsigned crt_order_flags = 0; herr_t ret; - if (pass) { - gid = H5Gopen2(fid, group_name, H5P_DEFAULT); + gid = H5Gopen2(fid, group_name, H5P_DEFAULT); - if (gid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_0: H5Gopen2() failed"; - } - HDassert(gid > 0); + if (gid <= 0) { + failure_mssg = "vrfy_ns_grp_0: H5Gopen2() failed"; + return false; } - if (pass) { - gcpl = H5Gget_create_plist(gid); + gcpl = H5Gget_create_plist(gid); - if (gcpl <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_0: H5Gget_create_plist() failed"; - } - HDassert(gcpl > 0); + if (gcpl <= 0) { + failure_mssg = "vrfy_ns_grp_0: H5Gget_create_plist() failed"; + return false; } - if (pass) { - ret = H5Pget_link_creation_order(gcpl, &crt_order_flags); + ret = H5Pget_link_creation_order(gcpl, &crt_order_flags); - if (gcpl <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_0: H5Pget_link_creation_order() failed"; - } - else if ( H5P_CRT_ORDER_TRACKED != crt_order_flags) { - pass = FALSE; - failure_mssg = - "vrfy_ns_grp_0: H5P_CRT_ORDER_TRACKED != crt_order_flags"; - } - HDassert(ret >= 0); - HDassert(H5P_CRT_ORDER_TRACKED == crt_order_flags); + if (ret < 0) { + failure_mssg = "vrfy_ns_grp_0: H5Pget_link_creation_order() failed"; + return false; + } else if ( H5P_CRT_ORDER_TRACKED != crt_order_flags) { + failure_mssg = + "vrfy_ns_grp_0: H5P_CRT_ORDER_TRACKED != crt_order_flags"; + return false; } - if (pass) { - ret = H5Pclose(gcpl); + ret = H5Pclose(gcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_0: H5Pclose() failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ns_grp_0: H5Pclose() failed"; + return false; } - if (pass) { - HDmemset(&grp_info, 0, sizeof(grp_info)); - ret = H5Gget_info(gid, &grp_info); - - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_0: H5Gget_info() failed"; - } - else if (H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type) { - pass = FALSE; - failure_mssg = - "vrfy_ns_grp_0: H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type"; - } - else if (0 != grp_info.nlinks) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_0: 0 != grp_info.nlinks"; - } - else if (0 != grp_info.max_corder) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_0: 0 != grp_info.max_corder"; - } - else if ( FALSE != grp_info.mounted) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_0: FALSE != grp_info.mounted"; - } + HDmemset(&grp_info, 0, sizeof(grp_info)); + ret = H5Gget_info(gid, &grp_info); - HDassert(ret >= 0); - HDassert(H5G_STORAGE_TYPE_COMPACT == grp_info.storage_type); - HDassert(0 == grp_info.nlinks); - HDassert(0 == grp_info.max_corder); - HDassert(false == grp_info.mounted); + if (ret < 0) { + failure_mssg = "vrfy_ns_grp_0: H5Gget_info() failed"; + return false; + } else if (H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type) { + failure_mssg = + "vrfy_ns_grp_0: H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type"; + return false; + } else if (0 != grp_info.nlinks) { + failure_mssg = "vrfy_ns_grp_0: 0 != grp_info.nlinks"; + return false; + } else if (0 != grp_info.max_corder) { + failure_mssg = "vrfy_ns_grp_0: 0 != grp_info.max_corder"; + return false; + } else if ( FALSE != grp_info.mounted) { + failure_mssg = "vrfy_ns_grp_0: FALSE != grp_info.mounted"; + return false; } - if (pass) { - ret = H5Gclose(gid); + ret = H5Gclose(gid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_0: H5Gclose() failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ns_grp_0: H5Gclose() failed"; + return false; } - return; + return true; } /* vrfy_ns_grp_0() */ @@ -233,12 +187,10 @@ void vrfy_ns_grp_0(hid_t fid, const char *group_name) { * Purpose: Create a compact "new style" group, with 'nlinks' * soft/hard/external links in it in the specified file. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 @@ -246,127 +198,98 @@ void vrfy_ns_grp_0(hid_t fid, const char *group_name) { *------------------------------------------------------------------------- */ -void -ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) { +bool +ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) +{ hid_t gid = -1; hid_t gcpl = -1; unsigned max_compact; unsigned u; herr_t ret; - if (pass) { - gcpl = H5Pcreate(H5P_GROUP_CREATE); + gcpl = H5Pcreate(H5P_GROUP_CREATE); - if (gcpl <= 0) { - pass = FALSE; - failure_mssg = "ns_grp_c: H5Pcreate(H5P_GROUP_CREATE) failed"; - } - HDassert(gcpl > 0); + if (gcpl <= 0) { + failure_mssg = "ns_grp_c: H5Pcreate(H5P_GROUP_CREATE) failed"; + return false; } - if (pass) { - ret = H5Pset_link_creation_order(gcpl, H5P_CRT_ORDER_TRACKED); + ret = H5Pset_link_creation_order(gcpl, H5P_CRT_ORDER_TRACKED); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ns_grp_c: H5Pset_link_creation_order() failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ns_grp_c: H5Pset_link_creation_order() failed"; + return false; } - if (pass) { - gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, gcpl, H5P_DEFAULT); + gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, gcpl, H5P_DEFAULT); - if (gid <= 0) { - pass = FALSE; - failure_mssg = "ns_grp_c: H5Gcreate2() failed"; - } - HDassert(gid > 0); + if (gid <= 0) { + failure_mssg = "ns_grp_c: H5Gcreate2() failed"; + return false; } - if (pass) { - max_compact = 0; - ret = H5Pget_link_phase_change(gcpl, &max_compact, NULL); - - if (ret < 0) { - pass = FALSE; - failure_mssg = "ns_grp_c: H5Pget_link_phase_change() failed"; - } - else if (nlinks <= 0) { - pass = FALSE; - failure_mssg = "ns_grp_c: nlinks <= 0"; - } - else if (nlinks >= max_compact) { - pass = FALSE; - failure_mssg = "ns_grp_c: nlinks >= max_compact"; - } + max_compact = 0; + ret = H5Pget_link_phase_change(gcpl, &max_compact, NULL); - HDassert(ret >= 0); - HDassert(nlinks > 0); - HDassert(nlinks < max_compact); + if (ret < 0) { + failure_mssg = "ns_grp_c: H5Pget_link_phase_change() failed"; + return false; + } else if (nlinks <= 0) { + failure_mssg = "ns_grp_c: nlinks <= 0"; + return false; + } else if (nlinks >= max_compact) { + failure_mssg = "ns_grp_c: nlinks >= max_compact"; + return false; } - u = 0; - while ((pass) && (u < nlinks)) { + for (u = 0; u < nlinks; u++) { char linkname[16]; HDsprintf(linkname, "%u", u); if (0 == (u % 3)) { - ret = H5Lcreate_soft(group_name, gid, linkname, H5P_DEFAULT, H5P_DEFAULT); + ret = H5Lcreate_soft(group_name, gid, linkname, H5P_DEFAULT, + H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "ns_grp_c: H5Lcreate_soft() failed"; + return false; } - HDassert(ret >= 0); - } /* end if */ - else if (1 == (u % 3)) { + } else if (1 == (u % 3)) { ret = H5Lcreate_hard(fid, "/", gid, linkname, H5P_DEFAULT, H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "ns_grp_c: H5Lcreate_hard() failed"; + return false; } - HDassert(ret >= 0); - } /* end else-if */ - else { + } else { HDassert(2 == (u % 3)); ret = H5Lcreate_external("external.h5", "/ext", gid, linkname, H5P_DEFAULT, H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "ns_grp_c: H5Lcreate_external() failed"; + return false; } - HDassert(ret >= 0); - } /* end else */ - - u++; - } /* end while() */ + } + } - if (pass) { - ret = H5Pclose(gcpl); + ret = H5Pclose(gcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ns_grp_c: H5Pclose(gcpl) failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ns_grp_c: H5Pclose(gcpl) failed"; + return false; } - if (pass) { - ret = H5Gclose(gid); + ret = H5Gclose(gid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ns_grp_c: H5Gclose(gid) failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ns_grp_c: H5Gclose(gid) failed"; + return false; } - return; + return true; } /* ns_grp_c() */ @@ -377,12 +300,10 @@ ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) { * Purpose: Verify a compact "new style" group, with 'nlinks' * soft/hard/external links in it in the specified file. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 @@ -390,8 +311,9 @@ ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) { *------------------------------------------------------------------------- */ -void -vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) { +bool +vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) +{ hid_t gid = -1; hid_t gcpl = -1; H5G_info_t grp_info; @@ -399,86 +321,61 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) { unsigned u; herr_t ret; - if (pass) { - gid = H5Gopen2(fid, group_name, H5P_DEFAULT); + gid = H5Gopen2(fid, group_name, H5P_DEFAULT); - if (gid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_c: H5Gopen2() failed"; - } - HDassert(gid > 0); + if (gid <= 0) { + failure_mssg = "vrfy_ns_grp_c: H5Gopen2() failed"; + return false; } - if (pass) { - gcpl = H5Gget_create_plist(gid); + gcpl = H5Gget_create_plist(gid); - if (gcpl <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_c: H5Gget_create_plist(gid) failed"; - } - HDassert(gcpl > 0); + if (gcpl <= 0) { + failure_mssg = "vrfy_ns_grp_c: H5Gget_create_plist(gid) failed"; + return false; } - if (pass) { - ret = H5Pget_link_creation_order(gcpl, &crt_order_flags); + ret = H5Pget_link_creation_order(gcpl, &crt_order_flags); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_c: H5Pget_link_creation_order() failed"; - } - else if ( H5P_CRT_ORDER_TRACKED != crt_order_flags) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_c: H5P_CRT_ORDER_TRACKED != crt_order_flags"; - } - HDassert(ret >= 0); - HDassert(H5P_CRT_ORDER_TRACKED == crt_order_flags); + if (ret < 0) { + failure_mssg = "vrfy_ns_grp_c: H5Pget_link_creation_order() failed"; + return false; + } else if ( H5P_CRT_ORDER_TRACKED != crt_order_flags) { + failure_mssg = + "vrfy_ns_grp_c: H5P_CRT_ORDER_TRACKED != crt_order_flags"; + return false; } - if (pass) { - ret = H5Pclose(gcpl); + ret = H5Pclose(gcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_c: H5Pclose() failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ns_grp_c: H5Pclose() failed"; + return false; } - if (pass) { - HDmemset(&grp_info, 0, sizeof(grp_info)); - ret = H5Gget_info(gid, &grp_info); - - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_c: H5Gget_info() failed"; - } - else if (H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type) { - pass = FALSE; - failure_mssg = - "vrfy_ns_grp_c: H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type"; - } - else if (nlinks != grp_info.nlinks) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_c: nlinks != grp_info.nlinks"; - } - else if (nlinks != grp_info.max_corder) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_c: nlinks != grp_info.max_corder"; - } - else if ( FALSE != grp_info.mounted) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_c: FALSE != grp_info.mounted"; - } + HDmemset(&grp_info, 0, sizeof(grp_info)); + ret = H5Gget_info(gid, &grp_info); - HDassert(ret >= 0); - HDassert(H5G_STORAGE_TYPE_COMPACT == grp_info.storage_type); - HDassert(nlinks == grp_info.nlinks); - HDassert(nlinks == grp_info.max_corder); - HDassert(false == grp_info.mounted); + if (ret < 0) { + failure_mssg = "vrfy_ns_grp_c: H5Gget_info() failed"; + return false; + } else if (H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type) { + failure_mssg = + "vrfy_ns_grp_c: H5G_STORAGE_TYPE_COMPACT != grp_info.storage_type"; + return false; + } else if (nlinks != grp_info.nlinks) { + failure_mssg = "vrfy_ns_grp_c: nlinks != grp_info.nlinks"; + return false; + } else if (nlinks != grp_info.max_corder) { + failure_mssg = "vrfy_ns_grp_c: nlinks != grp_info.max_corder"; + return false; + } else if ( FALSE != grp_info.mounted) { + failure_mssg = "vrfy_ns_grp_c: FALSE != grp_info.mounted"; + return false; } - u = 0; - while ((pass) && (u < nlinks)) { + + for (u = 0; u < nlinks; u++) { H5L_info_t lnk_info; char linkname[16]; htri_t link_exists; @@ -487,96 +384,78 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) { link_exists = H5Lexists(gid, linkname, H5P_DEFAULT); if (link_exists < 0) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_c: H5Lexists() failed"; + return false; } - HDassert(link_exists >= 0); HDmemset(&lnk_info, 0, sizeof(grp_info)); ret = H5Lget_info(gid, linkname, &lnk_info, H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_c: H5Lget_info() failed"; - } - else if ( TRUE != lnk_info.corder_valid) { - pass = FALSE; + return false; + } else if ( TRUE != lnk_info.corder_valid) { failure_mssg = "vrfy_ns_grp_c: TRUE != lnk_info.corder_valid"; - } - else if (u != lnk_info.corder) { - pass = FALSE; + return false; + } else if (u != lnk_info.corder) { failure_mssg = "vrfy_ns_grp_c: u != lnk_info.corder"; - } - else if (H5T_CSET_ASCII != lnk_info.cset) { - pass = FALSE; + return false; + } else if (H5T_CSET_ASCII != lnk_info.cset) { failure_mssg = "vrfy_ns_grp_c: H5T_CSET_ASCII != lnk_info.cset"; + return false; } - HDassert(ret >= 0); - HDassert(true == lnk_info.corder_valid); - HDassert(u == lnk_info.corder); - HDassert(H5T_CSET_ASCII == lnk_info.cset); if (0 == (u % 3)) { char *slinkval; if (H5L_TYPE_SOFT != lnk_info.type) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_c: H5L_TYPE_SOFT != lnk_info.type"; + return false; } else if ((HDstrlen(group_name) + 1) != lnk_info.u.val_size) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_c: (HDstrlen(group_name) + 1) != lnk_info.u.val_size"; + return false; } - HDassert(H5L_TYPE_SOFT == lnk_info.type); - HDassert((HDstrlen(group_name) + 1) == lnk_info.u.val_size); - slinkval = (char *) HDmalloc(lnk_info.u.val_size); + slinkval = HDmalloc(lnk_info.u.val_size); if (!slinkval) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_c: HDmalloc of slinkval failed"; + return false; } - HDassert(slinkval); ret = H5Lget_val(gid, linkname, slinkval, lnk_info.u.val_size, H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_c: H5Lget_val() failed"; - } - else if (0 != HDstrcmp(slinkval, group_name)) { - pass = FALSE; + HDfree(slinkval); + return false; + } else if (0 != HDstrcmp(slinkval, group_name)) { failure_mssg = "vrfy_ns_grp_c: 0 != HDstrcmp(slinkval, group_name)"; + HDfree(slinkval); + return false; } - HDassert(ret >= 0); - HDassert(0 == HDstrcmp(slinkval, group_name)); HDfree(slinkval); - } /* end if */ - else if (1 == (u % 3)) { + } else if (1 == (u % 3)) { H5O_info_t root_oinfo; if (H5L_TYPE_HARD != lnk_info.type) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_c: H5L_TYPE_HARD != lnk_info.type"; + return false; } - HDassert(H5L_TYPE_HARD == lnk_info.type); HDmemset(&root_oinfo, 0, sizeof(root_oinfo)); ret = H5Oget_info2(fid, &root_oinfo, H5O_INFO_BASIC); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_c: H5Oget_info() failed."; - } - else if (root_oinfo.addr != lnk_info.u.address) { - pass = FALSE; + return false; + } else if (root_oinfo.addr != lnk_info.u.address) { failure_mssg = "vrfy_ns_grp_c: root_oinfo.addr != lnk_info.u.address"; + return false; } - HDassert(ret >= 0); - HDassert(root_oinfo.addr == lnk_info.u.address); - } /* end else-if */ - else { + } else { void *elinkval; const char *file = NULL; const char *path = NULL; @@ -584,61 +463,53 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) { HDassert(2 == (u % 3)); if (H5L_TYPE_EXTERNAL != lnk_info.type) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_c: H5L_TYPE_EXTERNAL != lnk_info.type"; + failure_mssg = + "vrfy_ns_grp_c: H5L_TYPE_EXTERNAL != lnk_info.type"; + return false; } - HDassert(H5L_TYPE_EXTERNAL == lnk_info.type); elinkval = HDmalloc(lnk_info.u.val_size); if (!elinkval) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_c: HDmalloc of elinkval failed."; + return false; } - HDassert(elinkval); ret = H5Lget_val(gid, linkname, elinkval, lnk_info.u.val_size, H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_c: H5Lget_val() failed."; + return false; } - HDassert(ret >= 0); - ret = H5Lunpack_elink_val(elinkval, lnk_info.u.val_size, NULL, &file, &path); + ret = H5Lunpack_elink_val(elinkval, lnk_info.u.val_size, NULL, + &file, &path); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_c: H5Lunpack_elink_val() failed."; - } - else if (0 != HDstrcmp(file, "external.h5")) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_c: 0 != HDstrcmp(file, \"external.h5\")"; - } - else if (0 != HDstrcmp(path, "/ext")) { - pass = FALSE; + HDfree(elinkval); + return false; + } else if (0 != HDstrcmp(file, "external.h5")) { + failure_mssg = + "vrfy_ns_grp_c: 0 != HDstrcmp(file, \"external.h5\")"; + HDfree(elinkval); + return false; + } else if (0 != HDstrcmp(path, "/ext")) { failure_mssg = "vrfy_ns_grp_c: 0 != HDstrcmp(path, \"/ext\")"; + HDfree(elinkval); + return false; } - HDassert(ret >= 0); - HDassert(0 == HDstrcmp(file, "external.h5")); - HDassert(0 == HDstrcmp(path, "/ext")); - HDfree(elinkval); - } /* end else */ - - u++; - } /* end while */ + } + } - if (pass) { - ret = H5Gclose(gid); + ret = H5Gclose(gid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_c: H5Gclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ns_grp_c: H5Gclose() failed."; + return false; } - return; + return true; } /* vrfy_ns_grp_c() */ @@ -648,12 +519,10 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) { * Purpose: Create a dense "new style" group, with 'nlinks' * (soft/hard/external) links in it in the specified file. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 @@ -661,62 +530,49 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) { *------------------------------------------------------------------------- */ -void -ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) { +bool +ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) +{ hid_t gid = -1; hid_t gcpl = -1; unsigned max_compact; unsigned u; herr_t ret; - if (pass) { - gcpl = H5Pcreate(H5P_GROUP_CREATE); + gcpl = H5Pcreate(H5P_GROUP_CREATE); - if (gcpl <= 0) { - pass = FALSE; - failure_mssg = "ns_grp_d: H5Pcreate() failed."; - } - HDassert(gcpl > 0); + if (gcpl <= 0) { + failure_mssg = "ns_grp_d: H5Pcreate() failed."; + return false; } - if (pass) { - ret = H5Pset_link_creation_order(gcpl, H5P_CRT_ORDER_TRACKED); + ret = H5Pset_link_creation_order(gcpl, H5P_CRT_ORDER_TRACKED); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ns_grp_d: H5Pset_link_creation_order() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ns_grp_d: H5Pset_link_creation_order() failed."; + return false; } - if (pass) { - gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, gcpl, H5P_DEFAULT); + gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, gcpl, H5P_DEFAULT); - if (gid <= 0) { - pass = FALSE; - failure_mssg = "ns_grp_d: H5Gcreate2() failed."; - } - HDassert(gid > 0); + if (gid <= 0) { + failure_mssg = "ns_grp_d: H5Gcreate2() failed."; + return false; } - if (pass) { - max_compact = 0; - ret = H5Pget_link_phase_change(gcpl, &max_compact, NULL); + max_compact = 0; + ret = H5Pget_link_phase_change(gcpl, &max_compact, NULL); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ns_grp_d: H5Pget_link_phase_change() failed."; - } - else if (nlinks <= max_compact) { - pass = FALSE; - failure_mssg = "ns_grp_d: nlinks <= max_compact"; - } - HDassert(ret >= 0); - HDassert(nlinks > max_compact); + if (ret < 0) { + failure_mssg = "ns_grp_d: H5Pget_link_phase_change() failed."; + return false; + } + else if (nlinks <= max_compact) { + failure_mssg = "ns_grp_d: nlinks <= max_compact"; + return false; } - u = 0; - while ((pass) && (u < nlinks)) { + for (u = 0; u < nlinks; u++) { char linkname[16]; HDsprintf(linkname, "%u", u); @@ -726,58 +582,45 @@ ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) { H5P_DEFAULT, H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "ns_grp_d: H5Lcreate_soft() failed."; + return false; } - HDassert(ret >= 0); - } /* end if */ - else if (1 == (u % 3)) { + } else if (1 == (u % 3)) { ret = H5Lcreate_hard(fid, "/", gid, linkname, H5P_DEFAULT, H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "ns_grp_d: H5Lcreate_hard() failed."; + return false; } - HDassert(ret >= 0); - } /* end else-if */ - else { + } else { HDassert(2 == (u % 3)); ret = H5Lcreate_external("external.h5", "/ext", gid, linkname, H5P_DEFAULT, H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "ns_grp_d: H5Lcreate_external() failed."; + return false; } - HDassert(ret >= 0); - } /* end else */ - - u++; - } /* end while */ + } + } - if (pass) { - ret = H5Pclose(gcpl); + ret = H5Pclose(gcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ns_grp_d: H5Pclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ns_grp_d: H5Pclose() failed."; + return false; } - if (pass) { - ret = H5Gclose(gid); + ret = H5Gclose(gid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ns_grp_d: H5Gclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ns_grp_d: H5Gclose() failed."; + return false; } - return; + return true; } /* ns_grp_d() */ @@ -787,12 +630,10 @@ ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) { * Purpose: Verify a dense "new style" group, with 'nlinks' * soft/hard/external links in it in the specified file. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 @@ -801,8 +642,9 @@ ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) { */ -void -vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) { +bool +vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) +{ hid_t gid = -1; hid_t gcpl = -1; H5G_info_t grp_info; @@ -810,84 +652,59 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) { unsigned u; herr_t ret; - if (pass) { - gid = H5Gopen2(fid, group_name, H5P_DEFAULT); + gid = H5Gopen2(fid, group_name, H5P_DEFAULT); - if (gid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: H5Gopen2() failed."; - } - HDassert(gid > 0); + if (gid <= 0) { + failure_mssg = "vrfy_ns_grp_d: H5Gopen2() failed."; + return false; } - if (pass) { - gcpl = H5Gget_create_plist(gid); + gcpl = H5Gget_create_plist(gid); - if (gcpl <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: H5Gget_create_plist() failed."; - } - HDassert(gcpl > 0); + if (gcpl <= 0) { + failure_mssg = "vrfy_ns_grp_d: H5Gget_create_plist() failed."; + return false; } - if (pass) { - ret = H5Pget_link_creation_order(gcpl, &crt_order_flags); + ret = H5Pget_link_creation_order(gcpl, &crt_order_flags); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: H5Pget_link_creation_order() failed."; - } - else if (H5P_CRT_ORDER_TRACKED != crt_order_flags) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: H5P_CRT_ORDER_TRACKED != crt_order_flags"; - } - HDassert(ret >= 0); - HDassert(H5P_CRT_ORDER_TRACKED == crt_order_flags); + if (ret < 0) { + failure_mssg = "vrfy_ns_grp_d: H5Pget_link_creation_order() failed."; + return false; + } else if (H5P_CRT_ORDER_TRACKED != crt_order_flags) { + failure_mssg = + "vrfy_ns_grp_d: H5P_CRT_ORDER_TRACKED != crt_order_flags"; + return false; } - if (pass) { - ret = H5Pclose(gcpl); + ret = H5Pclose(gcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: H5Pclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ns_grp_d: H5Pclose() failed."; + return false; } - if (pass) { - HDmemset(&grp_info, 0, sizeof(grp_info)); - ret = H5Gget_info(gid, &grp_info); + HDmemset(&grp_info, 0, sizeof(grp_info)); + ret = H5Gget_info(gid, &grp_info); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: H5Gget_info() failed."; - } - else if (H5G_STORAGE_TYPE_DENSE != grp_info.storage_type) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: H5G_STORAGE_TYPE_DENSE != grp_info.storage_type"; - } - else if (nlinks != grp_info.nlinks) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: nlinks != grp_info.nlinks"; - } - else if (nlinks != grp_info.max_corder) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: nlinks != grp_info.max_corder"; - } - else if ( FALSE != grp_info.mounted) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: FALSE != grp_info.mounted"; - } - HDassert(ret >= 0); - HDassert(H5G_STORAGE_TYPE_DENSE == grp_info.storage_type); - HDassert(nlinks == grp_info.nlinks); - HDassert(nlinks == grp_info.max_corder); - HDassert(false == grp_info.mounted); + if (ret < 0) { + failure_mssg = "vrfy_ns_grp_d: H5Gget_info() failed."; + return false; + } else if (H5G_STORAGE_TYPE_DENSE != grp_info.storage_type) { + failure_mssg = "vrfy_ns_grp_d: H5G_STORAGE_TYPE_DENSE != grp_info.storage_type"; + return false; + } else if (nlinks != grp_info.nlinks) { + failure_mssg = "vrfy_ns_grp_d: nlinks != grp_info.nlinks"; + return false; + } else if (nlinks != grp_info.max_corder) { + failure_mssg = "vrfy_ns_grp_d: nlinks != grp_info.max_corder"; + return false; + } else if ( FALSE != grp_info.mounted) { + failure_mssg = "vrfy_ns_grp_d: FALSE != grp_info.mounted"; + return false; } - u = 0; - while ((pass) && (u < nlinks)) { + for (u = 0; u < nlinks; u++) { H5L_info_t lnk_info; char linkname[16]; htri_t link_exists; @@ -896,95 +713,76 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) { link_exists = H5Lexists(gid, linkname, H5P_DEFAULT); if (link_exists < 0) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_d: H5Lexists() failed."; + return false; } - HDassert(link_exists >= 0); HDmemset(&lnk_info, 0, sizeof(grp_info)); ret = H5Lget_info(gid, linkname, &lnk_info, H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_d: H5Lget_info() failed."; - } - else if (TRUE != lnk_info.corder_valid) { - pass = FALSE; + return false; + } else if (TRUE != lnk_info.corder_valid) { failure_mssg = "vrfy_ns_grp_d: TRUE != lnk_info.corder_valid"; - } - else if (u != lnk_info.corder) { - pass = FALSE; + return false; + } else if (u != lnk_info.corder) { failure_mssg = "vrfy_ns_grp_d: u != lnk_info.corder"; - } - else if (H5T_CSET_ASCII != lnk_info.cset) { - pass = FALSE; + return false; + } else if (H5T_CSET_ASCII != lnk_info.cset) { failure_mssg = "vrfy_ns_grp_d: H5T_CSET_ASCII != lnk_info.cset"; + return false; } - HDassert(ret >= 0); - HDassert(true == lnk_info.corder_valid); - HDassert(u == lnk_info.corder); - HDassert(H5T_CSET_ASCII == lnk_info.cset); if (0 == (u % 3)) { char *slinkval; if (H5L_TYPE_SOFT != lnk_info.type) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_d: H5L_TYPE_SOFT != lnk_info.type"; + return false; } else if ((HDstrlen(group_name) + 1) != lnk_info.u.val_size) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_d: H5L_TYPE_SOFT != lnk_info.type"; + return false; } - HDassert(H5L_TYPE_SOFT == lnk_info.type); - HDassert((HDstrlen(group_name) + 1) == lnk_info.u.val_size); - slinkval = (char *) HDmalloc(lnk_info.u.val_size); + slinkval = HDmalloc(lnk_info.u.val_size); if (!slinkval) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_d: HDmalloc of slinkval failed"; + return false; } - HDassert(slinkval); ret = H5Lget_val(gid, linkname, slinkval, lnk_info.u.val_size, - H5P_DEFAULT); + H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_d: H5Lget_val() failed"; - } - else if (0 != HDstrcmp(slinkval, group_name)) { - pass = FALSE; + HDfree(slinkval); + return false; + } else if (0 != HDstrcmp(slinkval, group_name)) { failure_mssg = "vrfy_ns_grp_d: 0 != HDstrcmp(slinkval, group_name)"; + HDfree(slinkval); + return false; } - HDassert(ret >= 0); - HDassert(0 == HDstrcmp(slinkval, group_name)); - HDfree(slinkval); - } /* end if */ - else if (1 == (u % 3)) { + } else if (1 == (u % 3)) { H5O_info_t root_oinfo; if (H5L_TYPE_HARD != lnk_info.type) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_d: H5L_TYPE_HARD != lnk_info.type"; + return false; } - HDassert(H5L_TYPE_HARD == lnk_info.type); HDmemset(&root_oinfo, 0, sizeof(root_oinfo)); ret = H5Oget_info2(fid, &root_oinfo, H5O_INFO_BASIC); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_d: H5Oget_info() failed."; - } - else if (root_oinfo.addr != lnk_info.u.address) { - pass = FALSE; + return false; + } else if (root_oinfo.addr != lnk_info.u.address) { failure_mssg = "vrfy_ns_grp_d: root_oinfo.addr != lnk_info.u.address"; + return false; } - HDassert(ret >= 0); - HDassert(root_oinfo.addr == lnk_info.u.address); - } /* end else-if */ - else { + } else { void *elinkval; const char *file = NULL; const char *path = NULL; @@ -992,61 +790,53 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) { HDassert(2 == (u % 3)); if (H5L_TYPE_EXTERNAL != lnk_info.type) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: H5L_TYPE_EXTERNAL != lnk_info.type"; + failure_mssg = + "vrfy_ns_grp_d: H5L_TYPE_EXTERNAL != lnk_info.type"; + return false; } - HDassert(H5L_TYPE_EXTERNAL == lnk_info.type); elinkval = HDmalloc(lnk_info.u.val_size); if (!elinkval) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_d: HDmalloc of elinkval failed."; + return false; } - HDassert(elinkval); ret = H5Lget_val(gid, linkname, elinkval, lnk_info.u.val_size, - H5P_DEFAULT); + H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_d: H5Lget_val failed."; + return false; } - HDassert(ret >= 0); - ret = H5Lunpack_elink_val(elinkval, lnk_info.u.val_size, NULL, &file, &path); + ret = H5Lunpack_elink_val(elinkval, lnk_info.u.val_size, NULL, + &file, &path); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ns_grp_d: H5Lunpack_elink_val failed."; - } - else if (0 != HDstrcmp(file, "external.h5")) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: 0 != HDstrcmp(file, \"external.h5\")."; - } - else if (0 != HDstrcmp(path, "/ext")) { - pass = FALSE; + HDfree(elinkval); + return false; + } else if (0 != HDstrcmp(file, "external.h5")) { + failure_mssg = + "vrfy_ns_grp_d: 0 != HDstrcmp(file, \"external.h5\")."; + HDfree(elinkval); + return false; + } else if (0 != HDstrcmp(path, "/ext")) { failure_mssg = "vrfy_ns_grp_d: 0 != HDstrcmp(path, \"/ext\")"; + HDfree(elinkval); + return false; } - HDassert(ret >= 0); - HDassert(0 == HDstrcmp(file, "external.h5")); - HDassert(0 == HDstrcmp(path, "/ext")); - HDfree(elinkval); - } /* end else */ - - u++; - } /* end while() */ + } + } - if (pass) { - ret = H5Gclose(gid); + ret = H5Gclose(gid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ns_grp_d: H5Gclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ns_grp_d: H5Gclose() failed."; + return false; } - return; + return true; } /* vrfy_ns_grp_d() */ @@ -1056,12 +846,10 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) { * * Purpose: Create an empty "old style" group. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 @@ -1069,7 +857,7 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) { *------------------------------------------------------------------------- */ -void +bool os_grp_0(hid_t fid, const char *group_name) { hid_t gid = -1; @@ -1078,66 +866,52 @@ os_grp_0(hid_t fid, const char *group_name) herr_t ret; - if ( pass ) { /* get the file's file access property list */ - fapl = H5Fget_access_plist(fid); - if ( fapl <= 0 ) { - pass = FALSE; - failure_mssg = "os_grp_0: H5Fget_access_plist() failed."; - } - HDassert(fapl > 0); + /* get the file's file access property list */ + fapl = H5Fget_access_plist(fid); + if ( fapl <= 0 ) { + failure_mssg = "os_grp_0: H5Fget_access_plist() failed."; + return false; } - if ( pass ) { /* get low and high bounds from fapl */ - ret = H5Pget_libver_bounds(fapl, &low, &high); - if ( ret < 0 ) { - pass = FALSE; - failure_mssg = "os_grp_0: H5Pget_libver_bounds() failed(1)."; - } - HDassert(ret >= 0); + /* get low and high bounds from fapl */ + ret = H5Pget_libver_bounds(fapl, &low, &high); + if ( ret < 0 ) { + failure_mssg = "os_grp_0: H5Pget_libver_bounds() failed(1)."; + return false; } - if ( pass ) { /* turn file format latest off */ - if(low >= H5F_LIBVER_V18) { - ret = H5Fset_libver_bounds(fid, H5F_LIBVER_EARLIEST, high); - if ( ret < 0 ) { - pass = FALSE; - failure_mssg = "os_grp_0: H5Fset_libver_bounds() failed(1)."; - } - HDassert(ret >= 0); + /* turn file format latest off */ + if(low >= H5F_LIBVER_V18) { + ret = H5Fset_libver_bounds(fid, H5F_LIBVER_EARLIEST, high); + if ( ret < 0 ) { + failure_mssg = "os_grp_0: H5Fset_libver_bounds() failed(1)."; + return false; } } - if ( pass ) { - gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if ( gid <= 0 ) { - pass = FALSE; - failure_mssg = "os_grp_0: H5Gcreate2() failed."; - } - HDassert(gid > 0); + gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if ( gid <= 0 ) { + failure_mssg = "os_grp_0: H5Gcreate2() failed."; + return false; } - if ( pass ) { - ret = H5Gclose(gid); + ret = H5Gclose(gid); - if ( ret < 0 ) { - pass = FALSE; - failure_mssg = "os_grp_0: H5Gclose() failed."; - } - HDassert(ret >= 0); + if ( ret < 0 ) { + failure_mssg = "os_grp_0: H5Gclose() failed."; + return false; } - if ( pass ) { /* restore low and high bounds */ - if(low >= H5F_LIBVER_V18) { - ret = H5Fset_libver_bounds(fid, low, high); - if ( ret < 0 ) { - pass = FALSE; - failure_mssg = "os_grp_0: H5Fset_libver_bounds() failed(1)."; - } - HDassert(ret >= 0); + /* restore low and high bounds */ + if(low >= H5F_LIBVER_V18) { + ret = H5Fset_libver_bounds(fid, low, high); + if ( ret < 0 ) { + failure_mssg = "os_grp_0: H5Fset_libver_bounds() failed(1)."; + return false; } } - return; + return true; } /* os_grp_0() */ @@ -1146,12 +920,10 @@ os_grp_0(hid_t fid, const char *group_name) * * Purpose: Validate an empty "old style" group. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 @@ -1159,102 +931,74 @@ os_grp_0(hid_t fid, const char *group_name) *------------------------------------------------------------------------- */ -void -vrfy_os_grp_0(hid_t fid, const char *group_name) { +bool +vrfy_os_grp_0(hid_t fid, const char *group_name) +{ hid_t gid = -1; hid_t gcpl = -1; H5G_info_t grp_info; unsigned crt_order_flags = 0; herr_t ret; - if (pass) { - gid = H5Gopen2(fid, group_name, H5P_DEFAULT); + gid = H5Gopen2(fid, group_name, H5P_DEFAULT); - if (gid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_0: H5Gopen2() failed."; - } - HDassert(gid > 0); + if (gid <= 0) { + failure_mssg = "vrfy_os_grp_0: H5Gopen2() failed."; + return false; } - if (pass) { - gcpl = H5Gget_create_plist(gid); + gcpl = H5Gget_create_plist(gid); - if (gcpl <= 0) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_0: H5Gget_create_plist() failed."; - } - HDassert(gcpl > 0); + if (gcpl <= 0) { + failure_mssg = "vrfy_os_grp_0: H5Gget_create_plist() failed."; + return false; } - if (pass) { + ret = H5Pget_link_creation_order(gcpl, &crt_order_flags); - ret = H5Pget_link_creation_order(gcpl, &crt_order_flags); - - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_0: H5Pget_link_creation_order() failed"; - } - else if (0 != crt_order_flags) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_0: 0 != crt_order_flags"; - } - HDassert(ret >= 0); - HDassert(0 == crt_order_flags); + if (ret < 0) { + failure_mssg = "vrfy_os_grp_0: H5Pget_link_creation_order() failed"; + return false; + } else if (0 != crt_order_flags) { + failure_mssg = "vrfy_os_grp_0: 0 != crt_order_flags"; + return false; } - if (pass) { - ret = H5Pclose(gcpl); + ret = H5Pclose(gcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_0: H5Pclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_os_grp_0: H5Pclose() failed."; + return false; } - if (pass) { - HDmemset(&grp_info, 0, sizeof(grp_info)); - ret = H5Gget_info(gid, &grp_info); + HDmemset(&grp_info, 0, sizeof(grp_info)); + ret = H5Gget_info(gid, &grp_info); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_0: H5Gget_info() failed."; - } - else if (H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_0: H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type"; - } - else if (0 != grp_info.nlinks) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_0: 0 != grp_info.nlinks"; - } - else if (0 != grp_info.max_corder) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_0: 0 != grp_info.max_corder"; - } - else if ( FALSE != grp_info.mounted) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_0: FALSE != grp_info.mounted"; - } - HDassert(ret >= 0); - HDassert(H5G_STORAGE_TYPE_SYMBOL_TABLE == grp_info.storage_type); - HDassert(0 == grp_info.nlinks); - HDassert(0 == grp_info.max_corder); - HDassert(false == grp_info.mounted); + if (ret < 0) { + failure_mssg = "vrfy_os_grp_0: H5Gget_info() failed."; + return false; + } else if (H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type) { + failure_mssg = "vrfy_os_grp_0: H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type"; + return false; + } else if (0 != grp_info.nlinks) { + failure_mssg = "vrfy_os_grp_0: 0 != grp_info.nlinks"; + return false; + } else if (0 != grp_info.max_corder) { + failure_mssg = "vrfy_os_grp_0: 0 != grp_info.max_corder"; + return false; + } else if ( FALSE != grp_info.mounted) { + failure_mssg = "vrfy_os_grp_0: FALSE != grp_info.mounted"; + return false; } - if (pass) { - ret = H5Gclose(gid); + ret = H5Gclose(gid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_0: H5Gclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_os_grp_0: H5Gclose() failed."; + return false; } - return; + return true; } /* vrfy_os_grp_0() */ @@ -1264,12 +1008,10 @@ vrfy_os_grp_0(hid_t fid, const char *group_name) { * Purpose: Create an "old style" group, with 'nlinks' soft/hard * links in it. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 @@ -1277,7 +1019,7 @@ vrfy_os_grp_0(hid_t fid, const char *group_name) { *------------------------------------------------------------------------- */ -void +bool os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) { hid_t gid = -1; @@ -1286,48 +1028,38 @@ os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) H5F_libver_t low, high; herr_t ret; - if ( pass ) { /* get the file's file access property list */ - fapl = H5Fget_access_plist(fid); - if ( fapl <= 0 ) { - pass = FALSE; - failure_mssg = "os_grp_n: H5Fget_access_plist() failed."; - } - HDassert(fapl > 0); + /* get the file's file access property list */ + fapl = H5Fget_access_plist(fid); + if ( fapl <= 0 ) { + failure_mssg = "os_grp_n: H5Fget_access_plist() failed."; + return false; } - if ( pass ) { /* get low and high bounds from fapl */ - ret = H5Pget_libver_bounds(fapl, &low, &high); - if ( ret < 0 ) { - pass = FALSE; - failure_mssg = "os_grp_0: H5Pget_libver_bounds() failed(1)."; - } - HDassert(ret >= 0); + /* get low and high bounds from fapl */ + ret = H5Pget_libver_bounds(fapl, &low, &high); + if ( ret < 0 ) { + failure_mssg = "os_grp_0: H5Pget_libver_bounds() failed(1)."; + return false; } - if ( pass ) { /* turn file format latest off */ - if(low >= H5F_LIBVER_V18) { - ret = H5Fset_libver_bounds(fid, H5F_LIBVER_EARLIEST, high); - if ( ret < 0 ) { - pass = FALSE; - failure_mssg = "os_grp_0: H5Fset_libver_bounds() failed(1)."; - } - HDassert(ret >= 0); + /* turn file format latest off */ + if(low >= H5F_LIBVER_V18) { + ret = H5Fset_libver_bounds(fid, H5F_LIBVER_EARLIEST, high); + if ( ret < 0 ) { + failure_mssg = "os_grp_0: H5Fset_libver_bounds() failed(1)."; + return false; } } - if ( pass ) { - gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - if ( gid <= 0 ) { - pass = FALSE; - failure_mssg = "os_grp_n: H5Gcreate2() failed."; - } - HDassert(gid > 0); + gid = H5Gcreate2(fid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if ( gid <= 0 ) { + failure_mssg = "os_grp_n: H5Gcreate2() failed."; + return false; } HDassert(nlinks > 0); - u = 0; - while ( ( pass ) && ( u < nlinks ) ) { + for (u = 0; u < nlinks; u++) { char linkname[32]; HDsprintf(linkname, "ln%d_%u", proc_num, u); @@ -1335,47 +1067,37 @@ os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) if(0 == (u % 2)) { ret = H5Lcreate_soft(group_name, gid, linkname, H5P_DEFAULT, H5P_DEFAULT); if ( ret < 0 ) { - pass = FALSE; failure_mssg = "os_grp_n: H5Lcreate_soft() failed."; + return false; } - HDassert(ret >= 0); - } /* end if */ - else { + } else { HDassert(1 == (u % 2)); ret = H5Lcreate_hard(fid, "/", gid, linkname, H5P_DEFAULT, H5P_DEFAULT); if ( ret < 0 ) { - pass = FALSE; failure_mssg = "os_grp_n: H5Lcreate_hard() failed."; + return false; } - HDassert(ret >= 0); - } /* end else */ - - u++; - } /* end while */ + } + } - if ( pass ) { - ret = H5Gclose(gid); + ret = H5Gclose(gid); - if ( ret < 0 ) { - pass = FALSE; - failure_mssg = "os_grp_n: H5Gclose() failed."; - } - HDassert(ret >= 0); + if ( ret < 0 ) { + failure_mssg = "os_grp_n: H5Gclose() failed."; + return false; } - if ( pass ) { /* restore low and high bounds */ - if(low >= H5F_LIBVER_V18) { - ret = H5Fset_libver_bounds(fid, low, high); - if ( ret < 0 ) { - pass = FALSE; - failure_mssg = "os_grp_n: H5Fset_libver_bounds() failed(2)."; - } - HDassert(ret >= 0); + /* restore low and high bounds */ + if(low >= H5F_LIBVER_V18) { + ret = H5Fset_libver_bounds(fid, low, high); + if ( ret < 0 ) { + failure_mssg = "os_grp_n: H5Fset_libver_bounds() failed(2)."; + return false; } } - return; + return true; } /* os_grp_n() */ @@ -1385,21 +1107,19 @@ os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) * Purpose: Validate an "old style" group with 'nlinks' soft/hard * links in it. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 * *------------------------------------------------------------------------- */ -void -vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, - unsigned nlinks) { +bool +vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) +{ hid_t gid = -1; hid_t gcpl = -1; H5G_info_t grp_info; @@ -1407,85 +1127,60 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned u; herr_t ret; - if (pass) { - gid = H5Gopen2(fid, group_name, H5P_DEFAULT); + gid = H5Gopen2(fid, group_name, H5P_DEFAULT); - if (gid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_n: H5Gopen2() failed"; - } - HDassert(gid > 0); + if (gid <= 0) { + failure_mssg = "vrfy_os_grp_n: H5Gopen2() failed"; + return false; } - if (pass) { - gcpl = H5Gget_create_plist(gid); + gcpl = H5Gget_create_plist(gid); - if (gcpl <= 0) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_n: H5Gget_create_plist() failed"; - } - HDassert(gcpl > 0); + if (gcpl <= 0) { + failure_mssg = "vrfy_os_grp_n: H5Gget_create_plist() failed"; + return false; } - if (pass) { - ret = H5Pget_link_creation_order(gcpl, &crt_order_flags); + ret = H5Pget_link_creation_order(gcpl, &crt_order_flags); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_n: H5Pget_link_creation_order"; - } - else if (0 != crt_order_flags) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_n: 0 != crt_order_flags"; - } - HDassert(ret >= 0); - HDassert(0 == crt_order_flags); + if (ret < 0) { + failure_mssg = "vrfy_os_grp_n: H5Pget_link_creation_order"; + return false; + } else if (0 != crt_order_flags) { + failure_mssg = "vrfy_os_grp_n: 0 != crt_order_flags"; + return false; } - if (pass) { - ret = H5Pclose(gcpl); + ret = H5Pclose(gcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_n: H5Pclose() failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_os_grp_n: H5Pclose() failed"; + return false; } - if (pass) { - HDmemset(&grp_info, 0, sizeof(grp_info)); + HDmemset(&grp_info, 0, sizeof(grp_info)); - ret = H5Gget_info(gid, &grp_info); + ret = H5Gget_info(gid, &grp_info); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_n: H5Gget_info() failed"; - } - else if (H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_n: H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type"; - } - else if (nlinks != grp_info.nlinks) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_n: nlinks != grp_info.nlinks"; - } - else if (0 != grp_info.max_corder) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_n: 0 != grp_info.max_corder"; - } - else if ( FALSE != grp_info.mounted) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_n: FALSE != grp_info.mounted"; - } - HDassert(ret >= 0); - HDassert(H5G_STORAGE_TYPE_SYMBOL_TABLE == grp_info.storage_type); - HDassert(nlinks == grp_info.nlinks); - HDassert(0 == grp_info.max_corder); - HDassert(false == grp_info.mounted); + if (ret < 0) { + failure_mssg = "vrfy_os_grp_n: H5Gget_info() failed"; + return false; + } else if (H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type) { + failure_mssg = "vrfy_os_grp_n: H5G_STORAGE_TYPE_SYMBOL_TABLE != grp_info.storage_type"; + return false; + } else if (nlinks != grp_info.nlinks) { + failure_mssg = "vrfy_os_grp_n: nlinks != grp_info.nlinks"; + return false; + } else if (0 != grp_info.max_corder) { + failure_mssg = "vrfy_os_grp_n: 0 != grp_info.max_corder"; + return false; + } else if ( FALSE != grp_info.mounted) { + failure_mssg = "vrfy_os_grp_n: FALSE != grp_info.mounted"; + return false; } - u = 0; - while ((pass) && (u < nlinks)) { + + for (u = 0; u < nlinks; u++) { H5L_info_t lnk_info; char linkname[32]; htri_t link_exists; @@ -1494,8 +1189,8 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, link_exists = H5Lexists(gid, linkname, H5P_DEFAULT); if (link_exists < 0) { - pass = FALSE; failure_mssg = "vrfy_os_grp_n: H5Lexists() failed"; + return false; } HDassert(link_exists >= 0); @@ -1503,99 +1198,80 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, ret = H5Lget_info(gid, linkname, &lnk_info, H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_os_grp_n: H5Lget_info() failed"; + return false; } else if ( FALSE != lnk_info.corder_valid) { - pass = FALSE; failure_mssg = "vrfy_os_grp_n: FALSE != lnk_info.corder_valid"; + return false; } else if (H5T_CSET_ASCII != lnk_info.cset) { - pass = FALSE; failure_mssg = "vrfy_os_grp_n: H5T_CSET_ASCII != lnk_info.cset"; + return false; } - HDassert(ret >= 0); - HDassert(false == lnk_info.corder_valid); - HDassert(H5T_CSET_ASCII == lnk_info.cset); if (0 == (u % 2)) { char *slinkval; if (H5L_TYPE_SOFT != lnk_info.type) { - pass = FALSE; failure_mssg = "vrfy_os_grp_n: H5L_TYPE_SOFT != lnk_info.type"; - } - else if ((HDstrlen(group_name) + 1) != lnk_info.u.val_size) { - pass = FALSE; + return false; + } else if ((HDstrlen(group_name) + 1) != lnk_info.u.val_size) { failure_mssg = "vrfy_os_grp_n: (HDstrlen(group_name) + 1) != lnk_info.u.val_size"; + return false; } - HDassert(H5L_TYPE_SOFT == lnk_info.type); - HDassert((HDstrlen(group_name) + 1) == lnk_info.u.val_size); - slinkval = (char *) HDmalloc(lnk_info.u.val_size); + slinkval = HDmalloc(lnk_info.u.val_size); if (!slinkval) { - pass = FALSE; failure_mssg = "vrfy_os_grp_n: HDmalloc of slinkval failed"; + return false; } - HDassert(slinkval); ret = H5Lget_val(gid, linkname, slinkval, lnk_info.u.val_size, - H5P_DEFAULT); + H5P_DEFAULT); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_os_grp_n: H5Lget_val() failed"; - } - else if (0 != HDstrcmp(slinkval, group_name)) { - pass = FALSE; + HDfree(slinkval); + return false; + } else if (0 != HDstrcmp(slinkval, group_name)) { failure_mssg = "vrfy_os_grp_n: 0 != HDstrcmp(slinkval, group_name)"; + HDfree(slinkval); + return false; } - HDassert(ret >= 0); - HDassert(0 == HDstrcmp(slinkval, group_name)); - HDfree(slinkval); - } /* end if */ - else { + } else { H5O_info_t root_oinfo; HDassert(1 == (u % 2)); if (H5L_TYPE_HARD != lnk_info.type) { - pass = FALSE; failure_mssg = "vrfy_os_grp_n: H5L_TYPE_HARD != lnk_info.type"; + return false; } - HDassert(H5L_TYPE_HARD == lnk_info.type); HDmemset(&root_oinfo, 0, sizeof(root_oinfo)); ret = H5Oget_info2(fid, &root_oinfo, H5O_INFO_BASIC); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_os_grp_n: H5Oget_info() failed."; - } - else if (root_oinfo.addr != lnk_info.u.address) { - pass = FALSE; + return false; + } else if (root_oinfo.addr != lnk_info.u.address) { failure_mssg = "vrfy_os_grp_n: root_oinfo.addr != lnk_info.u.address"; + return false; } - HDassert(ret >= 0); - HDassert(root_oinfo.addr == lnk_info.u.address); - } /* end else */ - - u++; - } /* end while */ + } + } - if (pass) { - ret = H5Gclose(gid); + ret = H5Gclose(gid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_os_grp_n: H5Gclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_os_grp_n: H5Gclose() failed."; + return false; } - return; + return true; } /* vrfy_os_grp_n() */ @@ -1606,20 +1282,19 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, * to the data set or not as indicated by the write_data * parameter. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 * *------------------------------------------------------------------------- */ -void -ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) { +bool +ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) +{ int *wdata = NULL; unsigned u; hid_t dsid = -1; @@ -1627,74 +1302,58 @@ ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) { hsize_t dims[1] = { DSET_DIMS }; herr_t ret; - if (pass) { - sid = H5Screate_simple(1, dims, NULL); + sid = H5Screate_simple(1, dims, NULL); - if (sid <= 0) { - pass = FALSE; - failure_mssg = "ds_ctg_i: H5Screate_simple() failed"; - } - HDassert(sid > 0); + if (sid <= 0) { + failure_mssg = "ds_ctg_i: H5Screate_simple() failed"; + return false; } - if (pass) { - dsid = H5Dcreate2(fid, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dsid = H5Dcreate2(fid, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); - if (dsid <= 0) { - pass = FALSE; - failure_mssg = "ds_ctg_i: H5Dcreate2() failed"; - } - HDassert(dsid > 0); + if (dsid <= 0) { + failure_mssg = "ds_ctg_i: H5Dcreate2() failed"; + return false; } - if (pass) { - ret = H5Sclose(sid); + ret = H5Sclose(sid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ds_ctg_i: H5Sclose() failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ds_ctg_i: H5Sclose() failed"; + return false; } - if ((pass) && (write_data)) { - wdata = (int *) HDmalloc(sizeof(int) * DSET_DIMS); + if (write_data) { + wdata = HDmalloc(sizeof(int) * DSET_DIMS); if (!wdata) { - pass = FALSE; failure_mssg = "ds_ctg_i: HDmalloc of wdata failed."; + return false; } - HDassert(wdata); - } - if ((pass) && (write_data)) { for (u = 0; u < DSET_DIMS; u++) wdata[u] = (int) u; - ret = H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, wdata); + ret = H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, + wdata); + + HDfree(wdata); if (ret < 0) { - pass = FALSE; failure_mssg = "ds_ctg_i: H5Dwrite() failed."; + return false; } - HDassert(ret >= 0); - - HDfree(wdata); } - if (pass) { - ret = H5Dclose(dsid); + ret = H5Dclose(dsid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ds_ctg_i: H5Dclose() failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ds_ctg_i: H5Dclose() failed"; + return false; } - return; + return true; } /* ds_ctg_i */ @@ -1704,20 +1363,19 @@ ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) { * Purpose: Validate a contiguous datasets w/int datatypes. Validate * data if indicated via the write_data parameter. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 * *------------------------------------------------------------------------- */ -void -vrfy_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) { +bool +vrfy_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) +{ int *rdata = NULL; unsigned u; hid_t dsid = -1; @@ -1731,191 +1389,137 @@ vrfy_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) { htri_t type_equal; herr_t ret; - if (pass) { - dsid = H5Dopen2(fid, dset_name, H5P_DEFAULT); + dsid = H5Dopen2(fid, dset_name, H5P_DEFAULT); - if (dsid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: H5Dopen2() failed."; - } - HDassert(dsid > 0); + if (dsid <= 0) { + failure_mssg = "vrfy_ds_ctg_i: H5Dopen2() failed."; + return false; } - if (pass) { - sid = H5Dget_space(dsid); + sid = H5Dget_space(dsid); - if (sid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: H5Dget_space() failed."; - } - HDassert(sid > 0); + if (sid <= 0) { + failure_mssg = "vrfy_ds_ctg_i: H5Dget_space() failed."; + return false; } - if (pass) { - ndims = H5Sget_simple_extent_ndims(sid); + ndims = H5Sget_simple_extent_ndims(sid); - if (1 != ndims) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: 1 != ndims"; - } - HDassert(1 == ndims); + if (1 != ndims) { + failure_mssg = "vrfy_ds_ctg_i: 1 != ndims"; + return false; } - if (pass) { - ret = H5Sget_simple_extent_dims(sid, dims, max_dims); + ret = H5Sget_simple_extent_dims(sid, dims, max_dims); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: H5Sget_simple_extent_dims() failed"; - } - else if ( DSET_DIMS != dims[0]) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: DSET_DIMS != dims[0]"; - } - else if ( DSET_DIMS != max_dims[0]) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: DSET_DIMS != max_dims[0]"; - } - HDassert(ret >= 0); - HDassert(DSET_DIMS == dims[0]); - HDassert(DSET_DIMS == max_dims[0]); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_i: H5Sget_simple_extent_dims() failed"; + return false; + } else if ( DSET_DIMS != dims[0]) { + failure_mssg = "vrfy_ds_ctg_i: DSET_DIMS != dims[0]"; + return false; + } else if ( DSET_DIMS != max_dims[0]) { + failure_mssg = "vrfy_ds_ctg_i: DSET_DIMS != max_dims[0]"; + return false; } - if (pass) { - ret = H5Sclose(sid); + ret = H5Sclose(sid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: H5Sclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_i: H5Sclose() failed."; + return false; } - if (pass) { - tid = H5Dget_type(dsid); + tid = H5Dget_type(dsid); - if (tid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: H5Dget_type() failed."; - } - HDassert(tid > 0); + if (tid <= 0) { + failure_mssg = "vrfy_ds_ctg_i: H5Dget_type() failed."; + return false; } - if (pass) { - type_equal = H5Tequal(tid, H5T_NATIVE_INT); + type_equal = H5Tequal(tid, H5T_NATIVE_INT); - if (1 != type_equal) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: type not H5T_NATIVE_INT"; - } - HDassert(1 == type_equal); + if (1 != type_equal) { + failure_mssg = "vrfy_ds_ctg_i: type not H5T_NATIVE_INT"; + return false; } - if (pass) { - ret = H5Tclose(tid); + ret = H5Tclose(tid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: H5Tclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_i: H5Tclose() failed."; + return false; } - if (pass) { - ret = H5Dget_space_status(dsid, &allocation); + ret = H5Dget_space_status(dsid, &allocation); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: H5Dget_space_status() failed."; - } - else if (write_data && (allocation != H5D_SPACE_STATUS_ALLOCATED)) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: write_data && allocation != H5D_SPACE_STATUS_ALLOCATED"; - } - else if (!write_data - && (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED)) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: !write_data && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED"; - } - HDassert(ret >= 0); - HDassert((write_data && allocation == H5D_SPACE_STATUS_ALLOCATED) - || (!write_data && allocation == H5D_SPACE_STATUS_NOT_ALLOCATED)); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_i: H5Dget_space_status() failed."; + return false; + } else if (write_data && (allocation != H5D_SPACE_STATUS_ALLOCATED)) { + failure_mssg = "vrfy_ds_ctg_i: " + "write_data && allocation != H5D_SPACE_STATUS_ALLOCATED"; + return false; + } else if (!write_data && (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED)) { + failure_mssg = "vrfy_ds_ctg_i: " + "!write_data && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED"; + return false; } - if (pass) { - dcpl = H5Dget_create_plist(dsid); + dcpl = H5Dget_create_plist(dsid); - if (dcpl <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: H5Dget_create_plist() failed."; - } - HDassert(dcpl > 0); + if (dcpl <= 0) { + failure_mssg = "vrfy_ds_ctg_i: H5Dget_create_plist() failed."; + return false; } - if (pass) { - layout = H5Pget_layout(dcpl); + layout = H5Pget_layout(dcpl); - if (H5D_CONTIGUOUS != layout) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: H5D_CONTIGUOUS != layout"; - } - HDassert(H5D_CONTIGUOUS == layout); + if (H5D_CONTIGUOUS != layout) { + failure_mssg = "vrfy_ds_ctg_i: H5D_CONTIGUOUS != layout"; + return false; } - if (pass) { - ret = H5Pclose(dcpl); + ret = H5Pclose(dcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: H5Pclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_i: H5Pclose() failed."; + return false; } - if ((pass) && (write_data)) { - rdata = (int *) HDmalloc(sizeof(int) * DSET_DIMS); + if (write_data) { + rdata = HDmalloc(sizeof(int) * DSET_DIMS); if (!rdata) { - pass = FALSE; failure_mssg = "vrfy_ds_ctg_i: HDmalloc of rdata failed."; + return false; } - HDassert(rdata); - } - if ((pass) && (write_data)) { - ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, rdata); + ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, + rdata); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ds_ctg_i: H5Dread() failed."; + return false; } - HDassert(ret >= 0); - } - if ((pass) && (write_data)) { for (u = 0; u < DSET_DIMS; u++) { if ((int) u != rdata[u]) { - pass = FALSE; failure_mssg = "vrfy_ds_ctg_i: u != rdata[u]."; - break; + HDfree(rdata); + return false; } - HDassert((int )u == rdata[u]); } - HDfree(rdata); - } /* end if */ + } - if (pass) { - ret = H5Dclose(dsid); + ret = H5Dclose(dsid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_i: H5Dclose() failed"; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_i: H5Dclose() failed"; + return false; } - return; + return true; } /* vrfy_ds_ctg_i() */ @@ -1927,20 +1531,19 @@ vrfy_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data) { * to the data set or not as indicated by the write_data * parameter. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 * *------------------------------------------------------------------------- */ -void -ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) { +bool +ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) +{ int *wdata = NULL; unsigned u; hid_t dsid = -1; @@ -1950,102 +1553,77 @@ ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) { hsize_t chunk_dims[1] = { DSET_CHUNK_DIMS }; herr_t ret; - if (pass) { - sid = H5Screate_simple(1, dims, NULL); + sid = H5Screate_simple(1, dims, NULL); - if (sid <= 0) { - pass = FALSE; - failure_mssg = "ds_chk_i: H5Screate_simple() failed."; - } - HDassert(sid > 0); + if (sid <= 0) { + failure_mssg = "ds_chk_i: H5Screate_simple() failed."; + return false; } - if (pass) { - dcpl = H5Pcreate(H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); - if (dcpl <= 0) { - pass = FALSE; - failure_mssg = "ds_chk_i: H5Pcreate() failed."; - } - HDassert(dcpl > 0); + if (dcpl <= 0) { + failure_mssg = "ds_chk_i: H5Pcreate() failed."; + return false; } - if (pass) { - ret = H5Pset_chunk(dcpl, 1, chunk_dims); + ret = H5Pset_chunk(dcpl, 1, chunk_dims); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ds_chk_i: H5Pset_chunk() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ds_chk_i: H5Pset_chunk() failed."; + return false; } - if (pass) { - dsid = H5Dcreate2(fid, dset_name, H5T_NATIVE_INT, sid, - H5P_DEFAULT, dcpl, H5P_DEFAULT); + dsid = H5Dcreate2(fid, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, + H5P_DEFAULT); - if (dsid <= 0) { - pass = FALSE; - failure_mssg = "ds_chk_i: H5Dcreate2() failed"; - } - HDassert(dsid > 0); + if (dsid <= 0) { + failure_mssg = "ds_chk_i: H5Dcreate2() failed"; + return false; } - if (pass) { - ret = H5Pclose(dcpl); + ret = H5Pclose(dcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ds_chk_i: H5Pclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ds_chk_i: H5Pclose() failed."; + return false; } - if (pass) { - ret = H5Sclose(sid); + ret = H5Sclose(sid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ds_chk_i: H5Sclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ds_chk_i: H5Sclose() failed."; + return false; } - if ((pass) && (write_data)) { - wdata = (int *) HDmalloc(sizeof(int) * DSET_DIMS); + if (write_data) { + wdata = HDmalloc(sizeof(int) * DSET_DIMS); if (!wdata) { - pass = FALSE; failure_mssg = "ds_chk_i: HDmalloc of wdata failed."; + return false; } - HDassert(wdata); - } - if ((pass) && (write_data)) { for (u = 0; u < DSET_DIMS; u++) wdata[u] = (int) u; - ret = H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, wdata); + ret = H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, + wdata); + HDfree(wdata); if (ret < 0) { - pass = FALSE; failure_mssg = "ds_chk_i: H5Dwrite() failed."; + return false; } - HDassert(ret >= 0); - HDfree(wdata); - } /* end if */ + } - if (pass) { - ret = H5Dclose(dsid); + ret = H5Dclose(dsid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ds_chk_i: H5Dclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ds_chk_i: H5Dclose() failed."; + return false; } - return; + return true; } /* ds_chk_i */ @@ -2055,20 +1633,19 @@ ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) { * Purpose: Validate a chunked datasets w/int datatypes. Validate * data if indicated via the write_data parameter. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 * *------------------------------------------------------------------------- */ -void -vrfy_ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) { +bool +vrfy_ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) +{ int *rdata = NULL; unsigned u; hid_t dsid = -1; @@ -2082,204 +1659,145 @@ vrfy_ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) { htri_t type_equal; herr_t ret; - if (pass) { - dsid = H5Dopen2(fid, dset_name, H5P_DEFAULT); + dsid = H5Dopen2(fid, dset_name, H5P_DEFAULT); - if (dsid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: H5Dopen2() failed."; - } - HDassert(dsid > 0); + if (dsid <= 0) { + failure_mssg = "vrfy_ds_chk_i: H5Dopen2() failed."; + return false; } - if (pass) { - sid = H5Dget_space(dsid); + sid = H5Dget_space(dsid); - if (sid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: H5Dget_space() failed."; - } - HDassert(sid > 0); + if (sid <= 0) { + failure_mssg = "vrfy_ds_chk_i: H5Dget_space() failed."; + return false; } - if (pass) { - ndims = H5Sget_simple_extent_ndims(sid); + ndims = H5Sget_simple_extent_ndims(sid); - if (1 != ndims) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: 1 != ndims"; - } - HDassert(1 == ndims); + if (1 != ndims) { + failure_mssg = "vrfy_ds_chk_i: 1 != ndims"; + return false; } - if (pass) { - ret = H5Sget_simple_extent_dims(sid, dims, max_dims); + ret = H5Sget_simple_extent_dims(sid, dims, max_dims); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: H5Sget_simple_extent_dims() failed"; - } - else if ( DSET_DIMS != dims[0]) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: DSET_DIMS != dims[0]"; - } - else if ( DSET_DIMS != max_dims[0]) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: DSET_DIMS != max_dims[0]"; - } - HDassert(ret >= 0); - HDassert(DSET_DIMS == dims[0]); - HDassert(DSET_DIMS == max_dims[0]); + if (ret < 0) { + failure_mssg = "vrfy_ds_chk_i: H5Sget_simple_extent_dims() failed"; + return false; + } else if ( DSET_DIMS != dims[0]) { + failure_mssg = "vrfy_ds_chk_i: DSET_DIMS != dims[0]"; + return false; + } else if ( DSET_DIMS != max_dims[0]) { + failure_mssg = "vrfy_ds_chk_i: DSET_DIMS != max_dims[0]"; + return false; } - if (pass) { - ret = H5Sclose(sid); + ret = H5Sclose(sid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: H5Sclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_chk_i: H5Sclose() failed."; + return false; } - if (pass) { - tid = H5Dget_type(dsid); + tid = H5Dget_type(dsid); - if (tid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: H5Dget_type() failed."; - } - HDassert(tid > 0); + if (tid <= 0) { + failure_mssg = "vrfy_ds_chk_i: H5Dget_type() failed."; + return false; } - if (pass) { - type_equal = H5Tequal(tid, H5T_NATIVE_INT); + type_equal = H5Tequal(tid, H5T_NATIVE_INT); - if (1 != type_equal) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: tid != H5T_NATIVE_INT"; - } - HDassert(1 == type_equal); + if (1 != type_equal) { + failure_mssg = "vrfy_ds_chk_i: tid != H5T_NATIVE_INT"; + return false; } - if (pass) { - ret = H5Tclose(tid); + ret = H5Tclose(tid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: H5Tclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_chk_i: H5Tclose() failed."; + return false; } - if (pass) { - ret = H5Dget_space_status(dsid, &allocation); + ret = H5Dget_space_status(dsid, &allocation); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: H5Dget_space_status() failed."; - } - else if (write_data && (allocation != H5D_SPACE_STATUS_ALLOCATED)) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: write_data && allocation != H5D_SPACE_STATUS_ALLOCATED"; - } - else if (!write_data && (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED)) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: !write_data && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED"; - } - HDassert(ret >= 0); - HDassert((write_data && allocation == H5D_SPACE_STATUS_ALLOCATED) - || (!write_data && allocation == H5D_SPACE_STATUS_NOT_ALLOCATED)); + if (ret < 0) { + failure_mssg = "vrfy_ds_chk_i: H5Dget_space_status() failed."; + return false; + } else if (write_data && (allocation != H5D_SPACE_STATUS_ALLOCATED)) { + failure_mssg = "vrfy_ds_chk_i: write_data && allocation != H5D_SPACE_STATUS_ALLOCATED"; + return false; + } else if (!write_data && (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED)) { + failure_mssg = "vrfy_ds_chk_i: !write_data && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED"; + return false; } - if (pass) { - dcpl = H5Dget_create_plist(dsid); + dcpl = H5Dget_create_plist(dsid); - if (dcpl <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: H5Dget_create_plist() failed."; - } - HDassert(dcpl > 0); + if (dcpl <= 0) { + failure_mssg = "vrfy_ds_chk_i: H5Dget_create_plist() failed."; + return false; } - if (pass) { - layout = H5Pget_layout(dcpl); + layout = H5Pget_layout(dcpl); - if (H5D_CHUNKED != layout) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: H5D_CHUNKED != layout"; - } - HDassert(H5D_CHUNKED == layout); + if (H5D_CHUNKED != layout) { + failure_mssg = "vrfy_ds_chk_i: H5D_CHUNKED != layout"; + return false; } - if (pass) { - ret = H5Pget_chunk(dcpl, 1, chunk_dims); + ret = H5Pget_chunk(dcpl, 1, chunk_dims); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: H5Pget_chunk"; - } - else if ( DSET_CHUNK_DIMS != chunk_dims[0]) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: "; - } - HDassert(ret >= 0); - HDassert(DSET_CHUNK_DIMS == chunk_dims[0]); + if (ret < 0) { + failure_mssg = "vrfy_ds_chk_i: H5Pget_chunk"; + return false; + } else if ( DSET_CHUNK_DIMS != chunk_dims[0]) { + failure_mssg = "vrfy_ds_chk_i: "; + return false; } - if (pass) { - ret = H5Pclose(dcpl); + ret = H5Pclose(dcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: H5Pclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_chk_i: H5Pclose() failed."; + return false; } - if ((pass) && (write_data)) { - rdata = (int *) HDmalloc(sizeof(int) * DSET_DIMS); + if (write_data) { + rdata = HDmalloc(sizeof(int) * DSET_DIMS); if (!rdata) { - pass = FALSE; failure_mssg = "vrfy_ds_chk_i: HDmalloc of rdata failed."; + return false; } - HDassert(rdata); - } - if ((pass) && (write_data)) { - ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); + ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, + rdata); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ds_chk_i: H5Dread() failed."; + return false; } - HDassert(ret >= 0); - } - if ((pass) && (write_data)) { for (u = 0; u < DSET_DIMS; u++) { if ((int) u != rdata[u]) { - pass = FALSE; failure_mssg = "vrfy_ds_chk_i: u != rdata[u]"; - break; + HDfree(rdata); + return false; } - HDassert((int )u == rdata[u]); } - HDfree(rdata); - } /* end if */ + } - if (pass) { - ret = H5Dclose(dsid); + ret = H5Dclose(dsid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_chk_i: H5Dclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_chk_i: H5Dclose() failed."; + return false; } - return; + return true; } /* vrfy_ds_chk_i() */ @@ -2290,20 +1808,19 @@ vrfy_ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data) { * to the data set or not as indicated by the write_data * parameter. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 * *------------------------------------------------------------------------- */ -void -ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) { +bool +ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) +{ int *wdata = NULL; unsigned u; hid_t dsid = -1; @@ -2312,104 +1829,78 @@ ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) { hsize_t dims[1] = { DSET_COMPACT_DIMS }; herr_t ret; - if (pass) { - sid = H5Screate_simple(1, dims, NULL); + sid = H5Screate_simple(1, dims, NULL); - if (sid <= 0) { - pass = FALSE; - failure_mssg = "ds_cpt_i: H5Screate_simple() failed."; - } - HDassert(sid > 0); + if (sid <= 0) { + failure_mssg = "ds_cpt_i: H5Screate_simple() failed."; + return false; } - if (pass) { - dcpl = H5Pcreate(H5P_DATASET_CREATE); + dcpl = H5Pcreate(H5P_DATASET_CREATE); - if (dcpl <= 0) { - pass = FALSE; - failure_mssg = "ds_cpt_i: H5Pcreate() failed."; - } - HDassert(dcpl > 0); + if (dcpl <= 0) { + failure_mssg = "ds_cpt_i: H5Pcreate() failed."; + return false; } - if (pass) { - ret = H5Pset_layout(dcpl, H5D_COMPACT); + ret = H5Pset_layout(dcpl, H5D_COMPACT); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ds_cpt_i: H5Pset_layout() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ds_cpt_i: H5Pset_layout() failed."; + return false; } - if (pass) { - dsid = H5Dcreate2(fid, dset_name, H5T_NATIVE_INT, sid, - H5P_DEFAULT, dcpl, H5P_DEFAULT); + dsid = H5Dcreate2(fid, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, + H5P_DEFAULT); - if (dsid <= 0) { - pass = FALSE; - failure_mssg = "ds_cpt_i: H5Dcreate2() failed."; - } - HDassert(dsid > 0); + if (dsid <= 0) { + failure_mssg = "ds_cpt_i: H5Dcreate2() failed."; + return false; } - if (pass) { - ret = H5Pclose(dcpl); + ret = H5Pclose(dcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ds_cpt_i: H5Pclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ds_cpt_i: H5Pclose() failed."; + return false; } - if (pass) { - ret = H5Sclose(sid); + ret = H5Sclose(sid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ds_cpt_i: H5Sclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ds_cpt_i: H5Sclose() failed."; + return false; } - if ((pass) && (write_data)) { - wdata = (int *) HDmalloc(sizeof(int) * DSET_COMPACT_DIMS); + if (write_data) { + wdata = HDmalloc(sizeof(int) * DSET_COMPACT_DIMS); if (!wdata) { - pass = FALSE; failure_mssg = "ds_cpt_i: HDmalloc of wdata failed."; + return false; } - HDassert(wdata); - } - if ((pass) && (write_data)) { for (u = 0; u < DSET_COMPACT_DIMS; u++) wdata[u] = (int) u; - ret = H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, wdata); + ret = H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, + wdata); + HDfree(wdata); if (ret < 0) { - pass = FALSE; failure_mssg = "ds_cpt_i: H5Dwrite() failed."; + return false; } - HDassert(ret >= 0); - - HDfree(wdata); - } /* end if */ + } - if (pass) { - ret = H5Dclose(dsid); + ret = H5Dclose(dsid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ds_cpt_i: H5Dclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ds_cpt_i: H5Dclose() failed."; + return false; } - return; + return true; } /* ds_cpt_i() */ @@ -2420,20 +1911,19 @@ ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) { * Purpose: Validate a compact datasets w/int datatypes. Validate * data if indicated via the write_data parameter. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 * *------------------------------------------------------------------------- */ -void -vrfy_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) { +bool +vrfy_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) +{ int *rdata = NULL; unsigned u; hid_t dsid = -1; @@ -2447,186 +1937,133 @@ vrfy_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) { htri_t type_equal; herr_t ret; - if (pass) { - dsid = H5Dopen2(fid, dset_name, H5P_DEFAULT); + dsid = H5Dopen2(fid, dset_name, H5P_DEFAULT); - if (dsid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: H5Dopen2() failed."; - } - HDassert(dsid > 0); + if (dsid <= 0) { + failure_mssg = "vrfy_ds_cpt_i: H5Dopen2() failed."; + return false; } - if (pass) { - sid = H5Dget_space(dsid); + sid = H5Dget_space(dsid); - if (sid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: H5Dget_space() failed."; - } - HDassert(sid > 0); + if (sid <= 0) { + failure_mssg = "vrfy_ds_cpt_i: H5Dget_space() failed."; + return false; } - if (pass) { - ndims = H5Sget_simple_extent_ndims(sid); + ndims = H5Sget_simple_extent_ndims(sid); - if (1 != ndims) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: 1 != ndims"; - } - HDassert(1 == ndims); + if (1 != ndims) { + failure_mssg = "vrfy_ds_cpt_i: 1 != ndims"; + return false; } - if (pass) { - ret = H5Sget_simple_extent_dims(sid, dims, max_dims); + ret = H5Sget_simple_extent_dims(sid, dims, max_dims); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: H5Sget_simple_extent_dims() failed"; - } - else if ( DSET_COMPACT_DIMS != dims[0]) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: DSET_COMPACT_DIMS != dims[0]"; - } - else if ( DSET_COMPACT_DIMS != max_dims[0]) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: DSET_COMPACT_DIMS != max_dims[0]"; - } - HDassert(ret >= 0); - HDassert(DSET_COMPACT_DIMS == dims[0]); - HDassert(DSET_COMPACT_DIMS == max_dims[0]); + if (ret < 0) { + failure_mssg = "vrfy_ds_cpt_i: H5Sget_simple_extent_dims() failed"; + return false; + } else if ( DSET_COMPACT_DIMS != dims[0]) { + failure_mssg = "vrfy_ds_cpt_i: DSET_COMPACT_DIMS != dims[0]"; + return false; + } else if ( DSET_COMPACT_DIMS != max_dims[0]) { + failure_mssg = "vrfy_ds_cpt_i: DSET_COMPACT_DIMS != max_dims[0]"; + return false; } - if (pass) { - ret = H5Sclose(sid); + ret = H5Sclose(sid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: H5Sclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_cpt_i: H5Sclose() failed."; + return false; } - if (pass) { - tid = H5Dget_type(dsid); + tid = H5Dget_type(dsid); - if (tid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: H5Dget_type() failed."; - } - HDassert(tid > 0); + if (tid <= 0) { + failure_mssg = "vrfy_ds_cpt_i: H5Dget_type() failed."; + return false; } - if (pass) { - type_equal = H5Tequal(tid, H5T_NATIVE_INT); + type_equal = H5Tequal(tid, H5T_NATIVE_INT); - if (1 != type_equal) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: type != H5T_NATIVE_INT"; - } - HDassert(1 == type_equal); + if (1 != type_equal) { + failure_mssg = "vrfy_ds_cpt_i: type != H5T_NATIVE_INT"; + return false; } - if (pass) { - ret = H5Tclose(tid); + ret = H5Tclose(tid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: H5Tclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_cpt_i: H5Tclose() failed."; + return false; } - if (pass) { - ret = H5Dget_space_status(dsid, &allocation); + ret = H5Dget_space_status(dsid, &allocation); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: H5Dget_space_status() failed."; - } - else if (H5D_SPACE_STATUS_ALLOCATED != allocation) { - pass = FALSE; - failure_mssg = - "vrfy_ds_cpt_i: H5D_SPACE_STATUS_ALLOCATED != allocation"; - } - HDassert(ret >= 0); - HDassert(H5D_SPACE_STATUS_ALLOCATED == allocation); + if (ret < 0) { + failure_mssg = "vrfy_ds_cpt_i: H5Dget_space_status() failed."; + return false; + } else if (H5D_SPACE_STATUS_ALLOCATED != allocation) { + failure_mssg = + "vrfy_ds_cpt_i: H5D_SPACE_STATUS_ALLOCATED != allocation"; + return false; } - if (pass) { - dcpl = H5Dget_create_plist(dsid); + dcpl = H5Dget_create_plist(dsid); - if (dcpl <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: H5Dget_create_plist() failed."; - } - HDassert(dcpl > 0); + if (dcpl <= 0) { + failure_mssg = "vrfy_ds_cpt_i: H5Dget_create_plist() failed."; + return false; } - if (pass) { - layout = H5Pget_layout(dcpl); + layout = H5Pget_layout(dcpl); - if (H5D_COMPACT != layout) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: H5D_COMPACT != layout"; - } - HDassert(H5D_COMPACT == layout); + if (H5D_COMPACT != layout) { + failure_mssg = "vrfy_ds_cpt_i: H5D_COMPACT != layout"; + return false; } - if (pass) { - ret = H5Pclose(dcpl); + ret = H5Pclose(dcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: H5Pclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_cpt_i: H5Pclose() failed."; + return false; } - if ((pass) && (write_data)) { - rdata = (int *) HDmalloc(sizeof(int) * DSET_COMPACT_DIMS); + if (write_data) { + rdata = HDmalloc(sizeof(int) * DSET_COMPACT_DIMS); if (!rdata) { - pass = FALSE; failure_mssg = "vrfy_ds_cpt_i: HDmalloc of rdata failed."; + return false; } - HDassert(rdata); - } - if ((pass) && (write_data)) { - ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5P_DEFAULT, rdata); + ret = H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, + rdata); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ds_cpt_i: H5Dread() failed."; + return false; } - HDassert(ret >= 0); - } - if ((pass) && (write_data)) { for (u = 0; u < DSET_COMPACT_DIMS; u++) { if ((int) u != rdata[u]) { - pass = FALSE; failure_mssg = "vrfy_ds_cpt_i: (int)u != rdata[u]"; - break; + HDfree(rdata); + return false; } - HDassert((int )u == rdata[u]); } - HDfree(rdata); - } /* end if */ + } - if (pass) { - ret = H5Dclose(dsid); + ret = H5Dclose(dsid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_cpt_i: H5Dclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_cpt_i: H5Dclose() failed."; + return false; } - return; + return true; } /* vrfy_ds_cpt_i() */ @@ -2637,20 +2074,19 @@ vrfy_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data) { * Write data to the data set or not as indicated by the * write_data parameter. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 * *------------------------------------------------------------------------- */ -void -ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) { +bool +ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) +{ hid_t dsid = -1; hid_t sid = -1; hid_t tid = -1; @@ -2659,124 +2095,101 @@ ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) { hvl_t *wdata = NULL; unsigned u; - if (pass) { - sid = H5Screate_simple(1, dims, NULL); + sid = H5Screate_simple(1, dims, NULL); - if (sid <= 0) { - pass = FALSE; - failure_mssg = "ds_ctg_v: H5Screate_simple"; - } - HDassert(sid > 0); + if (sid <= 0) { + failure_mssg = "ds_ctg_v: H5Screate_simple"; + return false; } - if (pass) { - tid = H5Tvlen_create(H5T_NATIVE_INT); + tid = H5Tvlen_create(H5T_NATIVE_INT); - if (tid <= 0) { - pass = FALSE; - failure_mssg = "ds_ctg_v: H5Tvlen_create() failed."; - } - HDassert(tid > 0); + if (tid <= 0) { + failure_mssg = "ds_ctg_v: H5Tvlen_create() failed."; + return false; } - if (pass) { - dsid = H5Dcreate2(fid, dset_name, tid, sid, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dsid = H5Dcreate2(fid, dset_name, tid, sid, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); - if (dsid <= 0) { - pass = FALSE; - failure_mssg = "ds_ctg_v: H5Dcreate2() failed."; - } - HDassert(dsid > 0); + if (dsid <= 0) { + failure_mssg = "ds_ctg_v: H5Dcreate2() failed."; + return false; } - if ((pass) && (write_data)) { - wdata = (hvl_t *) HDmalloc(sizeof(hvl_t) * DSET_SMALL_DIMS); + if (write_data) { + wdata = HDmalloc(sizeof(hvl_t) * DSET_SMALL_DIMS); if (!wdata) { - pass = FALSE; failure_mssg = "ds_ctg_v: HDmalloc of wdata failed."; + return false; } - HDassert(wdata); - } - if ((pass) && (write_data)) { for (u = 0; u < DSET_SMALL_DIMS; u++) { int *tdata; unsigned len; unsigned v; len = (u % 10) + 1; - tdata = (int *) HDmalloc(sizeof(int) * len); + tdata = HDmalloc(sizeof(int) * len); if (!tdata) { - pass = FALSE; failure_mssg = "ds_ctg_v: HDmalloc of tdata failed."; - break; + while (u > 0) + free(wdata[u--].p); + HDfree(wdata); + return false; } - HDassert(tdata); for (v = 0; v < len; v++) tdata[v] = (int) (u + v); wdata[u].len = len; wdata[u].p = tdata; - } /* end for */ - } + } - if ((pass) && (write_data)) { ret = H5Dwrite(dsid, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); if (ret < 0) { - pass = FALSE; failure_mssg = "ds_ctg_v: H5Dwrite() failed."; + for (u = 0; u < DSET_SMALL_DIMS; u++) + free(wdata[u].p); + HDfree(wdata); + return false; } - HDassert(ret >= 0); - } - if ((pass) && (write_data)) { ret = H5Treclaim(tid, sid, H5P_DEFAULT, wdata); + HDfree(wdata); + if (ret < 0) { - pass = FALSE; failure_mssg = "ds_ctg_v: H5Treclaim() failed."; + return false; } - HDassert(ret >= 0); - - HDfree(wdata); - } /* end if */ + } - if (pass) { - ret = H5Sclose(sid); + ret = H5Sclose(sid); - if (sid < 0) { - pass = FALSE; - failure_mssg = "ds_ctg_v: H5Sclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ds_ctg_v: H5Sclose() failed."; + return false; } - if (pass) { - ret = H5Tclose(tid); + ret = H5Tclose(tid); - if (tid < 0) { - pass = FALSE; - failure_mssg = "ds_ctg_v: H5Tclose() failed."; - } - HDassert(ret >= 0); + if (tid < 0) { + failure_mssg = "ds_ctg_v: H5Tclose() failed."; + return false; } - if (pass) { - ret = H5Dclose(dsid); + ret = H5Dclose(dsid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "ds_ctg_v: H5Dclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "ds_ctg_v: H5Dclose() failed."; + return false; } - return; + return true; } /* ds_ctg_v() */ @@ -2786,20 +2199,19 @@ ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) { * Purpose: Validate a contiguous datasets w/variable-length datatypes. * Validate data if indicated via the write_data parameter. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * - * Return: void + * Return: true on success, false on failure. * * Programmer: John Mainzer * 9/14/15 * *------------------------------------------------------------------------- */ -void -vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) { +bool +vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) +{ hid_t dsid = -1; hid_t sid = -1; hid_t tid = -1; @@ -2814,170 +2226,120 @@ vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) { unsigned u; herr_t ret; - if (pass) { - dsid = H5Dopen2(fid, dset_name, H5P_DEFAULT); + dsid = H5Dopen2(fid, dset_name, H5P_DEFAULT); - if (dsid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5Dopen2() failed."; - } - HDassert(dsid > 0); + if (dsid <= 0) { + failure_mssg = "vrfy_ds_ctg_v: H5Dopen2() failed."; + return false; } - if (pass) { - sid = H5Dget_space(dsid); + sid = H5Dget_space(dsid); - if (sid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5Dget_space() failed"; - } - HDassert(sid > 0); + if (sid <= 0) { + failure_mssg = "vrfy_ds_ctg_v: H5Dget_space() failed"; + return false; } - if (pass) { - ndims = H5Sget_simple_extent_ndims(sid); + ndims = H5Sget_simple_extent_ndims(sid); - if (1 != ndims) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: 1 != ndims"; - } - HDassert(1 == ndims); + if (1 != ndims) { + failure_mssg = "vrfy_ds_ctg_v: 1 != ndims"; + return false; } - if (pass) { - ret = H5Sget_simple_extent_dims(sid, dims, max_dims); + ret = H5Sget_simple_extent_dims(sid, dims, max_dims); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5Sget_simple_extent_dims() failed."; - } - else if ( DSET_SMALL_DIMS != dims[0]) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: DSET_SMALL_DIMS != dims[0]"; - } - else if ( DSET_SMALL_DIMS != max_dims[0]) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: DSET_SMALL_DIMS != max_dims[0]"; - } - HDassert(ret >= 0); - HDassert(DSET_SMALL_DIMS == dims[0]); - HDassert(DSET_SMALL_DIMS == max_dims[0]); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_v: H5Sget_simple_extent_dims() failed."; + return false; + } else if ( DSET_SMALL_DIMS != dims[0]) { + failure_mssg = "vrfy_ds_ctg_v: DSET_SMALL_DIMS != dims[0]"; + return false; + } else if ( DSET_SMALL_DIMS != max_dims[0]) { + failure_mssg = "vrfy_ds_ctg_v: DSET_SMALL_DIMS != max_dims[0]"; + return false; } - if (pass) { - tid = H5Dget_type(dsid); + tid = H5Dget_type(dsid); - if (tid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5Dget_type() failed."; - } - HDassert(tid > 0); + if (tid <= 0) { + failure_mssg = "vrfy_ds_ctg_v: H5Dget_type() failed."; + return false; } - if (pass) { - tmp_tid = H5Tvlen_create(H5T_NATIVE_INT); + tmp_tid = H5Tvlen_create(H5T_NATIVE_INT); - if (tmp_tid <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5Tvlen_create() failed."; - } - HDassert(tmp_tid > 0); + if (tmp_tid <= 0) { + failure_mssg = "vrfy_ds_ctg_v: H5Tvlen_create() failed."; + return false; } - if (pass) { - type_equal = H5Tequal(tid, tmp_tid); + type_equal = H5Tequal(tid, tmp_tid); - if (1 != type_equal) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: type != vlen H5T_NATIVE_INT"; - } - HDassert(1 == type_equal); + if (1 != type_equal) { + failure_mssg = "vrfy_ds_ctg_v: type != vlen H5T_NATIVE_INT"; + return false; } - if (pass) { - ret = H5Tclose(tmp_tid); + ret = H5Tclose(tmp_tid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5Tclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_v: H5Tclose() failed."; + return false; } - if (pass) { - ret = H5Dget_space_status(dsid, &allocation); + ret = H5Dget_space_status(dsid, &allocation); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5Dget_space_status() failed"; - } - else if (write_data && (allocation != H5D_SPACE_STATUS_ALLOCATED)) { - pass = FALSE; - failure_mssg = - "vrfy_ds_ctg_v: write_data && allocation != H5D_SPACE_STATUS_ALLOCATED"; - } - else if (!write_data - && (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED)) { - pass = FALSE; - failure_mssg = - "vrfy_ds_ctg_v: !write_data && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED"; - } - HDassert(ret >= 0); - HDassert((write_data && allocation == H5D_SPACE_STATUS_ALLOCATED) - || (!write_data && allocation == H5D_SPACE_STATUS_NOT_ALLOCATED)); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_v: H5Dget_space_status() failed"; + return false; + } else if (write_data && (allocation != H5D_SPACE_STATUS_ALLOCATED)) { + failure_mssg = + "vrfy_ds_ctg_v: write_data && allocation != H5D_SPACE_STATUS_ALLOCATED"; + return false; + } else if (!write_data + && (allocation != H5D_SPACE_STATUS_NOT_ALLOCATED)) { + failure_mssg = + "vrfy_ds_ctg_v: !write_data && allocation != H5D_SPACE_STATUS_NOT_ALLOCATED"; + return false; } - if (pass) { - dcpl = H5Dget_create_plist(dsid); + dcpl = H5Dget_create_plist(dsid); - if (dcpl <= 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5Dget_create_plist() failed."; - } - HDassert(dcpl > 0); + if (dcpl <= 0) { + failure_mssg = "vrfy_ds_ctg_v: H5Dget_create_plist() failed."; + return false; } - if (pass) { - layout = H5Pget_layout(dcpl); + layout = H5Pget_layout(dcpl); - if (H5D_CONTIGUOUS != layout) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5D_CONTIGUOUS != layout"; - } - HDassert(H5D_CONTIGUOUS == layout); + if (H5D_CONTIGUOUS != layout) { + failure_mssg = "vrfy_ds_ctg_v: H5D_CONTIGUOUS != layout"; + return false; } - if (pass) { - ret = H5Pclose(dcpl); + ret = H5Pclose(dcpl); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5Pclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_v: H5Pclose() failed."; + return false; } - if ((pass) && (write_data)) { - rdata = (hvl_t *) HDmalloc(sizeof(hvl_t) * DSET_SMALL_DIMS); + if (write_data) { + rdata = HDmalloc(sizeof(hvl_t) * DSET_SMALL_DIMS); if (!rdata) { - pass = FALSE; failure_mssg = "vrfy_ds_ctg_v: HDmalloc of rdata failed."; + return false; } - HDassert(rdata); - } - if ((pass) && (write_data)) { ret = H5Dread(dsid, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ds_ctg_v: H5Dread() failed."; + return false; } - HDassert(ret >= 0); - } - if ((pass) && (write_data)) { for (u = 0; u < DSET_SMALL_DIMS; u++) { unsigned len; unsigned v; @@ -2987,64 +2349,47 @@ vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) { int *tdata = (int *) rdata[u].p; if (!tdata) { - pass = FALSE; failure_mssg = "vrfy_ds_ctg_v: !tdata"; - break; - } - else if ((int) (u + v) != tdata[v]) { - pass = FALSE; + return false; + } else if ((int) (u + v) != tdata[v]) { failure_mssg = "vrfy_ds_ctg_v: (int)(u + v) != tdata[v]"; - break; + return false; } - HDassert(tdata); - HDassert((int )(u + v) == tdata[v]); - } /* end for */ - } /* end for */ - } + } + } - if ((pass) && (write_data)) { ret = H5Treclaim(tid, sid, H5P_DEFAULT, rdata); + HDfree(rdata); + if (ret < 0) { - pass = FALSE; failure_mssg = "vrfy_ds_ctg_v: H5Treclaim() failed."; + return false; } - HDassert(ret >= 0); - - HDfree(rdata); - } /* end if */ + } - if (pass) { - ret = H5Sclose(sid); + ret = H5Sclose(sid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5Sclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_v: H5Sclose() failed."; + return false; } - if (pass) { - ret = H5Tclose(tid); + ret = H5Tclose(tid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5Tclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_v: H5Tclose() failed."; + return false; } - if (pass) { - ret = H5Dclose(dsid); + ret = H5Dclose(dsid); - if (ret < 0) { - pass = FALSE; - failure_mssg = "vrfy_ds_ctg_v: H5Dclose() failed."; - } - HDassert(ret >= 0); + if (ret < 0) { + failure_mssg = "vrfy_ds_ctg_v: H5Dclose() failed."; + return false; } - return; + return true; } /* vrfy_ds_ctg_v() */ /* Create or, if `validate` is true, validate objects in file `fid` under @@ -3053,10 +2398,11 @@ vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) { * * The valid selectors are consecutive and they start at 0. * - * If the selected objects cannot be created/validated, `pass` may be set + * If the selected objects cannot be created/validated, `*okp` will be set * to `false`, indicating that the selected objects could not be * created/validated, and `failure_mmsg` set to a description of the error - * that occurred. + * that occurred. If the objects can be created/validated, then `*okp` + * will be set to `true`. * * The program may also fail an assert()ion if the selected objects cannot * be created/validated. @@ -3065,74 +2411,77 @@ vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data) { */ static bool create_or_validate_selection(hid_t fid, const char *full_path, int proc_num, - int selector, bool skip_varlen, bool validate) + int selector, bool skip_varlen, bool validate, bool *okp) { const bool wr = !validate; + bool ok; switch (selector) { case 0: /* Add & verify an empty "new style" group */ - wr ? ns_grp_0(fid, full_path) : vrfy_ns_grp_0(fid, full_path); + ok = wr ? ns_grp_0(fid, full_path) : vrfy_ns_grp_0(fid, full_path); break; case 1: /* Add & verify a compact "new style" group (3 link messages) */ - wr ? ns_grp_c(fid, full_path, 3) : vrfy_ns_grp_c(fid, full_path, 3); + ok = wr ? ns_grp_c(fid, full_path, 3) + : vrfy_ns_grp_c(fid, full_path, 3); break; case 2: /* Add & verify a dense "new style" group (w/300 links, * in v2 B-tree & fractal heap) */ - wr ? ns_grp_d(fid, full_path, 300) : vrfy_ns_grp_d(fid, full_path, 300); + ok = wr ? ns_grp_d(fid, full_path, 300) + : vrfy_ns_grp_d(fid, full_path, 300); break; case 3: /* Add & verify an empty "old style" group to file */ - wr ? os_grp_0(fid, full_path) : vrfy_os_grp_0(fid, full_path); + ok = wr ? os_grp_0(fid, full_path) : vrfy_os_grp_0(fid, full_path); break; case 4: /* Add & verify an "old style" group (w/300 links, in * v1 B-tree & local heap) to file */ - wr ? os_grp_n(fid, full_path, proc_num, 300) - : vrfy_os_grp_n(fid, full_path, proc_num, 300); + ok = wr ? os_grp_n(fid, full_path, proc_num, 300) + : vrfy_os_grp_n(fid, full_path, proc_num, 300); break; case 5: /* Add & verify a contiguous dataset w/integer datatype (but no data) * to file */ - wr ? ds_ctg_i(fid, full_path, FALSE) - : vrfy_ds_ctg_i(fid, full_path, FALSE); + ok = wr ? ds_ctg_i(fid, full_path, FALSE) + : vrfy_ds_ctg_i(fid, full_path, FALSE); break; case 6: /* Add & verify a contiguous dataset w/integer datatype (with data) * to file */ - wr ? ds_ctg_i(fid, full_path, TRUE) - : vrfy_ds_ctg_i(fid, full_path, TRUE); + ok = wr ? ds_ctg_i(fid, full_path, TRUE) + : vrfy_ds_ctg_i(fid, full_path, TRUE); break; case 7: /* Add & verify a chunked dataset w/integer datatype (but no data) * to file */ - wr ? ds_chk_i(fid, full_path, FALSE) - : vrfy_ds_chk_i(fid, full_path, FALSE); + ok = wr ? ds_chk_i(fid, full_path, FALSE) + : vrfy_ds_chk_i(fid, full_path, FALSE); break; case 8: /* Add & verify a chunked dataset w/integer datatype (and data) * to file */ - wr ? ds_chk_i(fid, full_path, TRUE) - : vrfy_ds_chk_i(fid, full_path, TRUE); + ok = wr ? ds_chk_i(fid, full_path, TRUE) + : vrfy_ds_chk_i(fid, full_path, TRUE); break; case 9: /* Add & verify a compact dataset w/integer datatype (but no data) * to file */ - wr ? ds_cpt_i(fid, full_path, FALSE) - : vrfy_ds_cpt_i(fid, full_path, FALSE); + ok = wr ? ds_cpt_i(fid, full_path, FALSE) + : vrfy_ds_cpt_i(fid, full_path, FALSE); break; case 10: /* Add & verify a compact dataset w/integer datatype (and data) * to file */ - wr ? ds_cpt_i(fid, full_path, TRUE) - : vrfy_ds_cpt_i(fid, full_path, TRUE); + ok = wr ? ds_cpt_i(fid, full_path, TRUE) + : vrfy_ds_cpt_i(fid, full_path, TRUE); break; case 11: if (skip_varlen) @@ -3140,8 +2489,8 @@ create_or_validate_selection(hid_t fid, const char *full_path, int proc_num, /* Add & verify a contiguous dataset w/variable-length datatype * (but no data) to file */ - wr ? ds_ctg_v(fid, full_path, FALSE) - : vrfy_ds_ctg_v(fid, full_path, FALSE); + ok = wr ? ds_ctg_v(fid, full_path, FALSE) + : vrfy_ds_ctg_v(fid, full_path, FALSE); break; case 12: if (skip_varlen) @@ -3149,12 +2498,13 @@ create_or_validate_selection(hid_t fid, const char *full_path, int proc_num, /* Add & verify a contiguous dataset w/variable-length datatype * (and data) to file */ - wr ? ds_ctg_v(fid, full_path, TRUE) - : vrfy_ds_ctg_v(fid, full_path, TRUE); + ok = wr ? ds_ctg_v(fid, full_path, TRUE) + : vrfy_ds_ctg_v(fid, full_path, TRUE); break; default: return false; } + *okp = ok; return true; } @@ -3162,8 +2512,10 @@ create_or_validate_selection(hid_t fid, const char *full_path, int proc_num, * validate objects in file `fid` under group `base_path`. `proc_num` * tells the processor number the test runs on. If `skip_varlen` is * true, do NOT perform tests that use variable-length data. + * + * Return true if all tests pass, false if any test fails. */ -static void +static bool tend_zoo(hid_t fid, const char *base_path, int proc_num, bool skip_varlen, bool only_validate) { @@ -3171,32 +2523,34 @@ tend_zoo(hid_t fid, const char *base_path, int proc_num, bool skip_varlen, char full_path[1024]; int i, nwritten; char *leafp; + bool ok = true; nwritten = snprintf(full_path, sizeof(full_path), "%s/*", base_path); if (nwritten < 0 || (size_t)nwritten >= sizeof(full_path)) { - pass = false; failure_mssg = "create_zoo: snprintf failed"; - return; + return false; } if ((leafp = strrchr(full_path, '*')) == NULL) { - pass = false; failure_mssg = "create_zoo: strrchr failed"; - return; + return false; } - for (i = 0; pass; i++) { + for (i = 0; ok; i++) { assert('A' + i <= 'Z'); *leafp = (char)('A' + i); if (create && !create_or_validate_selection(fid, full_path, proc_num, i, - skip_varlen, false)) + skip_varlen, false, &ok)) break; zoo_create_hook(fid); if (!create_or_validate_selection(fid, full_path, proc_num, i, - skip_varlen, true)) + skip_varlen, true, &ok)) break; } + if (!ok) + fprintf(stderr, "%s: %s\n", __func__, failure_mssg); + return ok; } /*------------------------------------------------------------------------- @@ -3207,9 +2561,7 @@ tend_zoo(hid_t fid, const char *base_path, int proc_num, bool skip_varlen, * include instances of all on disk data structures used * in the HDF5 library. * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * * This function was initially created to assist in testing @@ -3222,10 +2574,10 @@ tend_zoo(hid_t fid, const char *base_path, int proc_num, bool skip_varlen, *------------------------------------------------------------------------- */ -void +bool create_zoo(hid_t fid, const char *base_path, int proc_num, bool skip_varlen) { - tend_zoo(fid, base_path, proc_num, skip_varlen, false); + return tend_zoo(fid, base_path, proc_num, skip_varlen, false); } /*------------------------------------------------------------------------- @@ -3234,9 +2586,7 @@ create_zoo(hid_t fid, const char *base_path, int proc_num, bool skip_varlen) * Purpose: Given the path to a group in which a "zoo" has been * constructed, validate the objects in the "zoo". * - * If pass is false on entry, do nothing. - * - * If an error is detected, set pass to FALSE, and set + * If an error is detected, return false, and set * failure_mssg to point to an appropriate error message. * * This function was initially created to assist in testing @@ -3249,9 +2599,9 @@ create_zoo(hid_t fid, const char *base_path, int proc_num, bool skip_varlen) *------------------------------------------------------------------------- */ -void +bool validate_zoo(hid_t fid, const char *base_path, int proc_num, bool skip_varlen) { - tend_zoo(fid, base_path, proc_num, skip_varlen, true); + return tend_zoo(fid, base_path, proc_num, skip_varlen, true); } |