summaryrefslogtreecommitdiffstats
path: root/test/mf.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2011-02-06 03:30:19 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2011-02-06 03:30:19 (GMT)
commit90727b65778c62d80f138496c6bf1a548ace5a23 (patch)
tree3882f921a6c69ade21cccb92310cff7ef9860c28 /test/mf.c
parentfceb72c657ee623aa5574208834dc38515170a72 (diff)
downloadhdf5-90727b65778c62d80f138496c6bf1a548ace5a23.zip
hdf5-90727b65778c62d80f138496c6bf1a548ace5a23.tar.gz
hdf5-90727b65778c62d80f138496c6bf1a548ace5a23.tar.bz2
[svn-r20053] Description:
Bring r20052 from trunk to 1.8 branch: Clean up Coverity warnings, and fix some style issues: r19735: Fix for memory leak in test/mf found by valgrind. r19736: Fix memory leak in h5repack. The buffer in copy_objects, when copying the entire dataset at once, was not checked for the presence of a vlen, and vlen storage was never reclaimed. Added check and call to H5D_vlen_reclaim(). r19772: Change H5assert() to if (H5T_VLEN != src->shared->type || H5T_VLEN != dst->shared->type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a H5T_VLEN datatype") r19774: removed unused priv. r19775: removed unused variables r19778: Fix memory leak comparing for variable length data types. r19834: Fixed memory leaks found by valgrind. Memory errors remain for another day. Tested on: Mac OS X/32 10.6.6 (amazon) w/debug & production (h5committested on branch)
Diffstat (limited to 'test/mf.c')
-rw-r--r--test/mf.c92
1 files changed, 61 insertions, 31 deletions
diff --git a/test/mf.c b/test/mf.c
index cdc7de5..6361adc 100644
--- a/test/mf.c
+++ b/test/mf.c
@@ -159,7 +159,7 @@ static unsigned
test_mf_eoa(const char *env_h5_drvr, hid_t fapl)
{
hid_t file = -1; /* File ID */
- hid_t fapl_new; /* copy of fapl */
+ hid_t fapl_new = -1; /* copy of fapl */
char filename[FILENAME_LEN]; /* Filename to use */
H5F_t *f = NULL; /* Internal file object pointer */
h5_stat_size_t file_size, new_file_size; /* file size */
@@ -258,9 +258,12 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl)
TEST_ERROR
/* Verify the file is the correct size */
- if (new_file_size != file_size)
+ if(new_file_size != file_size)
TEST_ERROR
+ if(H5Pclose(fapl_new) < 0)
+ FAIL_STACK_ERROR
+
PASSED()
} /* end if */
else {
@@ -272,6 +275,7 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl)
error:
H5E_BEGIN_TRY {
+ H5Pclose(fapl_new);
H5Fclose(file);
} H5E_END_TRY;
return(1);
@@ -298,7 +302,7 @@ static unsigned
test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl)
{
hid_t file = -1; /* File ID */
- hid_t fapl_new; /* copy of fapl */
+ hid_t fapl_new = -1; /* copy of fapl */
char filename[FILENAME_LEN]; /* Filename to use */
H5F_t *f = NULL; /* Internal file object pointer */
h5_stat_size_t file_size, new_file_size; /* file size */
@@ -384,8 +388,10 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl)
/* nothing should be changed in meta_aggr */
H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size);
- if (new_ma_addr != ma_addr) TEST_ERROR
- if (new_ma_size != ma_size) TEST_ERROR
+ if(new_ma_addr != ma_addr)
+ TEST_ERROR
+ if(new_ma_size != ma_size)
+ TEST_ERROR
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
@@ -395,7 +401,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl)
TEST_ERROR
/* Verify the file is the correct size */
- if (new_file_size != file_size)
+ if(new_file_size != file_size)
TEST_ERROR
PASSED()
@@ -443,7 +449,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl)
TEST_ERROR
/* Verify the file is the correct size */
- if (new_file_size != (file_size+TEST_BLOCK_SIZE30))
+ if(new_file_size != (file_size + TEST_BLOCK_SIZE30))
TEST_ERROR
PASSED()
@@ -487,7 +493,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl)
TEST_ERROR
/* Verify the file is the correct size */
- if (new_file_size != (file_size+TEST_BLOCK_SIZE30))
+ if(new_file_size != (file_size + TEST_BLOCK_SIZE30))
TEST_ERROR
PASSED()
@@ -519,8 +525,10 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl)
/* nothing should be changed in meta_aggr */
H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &ma_size);
- if (new_ma_addr != ma_addr) TEST_ERROR
- if (new_ma_size != ma_size) TEST_ERROR
+ if(new_ma_addr != ma_addr)
+ TEST_ERROR
+ if(new_ma_size != ma_size)
+ TEST_ERROR
if(H5Fclose(file) < 0)
FAIL_STACK_ERROR
@@ -530,9 +538,12 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl)
TEST_ERROR
/* Verify the file is the correct size */
- if (new_file_size != (file_size+10))
+ if(new_file_size != (file_size + 10))
TEST_ERROR
+ if(H5Pclose(fapl_new) < 0)
+ FAIL_STACK_ERROR
+
PASSED()
} /* end if */
else {
@@ -544,6 +555,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl)
error:
H5E_BEGIN_TRY {
+ H5Pclose(fapl_new);
H5Fclose(file);
} H5E_END_TRY;
return(1);
@@ -566,7 +578,7 @@ static unsigned
test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl)
{
hid_t file = -1; /* File ID */
- hid_t fapl_new; /* copy of fapl */
+ hid_t fapl_new = -1; /* copy of fapl */
char filename[FILENAME_LEN]; /* Filename to use */
H5F_t *f = NULL; /* Internal file object pointer */
h5_stat_size_t file_size, new_file_size; /* File size */
@@ -602,8 +614,10 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl)
TEST_ERROR
/* Turn off using meta/small data aggregator */
- H5Pset_meta_block_size(fapl_new, (hsize_t)0);
- H5Pset_small_data_block_size(fapl_new, (hsize_t)0);
+ if(H5Pset_meta_block_size(fapl_new, (hsize_t)0) < 0)
+ FAIL_STACK_ERROR
+ if(H5Pset_small_data_block_size(fapl_new, (hsize_t)0) < 0)
+ FAIL_STACK_ERROR
/* Re-open the file with meta/small data setting */
if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl_new)) < 0)
@@ -633,7 +647,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl)
TEST_ERROR
/* Verify the file is the correct size */
- if (new_file_size != (file_size+TEST_BLOCK_SIZE30))
+ if(new_file_size != (file_size + TEST_BLOCK_SIZE30))
TEST_ERROR
/* Re-open the file */
@@ -663,7 +677,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl)
TEST_ERROR
/* Verify the file is the correct size */
- if (new_file_size != (file_size+TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50))
+ if(new_file_size != (file_size + TEST_BLOCK_SIZE30 + TEST_BLOCK_SIZE50))
TEST_ERROR
PASSED()
@@ -696,12 +710,12 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl)
type = H5FD_MEM_SUPER;
addr = H5MF_alloc(f, type, H5P_DATASET_XFER_DEFAULT, (hsize_t)TEST_BLOCK_SIZE30);
- if (addr < (haddr_t)file_size)
+ if(addr < (haddr_t)file_size)
TEST_ERROR
/* nothing should be changed in meta_aggr */
H5MF_aggr_query(f, &(f->shared->meta_aggr), &new_ma_addr, &new_ma_size);
- if (new_ma_addr != ma_addr)
+ if(new_ma_addr != ma_addr)
TEST_ERROR
extended = H5MF_try_extend(f, H5P_DATASET_XFER_DEFAULT, type, (haddr_t)addr, (hsize_t)(TEST_BLOCK_SIZE30-10), (hsize_t)(TEST_BLOCK_SIZE50));
@@ -723,9 +737,12 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl)
TEST_ERROR
/* Verify the file is the correct size */
- if (new_file_size != file_size+TEST_BLOCK_SIZE30)
+ if(new_file_size != file_size + TEST_BLOCK_SIZE30)
TEST_ERROR
+ if(H5Pclose(fapl_new) < 0)
+ FAIL_STACK_ERROR
+
PASSED()
} /* end if */
else {
@@ -737,6 +754,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl)
error:
H5E_BEGIN_TRY {
+ H5Pclose(fapl_new);
H5Fclose(file);
} H5E_END_TRY;
return(1);
@@ -928,7 +946,7 @@ static unsigned
test_mf_fs_start(hid_t fapl)
{
hid_t file = -1; /* File ID */
- hid_t fapl_new; /* copy of fapl */
+ hid_t fapl_new = -1; /* copy of fapl */
char filename[FILENAME_LEN]; /* Filename to use */
H5F_t *f = NULL; /* Internal file object pointer */
h5_stat_size_t file_size, new_file_size; /* file size */
@@ -991,15 +1009,19 @@ test_mf_fs_start(hid_t fapl)
TEST_ERROR
/* Verify the file is the correct size */
- if (new_file_size != file_size)
+ if(new_file_size != file_size)
TEST_ERROR
+ if(H5Pclose(fapl_new) < 0)
+ FAIL_STACK_ERROR
+
PASSED()
return(0);
error:
H5E_BEGIN_TRY {
+ H5Pclose(fapl_new);
H5Fclose(file);
} H5E_END_TRY;
return(1);
@@ -1035,7 +1057,7 @@ static unsigned
test_mf_fs_alloc_free(hid_t fapl)
{
hid_t file = -1; /* File ID */
- hid_t fapl_new; /* copy of fapl */
+ hid_t fapl_new = -1; /* copy of fapl */
char filename[FILENAME_LEN]; /* Filename to use */
H5F_t *f = NULL; /* Internal file object pointer */
h5_stat_size_t file_size, new_file_size; /* file size */
@@ -1324,15 +1346,19 @@ test_mf_fs_alloc_free(hid_t fapl)
TEST_ERROR
/* Verify the file is the correct size */
- if (new_file_size != file_size)
+ if(new_file_size != file_size)
TEST_ERROR
+ if(H5Pclose(fapl_new) < 0)
+ FAIL_STACK_ERROR
+
PASSED()
return(0);
error:
H5E_BEGIN_TRY {
+ H5Pclose(fapl_new);
H5Fclose(file);
} H5E_END_TRY;
return(1);
@@ -1380,7 +1406,7 @@ static unsigned
test_mf_fs_extend(hid_t fapl)
{
hid_t file = -1; /* File ID */
- hid_t fapl_new; /* copy of fapl */
+ hid_t fapl_new = -1; /* copy of fapl */
char filename[FILENAME_LEN]; /* Filename to use */
H5F_t *f = NULL; /* Internal file object pointer */
h5_stat_size_t file_size, new_file_size; /* file size */
@@ -1870,15 +1896,19 @@ test_mf_fs_extend(hid_t fapl)
TEST_ERROR
/* Verify the file is the correct size */
- if (new_file_size != file_size)
+ if(new_file_size != file_size)
TEST_ERROR
+ if(H5Pclose(fapl_new) < 0)
+ FAIL_STACK_ERROR
+
PASSED()
return(0);
error:
H5E_BEGIN_TRY {
+ H5Pclose(fapl_new);
H5Fclose(file);
} H5E_END_TRY;
return(1);
@@ -5845,7 +5875,6 @@ error:
return(1);
} /* test_mf_align_alloc6() */
-
int
main(void)
{
@@ -5901,10 +5930,9 @@ main(void)
nerrors += test_mf_aggr_absorb(env_h5_drvr, fapl);
/* Tests for alignment */
- for(curr_test = TEST_NORMAL; curr_test < TEST_NTESTS; curr_test++) {
+ for(curr_test = TEST_NORMAL; curr_test < TEST_NTESTS; H5_INC_ENUM(test_type_t, curr_test)) {
switch(curr_test) {
-
case TEST_NORMAL: /* set alignment = 1024 */
if(H5Pset_alignment(new_fapl, (hsize_t)0, (hsize_t)TEST_ALIGN1024) < 0)
TEST_ERROR
@@ -5915,6 +5943,7 @@ main(void)
TEST_ERROR
break;
+ case TEST_NTESTS:
default:
TEST_ERROR;
break;
@@ -5930,7 +5959,7 @@ main(void)
nerrors += test_mf_align_alloc6(env_h5_drvr, fapl, new_fapl);
} /* end if */
- if (H5Pclose(new_fapl) < 0)
+ if(H5Pclose(new_fapl) < 0)
FAIL_STACK_ERROR
h5_cleanup(FILENAME, fapl);
@@ -5938,12 +5967,13 @@ main(void)
goto error;
puts("All free-space manager tests for file memory passed.");
- return (0);
+ return(0);
error:
puts("*** TESTS FAILED ***");
H5E_BEGIN_TRY {
H5Pclose(fapl);
+ H5Pclose(new_fapl);
} H5E_END_TRY;
- return (1);
+ return(1);
} /* main() */