summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-12-10 12:36:56 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-12-10 12:36:56 (GMT)
commit34d14bdf89d63023dfeb5ff471b71e5b591faa31 (patch)
tree64aa9fbfe2b3e011b55b39c70b4f85cc28c3a9c9 /test
parentadce7dfd846901f3164d446cf7443747ddefc492 (diff)
downloadhdf5-34d14bdf89d63023dfeb5ff471b71e5b591faa31.zip
hdf5-34d14bdf89d63023dfeb5ff471b71e5b591faa31.tar.gz
hdf5-34d14bdf89d63023dfeb5ff471b71e5b591faa31.tar.bz2
[svn-r17980] Description:
Bring Coverity changes into the trunk: (also other minor cleanups) r17955: Fix Coverity item 24. Add missing error condition to H5AC_ext_config_2_int_config. r17956: Fix Coverity item 24. Improve error checking in H5A_compact_build_table_cb. r17957: Fix Coverity item 150. Fix warning in H5A_compact_build_table_cb. r17958: Fix Coverity item 117. Fix error handling in H5B_shared_new. r17959: Fix Coverity item 209. Added an assertion for leaf->shared in H5B2_cache_leaf_dest. r17960: Fix Coverity item 208. Added an assertion for internal->shared in H5B2_cache_internal_dest. r17961: Fix Coverity item 89. Reworked the code to avoid array overrun in H5C__autoadjust__ageout__insert_new_marker. r17962: Fix for coverity Resource_leak 195,203,204,205. r17963: Fix Coverity item 44. Prevented potential NULL dereference in H5D_btree_debug. r17964: Fix Coverity issues #197, 198 & 199: memory not being released. (Also clean up other resource leaks in nearby and/or similar code). r17965: Fix Coverity issue #151: release resources on error r17966: Fix Coverity issue #187: Remove leftover code remnant from prior bugfix which was causing resource leak of open files. r17967: Fixed Coverity issues # 193 & 194. Removed unnecessary memory allocation and added comparison of length of path parameter to the size of the destination buffer in h5import.h/h5import.c. r17968: Fix Coverity item 144. Fixed memory leak on error in H5D_chunk_copy. r17969: Fix for coverity Resource_leak #196. r17970: Coverity 167-173: Initialized pointer of buffers. In error handling, closed types and free memory. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.2 (amazon) in debug mode Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'test')
-rw-r--r--test/btree2.c4
-rw-r--r--test/dsets.c2
-rw-r--r--test/dt_arith.c2
-rw-r--r--test/dtypes.c2
-rw-r--r--test/hyperslab.c2
-rw-r--r--test/istore.c2
-rw-r--r--test/ntypes.c1315
-rw-r--r--test/pool.c2
-rw-r--r--test/theap.c2
-rw-r--r--test/tskiplist.c2
-rw-r--r--test/ttst.c2
-rw-r--r--test/tunicode.c2
-rw-r--r--test/unlink.c76
-rw-r--r--test/vfd.c5
14 files changed, 858 insertions, 562 deletions
diff --git a/test/btree2.c b/test/btree2.c
index fb24433..eabd208 100644
--- a/test/btree2.c
+++ b/test/btree2.c
@@ -2770,7 +2770,7 @@ test_insert_lots(hid_t fapl, const H5B2_create_t *cparam,
curr_time=1109170019;
HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
#endif /* QAK */
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/*
* Test inserting many records into v2 B-tree
@@ -6445,7 +6445,7 @@ test_remove_lots(const char *env_h5_drvr, hid_t fapl, const H5B2_create_t *cpara
curr_time = 1163537969;
HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time);
#endif /* QAK */
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/*
* Test removing many records into v2 B-tree
diff --git a/test/dsets.c b/test/dsets.c
index 58fa2c8..b4c6a84 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -7309,7 +7309,7 @@ main(void)
envval = "nomatch";
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
/* Testing setup */
h5_reset();
diff --git a/test/dt_arith.c b/test/dt_arith.c
index 43855a8..420570a 100644
--- a/test/dt_arith.c
+++ b/test/dt_arith.c
@@ -5218,7 +5218,7 @@ main(void)
unsigned long nerrors = 0;
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
reset_hdf5();
diff --git a/test/dtypes.c b/test/dtypes.c
index d2db20b..04f526a 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -6337,7 +6337,7 @@ main(void)
hid_t fapl = -1;
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
reset_hdf5();
fapl = h5_fileaccess();
diff --git a/test/hyperslab.c b/test/hyperslab.c
index 194c0f6..b756449 100644
--- a/test/hyperslab.c
+++ b/test/hyperslab.c
@@ -1234,7 +1234,7 @@ main(int argc, char *argv[])
printf("\n");
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
/*
* Open the library explicitly for thread-safe builds, so per-thread
diff --git a/test/istore.c b/test/istore.c
index fff6706..fb0f3fc 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -596,7 +596,7 @@ main(int argc, char *argv[])
printf("\n");
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
/* Reset library */
h5_reset();
diff --git a/test/ntypes.c b/test/ntypes.c
index a82f051..87484d9 100644
--- a/test/ntypes.c
+++ b/test/ntypes.c
@@ -23,8 +23,8 @@
#include "h5test.h"
const char *FILENAME[] = {
- "ntypes",
- NULL
+ "ntypes",
+ NULL
};
#define DIM0 100
@@ -60,6 +60,7 @@ int ipoints3[DIM0][DIM1][5], icheck3[DIM0][DIM1][5];
#define SPACE2_DIM1 10
#define SPACE2_DIM2 10
+
/*-------------------------------------------------------------------------
* Function: test_atomic_dtype
@@ -80,11 +81,11 @@ int ipoints3[DIM0][DIM1][5], icheck3[DIM0][DIM1][5];
static herr_t
test_atomic_dtype(hid_t file)
{
- hid_t dataset, space;
- hid_t dtype, native_type;
- int i, j, n;
- hsize_t dims[2];
- void *tmp;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ void *tmp = NULL;
TESTING("atomic datatype");
@@ -101,7 +102,8 @@ test_atomic_dtype(hid_t file)
/*------------------- Test data values ------------------------*/
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_1, H5T_STD_I32BE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Write the data to the dataset */
if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints2) < 0)
@@ -127,18 +129,20 @@ test_atomic_dtype(hid_t file)
TEST_ERROR;
/* Read the dataset back. The temporary buffer is for special platforms
- * like Cray. */
- tmp = malloc((size_t)(DIM0 * DIM1 * H5Tget_size(native_type)));
+ * like Cray. */
+ if(NULL == (tmp = HDmalloc((size_t)(DIM0 * DIM1 * H5Tget_size(native_type)))))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
TEST_ERROR;
/* Copy data from temporary buffer to destination buffer */
- memcpy(icheck2, tmp, (size_t)(DIM0 * DIM1 * H5Tget_size(native_type)));
- free(tmp);
+ HDmemcpy(icheck2, tmp, (size_t)(DIM0 * DIM1 * H5Tget_size(native_type)));
+ HDfree(tmp);
+ tmp = NULL;
/* Convert to the integer type */
- if(H5Tconvert(native_type, H5T_NATIVE_INT, (DIM0*DIM1), icheck2, NULL, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, H5T_NATIVE_INT, (DIM0 * DIM1), icheck2, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
@@ -159,7 +163,8 @@ test_atomic_dtype(hid_t file)
/* Create the dataset of H5T_STD_I64LE */
if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_2, H5T_STD_I64LE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
@@ -181,7 +186,8 @@ test_atomic_dtype(hid_t file)
/* Create the dataset of H5T_STD_I8LE */
if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_3, H5T_STD_I8LE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
@@ -203,7 +209,8 @@ test_atomic_dtype(hid_t file)
/* Create the dataset of H5T_IEEE_F32BE */
if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_4, H5T_IEEE_F32BE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
@@ -225,7 +232,8 @@ test_atomic_dtype(hid_t file)
/* Create the dataset of H5T_IEEE_F64BE */
if((dataset = H5Dcreate2(file, DSET_ATOMIC_NAME_5, H5T_IEEE_F64BE, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
if((dtype = H5Dget_type(dataset)) < 0) TEST_ERROR;
@@ -253,6 +261,16 @@ test_atomic_dtype(hid_t file)
return 0;
error:
+ if(tmp)
+ HDfree(tmp);
+
+ H5E_BEGIN_TRY {
+ H5Dclose(dataset);
+ H5Tclose(native_type);
+ H5Tclose(dtype);
+ H5Sclose(space);
+ } H5E_END_TRY;
+
return -1;
}
@@ -286,14 +304,14 @@ test_compound_dtype2(hid_t file)
s2 st;
unsigned long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, tid_m, tid_m2,
- mem_id, nest_mem_id;
- int i, j, n;
- hsize_t dims[2];
- s1 *temp_point, *temp_check;
- s1 *points=NULL, *check=NULL;
- void *tmp, *bkg;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1,
+ tid_m2 = -1, mem_id = -1, nest_mem_id = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ s1 *temp_point = NULL, *temp_check = NULL;
+ s1 *points = NULL, *check = NULL;
+ void *tmp = NULL, *bkg = NULL;
TESTING("nested compound datatype");
@@ -304,15 +322,15 @@ test_compound_dtype2(hid_t file)
TEST_ERROR;
/* Initialize the dataset */
- for (i = n = 0, temp_point=points; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++,temp_point++) {
- temp_point->c = 't';
- temp_point->i = n++;
- temp_point->st.c2 = (short)(i + j);
- temp_point->st.l2 = (i * 5 + j * 50) * n;
- temp_point->l = (unsigned long long)((i * 10 + j * 100) * n);
- }
- }
+ for(i = n = 0, temp_point = points; i < DIM0; i++) {
+ for(j = 0; j < DIM1; j++, temp_point++) {
+ temp_point->c = 't';
+ temp_point->i = n++;
+ temp_point->st.c2 = (short)(i + j);
+ temp_point->st.l2 = (i * 5 + j * 50) * n;
+ temp_point->l = (unsigned long long)((i * 10 + j * 100) * n);
+ } /* end for */
+ } /* end for */
/* Create the data space */
dims[0] = DIM0;
@@ -353,7 +371,8 @@ test_compound_dtype2(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_2, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create compound datatype for memory */
if((tid_m2 = H5Tcreate(H5T_COMPOUND, sizeof(s2))) < 0) TEST_ERROR;
@@ -369,7 +388,7 @@ test_compound_dtype2(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -451,36 +470,39 @@ test_compound_dtype2(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0*DIM1*H5Tget_size(native_type));
- if((bkg=calloc(sizeof(s1),DIM0*DIM1))==NULL)
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
+ if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, bkg, H5P_DEFAULT))
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0)
TEST_ERROR;
- free(bkg);
+ HDfree(bkg);
+ bkg = NULL;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++, temp_point++,temp_check++) {
- if(temp_point->c != temp_check->c ||
- temp_point->i != temp_check->i ||
- temp_point->st.c2 != temp_check->st.c2 ||
- temp_point->st.l2 != temp_check->st.l2 ||
- temp_point->l != temp_check->l ) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
- }
- }
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++) {
+ for(j = 0; j < DIM1; j++, temp_point++, temp_check++) {
+ if(temp_point->c != temp_check->c ||
+ temp_point->i != temp_check->i ||
+ temp_point->st.c2 != temp_check->st.c2 ||
+ temp_point->st.l2 != temp_check->st.l2 ||
+ temp_point->l != temp_check->l ) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
+ } /* end for */
+ } /* end for */
/* Close temporary datatypes */
if(H5Tclose(tid2) < 0) TEST_ERROR;
@@ -494,17 +516,35 @@ test_compound_dtype2(hid_t file)
H5Tclose(tid_m);
/* Free memory for test data */
- free(points);
- free(check);
+ HDfree(points);
+ HDfree(check);
PASSED();
return 0;
error:
- if(points!=NULL)
- free(points);
- if(check!=NULL)
- free(check);
+ if(tmp)
+ HDfree(tmp);
+ if(bkg)
+ HDfree(bkg);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid_m);
+ H5Tclose(tid_m2);
+ H5Sclose(space);
+ H5Tclose(mem_id);
+ H5Tclose(nest_mem_id);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ } H5E_END_TRY;
+
return -1;
}
@@ -533,17 +573,19 @@ test_compound_dtype(hid_t file)
unsigned int i;
long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, mem_id;
- int i, j, n;
- hsize_t dims[2];
- s1 *temp_point, *temp_check;
- s1 *points, *check;
- void *tmp, *bkg;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, mem_id = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ s1 *temp_point = NULL;
+ s1 *temp_check = NULL;
+ s1 *points = NULL;
+ s1 *check = NULL;
+ void *tmp = NULL;
+ void *bkg = NULL;
TESTING("compound datatype");
-
/* Allocate space for the points & check arrays */
if(NULL == (points = (s1 *)HDmalloc(sizeof(s1) * DIM0 * DIM1)))
TEST_ERROR;
@@ -551,12 +593,12 @@ test_compound_dtype(hid_t file)
TEST_ERROR;
/* Initialize the dataset */
- for(i = n = 0, temp_point=points; i < DIM0; i++)
- for(j = 0; j < DIM1; j++,temp_point++) {
- temp_point->c = 't';
- temp_point->i = (unsigned int)(n++);
- temp_point->l = (i*10+j*100)*n;
- } /* end for */
+ for(i = n = 0, temp_point = points; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++) {
+ temp_point->c = 't';
+ temp_point->i = (unsigned int)(n++);
+ temp_point->l = (i * 10 + j * 100) * n;
+ } /* end for */
/* Create the data space */
dims[0] = DIM0;
@@ -573,7 +615,8 @@ test_compound_dtype(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create compound datatype for datatype in memory */
if((tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR;
@@ -583,7 +626,7 @@ test_compound_dtype(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -633,33 +676,35 @@ test_compound_dtype(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0*DIM1*H5Tget_size(native_type));
- bkg = calloc(sizeof(s1),DIM0*DIM1);
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
+ if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1)))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid2, (DIM0*DIM1), check, bkg, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, tid2, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0)
TEST_ERROR;
- free(bkg);
+ HDfree(bkg);
+ bkg = NULL;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++, temp_point++,temp_check++) {
- if(temp_point->c != temp_check->c ||
- temp_point->i != temp_check->i ||
- temp_point->l != temp_check->l ) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
- }
- }
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++, temp_check++)
+ if(temp_point->c != temp_check->c ||
+ temp_point->i != temp_check->i ||
+ temp_point->l != temp_check->l ) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
/* Close datatype */
if(H5Tclose(tid) < 0) TEST_ERROR;
@@ -670,13 +715,33 @@ test_compound_dtype(hid_t file)
H5Tclose(tid2);
/* Free memory for test data */
- free(points);
- free(check);
+ HDfree(points);
+ HDfree(check);
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+ if(bkg)
+ HDfree(bkg);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Tclose(tid);
+ H5Sclose(space);
+ H5Tclose(mem_id);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid2);
+ } H5E_END_TRY;
+
return -1;
}
@@ -705,15 +770,15 @@ test_compound_dtype3(hid_t file)
int a[5];
long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, tid_m, tid_m2,
- mem_id, nest_mem_id;
- hsize_t array_dims[1]={5};
- int i, j, k, n;
- hsize_t dims[2];
- s1 *temp_point, *temp_check;
- s1 *points=NULL, *check=NULL;
- void *tmp, *bkg;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1,
+ tid_m2 = -1, mem_id = -1, nest_mem_id = -1;
+ hsize_t array_dims[1] = {5};
+ int i, j, k, n;
+ hsize_t dims[2];
+ s1 *temp_point = NULL, *temp_check = NULL;
+ s1 *points = NULL, *check = NULL;
+ void *tmp = NULL, *bkg = NULL;
TESTING("compound datatype with array as field");
@@ -724,13 +789,13 @@ test_compound_dtype3(hid_t file)
TEST_ERROR;
/* Initialize the dataset */
- for(i = n = 0, temp_point=points; i < DIM0; i++)
- for(j = 0; j < DIM1; j++,temp_point++) {
- temp_point->c = 't';
- temp_point->l = (i*10+j*100)*n;
- for(k = 0; k < 5; k++)
- (temp_point->a)[k] = n++;
- } /* end for */
+ for(i = n = 0, temp_point = points; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++) {
+ temp_point->c = 't';
+ temp_point->l = (i * 10 + j * 100) * n;
+ for(k = 0; k < 5; k++)
+ (temp_point->a)[k] = n++;
+ } /* end for */
/* Create the data space */
dims[0] = DIM0;
@@ -750,7 +815,8 @@ test_compound_dtype3(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_3, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create array datatype */
if((tid_m2 = H5Tarray_create2(H5T_NATIVE_INT, 1, array_dims)) < 0) TEST_ERROR;
@@ -763,7 +829,7 @@ test_compound_dtype3(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -825,42 +891,44 @@ test_compound_dtype3(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0*DIM1*H5Tget_size(native_type));
- if((bkg=calloc(sizeof(s1),DIM0*DIM1))==NULL)
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR;
+ if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, bkg, H5P_DEFAULT))
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0)
TEST_ERROR;
- free(bkg);
+ HDfree(bkg);
+ bkg = NULL;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++, temp_point++,temp_check++) {
- if(temp_point->c != temp_check->c ||
- temp_point->l != temp_check->l ) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
-
- for (k = 0; k < 5; k++) {
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++, temp_check++) {
+ if(temp_point->c != temp_check->c ||
+ temp_point->l != temp_check->l ) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
+
+ for(k = 0; k < 5; k++) {
if(temp_point->a[k] != temp_check->a[k]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d,%d\n", i, j, k);
- goto error;
- }
- }
- }
- }
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d,%d\n", i, j, k);
+ goto error;
+ } /* end if */
+ } /* end for */
+ } /* end for */
H5Dclose(dataset);
H5Tclose(dtype);
@@ -869,13 +937,36 @@ test_compound_dtype3(hid_t file)
H5Tclose(tid_m2);
/* Free memory for test data */
- free(points);
- free(check);
+ HDfree(points);
+ HDfree(check);
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+ if(bkg)
+ HDfree(bkg);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Tclose(mem_id);
+ H5Tclose(nest_mem_id);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid_m);
+ H5Tclose(tid_m2);
+ } H5E_END_TRY;
+
return -1;
}
@@ -904,14 +995,14 @@ test_compound_opaque(hid_t file)
unsigned char o[5];
long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, tid_m,
- mem_id;
- int i, j, k, n;
- hsize_t dims[2];
- s1 *temp_point, *temp_check;
- s1 *points=NULL, *check=NULL;
- void *tmp, *bkg;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid_m = -1,
+ mem_id = -1;
+ int i, j, k, n;
+ hsize_t dims[2];
+ s1 *temp_point = NULL, *temp_check = NULL;
+ s1 *points = NULL, *check = NULL;
+ void *tmp = NULL, *bkg = NULL;
TESTING("compound datatype with opaque field");
@@ -922,13 +1013,13 @@ test_compound_opaque(hid_t file)
TEST_ERROR;
/* Initialize the dataset */
- for(i = n = 0, temp_point=points; i < DIM0; i++)
- for(j = 0; j < DIM1; j++,temp_point++) {
- temp_point->c = 't';
- temp_point->l = (i*10+j*100)*n;
- for(k = 0; k < 5; k++)
- (temp_point->o)[k] = (unsigned char)(n++);
- } /* end for */
+ for(i = n = 0, temp_point = points; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++) {
+ temp_point->c = 't';
+ temp_point->l = (i * 10 + j * 100) * n;
+ for(k = 0; k < 5; k++)
+ (temp_point->o)[k] = (unsigned char)(n++);
+ } /* end for */
/* Create the data space */
dims[0] = DIM0;
@@ -949,7 +1040,8 @@ test_compound_opaque(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_COMPOUND_NAME_4, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create compound datatype for datatype in memory */
if((tid_m = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR;
@@ -959,7 +1051,7 @@ test_compound_opaque(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -1014,42 +1106,44 @@ test_compound_opaque(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = HDmalloc(DIM0*DIM1*H5Tget_size(native_type));
- if((bkg=HDcalloc(sizeof(s1),DIM0*DIM1))==NULL)
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR;
+ if(NULL == (bkg = HDcalloc(sizeof(s1), DIM0 * DIM1)))
TEST_ERROR;
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- HDmemcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
+ HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, bkg, H5P_DEFAULT))
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, bkg, H5P_DEFAULT) < 0)
TEST_ERROR;
HDfree(bkg);
+ bkg = NULL;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++, temp_point++,temp_check++) {
- if(temp_point->c != temp_check->c ||
- temp_point->l != temp_check->l ) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
- goto error;
- }
-
- for (k = 0; k < 5; k++) {
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++, temp_point++, temp_check++) {
+ if(temp_point->c != temp_check->c ||
+ temp_point->l != temp_check->l ) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
+ goto error;
+ } /* end if */
+
+ for(k = 0; k < 5; k++) {
if(temp_point->o[k] != temp_check->o[k]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d,%d\n", i, j, k);
- goto error;
- }
- }
- }
- }
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d,%d\n", i, j, k);
+ goto error;
+ } /* end if */
+ } /* end for */
+ } /* end for */
H5Dclose(dataset);
H5Tclose(dtype);
@@ -1063,7 +1157,28 @@ test_compound_opaque(hid_t file)
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+ if(bkg)
+ HDfree(bkg);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Tclose(mem_id);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid_m);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1087,28 +1202,28 @@ test_compound_opaque(hid_t file)
static herr_t
test_enum_dtype(hid_t file)
{
- hid_t dataset, space;
- hid_t tid, tid_m, dtype, native_type;
- int i, j, n;
- hsize_t dims[2];
- void *tmp;
- short colors[8];
- unsigned char sub_colors[16];
- const char *mname[] = { "RED",
- "GREEN",
- "BLUE",
- "YELLOW",
- "PINK",
- "PURPLE",
- "ORANGE",
- "WHITE" };
+ hid_t dataset = -1, space = -1;
+ hid_t tid = -1, tid_m = -1, dtype = -1, native_type = -1;
+ int i, j, n;
+ hsize_t dims[2];
+ void *tmp = NULL;
+ short colors[8];
+ unsigned char sub_colors[16];
+ const char *mname[] = { "RED",
+ "GREEN",
+ "BLUE",
+ "YELLOW",
+ "PINK",
+ "PURPLE",
+ "ORANGE",
+ "WHITE" };
TESTING("enum datatype");
/* Initialize the dataset */
for(i = 0; i < DIM0; i++)
for(j = 0, n = 0; j < DIM1; j++, n++)
- spoints2[i][j] = (short)((i * 10 + j * 100 + n) % 8);
+ spoints2[i][j] = (short)((i * 10 + j * 100 + n) % 8);
/* Create the data space */
dims[0] = DIM0;
@@ -1126,7 +1241,8 @@ test_enum_dtype(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_ENUM_NAME, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Construct enum type based on native type in memory */
if((tid_m = H5Tenum_create(H5T_NATIVE_SHORT)) < 0) TEST_ERROR;
@@ -1138,7 +1254,7 @@ test_enum_dtype(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, spoints2) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -1159,30 +1275,30 @@ test_enum_dtype(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = malloc(DIM0 * DIM1 * H5Tget_size(native_type));
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(scheck2, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(scheck2, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), scheck2, NULL, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), scheck2, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
- for (i = 0; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++) {
- if(spoints2[i][j] != scheck2[i][j]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d,%d\n", i, j);
+ for(i = 0; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
+ if(spoints2[i][j] != scheck2[i][j]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d,%d\n", i, j);
printf(" spoints2[i][j]=%hd, scheck2[i][j]=%hd\n", spoints2[i][j],
scheck2[i][j]);
- goto error;
- }
- }
- }
+ goto error;
+ } /* end if */
H5Dclose(dataset);
H5Tclose(dtype);
@@ -1191,7 +1307,20 @@ test_enum_dtype(hid_t file)
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid_m);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1220,13 +1349,13 @@ test_array_dtype(hid_t file)
int i;
long long l;
} s1;
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid2, tid3, tid_m;
- int i, j, k, n;
- hsize_t space_dims[2], array_dims[1]={5};
- s1 *temp_point, *temp_check;
- s1 *points=NULL, *check=NULL;
- void *tmp;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid2 = -1, tid3 = -1, tid_m = -1;
+ int i, j, k, n;
+ hsize_t space_dims[2], array_dims[1]={5};
+ s1 *temp_point = NULL, *temp_check = NULL;
+ s1 *points = NULL, *check = NULL;
+ void *tmp = NULL;
TESTING("array of compound datatype");
@@ -1237,13 +1366,13 @@ test_array_dtype(hid_t file)
TEST_ERROR;
/* Initialize the dataset */
- for(i = n = 0, temp_point=points; i < DIM0; i++)
- for(j = 0; j < DIM1; j++)
+ for(i = n = 0, temp_point = points; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
for(k = 0; k < 5; k++,temp_point++) {
temp_point->c= 't';
temp_point->i= n++;
- temp_point->l= (i*10+j*100)*n;
- }
+ temp_point->l= (i * 10 + j * 100) * n;
+ } /* end for */
/* Create the data space */
space_dims[0] = DIM0;
@@ -1263,7 +1392,8 @@ test_array_dtype(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_ARRAY_NAME, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create compound datatype for datatype in memory */
if((tid3 = H5Tcreate(H5T_COMPOUND, sizeof(s1))) < 0) TEST_ERROR;
@@ -1276,7 +1406,7 @@ test_array_dtype(hid_t file)
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -1298,32 +1428,31 @@ test_array_dtype(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type));
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(check, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, NULL, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), check, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
- for (i = 0, temp_point=points, temp_check=check; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++) {
- for (k = 0; k < 5; k++, temp_point++,temp_check++) {
+ for(i = 0, temp_point = points, temp_check = check; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
+ for(k = 0; k < 5; k++, temp_point++, temp_check++)
if(temp_point->c != temp_check->c ||
- temp_point->i != temp_check->i ||
- temp_point->l != temp_check->l ) {
+ temp_point->i != temp_check->i ||
+ temp_point->l != temp_check->l ) {
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %d,%d\n", i, j);
goto error;
- }
- }
- }
- }
+ } /* end if */
/* Close HDF5 objects */
if(H5Dclose(dataset)) TEST_ERROR;
@@ -1333,17 +1462,32 @@ test_array_dtype(hid_t file)
if(H5Tclose(tid3) < 0) TEST_ERROR;
/* Free memory for test data */
- free(points);
- free(check);
+ HDfree(points);
+ HDfree(check);
PASSED();
return 0;
error:
- if(points!=NULL)
- free(points);
- if(check!=NULL)
- free(check);
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+ if(points)
+ HDfree(points);
+ if(check)
+ HDfree(check);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid3);
+ H5Tclose(tid_m);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1367,17 +1511,17 @@ error:
static herr_t
test_array_dtype2(hid_t file)
{
- hid_t dataset, space;
- hid_t dtype, native_type, tid, tid_m;
- int i, j, k, n;
- hsize_t space_dims[2], array_dims[1]={5};
- void *tmp;
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, tid = -1, tid_m = -1;
+ int i, j, k, n;
+ hsize_t space_dims[2], array_dims[1] = {5};
+ void *tmp = NULL;
TESTING("array of atomic datatype");
/* Initialize the dataset */
for(i = n = 0;i < DIM0; i++)
- for(j = 0; j < DIM1; j++)
+ for(j = 0; j < DIM1; j++)
for(k = 0; k < 5; k++)
ipoints3[i][j][k] = n++;
@@ -1391,14 +1535,15 @@ test_array_dtype2(hid_t file)
/* Create the dataset */
if((dataset = H5Dcreate2(file, DSET_ARRAY2_NAME, tid, space,
- H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* Create array datatype for memory */
if((tid_m = H5Tarray_create2(H5T_NATIVE_INT, 1, array_dims)) < 0) TEST_ERROR;
/* Write the data to the dataset */
if(H5Dwrite(dataset, tid_m, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints3) < 0)
- TEST_ERROR;
+ TEST_ERROR;
/* Close dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
@@ -1409,7 +1554,6 @@ test_array_dtype2(hid_t file)
/* Close dataspace */
if(H5Sclose(space) < 0) TEST_ERROR;
-
/* Open dataset again to check H5Tget_native_type */
if((dataset = H5Dopen2(file, DSET_ARRAY2_NAME, H5P_DEFAULT)) < 0) TEST_ERROR;
@@ -1420,30 +1564,29 @@ test_array_dtype2(hid_t file)
/* Read the dataset back. Temporary buffer is for special platforms like
* Cray */
- tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type));
+ if(NULL == (tmp = HDmalloc(DIM0 * DIM1 * H5Tget_size(native_type))))
+ TEST_ERROR
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, tmp) < 0)
- TEST_ERROR;
+ TEST_ERROR;
- memcpy(icheck3, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
- free(tmp);
+ HDmemcpy(icheck3, tmp, DIM0 * DIM1 * H5Tget_size(native_type));
+ HDfree(tmp);
+ tmp = NULL;
- if(H5Tconvert(native_type, tid_m, (DIM0*DIM1), icheck3, NULL, H5P_DEFAULT) < 0)
+ if(H5Tconvert(native_type, tid_m, (DIM0 * DIM1), icheck3, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
- for (i = 0; i < DIM0; i++) {
- for (j = 0; j < DIM1; j++) {
- for (k = 0; k < 5; k++) {
+ for(i = 0; i < DIM0; i++)
+ for(j = 0; j < DIM1; j++)
+ for(k = 0; k < 5; k++)
if(icheck3[i][j][k] != ipoints3[i][j][k]) {
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %d,%d\n", i, j);
goto error;
- }
- }
- }
- }
+ } /* end if */
/* Close HDF5 objects */
if(H5Dclose(dataset)) TEST_ERROR;
@@ -1455,6 +1598,19 @@ test_array_dtype2(hid_t file)
return 0;
error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid);
+ H5Tclose(tid_m);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1478,37 +1634,36 @@ error:
static herr_t
test_vl_dtype(hid_t file)
{
- hvl_t wdata[SPACE1_DIM1]; /* Information to write */
- hvl_t rdata[SPACE1_DIM1]; /* Information read in */
- hvl_t *t1, *t2; /* Temporary pointer to VL information */
- hsize_t dims1[] = {SPACE1_DIM1};
- hid_t dataset, space;
- hid_t dtype, native_type, nat_super_type, tid, tid2, tid_m, tid_m2;
- size_t i, j, k;
- void* *tmp;
+ hvl_t wdata[SPACE1_DIM1]; /* Information to write */
+ hvl_t rdata[SPACE1_DIM1]; /* Information read in */
+ hvl_t *t1, *t2; /* Temporary pointer to VL information */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ hid_t dataset = -1, space = -1;
+ hid_t dtype = -1, native_type = -1, nat_super_type = -1, tid = -1, tid2 = -1, tid_m = -1, tid_m2 = -1;
+ size_t i, j, k;
+ void **tmp = NULL;
TESTING("variable length datatype");
/* Allocate and initialize VL data to write */
- for(i=0; i<SPACE1_DIM1; i++) {
+ for(i = 0; i < SPACE1_DIM1; i++) {
wdata[i].p = HDmalloc((i + 1) * sizeof(hvl_t));
- if(wdata[i].p==NULL) {
+ if(NULL == wdata[i].p) {
H5_FAILED();
printf(" Cannot allocate memory for VL data! i=%u\n",(unsigned)i);
goto error;
} /* end if */
- wdata[i].len=i+1;
+ wdata[i].len = i + 1;
for(t1 = (hvl_t *)wdata[i].p, j = 0; j < (i + 1); j++, t1++) {
t1->p = HDmalloc((j + 1) * sizeof(unsigned int));
- if(t1->p==NULL) {
+ if(NULL == t1->p) {
H5_FAILED();
printf(" Cannot allocate memory for VL data! i=%u, j=%u\n",(unsigned)i,(unsigned)j);
goto error;
} /* end if */
- t1->len=j+1;
- for(k=0; k<(j+1); k++) {
- ((unsigned int *)t1->p)[k]=(unsigned int)(i*100+j*10+k);
- }
+ t1->len = j + 1;
+ for(k = 0; k < (j + 1); k++)
+ ((unsigned int *)t1->p)[k] = (unsigned int)(i * 100 + j * 10 + k);
} /* end for */
} /* end for */
@@ -1566,7 +1721,7 @@ test_vl_dtype(hid_t file)
printf(" VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len);
goto error;
} /* end if */
- for(t1 = (hvl_t *)wdata[i].p, t2 = (hvl_t *)rdata[i].p, j = 0; j<rdata[i].len; j++, t1++, t2++) {
+ for(t1 = (hvl_t *)wdata[i].p, t2 = (hvl_t *)rdata[i].p, j = 0; j < rdata[i].len; j++, t1++, t2++) {
if(t1->len != t2->len) {
H5_FAILED();
printf(" VL data length don't match!, wdata[%d].len=%d, rdata[%d].len=%d\n",(int)i,(int)wdata[i].len,(int)i,(int)rdata[i].len);
@@ -1575,36 +1730,38 @@ test_vl_dtype(hid_t file)
/* use temporary buffer to convert datatype. This is for special
* platforms like Cray */
- tmp = (void **)HDmalloc(t2->len * sizeof(unsigned int));
+ if(NULL == (tmp = (void **)HDmalloc(t2->len * sizeof(unsigned int))))
+ TEST_ERROR
HDmemcpy(tmp, t2->p, t2->len * H5Tget_size(nat_super_type));
- if(H5Tconvert(nat_super_type, H5T_NATIVE_UINT, t2->len, tmp, NULL, H5P_DEFAULT))
+ if(H5Tconvert(nat_super_type, H5T_NATIVE_UINT, t2->len, tmp, NULL, H5P_DEFAULT) < 0)
TEST_ERROR;
- for(k=0; k<t2->len; k++) {
- if( ((unsigned int *)t1->p)[k] != ((unsigned int *)tmp)[k] ) {
+ for(k = 0; k < t2->len; k++) {
+ if(((unsigned int *)t1->p)[k] != ((unsigned int *)tmp)[k]) {
H5_FAILED();
printf(" VL data don't match!, wdata[%u].p=%d, rdata[%u].p=%u\n",
- (unsigned)i,((unsigned int*)t1->p)[k],(unsigned)i,((unsigned int*)tmp)[k]);
+ (unsigned)i, ((unsigned int*)t1->p)[k], (unsigned)i, ((unsigned int*)tmp)[k]);
goto error;
- }
+ } /* end if */
} /* end for */
- free(tmp);
+ HDfree(tmp);
} /* end for */
} /* end for */
/* Reclaim the read VL data */
- if(H5Dvlen_reclaim(native_type,space,H5P_DEFAULT,rdata) < 0) TEST_ERROR;
+ if(H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, rdata) < 0) TEST_ERROR;
/* Reclaim the write VL data */
- if(H5Dvlen_reclaim(native_type,space,H5P_DEFAULT,wdata) < 0) TEST_ERROR;
+ if(H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, wdata) < 0) TEST_ERROR;
/* Close Dataset */
if(H5Dclose(dataset) < 0) TEST_ERROR;
/* Close datatype */
if(H5Tclose(native_type) < 0) TEST_ERROR;
+ native_type = -1; /* reset so that error handling can check for VL reclaim */
if(H5Tclose(dtype) < 0) TEST_ERROR;
if(H5Tclose(tid_m) < 0) TEST_ERROR;
if(H5Tclose(tid_m2) < 0) TEST_ERROR;
@@ -1616,7 +1773,27 @@ test_vl_dtype(hid_t file)
PASSED();
return 0;
- error:
+error:
+ /* Free memory for test data */
+ if(tmp)
+ HDfree(tmp);
+
+ H5E_BEGIN_TRY {
+ if(native_type > 0) {
+ H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, rdata);
+ H5Dvlen_reclaim(native_type, space, H5P_DEFAULT, wdata);
+ } /* end if */
+ H5Sclose(space);
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(nat_super_type);
+ H5Tclose(tid);
+ H5Tclose(tid2);
+ H5Tclose(tid_m);
+ H5Tclose(tid_m2);
+ } H5E_END_TRY;
+
return -1;
} /* end test_vl_type() */
@@ -1641,17 +1818,18 @@ static herr_t
test_vlstr_dtype(hid_t file)
{
const char *wdata[SPACE1_DIM1]= {
- "Four score and seven years ago our forefathers brought forth on this continent a new nation,",
- "conceived in liberty and dedicated to the proposition that all men are created equal.",
- "Now we are engaged in a great civil war,",
- "testing whether that nation or any nation so conceived and so dedicated can long endure."
- }; /* Information to write */
- char *rdata[SPACE1_DIM1]; /* Information read in */
- hid_t dataset; /* Dataset ID */
- hid_t sid1; /* Dataspace ID */
- hid_t tid1,dtype,native_type; /* Datatype ID */
- hsize_t dims1[] = {SPACE1_DIM1};
- unsigned i; /* counting variable */
+ "Four score and seven years ago our forefathers brought forth on this continent a new nation,",
+ "conceived in liberty and dedicated to the proposition that all men are created equal.",
+ "Now we are engaged in a great civil war,",
+ "testing whether that nation or any nation so conceived and so dedicated can long endure."
+ }; /* Information to write */
+ char *rdata[SPACE1_DIM1]; /* Information read in */
+ hbool_t rdata_alloc = FALSE; /* Whether the read data is allocated */
+ hid_t dataset = -1; /* Dataset ID */
+ hid_t sid1 = -1; /* Dataspace ID */
+ hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ unsigned i; /* counting variable */
/* Output message about test being performed */
TESTING("variable length string datatype");
@@ -1691,19 +1869,20 @@ test_vlstr_dtype(hid_t file)
/* Read dataset from disk */
if(H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR;
+ rdata_alloc = TRUE;
/* Compare data read in */
for(i = 0; i < SPACE1_DIM1; i++) {
if(HDstrlen(wdata[i]) != HDstrlen(rdata[i])) {
H5_FAILED();
printf(" VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",
- (int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i]));
+ (int)i, (int)HDstrlen(wdata[i]), (int)i, (int)HDstrlen(rdata[i]));
goto error;
} /* end if */
if(HDstrcmp(wdata[i], rdata[i]) != 0 ) {
H5_FAILED();
printf(" VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",
- (int)i,wdata[i],(int)i,rdata[i]);
+ (int)i, wdata[i], (int)i, rdata[i]);
goto error;
} /* end if */
} /* end for */
@@ -1719,14 +1898,28 @@ test_vlstr_dtype(hid_t file)
if(H5Sclose(sid1) < 0) TEST_ERROR;
/* Free memory for rdata */
- for(i=0; i<SPACE1_DIM1; i++) {
+ for(i = 0; i < SPACE1_DIM1; i++)
HDfree(rdata[i]);
- }
+ rdata_alloc = FALSE;
PASSED();
return 0;
error:
+ if(rdata_alloc) {
+ /* Free memory for rdata */
+ for(i = 0; i < SPACE1_DIM1; i++)
+ HDfree(rdata[i]);
+ } /* end if */
+
+ H5E_BEGIN_TRY {
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(sid1);
+ H5Tclose(tid1);
+ } H5E_END_TRY;
+
return -1;
} /* end test_vlstr_dtype() */
@@ -1750,18 +1943,18 @@ error:
static herr_t
test_str_dtype(hid_t file)
{
- const char wdata[SPACE1_DIM1][4]= {
- "one",
- "two",
- "3rd",
- "4th"
- }; /* Information to write */
- char rdata[SPACE1_DIM1][4]; /* Information read in */
- hid_t dataset; /* Dataset ID */
- hid_t sid1; /* Dataspace ID */
- hid_t tid1,dtype,native_type; /* Datatype ID */
- hsize_t dims1[] = {SPACE1_DIM1};
- unsigned i; /* counting variable */
+ const char wdata[SPACE1_DIM1][4]= {
+ "one",
+ "two",
+ "3rd",
+ "4th"
+ }; /* Information to write */
+ char rdata[SPACE1_DIM1][4]; /* Information read in */
+ hid_t dataset = -1; /* Dataset ID */
+ hid_t sid1 = -1; /* Dataspace ID */
+ hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */
+ hsize_t dims1[] = {SPACE1_DIM1};
+ unsigned i; /* counting variable */
/* Output message about test being performed */
TESTING("fixed-length string datatype");
@@ -1806,13 +1999,13 @@ test_str_dtype(hid_t file)
if(HDstrlen(wdata[i]) != HDstrlen(rdata[i])) {
H5_FAILED();
printf(" data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",
- (int)i,(int)strlen(wdata[i]),(int)i,(int)strlen(rdata[i]));
+ (int)i, (int)HDstrlen(wdata[i]), (int)i, (int)HDstrlen(rdata[i]));
goto error;
} /* end if */
if(HDstrcmp(wdata[i], rdata[i]) != 0 ) {
H5_FAILED();
printf(" data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",
- (int)i,wdata[i],(int)i,rdata[i]);
+ (int)i, wdata[i], (int)i, rdata[i]);
goto error;
} /* end if */
} /* end for */
@@ -1831,11 +2024,17 @@ test_str_dtype(hid_t file)
return 0;
error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dataset);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Tclose(tid1);
+ H5Tclose(sid1);
+ } H5E_END_TRY;
+
return -1;
} /* end test_str_dtype() */
-
-
/*-------------------------------------------------------------------------
* Function: test_refer_dtype
@@ -1856,7 +2055,6 @@ error:
static herr_t
test_refer_dtype(hid_t file)
{
-
/* Compound datatype */
typedef struct s1_t {
unsigned int a;
@@ -1864,21 +2062,23 @@ test_refer_dtype(hid_t file)
float c;
} s1_t;
- hid_t dataset; /* Dataset ID */
- hid_t group; /* Group ID */
- hid_t sid1; /* Dataspace ID */
- hid_t tid1, dtype, native_type; /* Datatype ID */
- hsize_t dims1[] = {1};
- H5O_type_t obj_type; /* Object type */
- hobj_ref_t *wbuf, /* buffer to write to disk */
- *rbuf; /* buffer read from disk */
+ hid_t dataset = -1; /* Dataset ID */
+ hid_t group = -1; /* Group ID */
+ hid_t sid1 = -1; /* Dataspace ID */
+ hid_t tid1 = -1, dtype = -1, native_type = -1; /* Datatype ID */
+ hsize_t dims1[] = {1};
+ H5O_type_t obj_type; /* Object type */
+ hobj_ref_t *wbuf = NULL, /* buffer to write to disk */
+ *rbuf = NULL; /* buffer read from disk */
/* Output message about test being performed */
TESTING("reference datatype");
/* Allocate write & read buffers */
- wbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)));
- rbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)));
+ if(NULL == (wbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)))))
+ TEST_ERROR
+ if(NULL == (rbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)))))
+ TEST_ERROR
/* Create dataspace for datasets */
if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0)
@@ -1937,7 +2137,6 @@ test_refer_dtype(hid_t file)
if(H5Dclose(dataset) < 0)
TEST_ERROR;
-
/* Open the dataset */
if((dataset = H5Dopen2(file, "/Dataset3", H5P_DEFAULT)) < 0)
TEST_ERROR;
@@ -1973,19 +2172,36 @@ test_refer_dtype(hid_t file)
if(H5Tclose(tid1) < 0)
TEST_ERROR;
+ if(H5Tclose(native_type) < 0)
+ TEST_ERROR;
+
/* Close Dataset */
if(H5Dclose(dataset) < 0)
TEST_ERROR;
/* Free memory buffers */
- free(wbuf);
- free(rbuf);
+ HDfree(wbuf);
+ HDfree(rbuf);
PASSED();
return 0;
error:
+ if(wbuf)
+ HDfree(wbuf);
+ if(rbuf)
+ HDfree(rbuf);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(sid1);
+ H5Gclose(group);
+ H5Tclose(tid1);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Dclose(dataset);
+ } H5E_END_TRY;
+
return -1;
} /* test_refer_dtype() */
@@ -2009,38 +2225,40 @@ error:
static herr_t
test_refer_dtype2(hid_t file)
{
- hid_t dset1, /* Dataset ID */
- dset2; /* Dereferenced dataset ID */
- hid_t sid1, /* Dataspace ID #1 */
- sid2; /* Dataspace ID #2 */
- hid_t dtype, native_type;
- hsize_t dims1[] = {1},
- dims2[] = {SPACE2_DIM1, SPACE2_DIM2};
- hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */
- hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */
- hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */
- hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */
- hdset_reg_ref_t wbuf, /* buffer to write to disk */
- rbuf; /* buffer read from disk */
- uint8_t *dwbuf, /* Buffer for writing numeric data to disk */
- *drbuf; /* Buffer for reading numeric data from disk */
- uint8_t *tu8; /* Temporary pointer to uint8 data */
- H5O_type_t obj_type; /* Object type */
- int i; /* counting variables */
+ hid_t dset1 = -1, /* Dataset ID */
+ dset2 = -1; /* Dereferenced dataset ID */
+ hid_t sid1 = -1, /* Dataspace ID #1 */
+ sid2 = -1; /* Dataspace ID #2 */
+ hid_t dtype = -1, native_type = -1;
+ hsize_t dims1[] = { 1 }, dims2[] = { SPACE2_DIM1, SPACE2_DIM2 };
+ hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */
+ hsize_t stride[SPACE2_RANK]; /* Stride of hyperslab */
+ hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */
+ hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */
+ hdset_reg_ref_t wbuf, /* buffer to write to disk */
+ rbuf; /* buffer read from disk */
+ uint8_t *dwbuf = NULL, /* Buffer for writing numeric data to disk */
+ *drbuf = NULL; /* Buffer for reading numeric data from disk */
+ uint8_t *tu8 = NULL; /* Temporary pointer to uint8 data */
+ H5O_type_t obj_type; /* Object type */
+ int i; /* counting variables */
/* Output message about test being performed */
TESTING("dataset region reference");
/* Allocate write & read buffers */
- dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2);
- drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2);
+ if(NULL == (dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2)))
+ TEST_ERROR
+ if(NULL == (drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2)))
+ TEST_ERROR
/* Create dataspace for datasets */
if((sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL)) < 0)
TEST_ERROR;
/* Create a dataset */
- if((dset2 = H5Dcreate2(file, "Dataset2", H5T_STD_U8LE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((dset2 = H5Dcreate2(file, "Dataset2", H5T_STD_U8LE, sid2, H5P_DEFAULT,
+ H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
for(tu8 = dwbuf, i = 0; i < SPACE2_DIM1 * SPACE2_DIM2; i++)
@@ -2054,21 +2272,25 @@ test_refer_dtype2(hid_t file)
if(H5Dclose(dset2) < 0)
TEST_ERROR;
-
/* Create dataspace for the reference dataset */
if((sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL)) < 0)
TEST_ERROR;
/* Create a reference dataset */
- if((dset1 = H5Dcreate2(file, "Dataset1", H5T_STD_REF_DSETREG, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((dset1 = H5Dcreate2(file, "Dataset1", H5T_STD_REF_DSETREG, sid1,
+ H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
/* Create references */
/* Select 6x6 hyperslab for first reference */
- start[0] = 2; start[1] = 2;
- stride[0] = 1; stride[1] = 1;
- count[0] = 1; count[1] = 1;
- block[0] = 6; block[1] = 6;
+ start[0] = 2;
+ start[1] = 2;
+ stride[0] = 1;
+ stride[1] = 1;
+ count[0] = 1;
+ count[1] = 1;
+ block[0] = 6;
+ block[1] = 6;
if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block) < 0)
TEST_ERROR;
@@ -2100,9 +2322,6 @@ test_refer_dtype2(hid_t file)
if(H5Sclose(sid2) < 0)
TEST_ERROR;
-
-
-
/* Open the dataset */
if((dset1 = H5Dopen2(file, "/Dataset1", H5P_DEFAULT)) < 0)
TEST_ERROR;
@@ -2175,13 +2394,28 @@ test_refer_dtype2(hid_t file)
TEST_ERROR;
/* Free memory buffers */
- free(dwbuf);
- free(drbuf);
+ HDfree(dwbuf);
+ HDfree(drbuf);
PASSED();
return 0;
-error:
+error:
+ /* Free memory buffers */
+ if(dwbuf)
+ HDfree(dwbuf);
+ if(drbuf)
+ HDfree(drbuf);
+
+ H5E_BEGIN_TRY {
+ H5Sclose(sid2);
+ H5Sclose(sid1);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Dclose(dset2);
+ H5Dclose(dset1);
+ } H5E_END_TRY;
+
return -1;
} /* test_refer_dtype2() */
@@ -2205,21 +2439,21 @@ error:
static herr_t
test_opaque_dtype(hid_t file)
{
- hid_t type=-1, space=-1, dset=-1;
- hid_t dataset, dtype, native_type;
- size_t i;
- unsigned char wbuf[32], rbuf[32];
- hsize_t nelmts;
+ hid_t type = -1, space = -1, dset = -1;
+ hid_t dataset = -1, dtype = -1, native_type = -1;
+ size_t i;
+ unsigned char wbuf[32], rbuf[32];
+ hsize_t nelmts;
TESTING("opaque datatype");
/* opaque_1 */
nelmts = sizeof(wbuf);
- if((type = H5Tcreate(H5T_OPAQUE, 1)) < 0 ||
- H5Tset_tag(type, "testing 1-byte opaque type") < 0 ||
- (space = H5Screate_simple(1, &nelmts, NULL)) < 0 ||
- (dset = H5Dcreate2(file, DSET_OPAQUE_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- TEST_ERROR;
+ if((type = H5Tcreate(H5T_OPAQUE, 1)) < 0) TEST_ERROR;
+ if(H5Tset_tag(type, "testing 1-byte opaque type") < 0) TEST_ERROR;
+ if((space = H5Screate_simple(1, &nelmts, NULL)) < 0) TEST_ERROR;
+ if((dset = H5Dcreate2(file, DSET_OPAQUE_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
for(i = 0; i < sizeof(wbuf); i++)
wbuf[i] = (unsigned char)0xff ^ (unsigned char)i;
@@ -2243,11 +2477,11 @@ test_opaque_dtype(hid_t file)
TEST_ERROR;
for(i = 0; i < sizeof(rbuf); i++)
- if(rbuf[i] != wbuf[i]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
+ if(rbuf[i] != wbuf[i]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
printf(" At index %u\n", (unsigned)i);
- goto error;
+ goto error;
} /* end if */
if(H5Tclose(type) < 0) TEST_ERROR;
@@ -2259,6 +2493,15 @@ test_opaque_dtype(hid_t file)
return 0;
error:
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Tclose(type);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Dclose(dset);
+ H5Dclose(dataset);
+ } H5E_END_TRY;
+
return -1;
} /* test_opaque_dtype */
@@ -2282,20 +2525,20 @@ error:
static herr_t
test_bitfield_dtype(hid_t file)
{
- hid_t type=-1, space=-1, dset=-1;
- hid_t dataset, dtype, native_type;
- size_t i;
- unsigned char wbuf[32];
- hsize_t nelmts;
+ hid_t type = -1, space = -1, dset = -1;
+ hid_t dataset = -1, dtype = -1, native_type = -1;
+ size_t i;
+ unsigned char wbuf[32];
+ hsize_t nelmts;
TESTING("bitfield datatype");
/* opaque_1 */
nelmts = sizeof(wbuf);
- if((type = H5Tcopy(H5T_STD_B8LE)) < 0 ||
- (space = H5Screate_simple(1, &nelmts, NULL)) < 0 ||
- (dset = H5Dcreate2(file, DSET_BITFIELD_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- TEST_ERROR;
+ if((type = H5Tcopy(H5T_STD_B8LE)) < 0) TEST_ERROR;
+ if((space = H5Screate_simple(1, &nelmts, NULL)) < 0) TEST_ERROR;
+ if((dset = H5Dcreate2(file, DSET_BITFIELD_NAME, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
for(i = 0; i < sizeof(wbuf); i++)
wbuf[i] = (unsigned char)0xff ^ (unsigned char)i;
@@ -2327,6 +2570,15 @@ test_bitfield_dtype(hid_t file)
return 0;
error:
+ H5E_BEGIN_TRY {
+ H5Sclose(space);
+ H5Tclose(type);
+ H5Tclose(dtype);
+ H5Tclose(native_type);
+ H5Dclose(dset);
+ H5Dclose(dataset);
+ } H5E_END_TRY;
+
return -1;
} /* test_bitfield_dtype */
@@ -2350,176 +2602,166 @@ error:
static herr_t
test_ninteger(void)
{
- hid_t fid1=(-1); /* file ID */
- hid_t fid2=(-1); /* file ID */
- hid_t did1=(-1); /* dataset ID */
- hid_t did2=(-1); /* dataset ID */
- hid_t sid1=(-1); /* dataspace ID */
- hid_t dcpl1=(-1); /* dataset creation property list ID */
- hid_t dcpl2=(-1); /* dataset creation property list ID */
- hid_t tid1=(-1); /* file datatype */
- hid_t tid2=(-1); /* file datatype */
- hid_t nid1=(-1); /* native datatype */
- hid_t nid2=(-1); /* native datatype */
- hsize_t dims[1]={DIM3}; /* dataspace dimensions */
+ hid_t fid1 = -1; /* file ID */
+ hid_t fid2 = -1; /* file ID */
+ hid_t did1 = -1; /* dataset ID */
+ hid_t did2 = -1; /* dataset ID */
+ hid_t sid1 = -1; /* dataspace ID */
+ hid_t dcpl1 = -1; /* dataset creation property list ID */
+ hid_t dcpl2 = -1; /* dataset creation property list ID */
+ hid_t tid1 = -1; /* file datatype */
+ hid_t tid2 = -1; /* file datatype */
+ hid_t nid1 = -1; /* native datatype */
+ hid_t nid2 = -1; /* native datatype */
+ hsize_t dims[1] = {DIM3}; /* dataspace dimensions */
hsize_t nelmts; /* number of elements in dataset */
- int rank=1; /* rank of dataset */
+ int rank = 1; /* rank of dataset */
int buf[DIM3];
int chk[DIM3];
int i;
- for (i=0; i<DIM3; i++){
- buf[i]=i;
- }
-
TESTING("native integer ");
- /*-------------------------------------------------------------------------
- * step1: create a file
- *-------------------------------------------------------------------------
- */
+ for(i = 0; i < DIM3; i++)
+ buf[i] = i;
+
+ /*-------------------------------------------------------------------------
+ * step1: create a file
+ *-------------------------------------------------------------------------
+ */
/* create a file using default properties */
- if((fid1=H5Fcreate("tstint1.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
- goto error;
+ if((fid1 = H5Fcreate("tstint1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
/* create a data space */
- if((sid1 = H5Screate_simple(rank,dims,NULL)) < 0) goto error;
+ if((sid1 = H5Screate_simple(rank, dims, NULL)) < 0) FAIL_STACK_ERROR
/* create dcpl */
- if((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
+ if((dcpl1 = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
/* create a dataset */
- if((did1 = H5Dcreate2(fid1, "dset", H5T_NATIVE_INT, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) goto error;
+ if((did1 = H5Dcreate2(fid1, "dset", H5T_NATIVE_INT, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* write */
- if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
- goto error;
+ if(H5Dwrite(did1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) FAIL_STACK_ERROR
/* close */
- if(H5Sclose(sid1) < 0) goto error;
- if(H5Pclose(dcpl1) < 0) goto error;
- if(H5Dclose(did1) < 0) goto error;
- if(H5Fclose(fid1) < 0) goto error;
+ if(H5Sclose(sid1) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl1) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did1) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR
- /*-------------------------------------------------------------------------
- * step 2: open and create another file copying the data from file1
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * step 2: open and create another file copying the data from file1
+ *-------------------------------------------------------------------------
+ */
- /* open */
- if((fid1 = H5Fopen("tstint1.h5", H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) goto error;
+ /* open */
+ if((fid1 = H5Fopen("tstint1.h5", H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* open dataset */
- if((did1 = H5Dopen2(fid1, "dset", H5P_DEFAULT)) < 0) goto error;
+ if((did1 = H5Dopen2(fid1, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if((sid1 = H5Dget_space(did1)) < 0) goto error;
+ if((sid1 = H5Dget_space(did1)) < 0) FAIL_STACK_ERROR
/* get dcpl */
- if((dcpl1 = H5Dget_create_plist(did1)) < 0) goto error;
+ if((dcpl1 = H5Dget_create_plist(did1)) < 0) FAIL_STACK_ERROR
/* get file datatype */
- if((tid1 = H5Dget_type(did1)) < 0) goto error;
+ if((tid1 = H5Dget_type(did1)) < 0) FAIL_STACK_ERROR
/* get native datatype */
- if((nid1 = H5Tget_native_type(tid1, H5T_DIR_DEFAULT)) < 0) goto error;
+ if((nid1 = H5Tget_native_type(tid1, H5T_DIR_DEFAULT)) < 0) FAIL_STACK_ERROR
/* get size */
- if(H5Tget_size(nid1) == 0) goto error;
+ if(H5Tget_size(nid1) == 0) FAIL_STACK_ERROR
/* get rank */
- if((rank = H5Sget_simple_extent_ndims(sid1)) < 0) goto error;
+ if((rank = H5Sget_simple_extent_ndims(sid1)) < 0) FAIL_STACK_ERROR
HDmemset(dims, 0, sizeof dims);
/* get dimension */
- if(H5Sget_simple_extent_dims(sid1, dims, NULL) < 0) goto error;
+ if(H5Sget_simple_extent_dims(sid1, dims, NULL) < 0) FAIL_STACK_ERROR
nelmts = 1;
for(i = 0; i < rank; i++)
- nelmts *= dims[i];
+ nelmts *= dims[i];
/* read */
- if(H5Dread(did1, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0)
- goto error;
+ if(H5Dread(did1, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0) FAIL_STACK_ERROR
/* create a file using default properties */
- if((fid2 = H5Fcreate("tstint2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
- goto error;
+ if((fid2 = H5Fcreate("tstint2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* create a dataset using the native type */
- if((did2 = H5Dcreate2(fid2, "dset", nid1, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) goto error;
+ if((did2 = H5Dcreate2(fid2, "dset", nid1, sid1, H5P_DEFAULT, dcpl1, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* write */
- if(H5Dwrite(did2, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0)
- goto error;
+ if(H5Dwrite(did2, nid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, chk) < 0) FAIL_STACK_ERROR
/* get dcpl */
- if((dcpl2 = H5Dget_create_plist(did2)) < 0)
- goto error;
+ if((dcpl2 = H5Dget_create_plist(did2)) < 0) FAIL_STACK_ERROR
/* get file datatype */
- if((tid2 = H5Dget_type(did2)) < 0)
- goto error;
+ if((tid2 = H5Dget_type(did2)) < 0) FAIL_STACK_ERROR
/* get native datatype */
- if((nid2 = H5Tget_native_type(tid2, H5T_DIR_DEFAULT)) < 0)
- goto error;
+ if((nid2 = H5Tget_native_type(tid2, H5T_DIR_DEFAULT)) < 0) FAIL_STACK_ERROR
/* check */
if(H5Tget_precision(nid1) != H5Tget_precision(nid2)) {
- printf(" Precision differ.\n");
- goto error;
- }
+ printf(" Precision differ.\n");
+ TEST_ERROR
+ } /* end if */
/* compare dataset creation property lists */
if(H5Pequal(dcpl1, dcpl2) <= 0) {
- printf(" Property lists differ.\n");
- goto error;
- }
+ printf(" Property lists differ.\n");
+ TEST_ERROR
+ } /* end if */
/* check */
- for (i = 0; i < DIM3; i++) {
- if(buf[i] != chk[i]) {
- H5_FAILED();
- printf(" Read different values than written.\n");
- printf(" At index %d\n", i);
- goto error;
- }
- }
+ for(i = 0; i < DIM3; i++)
+ if(buf[i] != chk[i]) {
+ H5_FAILED();
+ printf(" Read different values than written.\n");
+ printf(" At index %d\n", i);
+ TEST_ERROR
+ } /* end if */
/* close */
- if(H5Sclose (sid1) < 0) goto error;
- if(H5Pclose (dcpl1) < 0) goto error;
- if(H5Pclose (dcpl2) < 0) goto error;
- if(H5Tclose (tid1) < 0) goto error;
- if(H5Tclose (tid2) < 0) goto error;
- if(H5Tclose (nid1) < 0) goto error;
- if(H5Tclose (nid2) < 0) goto error;
- if(H5Dclose (did1) < 0) goto error;
- if(H5Dclose (did2) < 0) goto error;
- if(H5Fclose (fid1) < 0) goto error;
- if(H5Fclose (fid2) < 0) goto error;
-
+ if(H5Sclose(sid1) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl1) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl2) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(tid1) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(tid2) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(nid1) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(nid2) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did1) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did2) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid1) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid2) < 0) FAIL_STACK_ERROR
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
- H5Pclose(dcpl1);
- H5Pclose(dcpl2);
- H5Tclose(tid1);
- H5Tclose(tid2);
- H5Tclose(nid1);
- H5Tclose(nid2);
- H5Dclose(did1);
- H5Dclose(did2);
- H5Sclose(sid1);
- H5Fclose(fid1);
- H5Fclose(fid2);
+ H5Pclose(dcpl1);
+ H5Pclose(dcpl2);
+ H5Tclose(tid1);
+ H5Tclose(tid2);
+ H5Tclose(nid1);
+ H5Tclose(nid2);
+ H5Dclose(did1);
+ H5Dclose(did2);
+ H5Sclose(sid1);
+ H5Fclose(fid1);
+ H5Fclose(fid2);
} H5E_END_TRY;
+
return -1;
} /* end test_ninteger() */
-
/*-------------------------------------------------------------------------
* Function: main
@@ -2536,43 +2778,54 @@ error:
int
main(void)
{
- hid_t file, fapl;
- int nerrors=0;
- char filename[1024];
+ hid_t file, fapl;
+ int nerrors = 0;
+ char filename[1024];
h5_reset();
fapl = h5_fileaccess();
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
- if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
- goto error;
-
- nerrors += test_atomic_dtype(file) < 0 ?1:0;
- nerrors += test_compound_dtype(file) < 0 ?1:0;
- nerrors += test_compound_dtype2(file) < 0 ?1:0;
- nerrors += test_compound_dtype3(file) < 0 ?1:0;
- nerrors += test_compound_opaque(file) < 0 ?1:0;
- nerrors += test_enum_dtype(file) < 0 ?1:0;
- nerrors += test_array_dtype(file) < 0 ?1:0;
- nerrors += test_array_dtype2(file) < 0 ?1:0;
- nerrors += test_vl_dtype(file) < 0 ?1:0;
- nerrors += test_vlstr_dtype(file) < 0 ?1:0;
- nerrors += test_str_dtype(file) < 0 ?1:0;
- nerrors += test_refer_dtype(file) < 0 ?1:0;
- nerrors += test_refer_dtype2(file) < 0 ?1:0;
- nerrors += test_opaque_dtype(file) < 0 ?1:0;
- nerrors += test_bitfield_dtype(file) < 0 ?1:0;
- nerrors += test_ninteger() < 0 ?1:0;
-
- if(H5Fclose(file) < 0) goto error;
- if(nerrors) goto error;
+ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ goto error;
+
+ nerrors += test_atomic_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_compound_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_compound_dtype2(file) < 0 ? 1 : 0;
+ nerrors += test_compound_dtype3(file) < 0 ? 1 : 0;
+ nerrors += test_compound_opaque(file) < 0 ? 1 : 0;
+ nerrors += test_enum_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_array_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_array_dtype2(file) < 0 ? 1 : 0;
+ nerrors += test_vl_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_vlstr_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_str_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_refer_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_refer_dtype2(file) < 0 ? 1 : 0;
+ nerrors += test_opaque_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_bitfield_dtype(file) < 0 ? 1 : 0;
+ nerrors += test_ninteger() < 0 ? 1 : 0;
+
+ if(H5Fclose(file) < 0)
+ goto error;
+ if(nerrors)
+ goto error;
+
printf("All native datatype tests passed.\n");
h5_cleanup(FILENAME, fapl);
+
return 0;
- error:
+error:
+ H5E_BEGIN_TRY {
+ H5Fclose(file);
+ h5_cleanup(FILENAME, fapl);
+ } H5E_END_TRY;
+
nerrors = MAX(1, nerrors);
printf("***** %d DATASET TEST%s FAILED! *****\n",
- nerrors, 1 == nerrors ? "" : "S");
+ nerrors, 1 == nerrors ? "" : "S");
+
return 1;
}
+
diff --git a/test/pool.c b/test/pool.c
index 22658ec..43e9cfd 100644
--- a/test/pool.c
+++ b/test/pool.c
@@ -645,7 +645,7 @@ test_allocate_random(void)
curr_time=1115412944;
HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time);
#endif /* QAK */
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/* Create a memory pool */
if(NULL == (mp = H5MP_create((size_t)MPOOL_PAGE_SIZE, MPOOL_FLAGS)))
diff --git a/test/theap.c b/test/theap.c
index 0c39868..230ec4d 100644
--- a/test/theap.c
+++ b/test/theap.c
@@ -93,7 +93,7 @@ test_heap_init(void)
/* Create randomized set of numbers */
curr_time=time(NULL);
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
for(u=0; u<NUM_ELEMS; u++)
/* Generate random numbers from -1000 to 1000 */
rand_num[u].val=(int)(HDrandom()%2001)-1001;
diff --git a/test/tskiplist.c b/test/tskiplist.c
index 7b3dcef..8510db2 100644
--- a/test/tskiplist.c
+++ b/test/tskiplist.c
@@ -71,7 +71,7 @@ test_skiplist_init(void)
/* Initialize random number seed */
curr_time = HDtime(NULL);
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
/* Create randomized set of numbers */
for(u=0; u<NUM_ELEMS; u++) {
diff --git a/test/ttst.c b/test/ttst.c
index c267404..4ffe4cd 100644
--- a/test/ttst.c
+++ b/test/ttst.c
@@ -124,7 +124,7 @@ test_tst_init(void)
for(u=0; u<num_uniq_words; u++)
rand_uniq_words[u]=uniq_words[u];
curr_time=HDtime(NULL);
- HDsrandom((unsigned long)curr_time);
+ HDsrandom((unsigned)curr_time);
for(u=0; u<num_uniq_words; u++) {
v=u+(HDrandom()%(num_uniq_words-u));
if(u!=v) {
diff --git a/test/tunicode.c b/test/tunicode.c
index efbf80e..892e563 100644
--- a/test/tunicode.c
+++ b/test/tunicode.c
@@ -807,7 +807,7 @@ void test_unicode(void)
MESSAGE(5, ("Testing UTF-8 Encoding\n"));
/* Create a random string with length NUM_CHARS */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
HDmemset(test_string, 0, sizeof(test_string));
for(x=0; x<NUM_CHARS; x++)
diff --git a/test/unlink.c b/test/unlink.c
index 60d6ac5..9bd6f42 100644
--- a/test/unlink.c
+++ b/test/unlink.c
@@ -1487,8 +1487,8 @@ delete_node(hid_t pid, hid_t id)
static int
test_unlink_rightleaf(hid_t fid)
{
- hid_t rootid, /* Group ID for root group */
- *gids; /* Array of IDs for groups created */
+ hid_t rootid = -1, /* Group ID for root group */
+ *gids = NULL; /* Array of IDs for groups created */
int n, /* Local index variable */
ngroups = 150; /* Number of groups to create */
char name[256]; /* Name of object to create */
@@ -1496,7 +1496,7 @@ test_unlink_rightleaf(hid_t fid)
TESTING("deleting right-most child in non-leaf B-tree node");
/* Allocate space for the group IDs */
- if(NULL == (gids = (hid_t *)HDmalloc((size_t)ngroups * sizeof(hid_t)))) TEST_ERROR
+ if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR
if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -1514,8 +1514,10 @@ test_unlink_rightleaf(hid_t fid)
} /* end for */
/* Close all the groups */
- for (n = 0; n < ngroups; n++)
+ for (n = 0; n < ngroups; n++) {
if(H5Gclose(gids[n]) < 0) TEST_ERROR
+ gids[n] = 0;
+ } /* end for */
/* Close root group ID */
if(H5Gclose(rootid) < 0) TEST_ERROR
@@ -1527,6 +1529,20 @@ test_unlink_rightleaf(hid_t fid)
return 0;
error:
+ if(gids) {
+ /* Close any open groups */
+ for (n = 0; n < ngroups; n++)
+ if(gids[n]) {
+ H5E_BEGIN_TRY {
+ H5Gclose(gids[n]);
+ } H5E_END_TRY;
+ } /* end if */
+ HDfree(gids);
+ } /* end if */
+ H5E_BEGIN_TRY {
+ H5Gclose(rootid);
+ } H5E_END_TRY;
+
return 1;
} /* end test_unlink_rightleaf() */
@@ -1550,8 +1566,8 @@ error:
static int
test_unlink_rightnode(hid_t fid)
{
- hid_t rootid, /* Group ID for root group */
- *gids; /* Array of IDs for groups created */
+ hid_t rootid = -1, /* Group ID for root group */
+ *gids = NULL; /* Array of IDs for groups created */
int n, /* Local index variable */
ngroups = 150; /* Number of groups to create */
char name[256]; /* Name of object to create */
@@ -1559,7 +1575,7 @@ test_unlink_rightnode(hid_t fid)
TESTING("deleting right-most child in non-leaf B-tree node");
/* Allocate space for the group IDs */
- if(NULL == (gids = (hid_t *)HDmalloc((size_t)ngroups * sizeof(hid_t)))) TEST_ERROR
+ if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR
if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -1570,8 +1586,10 @@ test_unlink_rightnode(hid_t fid)
} /* end for */
/* Close all the groups */
- for (n = 0; n < ngroups; n++)
+ for (n = 0; n < ngroups; n++) {
if(H5Gclose(gids[n]) < 0) FAIL_STACK_ERROR
+ gids[n] = 0;
+ } /* end for */
/* Unlink specific objects to trigger deletion of right leaf in non-leaf node */
if(H5Ldelete(fid, "/ZoneB77", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
@@ -1590,6 +1608,20 @@ test_unlink_rightnode(hid_t fid)
return 0;
error:
+ if(gids) {
+ /* Close any open groups */
+ for (n = 0; n < ngroups; n++)
+ if(gids[n]) {
+ H5E_BEGIN_TRY {
+ H5Gclose(gids[n]);
+ } H5E_END_TRY;
+ } /* end if */
+ HDfree(gids);
+ } /* end if */
+ H5E_BEGIN_TRY {
+ H5Gclose(rootid);
+ } H5E_END_TRY;
+
return 1;
} /* end test_unlink_rightnode() */
@@ -1613,8 +1645,8 @@ error:
static int
test_unlink_middlenode(hid_t fid)
{
- hid_t rootid, /* Group ID for root group */
- *gids; /* Array of IDs for groups created */
+ hid_t rootid = -1, /* Group ID for root group */
+ *gids = NULL; /* Array of IDs for groups created */
int n, /* Local index variable */
ngroups = 250; /* Number of groups to create */
char name[256]; /* Name of object to create */
@@ -1622,7 +1654,7 @@ test_unlink_middlenode(hid_t fid)
TESTING("deleting right-most child in non-leaf B-tree node");
/* Allocate space for the group IDs */
- if(NULL == (gids = (hid_t *)HDmalloc((size_t)ngroups * sizeof(hid_t)))) TEST_ERROR
+ if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR
if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
@@ -1633,8 +1665,10 @@ test_unlink_middlenode(hid_t fid)
} /* end for */
/* Close all the groups */
- for (n = 0; n < ngroups; n++)
+ for (n = 0; n < ngroups; n++) {
if(H5Gclose(gids[n]) < 0) FAIL_STACK_ERROR
+ gids[n] = 0;
+ } /* end for */
/* Unlink specific objects to trigger deletion of all leafs in "interior" non-leaf node */
if(H5Ldelete(fid, "/ZoneC11", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
@@ -1796,6 +1830,20 @@ test_unlink_middlenode(hid_t fid)
return 0;
error:
+ if(gids) {
+ /* Close any open groups */
+ for (n = 0; n < ngroups; n++)
+ if(gids[n]) {
+ H5E_BEGIN_TRY {
+ H5Gclose(gids[n]);
+ } H5E_END_TRY;
+ } /* end if */
+ HDfree(gids);
+ } /* end if */
+ H5E_BEGIN_TRY {
+ H5Gclose(rootid);
+ } H5E_END_TRY;
+
return 1;
} /* end test_unlink_middlenode() */
@@ -1819,7 +1867,7 @@ error:
static int
test_resurrect_dataset(hid_t fapl)
{
- hid_t f =-1, s =-1, d =-1;
+ hid_t f = -1, s = -1, d = -1;
char filename[1024];
TESTING("resurrecting dataset after deletion");
@@ -2404,7 +2452,7 @@ main(void)
double rdcc_w0;
/* Set the random # seed */
- HDsrandom((unsigned long)HDtime(NULL));
+ HDsrandom((unsigned)HDtime(NULL));
/* Open */
h5_reset();
diff --git a/test/vfd.c b/test/vfd.c
index f5a29c5..bd642be 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -808,7 +808,6 @@ test_family_compat(void)
char filename[1024];
char pathname[1024], pathname_individual[1024];
char newname[1024], newname_individual[1024];
- FILE *tmp_fp, *old_fp; /* Pointers to temp & old files */
int counter = 0;
TESTING("FAMILY file driver backward compatibility");
@@ -838,10 +837,6 @@ test_family_compat(void)
sprintf(pathname_individual, pathname, counter);
}
- if ((NULL != (old_fp = HDfopen(pathname_individual,"rb"))) &&
- (NULL != (tmp_fp = HDfopen(newname_individual,"wb"))))
- TEST_ERROR;
-
/* Make sure we can open the file. Use the read and write mode to flush the
* superblock. */
if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0)