summaryrefslogtreecommitdiffstats
path: root/test/ohdr.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-03-19 03:51:19 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-03-19 03:51:19 (GMT)
commitd812c6fe60fec2451d8d78b8fb51547628307a6c (patch)
treefb1f02516e6dfe5abce1cdb0155046b5d68a73d5 /test/ohdr.c
parentc31460c1b76c8d11534b57f025c57bdff9321f44 (diff)
downloadhdf5-d812c6fe60fec2451d8d78b8fb51547628307a6c.zip
hdf5-d812c6fe60fec2451d8d78b8fb51547628307a6c.tar.gz
hdf5-d812c6fe60fec2451d8d78b8fb51547628307a6c.tar.bz2
Cleanup API context function usage.
Diffstat (limited to 'test/ohdr.c')
-rw-r--r--test/ohdr.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/test/ohdr.c b/test/ohdr.c
index 5821357..d0f6966 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -69,7 +69,6 @@ test_cont(char *filename, hid_t fapl)
const char *short_name = "T";
const char *long_name = "This is the message";
size_t nchunks;
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
TESTING("object header continuation block");
@@ -79,8 +78,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Create the file to operate on */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
if (H5AC_ignore_tags(f) < 0) {
@@ -145,11 +142,9 @@ api_ctx_pushed = TRUE;
FAIL_STACK_ERROR
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
PASSED();
-
return SUCCEED;
error:
@@ -157,7 +152,6 @@ error:
H5O_close(&oh_locA, NULL);
H5O_close(&oh_locB, NULL);
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
return FAIL;
@@ -808,7 +802,7 @@ main(void)
time_t time_new, ro;
char msg[80]; /* Message for file format version */
int i; /* Local index variable */
-hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
+ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
herr_t ret; /* Generic return value */
/* Reset library */
@@ -816,6 +810,10 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
fapl = h5_fileaccess();
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
+ /* Push API context */
+ if(H5CX_push() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = TRUE;
+
/* Loop through all the combinations of low/high library format bounds */
for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) {
for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) {
@@ -846,8 +844,6 @@ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
/* Create the file to operate on */
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
FAIL_STACK_ERROR
-if(H5CX_push() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = TRUE;
if(NULL == (f = (H5F_t *)H5I_object(file)))
FAIL_STACK_ERROR
if(H5AC_ignore_tags(f) < 0) {
@@ -1037,8 +1033,6 @@ api_ctx_pushed = TRUE;
if(test_ohdr_cache(filename, fapl) < 0)
TEST_ERROR
-if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
-api_ctx_pushed = FALSE;
} /* high */
} /* low */
@@ -1049,6 +1043,10 @@ api_ctx_pushed = FALSE;
if(test_ohdr_swmr(TRUE) < 0) TEST_ERROR
if(test_ohdr_swmr(FALSE) < 0) TEST_ERROR
+ /* Pop API context */
+ if(api_ctx_pushed && H5CX_pop() < 0) FAIL_STACK_ERROR
+ api_ctx_pushed = FALSE;
+
HDputs("All object header tests passed.");
h5_cleanup(FILENAME, fapl);
return 0;
@@ -1057,9 +1055,10 @@ error:
puts("*** TESTS FAILED ***");
H5E_BEGIN_TRY {
H5Fclose(file);
-if(api_ctx_pushed) H5CX_pop();
} H5E_END_TRY;
+ if(api_ctx_pushed) H5CX_pop();
+
return 1;
} /* end main() */