summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-02-20 02:23:44 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-02-20 02:23:44 (GMT)
commit0c39a78927ae1e4b7471f96743a8cf5dd30350b0 (patch)
tree21eb68c066d6ef8a139278439d02c89202ce970f /test
parent7bac0bb48dd18809fa015e91848dc8756c0fe536 (diff)
downloadhdf5-0c39a78927ae1e4b7471f96743a8cf5dd30350b0.zip
hdf5-0c39a78927ae1e4b7471f96743a8cf5dd30350b0.tar.gz
hdf5-0c39a78927ae1e4b7471f96743a8cf5dd30350b0.tar.bz2
[svn-r18300] Description:
Bring Coverity fixes from branch to trunk: r18282: Fix Coverity issue #428 by wrapping testing calls with if(pass) {} block. r18283: Fix Coverity issue #425 by wrapping test calls in if(pass) {} block r18284: Issue 166: init_error() malloc'd 3 pointers in initialization and never freed inc ase of errors. Init pointers to NULL, check allocation results and free allocations in error block r18285: Fix Coverity issue #410 by wrapping test calls with if(pass) {} block. r18286: Issue 165: custom_print_cb() needed allocations freed in error block. r18287: Fix coverity issue # 409 Added if (pass) checks around calls to flush_cache. Additionally, added a check for file_ptr = NULL after call to setup_cache. r18288: Fix coverity# 107 free fh in H5HF_close() correctly before exit the function even when failure occurs. r18289: Fix Coverity issue #429: correct failure return values to match return type from routine. r18290: Fix Coverity issue #103: release allocated indirect section on error r18294: Issue 153, 152: Check allocations and free allocations in error block. Also cleaned up hid_t identifer that were opened in error block. r18295: Fix coverity# 101 free new_loc in H5HF_man_iter_start_entry() correctly before exit the function even when failure occurs r18296: Fix coverity# 100 free down_loc in H5HF_man_iter_down() before exit the function when failure occurs r18297: Fixed coverity issues 54, 55 and 216. Correctly handle the various ways that allocation of attr_name can fail in test_attr_basic_write. r18298: Fix coverity# 119 free object in H5HG_read() before exit the function when failure occurs r18299: Fix coverity issue #112: Add cleanup during error handling of H5MP_create. Tested on: Mac OS X/32 10.6.2 (amazon) w/debug & production Misc. Linux configurations (on original checkins)
Diffstat (limited to 'test')
-rw-r--r--test/cache.c274
-rw-r--r--test/dtransform.c441
-rw-r--r--test/err_compat.c19
-rw-r--r--test/error_test.c29
-rw-r--r--test/tattr.c68
5 files changed, 516 insertions, 315 deletions
diff --git a/test/cache.c b/test/cache.c
index a83d60e..e02f14a 100644
--- a/test/cache.c
+++ b/test/cache.c
@@ -13586,9 +13586,13 @@ check_get_entry_status(void)
}
}
- protect_entry(file_ptr, 0, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, 0, 0);
+
+ unprotect_entry(file_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET);
- unprotect_entry(file_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET);
+ }
if ( pass ) {
@@ -13610,7 +13614,11 @@ check_get_entry_status(void)
}
}
- protect_entry(file_ptr, 0, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, 0, 0);
+
+ }
if ( pass ) {
@@ -13632,7 +13640,11 @@ check_get_entry_status(void)
}
}
- unprotect_entry(file_ptr, 0, 0, FALSE, H5C__PIN_ENTRY_FLAG);
+ if ( pass ) {
+
+ unprotect_entry(file_ptr, 0, 0, FALSE, H5C__PIN_ENTRY_FLAG);
+
+ }
if ( pass ) {
@@ -13654,7 +13666,11 @@ check_get_entry_status(void)
}
}
- mark_pinned_entry_dirty(0, 0, FALSE, (size_t)0);
+ if ( pass ) {
+
+ mark_pinned_entry_dirty(0, 0, FALSE, (size_t)0);
+
+ }
if ( pass ) {
@@ -13676,7 +13692,11 @@ check_get_entry_status(void)
}
}
- unpin_entry(0, 0);
+ if ( pass ) {
+
+ unpin_entry(0, 0);
+
+ }
if ( pass ) {
@@ -14913,7 +14933,11 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+
+ }
if ( pass ) {
@@ -15032,7 +15056,11 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+
+ }
if ( pass ) {
@@ -15104,9 +15132,13 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__PIN_ENTRY_FLAG);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__PIN_ENTRY_FLAG);
+ }
if ( pass ) {
@@ -15230,10 +15262,14 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE,
+ H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE,
- H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG);
+ }
if ( pass ) {
@@ -15300,14 +15336,18 @@ check_resize_entry(void)
entry_size = LARGE_ENTRY_SIZE;
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, TRUE, H5C__NO_FLAGS_SET);
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__NO_FLAGS_SET);
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__NO_FLAGS_SET);
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, TRUE, H5C__NO_FLAGS_SET);
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__NO_FLAGS_SET);
+
+ }
if ( pass ) {
@@ -15324,7 +15364,11 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+
+ }
if ( pass ) {
@@ -15445,7 +15489,11 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+
+ }
if ( pass ) {
@@ -15517,9 +15565,13 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+ if ( pass ) {
+
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, FALSE, H5C__PIN_ENTRY_FLAG);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, FALSE, H5C__PIN_ENTRY_FLAG);
+
+ }
if ( pass ) {
@@ -15645,10 +15697,14 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+ if ( pass ) {
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, FALSE,
- H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG);
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3);
+
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, FALSE,
+ H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG);
+
+ }
if ( pass ) {
@@ -15695,15 +15751,18 @@ check_resize_entry(void)
}
}
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__DELETED_FLAG);
+ if ( pass ) {
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, FALSE, H5C__DELETED_FLAG);
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__DELETED_FLAG);
- protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
- unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__DELETED_FLAG);
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, FALSE, H5C__DELETED_FLAG);
+ protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0);
+ unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__DELETED_FLAG);
+
+ }
if ( pass ) {
@@ -15768,7 +15827,7 @@ check_evictions_enabled(void)
int mile_stone = 1;
H5F_t * file_ptr = NULL;
H5C_t * cache_ptr = NULL;
- test_entry_t * base_addr;
+ test_entry_t * base_addr = NULL;
test_entry_t * entry_ptr;
TESTING("evictions enabled/disabled functionality");
@@ -15821,9 +15880,18 @@ check_evictions_enabled(void)
file_ptr = setup_cache((size_t)(1 * 1024 * 1024),
(size_t)( 512 * 1024));
- cache_ptr = file_ptr->shared->cache;
+ if ( file_ptr == NULL ) {
- base_addr = entries[MONSTER_ENTRY_TYPE];
+ pass = FALSE;
+ failure_mssg = "file_ptr NULL from setup_cache.";
+
+ }
+ else
+ {
+ cache_ptr = file_ptr->shared->cache;
+
+ base_addr = entries[MONSTER_ENTRY_TYPE];
+ }
}
if ( show_progress ) /* 2 */
@@ -15867,12 +15935,16 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* fill the cache */
- for ( i = 0; i < 16 ; i++ )
- {
- protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i);
- unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i,
- FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* fill the cache */
+ for ( i = 0; i < 16 ; i++ )
+ {
+ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i);
+ unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i,
+ FALSE, H5C__NO_FLAGS_SET);
+ }
+
}
if ( show_progress ) /* 5 */
@@ -15900,10 +15972,14 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* protect and unprotect another entry */
- protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16);
- unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16,
- FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* protect and unprotect another entry */
+ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16);
+ unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16,
+ FALSE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 7 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -15966,8 +16042,12 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* insert an entry */
- insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 17, TRUE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* insert an entry */
+ insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 17, TRUE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 10 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -16066,10 +16146,14 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* protect and unprotect another entry */
- protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18);
- unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18,
- FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* protect and unprotect another entry */
+ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18);
+ unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18,
+ FALSE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 15 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -16095,8 +16179,12 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* insert another entry */
- insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 19, TRUE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* insert another entry */
+ insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 19, TRUE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 17 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -16139,10 +16227,14 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* protect and unprotect an entry that is in the cache */
- protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19);
- unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19,
- FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* protect and unprotect an entry that is in the cache */
+ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19);
+ unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19,
+ FALSE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 20 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -16168,10 +16260,14 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* protect and unprotect an entry that isn't in the cache */
- protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20);
- unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20,
- FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* protect and unprotect an entry that isn't in the cache */
+ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20);
+ unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20,
+ FALSE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 22 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -16289,13 +16385,16 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* protect and unprotect an entry that isn't in the cache, forcing
- * the cache to grow.
- */
- protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21);
- unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21,
- FALSE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+ /* protect and unprotect an entry that isn't in the cache, forcing
+ * the cache to grow.
+ */
+ protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21);
+ unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21,
+ FALSE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 27 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -16338,8 +16437,12 @@ check_evictions_enabled(void)
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
fcn_name, mile_stone++, (int)pass);
- /* insert an entry */
- insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 22, TRUE, H5C__NO_FLAGS_SET);
+ if ( pass ) {
+
+ /* insert an entry */
+ insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 22, TRUE, H5C__NO_FLAGS_SET);
+
+ }
if ( show_progress ) /* 30 */
HDfprintf(stdout, "%s() - %0d -- pass = %d\n",
@@ -22475,7 +22578,17 @@ check_auto_cache_resize_disable(void)
file_ptr = setup_cache((size_t)(2 * 1024),
(size_t)(1 * 1024));
- cache_ptr = file_ptr->shared->cache;
+
+ if ( file_ptr == NULL ) {
+
+ pass = FALSE;
+ failure_mssg = "file_ptr NULL from setup_cache.";
+
+ }
+ else {
+
+ cache_ptr = file_ptr->shared->cache;
+ }
}
if ( pass ) {
@@ -23536,8 +23649,11 @@ check_auto_cache_resize_disable(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
- /* flush the cache and destroy all entries so we start from a known point */
- flush_cache(file_ptr, TRUE, FALSE, FALSE);
+ if ( pass ) {
+
+ /* flush the cache and destroy all entries so we start from a known point */
+ flush_cache(file_ptr, TRUE, FALSE, FALSE);
+ }
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
@@ -23764,8 +23880,11 @@ check_auto_cache_resize_disable(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
- /* flush the cache and destroy all entries so we start from a known point */
- flush_cache(file_ptr, TRUE, FALSE, FALSE);
+ if ( pass ) {
+
+ /* flush the cache and destroy all entries so we start from a known point */
+ flush_cache(file_ptr, TRUE, FALSE, FALSE);
+ }
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
@@ -23999,8 +24118,11 @@ check_auto_cache_resize_disable(void)
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
- /* flush the cache and destroy all entries so we start from a known point */
- flush_cache(file_ptr, TRUE, FALSE, FALSE);
+ if ( pass ) {
+
+ /* flush the cache and destroy all entries so we start from a known point */
+ flush_cache(file_ptr, TRUE, FALSE, FALSE);
+ }
if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++);
diff --git a/test/dtransform.c b/test/dtransform.c
index cb58a6c..3b1133a 100644
--- a/test/dtransform.c
+++ b/test/dtransform.c
@@ -27,10 +27,10 @@ static int test_set(void);
static int test_getset(const hid_t dxpl_id_simple);
/* These are needed for multiple tests, so are declared here globally and are init'ed in init_test */
-hid_t dset_id_int;
-hid_t dset_id_float;
-hid_t dset_id_int_chunk;
-hid_t dset_id_float_chunk;
+hid_t dset_id_int = -1;
+hid_t dset_id_float = -1;
+hid_t dset_id_int_chunk = -1;
+hid_t dset_id_float_chunk = -1;
const float windchillFfloat[ROWS][COLS] =
@@ -68,15 +68,15 @@ const int transformData[ROWS][COLS] =
size_t i,j; \
\
for(i=0; i<ROWS; i++) \
- for(j=0; j<COLS; j++) \
- { \
- if(!( (((VAR1)[i][j] >= (TYPE)((VAR2)[i][j])) && ( ((VAR1)[i][j] - TOL) < (TYPE)((VAR2)[i][j]))) || ( ((VAR1)[i][j] <= (TYPE)((VAR2)[i][j])) && ( ((VAR1)[i][j] + TOL) > (TYPE)((VAR2)[i][j]))))) \
- { \
- H5_FAILED(); \
- fprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \
- goto error; \
- } \
- } \
+ for(j=0; j<COLS; j++) \
+ { \
+ if(!( (((VAR1)[i][j] >= (TYPE)((VAR2)[i][j])) && ( ((VAR1)[i][j] - TOL) < (TYPE)((VAR2)[i][j]))) || ( ((VAR1)[i][j] <= (TYPE)((VAR2)[i][j])) && ( ((VAR1)[i][j] + TOL) > (TYPE)((VAR2)[i][j]))))) \
+ { \
+ H5_FAILED(); \
+ fprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \
+ goto error; \
+ } \
+ } \
PASSED(); \
}
@@ -85,15 +85,15 @@ const int transformData[ROWS][COLS] =
size_t i,j; \
\
for(i=0; i<ROWS; i++) \
- for(j=0; j<COLS; j++) \
- { \
- if( !(((VAR1)[i][j] <= ((TYPE)(VAR2)[i][j] + TOL)) && ((VAR1)[i][j] >= ((TYPE)(VAR2)[i][j] - TOL))) ) \
- { \
- H5_FAILED(); \
- fprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \
- goto error; \
- } \
- } \
+ for(j=0; j<COLS; j++) \
+ { \
+ if( !(((VAR1)[i][j] <= ((TYPE)(VAR2)[i][j] + TOL)) && ((VAR1)[i][j] >= ((TYPE)(VAR2)[i][j] - TOL))) ) \
+ { \
+ H5_FAILED(); \
+ fprintf(stderr, " ERROR: Conversion failed to match computed data\n"); \
+ goto error; \
+ } \
+ } \
PASSED(); \
}
@@ -172,17 +172,17 @@ const int transformData[ROWS][COLS] =
\
hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, memspace, dset_chunk, filespace; \
hsize_t dim[2] = {ROWS, COLS}; \
- hsize_t offset[2] = {0, 0}; \
+ hsize_t offset[2] = {0, 0}; \
\
\
if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR; \
\
- cparms = H5Pcreate(H5P_DATASET_CREATE); \
- if(H5Pset_chunk(cparms, 2, dim) < 0) TEST_ERROR; \
+ if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; \
+ if(H5Pset_chunk(cparms, 2, dim) < 0) TEST_ERROR; \
\
if((dset_chunk = H5Dcreate2(file_id, "/transformtest_chunk_"TEST_STR, HDF_TYPE, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) TEST_ERROR; \
- filespace = H5Dget_space (dset_chunk); \
- memspace = H5Screate_simple(2, dim, NULL); \
+ if((filespace = H5Dget_space(dset_chunk)) < 0) TEST_ERROR \
+ if((memspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR \
if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0) TEST_ERROR; \
\
if(SIGNED) \
@@ -190,14 +190,14 @@ const int transformData[ROWS][COLS] =
if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \
if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) TEST_ERROR; \
if(H5Dwrite(dset_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR; \
- if(H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR; \
+ if(H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR; \
} \
else \
{ \
if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; \
if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) TEST_ERROR; \
if(H5Dwrite(dset_chunk, H5T_NATIVE_INT, dataspace, filespace, dxpl_id_utrans, transformData) < 0) TEST_ERROR; \
- if(H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR; \
+ if(H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR; \
} \
\
\
@@ -211,17 +211,17 @@ const int transformData[ROWS][COLS] =
\
if(SIGNED) \
{ \
- TESTING("chunked, with type conversion (float->"TEST_STR")") \
+ TESTING("chunked, with type conversion (float->"TEST_STR")") \
\
if(H5Dread(dset_id_float_chunk, HDF_TYPE, memspace, filespace, XFORM, array) < 0) TEST_ERROR; \
- COMPARE(TYPE, array, COMPARE_DATA, 2) \
+ COMPARE(TYPE, array, COMPARE_DATA, 2) \
} \
\
- \
- if(H5Pclose(cparms) < 0) TEST_ERROR; \
+ \
+ if(H5Pclose(cparms) < 0) TEST_ERROR; \
if(H5Dclose(dset_chunk) < 0) TEST_ERROR; \
- if(H5Sclose(dataspace) < 0) TEST_ERROR; \
- if(H5Sclose(memspace) < 0) TEST_ERROR; \
+ if(H5Sclose(dataspace) < 0) TEST_ERROR; \
+ if(H5Sclose(memspace) < 0) TEST_ERROR; \
}
#define INVALID_SET_TEST(TRANSFORM) \
@@ -240,7 +240,7 @@ const int transformData[ROWS][COLS] =
int main(void)
{
- hid_t dxpl_id_c_to_f, dxpl_id_c_to_f_copy, dxpl_id_simple, dxpl_id_polynomial, dxpl_id_polynomial_copy, dxpl_id_utrans_inv, file_id;
+ hid_t dxpl_id_c_to_f = -1, dxpl_id_c_to_f_copy = -1, dxpl_id_simple = -1, dxpl_id_polynomial = -1, dxpl_id_polynomial_copy = -1, dxpl_id_utrans_inv = -1, file_id = -1;
const char* c_to_f = "(9/5.0)*x + 32";
const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
@@ -344,6 +344,19 @@ int main(void)
return 0;
error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dset_id_int);
+ H5Dclose(dset_id_int_chunk);
+ H5Dclose(dset_id_float);
+ H5Dclose(dset_id_float_chunk);
+ H5Fclose(file_id);
+ H5Pclose(dxpl_id_c_to_f);
+ H5Pclose(dxpl_id_c_to_f_copy);
+ H5Pclose(dxpl_id_polynomial);
+ H5Pclose(dxpl_id_polynomial_copy);
+ H5Pclose(dxpl_id_simple);
+ H5Pclose(dxpl_id_utrans_inv);
+ } H5E_END_TRY
return -1;
}
@@ -354,93 +367,128 @@ init_test(hid_t file_id)
/* utrans is a transform for unsigned types: no negative numbers involved and results are < 255 to fit into uchar */
const char* utrans = "((x+100)/4)*3";
- hid_t dataspace, dxpl_id_f_to_c, dxpl_id_utrans, cparms, filespace;
- hsize_t dim[2] = {ROWS, COLS};
- hsize_t offset[2] = {0, 0};
-
- if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
- if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
+ hid_t dataspace = -1, dxpl_id_f_to_c = -1, dxpl_id_utrans = -1, cparms = -1, filespace = -1;
+ hsize_t dim[2] = { ROWS, COLS };
+ hsize_t offset[2] = { 0, 0 };
- if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0) TEST_ERROR;
- if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0) TEST_ERROR;
+ if((dxpl_id_f_to_c = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ TEST_ERROR
+ if((dxpl_id_utrans = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ TEST_ERROR
+ if(H5Pset_data_transform(dxpl_id_f_to_c, f_to_c) < 0)
+ TEST_ERROR
+ if(H5Pset_data_transform(dxpl_id_utrans, utrans) < 0)
+ TEST_ERROR
cparms = H5Pcreate(H5P_DATASET_CREATE);
- if(H5Pset_chunk(cparms, 2, dim) < 0) TEST_ERROR;
+ if(H5Pset_chunk(cparms, 2, dim) < 0)
+ TEST_ERROR
- if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) TEST_ERROR;
+ if((dataspace = H5Screate_simple(2, dim, NULL)) < 0)
+ TEST_ERROR
TESTING("Intializing test...")
- if((dset_id_int = H5Dcreate2(file_id, "/default_int", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
- if(H5Dwrite(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR;
-
- if((dset_id_float = H5Dcreate2(file_id, "/default_float", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR;
- if(H5Dwrite(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR;
-
- if((dset_id_int_chunk = H5Dcreate2(file_id, "/default_chunk_int", H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) TEST_ERROR;
-
- filespace = H5Dget_space (dset_id_int_chunk);
- if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0) TEST_ERROR;
- if(H5Dwrite(dset_id_int_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR;
-
- if((dset_id_float_chunk = H5Dcreate2(file_id, "/default_chunk_float", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0) TEST_ERROR;
- if(H5Dwrite(dset_id_float_chunk, H5T_NATIVE_FLOAT, dataspace, filespace, dxpl_id_f_to_c, windchillFfloat) < 0) TEST_ERROR;
-
+ if((dset_id_int = H5Dcreate2(file_id, "/default_int", H5T_NATIVE_INT,
+ dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
+ dxpl_id_f_to_c, windchillFfloat) < 0)
+ TEST_ERROR
+
+ if((dset_id_float = H5Dcreate2(file_id, "/default_float",
+ H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
+ dxpl_id_f_to_c, windchillFfloat) < 0)
+ TEST_ERROR
+
+ if((dset_id_int_chunk = H5Dcreate2(file_id, "/default_chunk_int",
+ H5T_NATIVE_INT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ if((filespace = H5Dget_space(dset_id_int_chunk)) < 0)
+ TEST_ERROR
+ if(H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dim, NULL) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id_int_chunk, H5T_NATIVE_FLOAT, dataspace, filespace,
+ dxpl_id_f_to_c, windchillFfloat) < 0)
+ TEST_ERROR
+
+ if((dset_id_float_chunk = H5Dcreate2(file_id, "/default_chunk_float",
+ H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT, cparms, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if(H5Dwrite(dset_id_float_chunk, H5T_NATIVE_FLOAT, dataspace, filespace,
+ dxpl_id_f_to_c, windchillFfloat) < 0)
+ TEST_ERROR
+
+ if(H5Pclose(cparms) < 0)
+ TEST_ERROR
+ if(H5Pclose(dxpl_id_f_to_c) < 0)
+ TEST_ERROR
+ if(H5Pclose(dxpl_id_utrans) < 0)
+ TEST_ERROR
+ if(H5Sclose(dataspace) < 0)
+ TEST_ERROR
+ if(H5Sclose(filespace) < 0)
+ TEST_ERROR
PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Pclose(cparms);
+ H5Pclose(dxpl_id_f_to_c);
+ H5Pclose(dxpl_id_utrans);
+ H5Sclose(dataspace);
+ H5Sclose(filespace);
+ } H5E_END_TRY
- if(H5Pclose(cparms) < 0) TEST_ERROR;
- if(H5Pclose(dxpl_id_f_to_c) < 0) TEST_ERROR;
- if(H5Pclose(dxpl_id_utrans) < 0) TEST_ERROR;
- if(H5Sclose(dataspace) < 0) TEST_ERROR;
-
- return 0;
-error:
- return -1;
+ return -1;
}
static int
test_poly(const hid_t dxpl_id_polynomial)
{
float polyflres[ROWS][COLS];
- int polyintread[ROWS][COLS];
+ int polyintread[ROWS][COLS];
float polyflread[ROWS][COLS];
int windchillC;
int row, col;
- for(row = 0; row<ROWS; row++)
- {
- for(col = 0; col<COLS; col++)
- {
- windchillC = (int)((5.0/9.0)*(windchillFfloat[row][col] - 32));
- polyflres[row][col] = (float)((2.0+windchillC)*((windchillC-8.0)/2.0));
- }
- }
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++) {
+ windchillC = (int) ((5.0 / 9.0) * (windchillFfloat[row][col] - 32));
+ polyflres[row][col] = (float) ((2.0 + windchillC) * ((windchillC - 8.0) / 2.0));
+ }
TESTING("data transform, polynomial transform (int->float)")
- if(H5Dread(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyflread) < 0) TEST_ERROR;
+ if(H5Dread(dset_id_int, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
+ dxpl_id_polynomial, polyflread) < 0)
+ TEST_ERROR
+
COMPARE(float, polyflread, polyflres, 2.0)
-
- for(row = 0; row<ROWS; row++)
- {
- for(col = 0; col<COLS; col++)
- {
- windchillC = (int)((5.0/9.0)*(windchillFfloat[row][col] - 32));
- polyflres[row][col] = (float)((2+windchillC)*((windchillC-8)/2));
- }
- }
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++) {
+ windchillC = (int) ((5.0 / 9.0) * (windchillFfloat[row][col] - 32));
+ polyflres[row][col] = (float) ((2 + windchillC) * ((windchillC - 8) / 2));
+ }
TESTING("data transform, polynomial transform (float->int)")
- if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial, polyintread) < 0) TEST_ERROR;
+ if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id_polynomial, polyintread) < 0)
+ TEST_ERROR
+
COMPARE(int, polyintread, polyflres, 4)
return 0;
-error:
- return -1;
+error:
+ return -1;
}
static int
@@ -452,27 +500,29 @@ test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy)
int windchillFintread[ROWS][COLS];
int row, col;
- for(row = 0; row<ROWS; row++)
- {
- for(col = 0; col<COLS; col++)
- {
- windchillC = (int)((5.0/9.0)*(windchillFfloat[row][col] - 32));
- polyflres[row][col] = (float)((2+windchillC)*((windchillC-8)/2));
- }
- }
-
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++) {
+ windchillC = (int) ((5.0 / 9.0) * (windchillFfloat[row][col] - 32));
+ polyflres[row][col] = (float) ((2 + windchillC) * ((windchillC - 8) / 2));
+ }
TESTING("data transform, linear transform w/ copied property")
- if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f_copy, windchillFintread) < 0) TEST_ERROR;
+ if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id_c_to_f_copy, windchillFintread) < 0)
+ TEST_ERROR
+
COMPARE(int, windchillFintread, windchillFfloat, 2)
TESTING("data transform, polynomial transform w/ copied property")
- if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_polynomial_copy, polyintread) < 0) TEST_ERROR;
+ if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id_polynomial_copy, polyintread) < 0)
+ TEST_ERROR
+
COMPARE(int, polyintread, polyflres, 2)
return 0;
-error:
+error:
return -1;
}
@@ -484,36 +534,28 @@ test_trivial(const hid_t dxpl_id_simple)
int row, col;
TESTING("data transform, trivial transform, without type conversion")
- if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFfloatread) < 0) TEST_ERROR;
- for(row = 0; row<ROWS; row++)
- {
- for(col = 0; col<COLS; col++)
- {
- if((windchillFfloatread[row][col] - 4.8) > FLOAT_TOL)
- {
- H5_FAILED();
- fprintf(stderr, " ERROR: Conversion failed to match computed data\n");
- goto error;
- }
- }
- }
- PASSED();
+ if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
+ dxpl_id_simple, windchillFfloatread) < 0)
+ TEST_ERROR
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++) {
+ if((windchillFfloatread[row][col] - 4.8) > FLOAT_TOL)
+ FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n");
+ }
+
+ PASSED()
TESTING("data transform, trivial transform, with type conversion")
- if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id_simple, windchillFintread) < 0) TEST_ERROR;
- for(row = 0; row<ROWS; row++)
- {
- for(col = 0; col<COLS; col++)
- {
- if(windchillFintread[row][col] != 4)
- {
- H5_FAILED();
- fprintf(stderr, " ERROR: Conversion failed to match computed data\n");
- goto error;
- }
- }
- }
- PASSED();
+ if(H5Dread(dset_id_float, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
+ dxpl_id_simple, windchillFintread) < 0)
+ TEST_ERROR
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++) {
+ if(windchillFintread[row][col] != 4)
+ FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n")
+ }
+
+ PASSED()
return 0;
error:
@@ -523,92 +565,96 @@ error:
static int
test_getset(const hid_t dxpl_id_c_to_f)
{
- int row, col;
- float windchillFfloatread[ROWS][COLS];
- const char* simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
- const char* c_to_f = "(9/5.0)*x + 32";
- char* ptrgetTest = (char *) HDmalloc(HDstrlen(simple)+1);
+ int row;
+ int col;
+ float windchillFfloatread[ROWS][COLS];
+ const char *simple = "(4/2) * ( (2 + 4)/(5 - 2.5))"; /* this equals 4.8 */
+ const char *c_to_f = "(9/5.0)*x + 32";
+ char *ptrgetTest = NULL;
TESTING("H5Pget_data_transform")
- H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(c_to_f)+1);
+
+ if(NULL == (ptrgetTest = (char *)HDmalloc(HDstrlen(simple) + 1)))
+ TEST_ERROR
+
+ if(H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(c_to_f) + 1) < 0)
+ TEST_ERROR
if(HDstrcmp(c_to_f, ptrgetTest) != 0)
- {
- H5_FAILED();
- fprintf(stderr, " ERROR: Data transform failed to match what was set\n");
- goto error;
- }
- else
- PASSED();
- free(ptrgetTest);
+ FAIL_PUTS_ERROR(" ERROR: Data transform failed to match what was set\n")
- if(H5Pset_data_transform(dxpl_id_c_to_f, simple) < 0) TEST_ERROR;
+ PASSED()
+
+ HDfree(ptrgetTest);
+ ptrgetTest = NULL;
TESTING("data transform, read after reseting of transform property")
- if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, dxpl_id_c_to_f, windchillFfloatread) < 0) TEST_ERROR;
- for(row = 0; row<ROWS; row++)
- {
- for(col = 0; col<COLS; col++)
- {
- if((windchillFfloatread[row][col] - 4.8) > FLOAT_TOL)
- {
- H5_FAILED();
- fprintf(stderr, " ERROR: Conversion failed to match computed data\n");
- goto error;
- }
- }
- }
- PASSED();
+ if(H5Pset_data_transform(dxpl_id_c_to_f, simple) < 0)
+ TEST_ERROR
+
+ if(H5Dread(dset_id_float, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
+ dxpl_id_c_to_f, windchillFfloatread) < 0)
+ TEST_ERROR
+
+ for(row = 0; row < ROWS; row++)
+ for(col = 0; col < COLS; col++) {
+ if((windchillFfloatread[row][col] - 4.8) > FLOAT_TOL)
+ FAIL_PUTS_ERROR(" ERROR: Conversion failed to match computed data\n")
+ }
- ptrgetTest = (char *) malloc(strlen(simple)+1);
+ PASSED()
- HDmemset(ptrgetTest, 0, strlen(simple)+1);
TESTING("H5Pget_data_transform, after resetting transform property")
- H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, strlen(simple)+1);
- if(strcmp(simple, ptrgetTest) != 0)
- {
- H5_FAILED();
- fprintf(stderr, " ERROR: Data transform failed to match what was set\n");
- goto error;
- }
- else
- PASSED();
-
- free(ptrgetTest);
+
+ if(NULL == (ptrgetTest = (char *)HDcalloc(1, HDstrlen(simple) + 1)))
+ TEST_ERROR
+ if(H5Pget_data_transform(dxpl_id_c_to_f, ptrgetTest, HDstrlen(simple) + 1) < 0)
+ TEST_ERROR
+ if(HDstrcmp(simple, ptrgetTest) != 0)
+ FAIL_PUTS_ERROR(" ERROR: Data transform failed to match what was set\n")
+
+ PASSED()
+
+ HDfree(ptrgetTest);
+ ptrgetTest = NULL;
return 0;
error:
- return -1;
+ if(ptrgetTest)
+ HDfree(ptrgetTest);
+
+ return -1;
}
static int
test_set(void)
{
- hid_t dxpl_id;
+ hid_t dxpl_id = -1;
H5E_auto2_t func;
- const char* str = "(9/5.0)*x + 32";
- char* ptrgetTest = (char *) malloc(strlen(str)+1);
+ const char *str = "(9/5.0)*x + 32";
+ char *ptrgetTest = NULL;
+
+ TESTING("H5Pget_data_transform (get before set)")
+
+ if(NULL == (ptrgetTest = (char *)HDmalloc(HDstrlen(str) + 1)))
+ TEST_ERROR
- if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR;
+ if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0)
+ TEST_ERROR
/* Test get before set */
- H5Eget_auto2(H5E_DEFAULT,&func,NULL);
+ H5Eget_auto2(H5E_DEFAULT, &func, NULL);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
- TESTING("H5Pget_data_transform (get before set)")
- if(H5Pget_data_transform(dxpl_id, ptrgetTest, strlen(str)+1) < 0)
- {
- PASSED();
- }
- else
- {
- H5_FAILED();
- fprintf(stderr, " ERROR: Data transform get before set succeeded (it shouldn't have)\n");
- free(ptrgetTest);
- goto error;
- }
- free(ptrgetTest);
+
+ if(H5Pget_data_transform(dxpl_id, ptrgetTest, HDstrlen(str) + 1) < 0)
+ PASSED()
+ else
+ FAIL_PUTS_ERROR(" ERROR: Data transform get before set succeeded (it shouldn't have)\n");
+
+ HDfree(ptrgetTest);
+ ptrgetTest = NULL;
TESTING("H5Pset_data_transform (set with NULL transform)");
INVALID_SET_TEST(NULL);
@@ -639,9 +685,18 @@ test_set(void)
H5Eset_auto2(H5E_DEFAULT, func, NULL);
+ if(H5Pclose(dxpl_id) < 0)
+ TEST_ERROR
+
return 0;
error:
- return -1;
+ if(ptrgetTest)
+ HDfree(ptrgetTest);
+ H5E_BEGIN_TRY {
+ H5Pclose(dxpl_id);
+ } H5E_END_TRY
+ return -1;
}
+
diff --git a/test/err_compat.c b/test/err_compat.c
index 33c172f..be86a2d 100644
--- a/test/err_compat.c
+++ b/test/err_compat.c
@@ -186,10 +186,10 @@ dump_error(void)
herr_t
custom_print_cb(int n, H5E_error1_t *err_desc, void* client_data)
{
- FILE *stream = (FILE *)client_data;
- char *maj;
- char *min;
- const int indent = 4;
+ FILE *stream = (FILE *)client_data;
+ char *maj = NULL;
+ char *min = NULL;
+ const int indent = 4;
if(NULL == (min = H5Eget_minor(err_desc->min_num)))
TEST_ERROR;
@@ -200,14 +200,21 @@ custom_print_cb(int n, H5E_error1_t *err_desc, void* client_data)
fprintf(stream, "%*serror #%03d: %s in %s(): line %u\n",
indent, "", n, err_desc->file_name,
err_desc->func_name, err_desc->line);
- fprintf(stream, "%*smajor: %s\n", indent*2, "", maj);
+
+ fprintf(stream, "%*smajor: %s\n", indent * 2, "", maj);
+ fprintf(stream, "%*sminor: %s\n", indent * 2, "", min);
+
HDfree(maj);
- fprintf (stream, "%*sminor: %s\n", indent*2, "", min);
HDfree(min);
return 0;
error:
+ if(maj)
+ HDfree(maj);
+ if(min)
+ HDfree(min);
+
return -1;
}
diff --git a/test/error_test.c b/test/error_test.c
index 21a3e58..e784eb9 100644
--- a/test/error_test.c
+++ b/test/error_test.c
@@ -186,11 +186,16 @@ test_error(hid_t file)
static herr_t
init_error(void)
{
- ssize_t cls_size = (ssize_t)HDstrlen(ERR_CLS_NAME)+1;
- char *cls_name = (char*)HDmalloc(HDstrlen(ERR_CLS_NAME)+1);
+ ssize_t cls_size = (ssize_t)HDstrlen(ERR_CLS_NAME) + 1;
ssize_t msg_size = (ssize_t)HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1;
- char *msg = (char*)HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG)+1);
- H5E_type_t *msg_type= (H5E_type_t *)HDmalloc(sizeof(H5E_type_t));
+ char *cls_name = NULL;
+ char *msg = NULL;
+ H5E_type_t msg_type;
+
+ if(NULL == (cls_name = (char *)HDmalloc(HDstrlen(ERR_CLS_NAME) + 1)))
+ TEST_ERROR
+ if(NULL == (msg = (char *)HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1)))
+ TEST_ERROR
if((ERR_CLS = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS)) < 0)
TEST_ERROR;
@@ -218,24 +223,28 @@ init_error(void)
if((ERR_MIN_GETNUM = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_GETNUM_MSG)) < 0)
TEST_ERROR;
- if(msg_size != H5Eget_msg(ERR_MIN_SUBROUTINE, msg_type, msg, (size_t)msg_size) + 1)
+ if(msg_size != H5Eget_msg(ERR_MIN_SUBROUTINE, &msg_type, msg, (size_t)msg_size) + 1)
TEST_ERROR;
- if(*msg_type != H5E_MINOR)
+ if(msg_type != H5E_MINOR)
TEST_ERROR;
if(HDstrcmp(msg, ERR_MIN_SUBROUTINE_MSG))
TEST_ERROR;
- HDfree(cls_name);
- HDfree(msg);
- HDfree(msg_type);
-
/* Register another class for later testing. */
if((ERR_CLS2 = H5Eregister_class(ERR_CLS2_NAME, PROG2_NAME, PROG_VERS)) < 0)
TEST_ERROR;
+ HDfree(cls_name);
+ HDfree(msg);
+
return 0;
error:
+ if(cls_name)
+ HDfree(cls_name);
+ if(msg)
+ HDfree(msg);
+
return -1;
} /* end init_error() */
diff --git a/test/tattr.c b/test/tattr.c
index 484d83f..828b8a8 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -274,60 +274,68 @@ test_attr_basic_write(hid_t fapl)
attr_name_size = H5Aget_name(attr, (size_t)0, NULL);
CHECK(attr_name_size, FAIL, "H5Aget_name");
- if(attr_name_size > 0)
+ if(attr_name_size > 0) {
attr_name = (char*)HDcalloc((size_t)(attr_name_size + 1), sizeof(char));
-
- ret = (herr_t)H5Aget_name(attr, (size_t)(attr_name_size + 1), attr_name);
- CHECK(ret, FAIL, "H5Aget_name");
- ret = HDstrcmp(attr_name, ATTR_TMP_NAME);
- VERIFY(ret, 0, "HDstrcmp");
-
- if(attr_name)
- HDfree(attr_name);
+ CHECK(attr_name, NULL, "HDcalloc");
+
+ if(attr_name) {
+ ret = (herr_t)H5Aget_name(attr, (size_t)(attr_name_size + 1), attr_name);
+ CHECK(ret, FAIL, "H5Aget_name");
+ ret = HDstrcmp(attr_name, ATTR_TMP_NAME);
+ VERIFY(ret, 0, "HDstrcmp");
+
+ HDfree(attr_name);
+ attr_name = NULL;
+ } /* end if */
+ } /* end if */
/* Read attribute information immediately, without closing attribute */
ret = H5Aread(attr, H5T_NATIVE_INT, read_data1);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1[i]!=read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]);
+ for(i = 0; i < ATTR1_DIM1; i++)
+ if(attr_data1[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]);
/* Close attribute */
- ret=H5Aclose(attr);
+ ret = H5Aclose(attr);
CHECK(ret, FAIL, "H5Aclose");
/* Open the second attribute again */
- attr2=H5Aopen(dataset, ATTR1A_NAME, H5P_DEFAULT);
+ attr2 = H5Aopen(dataset, ATTR1A_NAME, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
/* Verify new attribute name */
attr_name_size = H5Aget_name(attr2, (size_t)0, NULL);
CHECK(attr_name_size, FAIL, "H5Aget_name");
- if(attr_name_size>0)
+ if(attr_name_size > 0) {
attr_name = (char*)HDcalloc((size_t)(attr_name_size+1), sizeof(char));
-
- ret=(herr_t)H5Aget_name(attr2, (size_t)(attr_name_size+1), attr_name);
- CHECK(ret, FAIL, "H5Aget_name");
- ret=HDstrcmp(attr_name, ATTR1A_NAME);
- VERIFY(ret, 0, "HDstrcmp");
-
- if(attr_name)
- HDfree(attr_name);
+ CHECK(attr_name, NULL, "HDcalloc");
+
+ if(attr_name) {
+ ret = (herr_t)H5Aget_name(attr2, (size_t)(attr_name_size + 1), attr_name);
+ CHECK(ret, FAIL, "H5Aget_name");
+ ret = HDstrcmp(attr_name, ATTR1A_NAME);
+ VERIFY(ret, 0, "HDstrcmp");
+
+ HDfree(attr_name);
+ attr_name = NULL;
+ } /* end if */
+ } /* end if */
/* Read attribute information immediately, without closing attribute */
- ret=H5Aread(attr2,H5T_NATIVE_INT,read_data1);
+ ret = H5Aread(attr2, H5T_NATIVE_INT, read_data1);
CHECK(ret, FAIL, "H5Aread");
/* Verify values read in */
- for(i=0; i<ATTR1_DIM1; i++)
- if(attr_data1a[i]!=read_data1[i])
- TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1a[i],i,read_data1[i]);
+ for(i = 0; i < ATTR1_DIM1; i++)
+ if(attr_data1a[i] != read_data1[i])
+ TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1a[i], i, read_data1[i]);
/* Close attribute */
- ret=H5Aclose(attr2);
+ ret = H5Aclose(attr2);
CHECK(ret, FAIL, "H5Aclose");
ret = H5Sclose(sid1);
@@ -1539,7 +1547,7 @@ test_attr_delete(hid_t fapl)
CHECK(attr, FAIL, "H5Aopen_by_idx");
/* Verify Name */
- name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN,attr_name);
+ name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR1_NAME), "H5Aget_name");
if(HDstrcmp(attr_name, ATTR1_NAME))
TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR1_NAME);
@@ -1555,7 +1563,7 @@ test_attr_delete(hid_t fapl)
/* Verify Name */
name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name);
VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name");
- if(HDstrcmp(attr_name,ATTR3_NAME))
+ if(HDstrcmp(attr_name, ATTR3_NAME))
TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME);
/* Close attribute */