diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2015-09-16 21:57:01 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2015-09-16 21:57:01 (GMT) |
commit | 222e7186ea78e49b387284cbb9997677c933c368 (patch) | |
tree | 76379c5fca586e63a3ddd729436cbd16dff21963 /test | |
parent | 78848c63b7f0a3e6977ff7b34cafec50a2a25c29 (diff) | |
download | hdf5-222e7186ea78e49b387284cbb9997677c933c368.zip hdf5-222e7186ea78e49b387284cbb9997677c933c368.tar.gz hdf5-222e7186ea78e49b387284cbb9997677c933c368.tar.bz2 |
[svn-r27810] Description:
Clean up resources on failure
Tested on:
Linux/32 2.6.x (jam) w/Purify
Diffstat (limited to 'test')
-rw-r--r-- | test/dsets.c | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/test/dsets.c b/test/dsets.c index 7a25f03..a233b4e 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -389,11 +389,11 @@ static herr_t test_simple_io(const char *env_h5_drvr, hid_t fapl) { char filename[FILENAME_BUF_SIZE]; - hid_t file, dataset, space, xfer; + hid_t file = -1, dataset = -1, space = -1, xfer = -1; int i, j, n; hsize_t dims[2]; void *tconv_buf = NULL; - int f; + int f = -1; haddr_t offset; int rdata[DSET_DIM1][DSET_DIM2]; @@ -425,6 +425,8 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) /* Create the dataset */ if((dataset = H5Dcreate2(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if(H5Sclose(space) < 0) TEST_ERROR + space = -1; /* Test dataset address. Should be undefined. */ if(H5Dget_offset(dataset) != HADDR_UNDEF) goto error; @@ -455,8 +457,11 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) } if(H5Pclose (xfer) < 0) goto error; + xfer = -1; if(H5Dclose(dataset) < 0) goto error; + dataset = -1; if(H5Fclose(file) < 0) goto error; + file = -1; f = HDopen(filename, O_RDONLY, 0); HDlseek(f, (off_t)offset, SEEK_SET); @@ -475,8 +480,9 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) } HDclose(f); + f = -1; - HDfree (tconv_buf); + HDfree(tconv_buf); PASSED(); } /* end if */ else { @@ -487,8 +493,18 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) return 0; error: + if(space > 0) + if(H5Sclose(space) < 0) TEST_ERROR + if(xfer > 0) + if(H5Pclose(xfer) < 0) TEST_ERROR + if(dataset > 0) + if(H5Dclose(dataset) < 0) TEST_ERROR + if(file > 0) + if(H5Fclose(file) < 0) TEST_ERROR + if(f > 0) + HDclose(f); if(tconv_buf) - HDfree (tconv_buf); + HDfree(tconv_buf); return -1; } @@ -511,10 +527,10 @@ static herr_t test_userblock_offset(const char *env_h5_drvr, hid_t fapl) { char filename[FILENAME_BUF_SIZE]; - hid_t file, fcpl, dataset, space; + hid_t file = -1, fcpl = -1, dataset = -1, space = -1; int i, j; hsize_t dims[2]; - int f; + int f = -1; haddr_t offset; int rdata[DSET_DIM1][DSET_DIM2]; @@ -529,6 +545,8 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl) if((file=H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl)) < 0) goto error; + if(H5Pclose(fcpl) < 0) TEST_ERROR + fcpl = -1; /* Create the data space */ dims[0] = DSET_DIM1; @@ -538,6 +556,8 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl) /* Create the dataset */ if((dataset = H5Dcreate2(file, DSET_USERBLOCK_IO_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if(H5Sclose(space) < 0) TEST_ERROR + space = -1; /* Write the data to the dataset */ if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0) @@ -549,7 +569,9 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl) if((offset = H5Dget_offset(dataset)) == HADDR_UNDEF) goto error; if(H5Dclose(dataset) < 0) goto error; + dataset = -1; if(H5Fclose(file) < 0) goto error; + file = -1; f = HDopen(filename, O_RDONLY, 0); HDlseek(f, (off_t)offset, SEEK_SET); @@ -568,6 +590,7 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl) } HDclose(f); + f = -1; PASSED(); } /* end if */ @@ -579,6 +602,16 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl) return 0; error: + if(space > 0) + if(H5Sclose(space) < 0) TEST_ERROR + if(fcpl > 0) + if(H5Pclose(fcpl) < 0) TEST_ERROR + if(dataset > 0) + if(H5Dclose(dataset) < 0) TEST_ERROR + if(file > 0) + if(H5Fclose(file) < 0) TEST_ERROR + if(f > 0) + HDclose(f); return -1; } |