summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2012-08-08 23:01:20 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2012-08-08 23:01:20 (GMT)
commit88a94bbe7ffa3c0bb7779d1b16989b385d9eadd2 (patch)
treebe52b18015cf8df4af976ab5cfdc912748783b22 /test
parent79b2eb993e29cf0382db07b322fa3ca5cb00fc65 (diff)
downloadhdf5-88a94bbe7ffa3c0bb7779d1b16989b385d9eadd2.zip
hdf5-88a94bbe7ffa3c0bb7779d1b16989b385d9eadd2.tar.gz
hdf5-88a94bbe7ffa3c0bb7779d1b16989b385d9eadd2.tar.bz2
[svn-r22646] Description:
Changes resulting from Klocwork static analysis tool, from Mark Miller @ LLNL (miller86@llnl.gov). Tested on: Mac OS X/64 10.7.4 (amazon) w/debug, C++ & FORTRAN, using gcc 4.7.x (too minor to require h5committest)
Diffstat (limited to 'test')
-rw-r--r--test/accum.c18
-rw-r--r--test/cache.c4
-rw-r--r--test/cache_common.c2
-rw-r--r--test/cache_tagging.c8
-rw-r--r--test/dsets.c14
-rw-r--r--test/dt_arith.c6
-rw-r--r--test/dtypes.c35
-rw-r--r--test/file_image.c26
-rw-r--r--test/freespace.c2
-rw-r--r--test/h5test.c4
-rw-r--r--test/ntypes.c1
-rw-r--r--test/objcopy.c2
-rw-r--r--test/tunicode.c2
13 files changed, 70 insertions, 54 deletions
diff --git a/test/accum.c b/test/accum.c
index c5f6610..e4c1bd8 100644
--- a/test/accum.c
+++ b/test/accum.c
@@ -1793,15 +1793,17 @@ accum_printf(void)
printf("=====================================================\n");
} else {
printf("=====================================================\n");
- printf(" accumulator allocated size == %lu\n", (unsigned long)accum->alloc_size);
- printf(" accumulated data size == %lu\n", (unsigned long)accum->size);
- printf(" accumulator dirty? == %d\n", accum->dirty);
+ printf(" accumulator allocated size == %zu\n", accum->alloc_size);
+ printf(" accumulated data size == %zu\n", accum->size);
+ HDfprintf(stdout, " accumulator dirty? == %t\n", accum->dirty);
printf("=====================================================\n");
- printf(" start of accumulated data, loc = %llu\n", accum->loc);
- if (accum->dirty) printf(" start of dirty region, loc = %llu\n", accum->loc + accum->dirty_off);
- if (accum->dirty) printf(" end of dirty region, loc = %llu\n", accum->loc + accum->dirty_off + accum->dirty_len);
- printf(" end of accumulated data, loc = %llu\n", accum->loc + accum->size);
- printf(" end of accumulator allocation, loc = %llu\n", accum->loc + accum->alloc_size);
+ HDfprintf(stdout, " start of accumulated data, loc = %a\n", accum->loc);
+ if(accum->dirty) {
+ HDfprintf(stdout, " start of dirty region, loc = %a\n", (haddr_t)(accum->loc + accum->dirty_off));
+ HDfprintf(stdout, " end of dirty region, loc = %a\n", (haddr_t)(accum->loc + accum->dirty_off + accum->dirty_len));
+ } /* end if */
+ HDfprintf(stdout, " end of accumulated data, loc = %a\n", (haddr_t)(accum->loc + accum->size));
+ HDfprintf(stdout, " end of accumulator allocation, loc = %a\n", (haddr_t)(accum->loc + accum->alloc_size));
printf("=====================================================\n");
}
printf("\n\n");
diff --git a/test/cache.c b/test/cache.c
index 0e6cb42..ba51a38 100644
--- a/test/cache.c
+++ b/test/cache.c
@@ -33532,6 +33532,7 @@ check_notify_cb(void)
reset_entries();
file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024));
+ if ( !file_ptr ) CACHE_ERROR("setup_cache returned NULL")
cache_ptr = file_ptr->shared->cache;
base_addr = entries[entry_type];
@@ -33675,8 +33676,7 @@ check_notify_cb(void)
} /* end for */
done:
- if(file_ptr)
- takedown_cache(file_ptr, FALSE, FALSE);
+ takedown_cache(file_ptr, FALSE, FALSE);
if ( pass )
PASSED()
diff --git a/test/cache_common.c b/test/cache_common.c
index e6dd020..7b26714 100644
--- a/test/cache_common.c
+++ b/test/cache_common.c
@@ -2031,7 +2031,7 @@ verify_entry_status(H5C_t * cache_ptr,
int num_entries,
struct expected_entry_status expected[])
{
- static char msg[128];
+ static char msg[256];
int i;
i = 0;
diff --git a/test/cache_tagging.c b/test/cache_tagging.c
index 9aef651..5eb1e84 100644
--- a/test/cache_tagging.c
+++ b/test/cache_tagging.c
@@ -740,7 +740,7 @@ check_group_creation_tags(hid_t fcpl, int type)
hid_t fid = -1; /* File Identifier */
hid_t gid = -1; /* Group Identifier */
int verbose = FALSE; /* verbose file outout */
- haddr_t root_tag; /* Root Group Tag */
+ haddr_t root_tag = HADDR_UNDEF; /* Root Group Tag */
haddr_t g_tag; /* Group Tag */
haddr_t sbe_tag; /* Sblock Extension Tag */
@@ -1249,7 +1249,7 @@ check_group_open_tags(hid_t fcpl, int type)
hid_t fid = -1; /* File Identifier */
hid_t gid = -1; /* Group Identifier */
int verbose = FALSE; /* verbose file output */
- haddr_t root_tag;
+ haddr_t root_tag = HADDR_UNDEF;
haddr_t sbe_tag;
haddr_t g_tag;
@@ -3056,7 +3056,7 @@ check_object_info_tags(hid_t fcpl, int type)
hid_t fid = -1; /* File Identifier */
hid_t gid = -1; /* Group Identifier */
int verbose = FALSE; /* verbose file output */
- haddr_t root_tag;
+ haddr_t root_tag = HADDR_UNDEF;
haddr_t sbe_tag;
haddr_t g_tag;
H5O_info_t oinfo; /* Object info struct */
@@ -3170,7 +3170,7 @@ check_object_copy_tags(hid_t fcpl, int type)
hid_t fid = -1; /* File Identifier */
hid_t gid = -1; /* Group Identifier */
int verbose = FALSE; /* verbose file output */
- haddr_t root_tag;
+ haddr_t root_tag = HADDR_UNDEF;
haddr_t sbe_tag;
haddr_t g_tag;
haddr_t copy_tag;
diff --git a/test/dsets.c b/test/dsets.c
index ee341c9..3b081da 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -999,8 +999,8 @@ test_conv_buffer(hid_t fid)
herr_t status = -1;
int j, k, l;
- CmpField *cf;
- CmpFieldR *cfrR;
+ CmpField *cf = NULL;
+ CmpFieldR *cfrR = NULL;
hid_t dataset = -1; /* dataset ID */
hid_t space = -1; /* data space ID */
@@ -1014,7 +1014,7 @@ test_conv_buffer(hid_t fid)
TESTING("data type conversion buffer size");
- cf = (CmpField *)HDcalloc((size_t)1, sizeof(CmpField));
+ if ((cf = (CmpField *)HDcalloc((size_t)1, sizeof(CmpField))) == 0) goto error;
/* Populate the data members */
for(j = 0; j < DIM1; j++)
@@ -1063,7 +1063,7 @@ test_conv_buffer(hid_t fid)
if(H5Tinsert(ctype2, "C", HOFFSET(CmpFieldR, c), arr_type5) < 0) goto error;
/* Read should succeed since library will set conversion buffer big enough */
- cfrR = (CmpFieldR *)HDcalloc((size_t)1, sizeof(CmpFieldR));
+ if ((cfrR = (CmpFieldR *)HDcalloc((size_t)1, sizeof(CmpFieldR))) == 0) goto error;
if(H5Dread(dataset, ctype2, H5S_ALL, H5S_ALL, H5P_DEFAULT, cfrR) < 0) goto error;
/* Read should fail since conversion buffer isn't big enough */
@@ -1100,10 +1100,8 @@ test_conv_buffer(hid_t fid)
if(H5Tclose(arr_type5) < 0) goto error;
if(H5Dclose(dataset) < 0) goto error;
- if(cf)
- HDfree(cf);
- if(cfrR)
- HDfree(cfrR);
+ HDfree(cf);
+ HDfree(cfrR);
puts(" PASSED");
return(0);
diff --git a/test/dt_arith.c b/test/dt_arith.c
index 0001755..096b83e 100644
--- a/test/dt_arith.c
+++ b/test/dt_arith.c
@@ -1105,9 +1105,9 @@ test_derived_flt(void)
}
fails_this_test = 0;
- if(buf) free(buf);
- if(saved_buf) free(saved_buf);
- if(aligned) free(aligned);
+ free(buf);
+ free(saved_buf);
+ free(aligned);
buf = NULL;
saved_buf = NULL;
aligned = NULL;
diff --git a/test/dtypes.c b/test/dtypes.c
index 3db9bf8..117a21a 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -1127,10 +1127,8 @@ test_compound_5(void)
}
/* Free memory buffers */
- if(buf)
- HDfree(buf);
- if(bkg)
- HDfree(bkg);
+ HDfree(buf);
+ HDfree(bkg);
return retval;
}
@@ -4698,11 +4696,12 @@ test_bitfield_funcs(void)
{
hid_t type=-1, ntype=-1, super=-1;
int size;
- char* tag;
+ char* tag=0;
H5T_pad_t inpad;
H5T_cset_t cset;
H5T_str_t strpad;
herr_t ret;
+ int retval=-1;
TESTING("some type functions for bitfield");
@@ -4786,16 +4785,18 @@ test_bitfield_funcs(void)
goto error;
} /* end if */
- H5Tclose(type);
- H5Tclose(ntype);
- PASSED();
- reset_hdf5();
- return 0;
+ retval = 0;
error:
+
+ if (retval == -1) retval = 1;
+
+ HDfree(tag);
+ H5Tclose(ntype);
H5Tclose(type);
+ if (retval == 0) PASSED();
reset_hdf5();
- return 1;
+ return retval;
}
@@ -7049,11 +7050,13 @@ error:
*/
int test_utf_ascii_conv(void)
{
- hid_t fid;
- hid_t did;
- hid_t utf8_vtid, ascii_vtid;
- hid_t utf8_tid, ascii_tid;
- hid_t sid;
+ hid_t fid = -1;
+ hid_t did = -1;
+ hid_t utf8_vtid = -1;
+ hid_t ascii_vtid = -1;
+ hid_t utf8_tid = -1;
+ hid_t ascii_tid = -1;
+ hid_t sid = -1;
const char *utf8_w = "foo!";
char *ascii_r = NULL;
const char *ascii_w = "bar!";
diff --git a/test/file_image.c b/test/file_image.c
index 73c901e..9d7a48c 100644
--- a/test/file_image.c
+++ b/test/file_image.c
@@ -86,15 +86,16 @@ typedef struct {
static int
test_properties(void)
{
- hid_t fapl_1;
- hid_t fapl_2;
- char *buffer;
+ hid_t fapl_1 = -1;
+ hid_t fapl_2 = -1;
+ char *buffer = 0;
int count = 10;
- void *temp;
- char *temp2;
+ void *temp = 0;
+ char *temp2 = 0;
int i;
size_t size;
size_t temp_size;
+ int retval = 1;
TESTING("File image property list functions");
@@ -145,18 +146,21 @@ test_properties(void)
VERIFY(temp2 != temp, "Retrieved buffer is the same as previously retrieved buffer");
VERIFY(0 == HDmemcmp(temp2, buffer, size),"Buffers contain different data");
+ retval = 0;
+
+error:
+
/* Close everything */
- if(H5Pclose(fapl_1) < 0) FAIL_STACK_ERROR
- if(H5Pclose(fapl_2) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(fapl_1) < 0) retval = 1;
+ if(H5Pclose(fapl_2) < 0) retval = 1;
HDfree(buffer);
HDfree(temp);
HDfree(temp2);
- PASSED();
- return 0;
+ if(retval == 0)
+ PASSED();
-error:
- return 1;
+ return retval;
} /* end test_properties() */
/******************************************************************************
diff --git a/test/freespace.c b/test/freespace.c
index 6960e6d..c0df4c8 100644
--- a/test/freespace.c
+++ b/test/freespace.c
@@ -1522,8 +1522,10 @@ test_fs_sect_merge(hid_t fapl)
/* Free the section node(s) */
if(TEST_sect_free((H5FS_section_info_t *)sect_node1) < 0)
TEST_ERROR
+ sect_node1 = NULL;
if(TEST_sect_free((H5FS_section_info_t *)sect_node2) < 0)
TEST_ERROR
+ sect_node2 = NULL;
/* Close the free space manager */
if(H5FS_close(f, H5P_DATASET_XFER_DEFAULT, frsp) < 0)
diff --git a/test/h5test.c b/test/h5test.c
index 7faba81..ea30fad 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -735,6 +735,8 @@ h5_set_info_object(void)
valp = envp = next = HDstrdup(envp);
+ if (!valp) return 0;
+
/* create an INFO object if not created yet */
if (h5_io_info_g == MPI_INFO_NULL)
MPI_Info_create(&h5_io_info_g);
@@ -761,6 +763,8 @@ h5_set_info_object(void)
while (*namep && (*namep == ' ' || *namep == '\t'))
namep++;
+ if (!*namep) continue; /* was all white space, so move to next k/v pair */
+
/* eat up any ending white spaces */
endp = &namep[strlen(namep) - 1];
diff --git a/test/ntypes.c b/test/ntypes.c
index 165d21b..0af3a3f 100644
--- a/test/ntypes.c
+++ b/test/ntypes.c
@@ -1776,6 +1776,7 @@ test_vl_dtype(hid_t file)
} /* end for */
HDfree(tmp);
+ tmp = NULL;
} /* end for */
} /* end for */
diff --git a/test/objcopy.c b/test/objcopy.c
index 6b56b66..d7da8f3 100644
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -10343,7 +10343,7 @@ test_copy_cdt_merge_all_suggs(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
hid_t did = -1; /* Dataset ID */
hid_t exp_did = -1; /* Dataset ID */
hid_t tid_short = -1; /* Datatype ID */
- hid_t exp_tid; /* Expected datatype ID */
+ hid_t exp_tid = -1; /* Expected datatype ID */
hid_t ocpypl_id = -1; /* Object copy plist ID */
unsigned int i; /* Local index variables */
hsize_t dim1d[1]; /* Dataset dimensions */
diff --git a/test/tunicode.c b/test/tunicode.c
index 3b949e9..0386352 100644
--- a/test/tunicode.c
+++ b/test/tunicode.c
@@ -161,6 +161,7 @@ void test_strpad(hid_t UNUSED fid, const char *string)
/* Create a src_type that holds the UTF-8 string and its final NULL */
big_len = length + 1; /* +1 byte for final NULL */
+ HDassert((2*big_len)<=sizeof(cmpbuf));
src_type = mkstr(big_len, H5T_STR_NULLTERM);
CHECK(src_type, FAIL, "mkstr");
/* Create a dst_type that holds half of the UTF-8 string and a final
@@ -224,6 +225,7 @@ void test_strpad(hid_t UNUSED fid, const char *string)
/* Create a src_type that holds the UTF-8 string */
big_len = length;
+ HDassert((2*big_len)<=sizeof(cmpbuf));
src_type = mkstr(big_len, H5T_STR_NULLPAD);
CHECK(src_type, FAIL, "mkstr");
/* Create a dst_type that holds half of the UTF-8 string */