summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2013-09-05 20:44:14 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2013-09-05 20:44:14 (GMT)
commit5b876c929f79003c85585570827452f5d8052d01 (patch)
tree89a1fa7bb8221a8679f180868467464e331c18ce /test
parenta1fe10691cf7ce1737aa420191efb996f7fe5657 (diff)
downloadhdf5-5b876c929f79003c85585570827452f5d8052d01.zip
hdf5-5b876c929f79003c85585570827452f5d8052d01.tar.gz
hdf5-5b876c929f79003c85585570827452f5d8052d01.tar.bz2
[svn-r24101] Description:
Clean up warnings, enable new compiler warning flag(s) and bring back changes from Coverity branch: r20813: Remove the dead code as listed for coverity bug #1722. h5committested. r20814: Issue 69: Check return value and throw error if negative return. Also free datatype id on error r20815: Use HDstrncpy. --gh r20816: Replaced one last HDstrcat call with HDstrncat to resolve coverity issue 832. r20817: Use HDstrncpy and HDstrncat. --gh r20818: Purpose: Fix valgrind issues with h5jam Description: Modified h5jam to free strings strdup'd in parse_command_line before exit. Note that they may still not be freed in case of error, due to the widespread use of exit(). r20819: Issue 80: change loop to use int as loop index. r20820: Maintenance: Fixed the bug found by coverity CID 788 There were two problems with this function: 1) it tried to unnecessary free NULL pointer 2) it tried to allocate c_name buffer that is done by H5Pget_class_name Tested on: Mac OSX 10.8.4 (amazon) w/gcc 4.8.1, C++ & FORTRAN (too minor to require h5committest)
Diffstat (limited to 'test')
-rw-r--r--test/dsets.c10
-rw-r--r--test/dtypes.c62
2 files changed, 37 insertions, 35 deletions
diff --git a/test/dsets.c b/test/dsets.c
index 7abe818..cec8f9a 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -1023,10 +1023,10 @@ test_conv_buffer(hid_t fid)
cf->a[j][k][l] = 10*(j+1) + l + k;
for(j = 0; j < DIM2; j++)
- cf->b[j] = (float)(100.*(j+1) + 0.01*j);
+ cf->b[j] = (float)(100.0f*(j+1) + 0.01f*j);
for(j = 0; j < DIM3; j++)
- cf->c[j] = 100.*(j+1) + 0.02*j;
+ cf->c[j] = 100.0f*(j+1) + 0.02f*j;
/* Create data space */
@@ -2770,7 +2770,7 @@ test_nbit_int(hid_t file)
for(i= 0;i< (size_t)size[0]; i++)
for(j = 0; j < (size_t)size[1]; j++) {
orig_data[i][j] = (int)(((long long)HDrandom() %
- (long long)HDpow(2.0, (double)(precision - 1))) << offset);
+ (long long)HDpow(2.0f, (double)(precision - 1))) << offset);
/* even-numbered values are negtive */
if((i*size[1]+j+1)%2 == 0)
@@ -2872,8 +2872,8 @@ test_nbit_float(hid_t file)
/* orig_data[] are initialized to be within the range that can be represented by
* dataset datatype (no precision loss during datatype conversion)
*/
- float orig_data[2][5] = {{(float)188384.00, (float)19.103516, (float)-1.0831790e9, (float)-84.242188,
- (float)5.2045898}, {(float)-49140.000, (float)2350.2500, (float)-3.2110596e-1, (float)6.4998865e-5, (float)-0.0000000}};
+ float orig_data[2][5] = {{(float)188384.00f, (float)19.103516f, (float)-1.0831790e9f, (float)-84.242188f,
+ (float)5.2045898f}, {(float)-49140.000f, (float)2350.2500f, (float)-3.2110596e-1f, (float)6.4998865e-5f, (float)-0.0000000f}};
float new_data[2][5];
size_t precision, offset;
size_t i, j;
diff --git a/test/dtypes.c b/test/dtypes.c
index 117a21a..de64713 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -1859,7 +1859,7 @@ test_compound_10(void)
hsize_t dim1[1];
void *t1, *t2;
char filename[1024];
- int len;
+ size_t len;
int i;
TESTING("array datatype of compound type with VL string");
@@ -1867,12 +1867,12 @@ test_compound_10(void)
for(i=0; i<ARRAY_DIM; i++) {
wdata[i].i1 = i*10+i;
wdata[i].str = HDstrdup("C string A");
- wdata[i].str[9] += i;
+ wdata[i].str[9] += (char)i;
wdata[i].i2 = i*1000+i*10;
wdata[i].text.p = (void*)HDstrdup("variable-length text A\0");
- len = wdata[i].text.len = strlen((char*)wdata[i].text.p)+1;
- ((char*)(wdata[i].text.p))[len-2] += i;
+ len = wdata[i].text.len = HDstrlen((char*)wdata[i].text.p)+1;
+ ((char*)(wdata[i].text.p))[len-2] += (char)i;
((char*)(wdata[i].text.p))[len-1] = '\0';
}
@@ -2088,11 +2088,11 @@ test_compound_11(void)
/* Initialize buffer */
for(u = 0; u < NTESTELEM; u++) {
- ((big_t *)buf)[u].d1 = (double)u * (double)1.5;
- ((big_t *)buf)[u].d2 = (double)u * (double)2.5;
- ((big_t *)buf)[u].d3 = (double)u * (double)3.5;
- ((big_t *)buf)[u].i1 = u * 3;
- ((big_t *)buf)[u].i2 = u * 5;
+ ((big_t *)buf)[u].d1 = (double)u * (double)1.5f;
+ ((big_t *)buf)[u].d2 = (double)u * (double)2.5f;
+ ((big_t *)buf)[u].d3 = (double)u * (double)3.5f;
+ ((big_t *)buf)[u].i1 = (int)(u * 3);
+ ((big_t *)buf)[u].i2 = (int)(u * 5);
((big_t *)buf)[u].s1 = (char *)HDmalloc((size_t)32);
sprintf(((big_t *)buf)[u].s1, "%u", (unsigned)u);
} /* end for */
@@ -2351,8 +2351,8 @@ test_compound_13(void)
/* Create some phony data. */
HDmemset(&data_out, 0, sizeof(data_out));
for(u = 0; u < COMPOUND13_ARRAY_SIZE + 1; u++)
- data_out.x[u] = u;
- data_out.y = 99.99;
+ data_out.x[u] = (unsigned char)u;
+ data_out.y = 99.99f;
/* Set latest_format in access propertly list to enable the latest
* compound datatype format.
@@ -2966,7 +2966,7 @@ test_compound_16(void)
} cmpd_struct;
cmpd_struct wdata1 = {1254, 5471};
- int obj_count;
+ ssize_t obj_count;
hid_t file;
hid_t cmpd_m_tid, cmpd_f_tid, int_id;
hid_t space_id;
@@ -3003,7 +3003,7 @@ test_compound_16(void)
/* Check behavior of H5Fget_obj_count */
if((obj_count = H5Fget_obj_count(file, H5F_OBJ_DATATYPE)) != 1) {
H5_FAILED(); AT();
- printf(" H5Fget_obj_count returned: %d; expected: 1\n", obj_count);
+ printf(" H5Fget_obj_count returned: %zd; expected: 1\n", obj_count);
goto error;
}
@@ -3737,7 +3737,7 @@ test_named (hid_t fapl)
H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
for(i = 0; i < (size_t)ds_size[0]; i++)
for(j = 0; j < (size_t)ds_size[1]; j++)
- attr_data[i][j] = (int)(i * ds_size[1] + j);
+ attr_data[i][j] = (unsigned)(i * ds_size[1] + j);
if(H5Awrite(attr1, H5T_NATIVE_UINT, attr_data) < 0) goto error;
if(H5Aclose(attr1) < 0) goto error;
@@ -4282,9 +4282,9 @@ test_conv_str_2(void)
if((f_type = mkstr((size_t)8, H5T_STR_SPACEPAD)) < 0) goto error;
if(NULL == (buf = (char*)HDcalloc(nelmts, (size_t)8))) goto error;
for(i = 0; i < nelmts; i++) {
- nchars = HDrand() % 8;
+ nchars = (size_t)(HDrand() % 8);
for(j = 0; j < nchars; j++)
- buf[i * 8 + j] = 'a' + HDrand() % 26;
+ buf[i * 8 + j] = (char)('a' + HDrand() % 26);
while(j < nchars)
buf[i * 8 + j++] = '\0';
} /* end for */
@@ -4338,7 +4338,7 @@ test_conv_str_3(void)
const size_t nelmts = NTESTELEM;
size_t i, j, nchars;
int ret_value = 1;
- int size;
+ size_t size;
H5T_pad_t inpad;
H5T_sign_t sign;
char *tag = NULL;
@@ -4353,9 +4353,9 @@ test_conv_str_3(void)
if(NULL == (buf = (char*)HDcalloc(nelmts, (size_t)8)))
FAIL_PUTS_ERROR("Allocation failed.");
for(i = 0; i < nelmts; i++) {
- nchars = HDrand() % 8;
+ nchars = (size_t)(HDrand() % 8);
for(j = 0; j < nchars; j++)
- buf[i * 8 + j] = 'a' + HDrand() % 26;
+ buf[i * 8 + j] = (char)('a' + HDrand() % 26);
while(j < nchars)
buf[i * 8 + j++] = '\0';
} /* end for */
@@ -4461,7 +4461,7 @@ test_conv_enum_1(void)
if((t2 = H5Tenum_create(H5T_NATIVE_INT)) < 0) goto error;
s[1] = '\0';
for(i = 0; i < 26; i++) {
- s[0] = 'A' + i;
+ s[0] = (char)('A' + i);
H5Tenum_insert(t1, s, &i);
H5Tenum_insert(t2, s, (val = i * 1000 + i, &val));
} /* end for */
@@ -4535,7 +4535,7 @@ test_conv_enum_2(void)
srctype = H5Tenum_create(oddsize);
for (i=7; i>=0; --i) {
char pattern[3];
- pattern[2] = i;
+ pattern[2] = (char)i;
pattern[0] = pattern[1] = 0;
H5Tenum_insert(srctype, mname[i], pattern);
}
@@ -4549,7 +4549,7 @@ test_conv_enum_2(void)
/* Source data */
data = (int*)malloc(NTESTELEM*sizeof(int));
for (i=0; i<NTESTELEM; i++) {
- ((char*)data)[i*3+2] = i % 8;
+ ((char*)data)[i*3+2] = (char)(i % 8);
((char*)data)[i*3+0] = 0;
((char*)data)[i*3+1] = 0;
}
@@ -4695,7 +4695,7 @@ static int
test_bitfield_funcs(void)
{
hid_t type=-1, ntype=-1, super=-1;
- int size;
+ size_t size;
char* tag=0;
H5T_pad_t inpad;
H5T_cset_t cset;
@@ -5016,7 +5016,7 @@ static int
opaque_funcs(void)
{
hid_t type = -1, super=-1;
- int size;
+ size_t size;
H5T_pad_t inpad;
H5T_cset_t cset;
H5T_str_t strpad;
@@ -5920,13 +5920,13 @@ static int
test_int_float_except(void)
{
#if H5_SIZEOF_INT==4 && H5_SIZEOF_FLOAT==4
- float buf[CONVERT_SIZE] = {(float)INT_MIN - 172.0, (float)INT_MAX - 32.0,
- (float)INT_MAX - 68.0, (float)4.5};
+ float buf[CONVERT_SIZE] = {(float)INT_MIN - 172.0f, (float)INT_MAX - 32.0f,
+ (float)INT_MAX - 68.0f, (float)4.5f};
int buf_int[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX-127, 4};
- float buf_float[CONVERT_SIZE] = {INT_MIN, INT_MAX + 1.0, INT_MAX - 127.0, 4};
+ float buf_float[CONVERT_SIZE] = {(float)INT_MIN, (float)INT_MAX + 1.0f, (float)INT_MAX - 127.0f, 4};
int *intp; /* Pointer to buffer, as integers */
int buf2[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX - 72, 0};
- float buf2_float[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX - 127.0, (float)0.0};
+ float buf2_float[CONVERT_SIZE] = {(float)INT_MIN, (float)INT_MAX, (float)INT_MAX - 127.0f, (float)0.0f};
int buf2_int[CONVERT_SIZE] = {INT_MIN, INT_MAX, INT_MAX - 127, 0};
float *floatp; /* Pointer to buffer #2, as floats */
hid_t dxpl; /* Dataset transfer property list */
@@ -7048,7 +7048,8 @@ error:
* 10 November 2011
*-------------------------------------------------------------------------
*/
-int test_utf_ascii_conv(void)
+static int
+test_utf_ascii_conv(void)
{
hid_t fid = -1;
hid_t did = -1;
@@ -7265,7 +7266,7 @@ error:
int
main(void)
{
- unsigned long nerrors = 0;
+ long nerrors = 0;
hid_t fapl = -1;
/* Set the random # seed */
@@ -7338,3 +7339,4 @@ main(void)
return 0;
}
+