diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/bittests.c | 64 | ||||
-rw-r--r-- | test/dtypes.c | 16 | ||||
-rw-r--r-- | test/error_test.c | 10 | ||||
-rw-r--r-- | test/fheap.c | 12 | ||||
-rw-r--r-- | test/fillval.c | 44 | ||||
-rw-r--r-- | test/flush1.c | 28 | ||||
-rw-r--r-- | test/flush2.c | 15 | ||||
-rw-r--r-- | test/gheap.c | 68 | ||||
-rw-r--r-- | test/hyperslab.c | 20 | ||||
-rw-r--r-- | test/tchecksum.c | 4 | ||||
-rw-r--r-- | test/tfile.c | 19 | ||||
-rw-r--r-- | test/th5o.c | 34 | ||||
-rw-r--r-- | test/titerate.c | 14 | ||||
-rw-r--r-- | test/trefer.c | 28 | ||||
-rw-r--r-- | test/ttst.c | 2 | ||||
-rw-r--r-- | test/tunicode.c | 38 |
16 files changed, 204 insertions, 212 deletions
diff --git a/test/bittests.c b/test/bittests.c index c4dfe4c..38e419d 100644 --- a/test/bittests.c +++ b/test/bittests.c @@ -88,7 +88,7 @@ test_find (void) /* Try all combinations of one byte */ for(i = 0; i < 8 * (int)sizeof(v1); i++) { HDmemset(v1, 0, sizeof v1); - v1[i / 8] = 1 << (i % 8); + v1[i / 8] = (uint8_t)(1 << (i % 8)); n = H5T__bit_find(v1, (size_t)0, 8 * sizeof(v1), H5T_BIT_LSB, TRUE); if((ssize_t)i != n) { H5_FAILED(); @@ -120,8 +120,8 @@ test_find (void) /* Try all combinations of one byte */ for (i=0; i<8*(int)sizeof(v1); i++) { - memset (v1, 0xff, sizeof v1); - v1[i/8] &= ~(1<<(i%8)); + HDmemset(v1, 0xff, sizeof v1); + v1[i / 8] &= (uint8_t)~(1 << (i % 8)); n = H5T__bit_find (v1, (size_t)0, 8*sizeof(v1), H5T_BIT_LSB, FALSE); if ((ssize_t)i!=n) { H5_FAILED(); @@ -175,12 +175,12 @@ test_copy (void) TESTING("bit copy operations"); for (i=0; i<NTESTS; i++) { - s_offset = HDrand() % (8*sizeof v1); - d_offset = HDrand() % (8*sizeof v2); + s_offset = (size_t)HDrand() % (8 * sizeof v1); + d_offset = (size_t)HDrand() % (8 * sizeof v2); size = (unsigned)HDrand() % MIN (8*sizeof(v1), 8*sizeof(v2)); size = MIN3 (size, 8*sizeof(v1)-s_offset, 8*sizeof(v2)-d_offset); - memset (v1, 0xff, sizeof v1); - memset (v2, 0x00, sizeof v2); + HDmemset(v1, 0xff, sizeof v1); + HDmemset(v2, 0x00, sizeof v2); /* Copy some bits to v2 and make sure something was copied */ H5T__bit_copy (v2, d_offset, v1, s_offset, size); @@ -297,21 +297,21 @@ test_shift (void) TESTING("bit shift operations"); for (i=0; i<NTESTS; i++) { - offset = HDrand() % (8*sizeof vector); - size = (unsigned)HDrand() % (8*sizeof(vector)-offset); + offset = (size_t)HDrand() % (8 * sizeof vector); + size = (size_t)HDrand() % (8 * sizeof(vector) - offset); /* Don't want size to be 0 */ if(size == 0) continue; - shift_dist = HDrand() % size; + shift_dist = (ssize_t)((size_t)HDrand() % size); /*-------- LEFT-shift some bits and make sure something was shifted --------*/ - memset (vector, 0x00, sizeof vector); + HDmemset(vector, 0x00, sizeof vector); H5T__bit_set (vector, offset, size, 1); H5T__bit_shift (vector, shift_dist, offset, size); /* Look for the ones */ n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_LSB, 1); - if ((size_t)n!=offset+shift_dist) { + if(n != (ssize_t)offset + shift_dist) { H5_FAILED(); printf (" Unable to find first bit in destination " "(n=%d)\n", (int)n); @@ -331,7 +331,7 @@ test_shift (void) } /*-------- RIGHT-shift some bits and make sure something was shifted --------*/ - memset (vector, 0x00, sizeof vector); + HDmemset(vector, 0x00, sizeof vector); H5T__bit_set (vector, offset, size, 1); H5T__bit_shift (vector, -shift_dist, offset, size); @@ -350,7 +350,7 @@ test_shift (void) * that reverse searches work as expected. */ n = H5T__bit_find (vector, (size_t)0, 8*sizeof(vector), H5T_BIT_MSB, 1); - if (n!=(ssize_t)(offset+size-shift_dist-1)) { + if(n != (ssize_t)(offset + size) - shift_dist - 1) { H5_FAILED(); printf (" Unable to find last bit in destination " "(reverse, n=%d)\n", (int)n); @@ -362,11 +362,11 @@ test_shift (void) /* Randomly decide shift direction */ if(size % 2 == 0) - shift_dist = size; + shift_dist = (ssize_t)size; else shift_dist = -((ssize_t)size); - memset (vector, 0x00, sizeof vector); + HDmemset(vector, 0x00, sizeof vector); H5T__bit_set (vector, offset, size, 1); H5T__bit_shift (vector, shift_dist, offset, size); @@ -430,12 +430,12 @@ test_increment (void) TESTING("bit increment operations"); for (i=0; i<NTESTS; i++) { - offset = HDrand() % (8*sizeof vector); - size = (unsigned)HDrand() % (8*sizeof(vector)-offset); + offset = (size_t)HDrand() % (8 * sizeof vector); + size = (size_t)HDrand() % (8 * sizeof(vector) - offset); /* Don't want size to be 0 */ if(size == 0) continue; - memset (vector, 0x00, sizeof vector); + HDmemset(vector, 0x00, sizeof vector); if(size>1) /* if size=6, make a sequence like 011111 */ H5T__bit_set (vector, offset, size-1, 1); else /* if size=1, just set this one bit to 1 */ @@ -517,13 +517,13 @@ test_decrement (void) TESTING("bit decrement operations"); for (i=0; i<NTESTS; i++) { - offset = HDrand() % (8*sizeof vector); - size = (unsigned)HDrand() % (8*sizeof(vector)-offset); + offset = (size_t)HDrand() % (8 * sizeof vector); + size = (size_t)HDrand() % (8 * sizeof(vector) - offset); /* Don't want size to be 0 */ if(size == 0) continue; /* All-zero sequence will become 111111(size=6) after decrement */ - memset (vector, 0x00, sizeof vector); + HDmemset(vector, 0x00, sizeof vector); /* decrement the sequence by one */ H5T__bit_dec (vector, offset, size); @@ -589,13 +589,13 @@ test_negate (void) TESTING("bit negate operations"); for (i=0; i<NTESTS; i++) { - offset = HDrand() % (8*sizeof vector); - size = (unsigned)HDrand() % (8*sizeof(vector)-offset); + offset = (size_t)HDrand() % (8 * sizeof vector); + size = (size_t)HDrand() % (8 * sizeof(vector) - offset); /* Don't want size to be 0 */ if(size == 0) continue; /* All-zero sequence will become 111111(size=6) after negating */ - memset (vector, 0x00, sizeof vector); + HDmemset(vector, 0x00, sizeof vector); /* negate the sequence */ H5T__bit_neg (vector, offset, size); @@ -622,7 +622,7 @@ test_negate (void) } /* All-one sequence will become 000000(size=6) after negating */ - memset (vector, 0x00, sizeof vector); + HDmemset(vector, 0x00, sizeof vector); H5T__bit_set (vector, offset, size, 1); /* negate the sequence */ @@ -689,10 +689,10 @@ test_set (void) TESTING("bit set operations"); for (i=0; i<NTESTS; i++) { - d_offset = HDrand() % (8*sizeof v2); - size = (unsigned)HDrand() % (8*sizeof(v2)); + d_offset = (size_t)HDrand() % (8 * sizeof v2); + size = (size_t)HDrand() % (8 * sizeof(v2)); size = MIN (size, 8*sizeof(v2)-d_offset); - memset (v2, 0x00, sizeof v2); + HDmemset(v2, 0x00, sizeof v2); /* Set some bits in v2 */ H5T__bit_set (v2, d_offset, size, TRUE); @@ -806,10 +806,10 @@ test_clear (void) TESTING("bit clear operations"); for (i=0; i<NTESTS; i++) { - d_offset = HDrand() % (8*sizeof v2); - size = (unsigned)HDrand() % (8*sizeof(v2)); + d_offset = (size_t)HDrand() % (8 * sizeof v2); + size = (size_t)HDrand() % (8 * sizeof(v2)); size = MIN (size, 8*sizeof(v2)-d_offset); - memset (v2, 0xff, sizeof v2); + HDmemset(v2, 0xff, sizeof v2); /* Clear some bits in v2 */ H5T__bit_set (v2, d_offset, size, FALSE); diff --git a/test/dtypes.c b/test/dtypes.c index 255ef8e..f247bd9 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -1925,12 +1925,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] += (char)i; + wdata[i].str[9] = (char)(wdata[i].str[9] + i); wdata[i].i2 = i*1000+i*10; wdata[i].text.p = (void*)HDstrdup("variable-length text A\0"); 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 - 2] = (char)(((char *)(wdata[i].text.p))[len - 2] + i); ((char*)(wdata[i].text.p))[len-1] = '\0'; } @@ -2183,7 +2183,7 @@ test_compound_11(void) /* Verify converted buffer is correct */ for(u=0; u<NTESTELEM; u++) { - if(((big_t *)buf_orig)[u].d1!=((little_t *)buf)[u].d1) { + if(!H5_DBL_ABS_EQUAL(((big_t *)buf_orig)[u].d1, ((little_t *)buf)[u].d1)) { printf("Error, line #%d: buf_orig[%u].d1=%f, buf[%u].d1=%f\n",__LINE__, (unsigned)u,((big_t *)buf_orig)[u].d1,(unsigned)u,((little_t *)buf)[u].d1); TEST_ERROR @@ -2227,7 +2227,7 @@ test_compound_11(void) /* Verify converted buffer is correct */ for(u=0; u<NTESTELEM; u++) { - if(((big_t *)buf_orig)[u].d1!=((little_t *)buf)[u].d1) { + if(!H5_DBL_ABS_EQUAL(((big_t *)buf_orig)[u].d1, ((little_t *)buf)[u].d1)) { printf("Error, line #%d: buf_orig[%u].d1=%f, buf[%u].d1=%f\n",__LINE__, (unsigned)u,((big_t *)buf_orig)[u].d1,(unsigned)u,((little_t *)buf)[u].d1); TEST_ERROR @@ -2265,7 +2265,7 @@ test_compound_11(void) /* Verify converted buffer is correct */ for(u=0; u<NTESTELEM; u++) { - if(((big_t *)buf_orig)[u].d1!=((little_t *)buf)[u].d1) { + if(!H5_DBL_ABS_EQUAL(((big_t *)buf_orig)[u].d1, ((little_t *)buf)[u].d1)) { printf("Error, line #%d: buf_orig[%u].d1=%f, buf[%u].d1=%f\n",__LINE__, (unsigned)u,((big_t *)buf_orig)[u].d1,(unsigned)u,((little_t *)buf)[u].d1); TEST_ERROR @@ -2487,7 +2487,7 @@ test_compound_13(void) /* Check the data. */ for (u = 0; u < COMPOUND13_ARRAY_SIZE + 1; u++) if(data_out.x[u] != data_in.x[u]) TEST_ERROR - if(data_out.y != data_in.y) TEST_ERROR + if(!H5_FLT_ABS_EQUAL(data_out.y, data_in.y)) TEST_ERROR /* Release all resources. */ if(H5Aclose(attid) < 0) FAIL_STACK_ERROR @@ -6113,7 +6113,7 @@ test_int_float_except(void) /* Check the buffer after conversion, as floats */ for(u = 0; u < CONVERT_SIZE; u++) { floatp = (float *)&buf[u]; - if(*floatp != buf_float[u]) TEST_ERROR + if(!H5_FLT_ABS_EQUAL(*floatp, buf_float[u])) TEST_ERROR } /* end for */ /* Check for proper exceptions */ @@ -6134,7 +6134,7 @@ test_int_float_except(void) /* Check the buffer after conversion, as floats */ for(u = 0; u < CONVERT_SIZE; u++) { floatp = (float *)&buf2[u]; - if(*floatp != buf2_float[u]) TEST_ERROR + if(!H5_FLT_ABS_EQUAL(*floatp, buf2_float[u])) TEST_ERROR } /* end for */ /* Check for proper exceptions */ diff --git a/test/error_test.c b/test/error_test.c index ee181b1..5a7741f 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -270,7 +270,7 @@ error: static herr_t error_stack(void) { - int err_num; + ssize_t err_num; const char *FUNC_error_stack = "error_stack"; if((err_num = H5Eget_num(H5E_DEFAULT)) < 0) @@ -284,7 +284,7 @@ error_stack(void) /* Make it push error, force this function to fail */ if((err_num = H5Eget_num(ERR_STACK)) == 0) { H5Epush(ERR_STACK, __FILE__, FUNC_error_stack, __LINE__, ERR_CLS, ERR_MAJ_API, ERR_MIN_GETNUM, - "Get number test failed, returned %d", err_num); + "Get number test failed, returned %zd", err_num); goto error; } /* end if */ @@ -354,7 +354,7 @@ test_long_desc(void) /* Create the long part of the error description */ for(u = 0; u < LONG_DESC_SIZE; u++) - long_desc[u] = 'A' + (u % 26); + long_desc[u] = (char)('A' + (u % 26)); long_desc[LONG_DESC_SIZE - 1] = '\0'; /* Clear the default error stack */ @@ -487,7 +487,7 @@ test_create(void) { const char *err_func = "test_create"; /* Function name for pushing error */ const char *err_msg = "Error message"; /* Error message for pushing error */ - int err_num; /* Number of errors on stack */ + ssize_t err_num; /* Number of errors on stack */ hid_t estack_id; /* Error stack ID */ /* Create an empty error stack */ @@ -538,7 +538,7 @@ test_copy(void) { const char *err_func = "test_copy"; /* Function name for pushing error */ const char *err_msg = "Error message"; /* Error message for pushing error */ - int err_num; /* Number of errors on stack */ + ssize_t err_num; /* Number of errors on stack */ hid_t estack_id; /* Error stack ID */ herr_t ret; /* Generic return value */ diff --git a/test/fheap.c b/test/fheap.c index a59c27f..8e364de 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -13758,7 +13758,7 @@ test_filtered_huge(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam unsigned char obj_type; /* Type of storage for object */ fheap_heap_state_t state; /* State of fractal heap */ unsigned deflate_level; /* Deflation level */ - unsigned old_actual_id_len = 0; /* Old actual ID length */ + size_t old_actual_id_len =0 ; /* Old actual ID length */ hbool_t huge_ids_direct; /* Are 'huge' objects directly acccessed? */ const char *base_desc = "insert 'huge' object into heap with I/O filters, then remove %s"; /* Test description */ @@ -15741,7 +15741,7 @@ HDfprintf(stderr, "Random # seed was: %lu\n", seed); /* Loop over adding objects to the heap, until the size limit is reached */ total_obj_added = 0; while(total_obj_added < size_limit) { - unsigned size_range = (tmp_cparam.managed.start_block_size / 8); /* Object size range */ + size_t size_range = (tmp_cparam.managed.start_block_size / 8); /* Object size range */ /* Determine the size of the range for this object */ /* (50% of the objects inserted will use the initial size range, @@ -16061,9 +16061,9 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) /* Change size of data to write */ if(u < 20) - obj_size = (size_t)(obj_size * 1.3F); + obj_size = (size_t)((float)obj_size * 1.3F); else - obj_size = (size_t)(obj_size / 1.3F); + obj_size = (size_t)((float)obj_size / 1.3F); } /* end for */ /* Close the fractal heap */ @@ -16110,9 +16110,9 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) /* Change size of data to write */ if(u < 20) - obj_size = (size_t)(obj_size * 1.3F); + obj_size = (size_t)((float)obj_size * 1.3F); else - obj_size = (size_t)(obj_size / 1.3F); + obj_size = (size_t)((float)obj_size / 1.3F); } /* end for */ /* Close the fractal heap */ diff --git a/test/fillval.c b/test/fillval.c index 1ea2ae6..3f713e9 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -623,7 +623,7 @@ test_create(hid_t fapl, const char *base_name, H5D_layout_t layout) if((dset9 = H5Dopen2(file, "dset9", H5P_DEFAULT)) < 0) goto error; if((dcpl = H5Dget_create_plist(dset9)) < 0) goto error; if(H5Pget_fill_value(dcpl, comp_type_id, &rd_c) < 0) goto error; - if( rd_c.a!=0 || rd_c.y != fill_ctype.y || rd_c.x != 0 || rd_c.z != '\0') { + if(!H5_FLT_ABS_EQUAL(rd_c.a, 0) || !H5_DBL_ABS_EQUAL(rd_c.y, fill_ctype.y) || rd_c.x != 0 || rd_c.z != '\0') { H5_FAILED(); puts(" Got wrong fill value"); printf(" Got rd_c.a=%f, rd_c.y=%f and rd_c.x=%d, rd_c.z=%c\n", @@ -696,7 +696,7 @@ test_create(hid_t fapl, const char *base_name, H5D_layout_t layout) if((dset8 = H5Dopen2(file, "dset8", H5P_DEFAULT)) < 0) goto error; if((dcpl = H5Dget_create_plist(dset8)) < 0) goto error; if(H5Pget_fill_value(dcpl, comp_type_id, &rd_c) < 0) goto error; - if(rd_c.a != 0 || rd_c.y != fill_ctype.y || rd_c.x != 0 || rd_c.z!='\0') { + if(!H5_FLT_ABS_EQUAL(rd_c.a, 0) || !H5_DBL_ABS_EQUAL(rd_c.y, fill_ctype.y) || rd_c.x != 0 || rd_c.z != '\0') { H5_FAILED(); puts(" Got wrong fill value"); printf(" Got rd_c.a=%f, rd_c.y=%f and rd_c.x=%d, rd_c.z=%c\n", @@ -789,7 +789,7 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, goto error; for (i=0; i<1000; i++) { for (j=0; j<5; j++) - hs_offset[j] = rand() % cur_size[j]; + hs_offset[j] = (hsize_t)HDrand() % cur_size[j]; if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) goto error; @@ -811,9 +811,9 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, } else if(datatype==H5T_COMPOUND) { if(H5Dread(dset2, ctype_id, mspace, fspace, H5P_DEFAULT, &rd_c) < 0) goto error; - if(fill_time!=H5D_FILL_TIME_NEVER && (rd_c.a!=fill_c.a || - rd_c.x!=fill_c.x || rd_c.y!=fill_c.y || - rd_c.z!=fill_c.z)) { + if(fill_time != H5D_FILL_TIME_NEVER && (!H5_FLT_ABS_EQUAL(rd_c.a, fill_c.a) || + rd_c.x != fill_c.x || !H5_DBL_ABS_EQUAL(rd_c.y, fill_c.y) || + rd_c.z != fill_c.z)) { H5_FAILED(); HDfprintf(stdout, "%u: Value read was not a fill value.\n", (unsigned)__LINE__); HDfprintf(stdout," Elmt={%Hu,%Hu,%Hu,%Hu,%Hu}, read: %f, %d, %f, %c" @@ -879,8 +879,8 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, /* Verify values, except if no fill value written */ if(fill_time != H5D_FILL_TIME_NEVER) { for(u = 0; u < nelmts; u++) { - if(buf_c[u].a != fill_c.a || buf_c[u].x != fill_c.x || - buf_c[u].y != fill_c.y || buf_c[u].z != fill_c.z) { + if(!H5_FLT_ABS_EQUAL(buf_c[u].a, fill_c.a) || buf_c[u].x != fill_c.x || + !H5_DBL_ABS_EQUAL(buf_c[u].y, fill_c.y) || buf_c[u].z != fill_c.z) { H5_FAILED(); HDfprintf(stdout, "%u: Value read was not a fill value.\n", (unsigned)__LINE__); HDfprintf(stdout," Elmt={%Hu, %Hu, %Hu, %Hu, %Hu}, read: %f, %d, %f, %c" @@ -938,7 +938,7 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, goto error; for(i = 0; i < 1000; i++) { for(j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = rand() % cur_size[j]; + hs_offset[j] = (hsize_t)HDrand() % cur_size[j]; odd += (int)(hs_offset[j]%2); } /* end for */ if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) @@ -993,8 +993,8 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, should_be_c.y=buf_c[0].y; should_be_c.z=buf_c[0].z; } - if( rd_c.a!=should_be_c.a || rd_c.x!=should_be_c.x || - rd_c.y!=should_be_c.y || rd_c.z!=should_be_c.z) { + if(!H5_FLT_ABS_EQUAL(rd_c.a, should_be_c.a) || rd_c.x != should_be_c.x || + !H5_DBL_ABS_EQUAL(rd_c.y, should_be_c.y) || rd_c.z != should_be_c.z) { H5_FAILED(); HDfprintf(stdout, "%u: Value read was not correct.\n", (unsigned)__LINE__); printf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %f,%d,%f,%c " @@ -1012,8 +1012,8 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, should_be_c.x=buf_c[0].x; should_be_c.y=buf_c[0].y; should_be_c.z=buf_c[0].z; - if( rd_c.a!=should_be_c.a || rd_c.x!=should_be_c.x || - rd_c.y!=should_be_c.y || rd_c.z!=should_be_c.z) { + if(!H5_FLT_ABS_EQUAL(rd_c.a, should_be_c.a) || rd_c.x != should_be_c.x || + !H5_DBL_ABS_EQUAL(rd_c.y, should_be_c.y) || rd_c.z != should_be_c.z) { H5_FAILED(); HDfprintf(stdout, "%u: Value read was not correct.\n", (unsigned)__LINE__); printf(" Elmt={%ld,%ld,%ld,%ld,%ld}, read: %f,%d,%f,%c " @@ -1438,9 +1438,11 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, int (*verify_rtn)(unsigned, const hsize_t *, const void *, const void *); int (*release_rtn)(void *); size_t val_size; /* Size of element */ - void *val_rd, *should_be, *init_val, *odd_val, *even_val; + void *val_rd, *odd_val; + const void *init_val, *should_be, *even_val; int val_rd_i, init_val_i = 9999; - comp_vl_datatype val_rd_c, init_val_c = {87, "baz", "mumble", 129}; + comp_vl_datatype init_val_c = {87, "baz", "mumble", 129}; + comp_vl_datatype val_rd_c; void *buf = NULL; unsigned odd; /* Whether an odd or even coord. was read */ unsigned i, j; /* Local index variables */ @@ -1495,7 +1497,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, for(i = 0; i < 1000; i++) { /* Set offset for random element */ for(j = 0; j < 5; j++) - hs_offset[j] = rand() % start_size[j]; + hs_offset[j] = (hsize_t)HDrand() % start_size[j]; /* Select the random element */ if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, one, NULL) < 0) TEST_ERROR @@ -1548,7 +1550,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, for(i = 0; i < 1000; i++) { /* Set offset for random element */ for(j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = rand() % start_size[j]; + hs_offset[j] = (hsize_t)HDrand() % start_size[j]; odd += (unsigned)(hs_offset[j] % 2); } /* end for */ @@ -1586,7 +1588,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, for(i = 0; i < 1000; i++) { /* Set offset for random element */ for(j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = rand() % extend_size[j]; + hs_offset[j] = (hsize_t)HDrand() % extend_size[j]; if(hs_offset[j] >= start_size[j]) odd = 1; else @@ -1625,7 +1627,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, for(i = 0; i < 1000; i++) { /* Set offset for random element */ for(j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = rand() % max_size[j]; + hs_offset[j] = (hsize_t)HDrand() % max_size[j]; if(hs_offset[j] >= start_size[j]) odd = 1; else @@ -1666,7 +1668,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, for(i = 0; i < 1000; i++) { /* Set offset for random element */ for(j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = rand() % extend_size[j]; + hs_offset[j] = (hsize_t)HDrand() % extend_size[j]; if(hs_offset[j] >= start_size[j]) odd = 1; else @@ -1759,7 +1761,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name, for(i = 0; i < 1000; i++) { /* Set offset for random element */ for(j = 0, odd = 0; j < 5; j++) { - hs_offset[j] = rand() % extend_size[j]; + hs_offset[j] = (hsize_t)HDrand() % extend_size[j]; if(hs_offset[j] >= start_size[j]) odd = 1; else diff --git a/test/flush1.c b/test/flush1.c index f15a05a..f1169ea 100644 --- a/test/flush1.c +++ b/test/flush1.c @@ -68,13 +68,8 @@ create_file(char* name, hid_t fapl) /* Write some data */ for(i = 0; i < ds_size[0]; i++) - /* - * The extra cast in the following statement is a bug workaround - * for the Win32 version 5.0 compiler. - * 1998-11-06 ptl - */ for(j = 0; j < (size_t)ds_size[1]; j++) - the_data[i][j] = (double)(hssize_t)i/(hssize_t)(j+1); + the_data[i][j] = (double)i / (double)(j + 1); if(H5Dwrite(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, the_data) < 0) FAIL_STACK_ERROR /* Create some groups */ @@ -124,25 +119,15 @@ extend_file(hid_t file) goto error; /* Write some data */ - for (i=0; i<ds_size[0]; i++) { - /* - * The extra cast in the following statement is a bug workaround - * for the Win32 version 5.0 compiler. - * 1998-11-06 ptl - */ - for (j=0; j<(size_t)ds_size[1]; j++) { - the_data[i][j] = (double)(hssize_t)i/(hssize_t)(j+1); - } - } - if (H5Dwrite(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, - the_data) < 0) goto error; - + for(i = 0; i < ds_size[0]; i++) + for(j = 0; j < (size_t)ds_size[1]; j++) + the_data[i][j] = (double)i / (double)(j + 1); + if(H5Dwrite(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, the_data) < 0) goto error; return file; error: - HD_exit(1); - + HD_exit(1); } /*------------------------------------------------------------------------- @@ -206,3 +191,4 @@ error: HD_exit(1); return 1; } + diff --git a/test/flush2.c b/test/flush2.c index e86d646..7dc45be 100644 --- a/test/flush2.c +++ b/test/flush2.c @@ -63,22 +63,15 @@ check_dset(hid_t file, const char* name) assert(100 == ds_size[0] && 100 == ds_size[1]); /* Read some data */ - if(H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, - the_data) < 0) goto error; + if(H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, the_data) < 0) goto error; for(i = 0; i < (size_t)ds_size[0]; i++) for(j = 0; j < (size_t)ds_size[1]; j++) { - /* - * The extra cast in the following statement is a bug workaround - * for the Win32 version 5.0 compiler. - * 1998-11-06 ptl - */ - error = fabs(the_data[i][j] - (double)(hssize_t)i / ((hssize_t)j + 1)); - if(error > 0.0001F) { + error = HDfabs(the_data[i][j] - (double)i / (double)(j + 1)); + if(error > (double)0.0001F) { H5_FAILED(); printf(" dset[%lu][%lu] = %g\n", (unsigned long)i, (unsigned long)j, the_data[i][j]); - printf(" should be %g\n", - (double)(hssize_t)i/(hssize_t)(j+1)); + printf(" should be %g\n", (double)i / (double)(j + 1)); goto error; } } diff --git a/test/gheap.c b/test/gheap.c index 3f66d35..317e306 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -81,7 +81,7 @@ test_1 (hid_t fapl) H5HG_t obj[1024]; uint8_t out[1024]; uint8_t in[1024]; - int i; + size_t u; size_t size; herr_t status; int nerrors = 0; @@ -104,16 +104,16 @@ test_1 (hid_t fapl) * a clean file, the addresses allocated for the collections should also * be monotonically increasing. */ - for(i = 0; i < 1024; i++) { - size = i + 1; - HDmemset(out, 'A' + i % 26, size); + for(u = 0; u < 1024; u++) { + size = u + 1; + HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); - status = H5HG_insert(f, H5AC_ind_read_dxpl_id, size, out, obj + i); + status = H5HG_insert(f, H5AC_ind_read_dxpl_id, size, out, obj + u); if(status < 0) { H5_FAILED(); puts(" Unable to insert object into global heap"); nerrors++; - } else if(i && H5F_addr_gt(obj[i - 1].addr, obj[i].addr)) { + } else if(u && H5F_addr_gt(obj[u - 1].addr, obj[u].addr)) { H5_FAILED(); puts(" Collection addresses are not monotonically increasing"); nerrors++; @@ -123,11 +123,11 @@ test_1 (hid_t fapl) /* * Now try to read each object back. */ - for(i = 0; i < 1024; i++) { - size = i + 1; - HDmemset(out, 'A' + i % 26, size); + for(u = 0; u < 1024; u++) { + size = u + 1; + HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); - if(NULL == H5HG_read(f, H5AC_ind_read_dxpl_id, obj + i, in, NULL)) { + if(NULL == H5HG_read(f, H5AC_ind_read_dxpl_id, obj + u, in, NULL)) { H5_FAILED(); puts(" Unable to read object"); nerrors++; @@ -177,7 +177,7 @@ test_2 (hid_t fapl) H5HG_t obj[1024]; uint8_t out[1024]; uint8_t in[1024]; - int i; + size_t u; size_t size; int nerrors = 0; char filename[1024]; @@ -197,11 +197,11 @@ test_2 (hid_t fapl) /* * Write the objects, monotonically decreasing in length. */ - for (i=0; i<1024; i++) { - size = 1024-i; - memset (out, 'A'+i%26, size); + for(u = 0; u < 1024; u++) { + size = 1024 - u; + HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); - if (H5HG_insert (f, H5AC_ind_read_dxpl_id, size, out, obj+i)<0) { + if (H5HG_insert (f, H5AC_ind_read_dxpl_id, size, out, obj + u) < 0) { H5_FAILED(); puts(" Unable to insert object into global heap"); nerrors++; @@ -211,11 +211,11 @@ test_2 (hid_t fapl) /* * Now try to read each object back. */ - for (i=0; i<1024; i++) { - size = 1024-i; - memset (out, 'A'+i%26, size); + for(u = 0; u < 1024; u++) { + size = 1024 - u; + HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); - if (NULL==H5HG_read (f, H5AC_ind_read_dxpl_id, obj+i, in, NULL)) { + if (NULL==H5HG_read (f, H5AC_ind_read_dxpl_id, obj + u, in, NULL)) { H5_FAILED(); puts(" Unable to read object"); nerrors++; @@ -263,7 +263,7 @@ test_3 (hid_t fapl) H5F_t *f = NULL; H5HG_t obj[1024]; uint8_t out[1024]; - int i; + size_t u; size_t size; herr_t status; int nerrors = 0; @@ -282,11 +282,11 @@ test_3 (hid_t fapl) } /* Create some stuff */ - for (i=0; i<1024; i++) { - size = i%30+100; - memset (out, 'A'+i%26, size); + for(u = 0; u < 1024; u++) { + size = u % 30 + 100; + HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); - status = H5HG_insert (f, H5AC_ind_read_dxpl_id, size, out, obj+i); + status = H5HG_insert (f, H5AC_ind_read_dxpl_id, size, out, obj + u); if (status<0) { H5_FAILED(); puts(" Unable to insert object into global heap"); @@ -295,8 +295,8 @@ test_3 (hid_t fapl) } /* Remove everything */ - for (i=0; i<1024; i++) { - status = H5HG_remove (f, H5AC_ind_read_dxpl_id, obj+i); + for(u = 0; u < 1024; u++) { + status = H5HG_remove (f, H5AC_ind_read_dxpl_id, obj + u); if (status<0) { H5_FAILED(); puts(" Unable to remove object"); @@ -342,7 +342,7 @@ test_4 (hid_t fapl) H5F_t *f = NULL; H5HG_t obj[1024]; uint8_t out[1024]; - int i; + size_t u; size_t size; herr_t status; int nerrors = 0; @@ -360,12 +360,12 @@ test_4 (hid_t fapl) goto error; } - for (i=0; i<1024; i++) { + for(u = 0; u < 1024; u++) { /* Insert */ - size = i%30+100; - memset (out, 'A'+i%26, size); + size = u % 30 + 100; + HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); - status = H5HG_insert (f, H5AC_ind_read_dxpl_id, size, out, obj+i); + status = H5HG_insert (f, H5AC_ind_read_dxpl_id, size, out, obj + u); if (status<0) { H5_FAILED(); puts(" Unable to insert object into global heap"); @@ -377,15 +377,15 @@ test_4 (hid_t fapl) * next one has already been inserted. That is, insert A, B, C; * remove B, insert D, E, F; remove E; etc. */ - if (1==i%3) { + if(1 == (u % 3)) { H5Eclear2(H5E_DEFAULT); - status = H5HG_remove (f, H5AC_ind_read_dxpl_id, obj+i-1); + status = H5HG_remove (f, H5AC_ind_read_dxpl_id, obj + u - 1); if (status<0) { H5_FAILED(); puts(" Unable to remove object"); nerrors++; } - memset (obj+i-1, 0, sizeof *obj); + HDmemset(obj + u - 1, 0, sizeof *obj); } } diff --git a/test/hyperslab.c b/test/hyperslab.c index 2cf47b1..9ba5731 100644 --- a/test/hyperslab.c +++ b/test/hyperslab.c @@ -223,7 +223,7 @@ test_fill(size_t nx, size_t ny, size_t nz, for(v = (size_t)dst_offset[1]; v < dst_offset[1] + dy; v++) for(w = (size_t)dst_offset[2]; w < dst_offset[2] + dz; w++) ref_value -= dst[u * ny * nz + v * nz + w]; - ref_value += fill_value * dx * dy * dz; + ref_value += fill_value * (unsigned)dx * (unsigned)dy * (unsigned)dz; /* Fill the hyperslab with some value */ H5VM_hyper_fill(ndims, hs_size, dst_size, dst_offset, dst, fill_value); @@ -819,8 +819,8 @@ test_transpose(size_t nx, size_t ny) size[1] = ny; src_stride[0] = 0; src_stride[1] = sizeof(*src); - dst_stride[0] = (ssize_t)((1 - nx * ny) * sizeof(*src)); - dst_stride[1] = (ssize_t)(nx * sizeof(*src)); + dst_stride[0] = (hsize_t)((1 - nx * ny) * sizeof(*src)); + dst_stride[1] = (hsize_t)(nx * sizeof(*src)); /* Copy and transpose */ if(nx == ny) @@ -923,7 +923,7 @@ test_sub_super(size_t nx, size_t ny) /* Setup */ size[0] = nx; size[1] = ny; - src_stride[0] = (ssize_t)(2 * ny); + src_stride[0] = (hsize_t)(2 * ny); src_stride[1] = 2; dst_stride[0] = 0; dst_stride[1] = 1; @@ -972,9 +972,9 @@ test_sub_super(size_t nx, size_t ny) src_stride[1] = 1; src_stride[2] = 0; src_stride[3] = 0; - dst_stride[0] = (ssize_t)(2 * ny); - dst_stride[1] = (ssize_t)(2 * sizeof(uint8_t) - 4 * ny); - dst_stride[2] = (ssize_t)(2 * ny - 2 * sizeof(uint8_t)); + dst_stride[0] = (hsize_t)(2 * ny); + dst_stride[1] = (hsize_t)(2 * sizeof(uint8_t) - 4 * ny); + dst_stride[2] = (hsize_t)(2 * ny - 2 * sizeof(uint8_t)); dst_stride[3] = sizeof(uint8_t); /* Copy */ @@ -1144,9 +1144,9 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z) /* Check offsets */ for(u = 0; u < n; u++) { /* Get random coordinate */ - coords[0] = (hssize_t)(HDrandom() % z); - coords[1] = (hssize_t)(HDrandom() % y); - coords[2] = (hssize_t)(HDrandom() % x); + coords[0] = (hsize_t)((size_t)HDrandom() % z); + coords[1] = (hsize_t)((size_t)HDrandom() % y); + coords[2] = (hsize_t)((size_t)HDrandom() % x); /* Get offset of coordinate */ off = H5VM_array_offset(ARRAY_OFFSET_NDIMS, dims, coords); diff --git a/test/tchecksum.c b/test/tchecksum.c index cb7c023..ca6c227 100644 --- a/test/tchecksum.c +++ b/test/tchecksum.c @@ -189,7 +189,7 @@ test_chksum_large(void) /* Initialize buffer w/known data */ for(u = 0; u < BUF_LEN; u++) - large_buf[u] = u * 3; + large_buf[u] = (uint8_t)(u * 3); /* Buffer w/real data */ chksum = H5_checksum_fletcher32(large_buf, sizeof(large_buf)); @@ -247,7 +247,7 @@ test_checksum(void) * *------------------------------------------------------------------------- */ -H5_ATTR_PURE void +H5_ATTR_PURE H5_ATTR_CONST void cleanup_checksum(void) { /* no file to clean */ diff --git a/test/tfile.c b/test/tfile.c index 74f3b86..833d2d9 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1858,7 +1858,7 @@ test_file_open_overlap(void) hid_t did1, did2; hid_t gid; hid_t sid; - int nobjs; /* # of open objects */ + ssize_t nobjs; /* # of open objects */ unsigned intent; herr_t ret; /* Generic return value */ @@ -2197,8 +2197,9 @@ test_file_double_file_dataset_open(hbool_t new_format) hsize_t max_dims1[1] = {H5S_UNLIMITED}; /* Maximum dimesion sizes for extensible array index */ hsize_t max_dims2[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; /* Maximum dimension sizes for v2 B-tree index */ hsize_t chunks[1] = {2}, chunks2[2] = {4, 5}; /* Chunk dimension sizes */ - char* data[] = {"String 1", "String 2", "String 3", "String 4", "String 5"}; /* Input Data */ - char* e_data[] = {"String 1", "String 2", "String 3", "String 4", "String 5", "String 6", "String 7"}; /* Input Data */ + hsize_t size; /* File size */ + const char* data[] = {"String 1", "String 2", "String 3", "String 4", "String 5"}; /* Input Data */ + const char* e_data[] = {"String 1", "String 2", "String 3", "String 4", "String 5", "String 6", "String 7"}; /* Input Data */ char* buffer[5]; /* Output buffer */ int wbuf[4] = {1, 2, 3, 4}; /* Input data */ herr_t ret; /* Generic return value */ @@ -2432,8 +2433,8 @@ test_file_double_file_dataset_open(hbool_t new_format) CHECK(did1, FAIL, "H5Dopen2"); /* First file's get storage size */ - ret = H5Dget_storage_size(did1); - CHECK(ret, FAIL, "H5Dget_storage_size"); + size = H5Dget_storage_size(did1); + CHECK(size, 0, "H5Dget_storage_size"); /* Second file open */ fid2 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); @@ -2452,8 +2453,8 @@ test_file_double_file_dataset_open(hbool_t new_format) CHECK(ret, FAIL, "H5Fclose"); /* Second file's get storage size */ - ret = H5Dget_storage_size(did2); - CHECK(ret, FAIL, "H5Dget_storage_size"); + size = H5Dget_storage_size(did2); + CHECK(size, 0, "H5Dget_storage_size"); /* Second file's dataset close */ ret = H5Dclose(did2); @@ -2775,7 +2776,7 @@ test_rw_noupdate(void) diff = HDdifftime(sb2.st_mtime, sb1.st_mtime); /* Check That Timestamps Are Equal */ - if(diff > 0.0F) { + if(diff > (double)0.0F) { /* Output message about test being performed */ MESSAGE(1, ("Testing to verify that nothing is written if nothing is changed: This test is skipped on this system because the modification time from stat is the same as the last access time.\n")); } /* end if */ @@ -2808,7 +2809,7 @@ test_rw_noupdate(void) /* Ensure That Timestamps Are Equal */ diff = HDdifftime(sb2.st_mtime, sb1.st_mtime); - ret = (diff > 0.0F); + ret = (diff > (double)0.0F); VERIFY(ret, 0, "Timestamp"); } /* end else */ } /* end test_rw_noupdate() */ diff --git a/test/th5o.c b/test/th5o.c index 3be5d12..125e11b 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -920,6 +920,7 @@ test_h5o_comment(void) const char *dtype_comment = "datatype comment"; char check_comment[64]; ssize_t comment_len = 0; + ssize_t len; herr_t ret; /* Value returned from API calls */ int ret_value; @@ -1008,8 +1009,8 @@ test_h5o_comment(void) comment_len = H5Oget_comment(fid, NULL, (size_t)0); CHECK(comment_len, FAIL, "H5Oget_comment"); - ret = H5Oget_comment(fid, check_comment, (size_t)comment_len+1); - CHECK(ret, FAIL, "H5Oget_comment"); + len = H5Oget_comment(fid, check_comment, (size_t)comment_len+1); + CHECK(len, FAIL, "H5Oget_comment"); ret_value = HDstrcmp(file_comment, check_comment); VERIFY(ret_value, 0, "H5Oget_comment"); @@ -1022,8 +1023,8 @@ test_h5o_comment(void) comment_len = H5Oget_comment(grp, NULL, (size_t)0); CHECK(comment_len, FAIL, "H5Oget_comment"); - ret = H5Oget_comment(grp, check_comment, (size_t)comment_len+1); - CHECK(ret, FAIL, "H5Oget_comment"); + len = H5Oget_comment(grp, check_comment, (size_t)comment_len+1); + CHECK(len, FAIL, "H5Oget_comment"); ret_value = HDstrcmp(grp_comment, check_comment); VERIFY(ret_value, 0, "H5Oget_comment"); @@ -1036,8 +1037,8 @@ test_h5o_comment(void) comment_len = H5Oget_comment(dtype, NULL, (size_t)0); CHECK(comment_len, FAIL, "H5Oget_comment"); - ret = H5Oget_comment(dtype, check_comment, (size_t)comment_len+1); - CHECK(ret, FAIL, "H5Oget_comment"); + len = H5Oget_comment(dtype, check_comment, (size_t)comment_len+1); + CHECK(len, FAIL, "H5Oget_comment"); ret_value = HDstrcmp(dtype_comment, check_comment); VERIFY(ret_value, 0, "H5Oget_comment"); @@ -1050,8 +1051,8 @@ test_h5o_comment(void) comment_len = H5Oget_comment(dset, NULL, (size_t)0); CHECK(comment_len, FAIL, "H5Oget_comment"); - ret = H5Oget_comment(dset, check_comment, (size_t)comment_len+1); - CHECK(ret, FAIL, "H5Oget_comment"); + len = H5Oget_comment(dset, check_comment, (size_t)comment_len+1); + CHECK(ret, len, "H5Oget_comment"); ret_value = HDstrcmp(dset_comment, check_comment); VERIFY(ret_value, 0, "H5Oget_comment"); @@ -1092,6 +1093,7 @@ test_h5o_comment_by_name(void) const char *dtype_comment = "datatype comment by name"; char check_comment[64]; ssize_t comment_len = 0; + ssize_t len; herr_t ret; /* Value returned from API calls */ int ret_value; @@ -1179,8 +1181,8 @@ test_h5o_comment_by_name(void) comment_len = H5Oget_comment_by_name(fid, ".", NULL, (size_t)0, H5P_DEFAULT); CHECK(comment_len, FAIL, "H5Oget_comment_by_name"); - ret = H5Oget_comment_by_name(fid, ".", check_comment, (size_t)comment_len+1, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_comment_by_name"); + len = H5Oget_comment_by_name(fid, ".", check_comment, (size_t)comment_len+1, H5P_DEFAULT); + CHECK(len, FAIL, "H5Oget_comment_by_name"); ret_value = HDstrcmp(file_comment, check_comment); VERIFY(ret_value, 0, "H5Oget_comment_by_name"); @@ -1193,8 +1195,8 @@ test_h5o_comment_by_name(void) comment_len = H5Oget_comment_by_name(fid, "group", NULL, (size_t)0, H5P_DEFAULT); CHECK(comment_len, FAIL, "H5Oget_comment_by_name"); - ret = H5Oget_comment_by_name(fid, "group", check_comment, (size_t)comment_len+1, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_comment_by_name"); + len = H5Oget_comment_by_name(fid, "group", check_comment, (size_t)comment_len+1, H5P_DEFAULT); + CHECK(len, FAIL, "H5Oget_comment_by_name"); ret_value = HDstrcmp(grp_comment, check_comment); VERIFY(ret_value, 0, "H5Oget_comment_by_name"); @@ -1203,8 +1205,8 @@ test_h5o_comment_by_name(void) comment_len = H5Oget_comment_by_name(grp, "datatype", NULL, (size_t)0, H5P_DEFAULT); CHECK(comment_len, FAIL, "H5Oget_comment_by_name"); - ret = H5Oget_comment_by_name(grp, "datatype", check_comment, (size_t)comment_len+1, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_comment"); + len = H5Oget_comment_by_name(grp, "datatype", check_comment, (size_t)comment_len+1, H5P_DEFAULT); + CHECK(len, FAIL, "H5Oget_comment"); ret_value = HDstrcmp(dtype_comment, check_comment); VERIFY(ret_value, 0, "H5Oget_comment_by_name"); @@ -1213,8 +1215,8 @@ test_h5o_comment_by_name(void) comment_len = H5Oget_comment_by_name(fid, "dataset", NULL, (size_t)0, H5P_DEFAULT); CHECK(comment_len, FAIL, "H5Oget_comment_by_name"); - ret = H5Oget_comment_by_name(fid, "dataset", check_comment, (size_t)comment_len+1, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_comment_by_name"); + len = H5Oget_comment_by_name(fid, "dataset", check_comment, (size_t)comment_len+1, H5P_DEFAULT); + CHECK(len, FAIL, "H5Oget_comment_by_name"); ret_value = HDstrcmp(dset_comment, check_comment); VERIFY(ret_value, 0, "H5Oget_comment_by_name"); diff --git a/test/titerate.c b/test/titerate.c index f61842a..9f0b900 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -283,7 +283,8 @@ test_iter_group(hid_t fapl, hbool_t new_format) /* Test all objects in group, when callback always returns 1 */ /* This also tests the "restarting" ability, because the index changes */ info.command = RET_TWO; - idx = i = 0; + i = 0; + idx = 0; while((ret = H5Literate(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info)) > 0) { /* Verify return value from iterator gets propagated correctly */ VERIFY(ret, 2, "H5Literate"); @@ -308,7 +309,8 @@ test_iter_group(hid_t fapl, hbool_t new_format) /* Test all objects in group, when callback changes return value */ /* This also tests the "restarting" ability, because the index changes */ info.command = new_format ? RET_CHANGE2 : RET_CHANGE; - idx = i = 0; + i = 0; + idx = 0; while((ret = H5Literate(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb, &info)) >= 0) { /* Verify return value from iterator gets propagated correctly */ VERIFY(ret, 1, "H5Literate"); @@ -462,7 +464,8 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) /* Test all attributes on dataset, when callback always returns 1 */ /* This also tests the "restarting" ability, because the index changes */ info.command = RET_TWO; - idx = i = 0; + i = 0; + idx = 0; while((ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info)) > 0) { /* Verify return value from iterator gets propagated correctly */ VERIFY(ret, 2, "H5Aiterate2"); @@ -488,7 +491,8 @@ static void test_iter_attr(hid_t fapl, hbool_t new_format) /* Test all attributes on dataset, when callback changes return value */ /* This also tests the "restarting" ability, because the index changes */ info.command = new_format ? RET_CHANGE2 : RET_CHANGE; - idx = i = 0; + i = 0; + idx = 0; while((ret = H5Aiterate2(dataset, H5_INDEX_NAME, H5_ITER_INC, &idx, aiter_cb, &info)) > 0) { /* Verify return value from iterator gets propagated correctly */ VERIFY(ret, 1, "H5Aiterate2"); @@ -672,7 +676,7 @@ test_iter_group_large(hid_t fapl) ret = H5Literate(file, H5_INDEX_NAME, H5_ITER_INC, NULL, liter_cb2, curr_name); CHECK(ret, FAIL, "H5Literate"); for(i = 1; i < 100; i++) { - hsize_t idx = i; + hsize_t idx = (hsize_t)i; curr_name = &names[i]; ret = H5Literate(file, H5_INDEX_NAME, H5_ITER_INC, &idx, liter_cb2, curr_name); diff --git a/test/trefer.c b/test/trefer.c index cb0f44e..433239a 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -84,8 +84,8 @@ test_reference_params(void) int i; /* counting variables */ const char *write_comment = "Foo!"; /* Comments for group */ hid_t ret_id; /* Generic hid_t return value */ + ssize_t name_size; /* Size of reference name */ herr_t ret; /* Generic return value */ - size_t name_size; /* Size of reference name */ /* Output message about test being performed */ MESSAGE(5, ("Testing Reference Parameters\n")); @@ -120,7 +120,7 @@ test_reference_params(void) CHECK(dataset, FAIL, "H5Dcreate2"); for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++=i*3; + *tu32++ = (unsigned)i * 3; /* Write selection to disk */ ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); @@ -266,6 +266,7 @@ test_reference_obj(void) const char *write_comment="Foo!"; /* Comments for group */ char read_comment[10]; H5O_type_t obj_type; /* Object type */ + ssize_t size; /* Comment length */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -301,7 +302,7 @@ test_reference_obj(void) CHECK(dataset, FAIL, "H5Dcreate2"); for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++=i*3; + *tu32++ = (unsigned)i * 3; /* Write selection to disk */ ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); @@ -432,8 +433,8 @@ test_reference_obj(void) CHECK(group, FAIL, "H5Rdereference2"); /* Get group's comment */ - ret = H5Oget_comment(group, read_comment, (size_t)10); - CHECK(ret, FAIL, "H5Oget_comment"); + size = H5Oget_comment(group, read_comment, (size_t)10); + CHECK(size, FAIL, "H5Oget_comment"); /* Check for correct comment value */ if(HDstrcmp(write_comment, read_comment) != 0) @@ -557,7 +558,7 @@ test_reference_region(void) CHECK(dset2, FAIL, "H5Dcreate2"); for(tu8 = dwbuf, i = 0; i < (SPACE2_DIM1 * SPACE2_DIM2); i++) - *tu8++ = i * 3; + *tu8++ = (uint8_t)(i * 3); /* Write selection to disk */ ret = H5Dwrite(dset2, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf); @@ -762,7 +763,7 @@ test_reference_region(void) VERIFY(ret, 36, "H5Sget_select_npoints"); ret = (int)H5Sget_select_hyper_nblocks(sid2); VERIFY(ret, 1, "H5Sget_select_hyper_nblocks"); - coords = (hsize_t *)HDmalloc(ret * SPACE2_RANK * sizeof(hsize_t) * 2); /* allocate space for the hyperslab blocks */ + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t) * 2); /* allocate space for the hyperslab blocks */ ret = H5Sget_select_hyper_blocklist(sid2, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); VERIFY(coords[0], 2, "Hyperslab Coordinates"); @@ -790,7 +791,7 @@ test_reference_region(void) VERIFY(ret, 10, "H5Sget_select_npoints"); ret = (int)H5Sget_select_elem_npoints(sid2); VERIFY(ret, 10, "H5Sget_select_elem_npoints"); - coords = (hsize_t *)HDmalloc(ret * SPACE2_RANK * sizeof(hsize_t)); /* allocate space for the element points */ + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t)); /* allocate space for the element points */ ret = H5Sget_select_elem_pointlist(sid2, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_elem_pointlist"); VERIFY(coords[0], coord1[0][0], "Element Coordinates"); @@ -945,7 +946,7 @@ test_reference_region_1D(void) CHECK(dset3, FAIL, "H5Dcreate2"); for(tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++) - *tu8++ = i * 3; + *tu8++ = (uint8_t)(i * 3); /* Write selection to disk */ ret = H5Dwrite(dset3, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf); @@ -1068,7 +1069,7 @@ test_reference_region_1D(void) VERIFY(ret, 30, "H5Sget_select_npoints"); ret = (int)H5Sget_select_hyper_nblocks(sid3); VERIFY(ret, 15, "H5Sget_select_hyper_nblocks"); - coords = (hsize_t *)HDmalloc(ret * SPACE3_RANK * sizeof(hsize_t) * 2); /* allocate space for the hyperslab blocks */ + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t) * 2); /* allocate space for the hyperslab blocks */ ret = H5Sget_select_hyper_blocklist(sid3, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); VERIFY(coords[0], 2, "Hyperslab Coordinates"); @@ -1120,7 +1121,7 @@ test_reference_region_1D(void) VERIFY(ret, 10, "H5Sget_select_npoints"); ret = (int)H5Sget_select_elem_npoints(sid3); VERIFY(ret, 10, "H5Sget_select_elem_npoints"); - coords = (hsize_t *)HDmalloc(ret * SPACE3_RANK * sizeof(hsize_t)); /* allocate space for the element points */ + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t)); /* allocate space for the element points */ ret = H5Sget_select_elem_pointlist(sid3, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_elem_pointlist"); VERIFY(coords[0], coord1[0][0], "Element Coordinates"); @@ -1329,6 +1330,7 @@ test_reference_group(void) char objname[NAME_SIZE]; /* Buffer to store name */ H5O_info_t oinfo; /* Object info struct */ int count = 0; /* Count within iterated group */ + ssize_t size; /* Name length */ herr_t ret; /* Create file with a group and a dataset containing an object reference to the group */ @@ -1409,8 +1411,8 @@ test_reference_group(void) CHECK(ret, FAIL, "H5Gget_info"); VERIFY(ginfo.nlinks, 3, "H5Gget_info"); - ret = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, objname, (size_t)NAME_SIZE, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Lget_name_by_idx"); + size = H5Lget_name_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, objname, (size_t)NAME_SIZE, H5P_DEFAULT); + CHECK(size, FAIL, "H5Lget_name_by_idx"); VERIFY_STR(objname, DSETNAME2, "H5Lget_name_by_idx"); ret = H5Oget_info_by_idx(gid, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, &oinfo, H5P_DEFAULT); diff --git a/test/ttst.c b/test/ttst.c index 0c47dad..a7c43a2 100644 --- a/test/ttst.c +++ b/test/ttst.c @@ -123,7 +123,7 @@ test_tst_init(void) curr_time=HDtime(NULL); HDsrandom((unsigned)curr_time); for(u=0; u<num_uniq_words; u++) { - v=u+(HDrandom()%(num_uniq_words-u)); + v = u + ((size_t)HDrandom() % (num_uniq_words - u)); if(u!=v) { tmp_word=rand_uniq_words[u]; rand_uniq_words[u]=rand_uniq_words[v]; diff --git a/test/tunicode.c b/test/tunicode.c index 68e9073..2bba9ae 100644 --- a/test/tunicode.c +++ b/test/tunicode.c @@ -384,6 +384,7 @@ void test_objnames(hid_t fid, const char* string) char path_buf[MAX_PATH_LENGTH]; hsize_t dims=1; hobj_ref_t obj_ref; + ssize_t size; herr_t ret; /* Create a group with a UTF-8 name */ @@ -395,8 +396,8 @@ void test_objnames(hid_t fid, const char* string) */ ret = H5Oset_comment_by_name(fid, string, string, H5P_DEFAULT); CHECK(ret, FAIL, "H5Oset_comment_by_name"); - ret = H5Oget_comment_by_name(fid, string, read_buf, (size_t)MAX_STRING_LENGTH, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Oget_comment_by_name"); + size = H5Oget_comment_by_name(fid, string, read_buf, (size_t)MAX_STRING_LENGTH, H5P_DEFAULT); + CHECK(size, FAIL, "H5Oget_comment_by_name"); ret = H5Gclose(grp_id); CHECK(ret, FAIL, "H5Gclose"); @@ -510,6 +511,7 @@ void test_attrname(hid_t fid, const char * string) hid_t dtype_id, space_id; hsize_t dims=1; char read_buf[MAX_STRING_LENGTH]; + ssize_t size; herr_t ret; /* Create a new group and give it an attribute whose @@ -528,8 +530,8 @@ void test_attrname(hid_t fid, const char * string) /* Create the attribute and check that its name is correct */ attr_id = H5Acreate2(group_id, string, dtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr_id, FAIL, "H5Acreate2"); - ret = H5Aget_name(attr_id, (size_t)MAX_STRING_LENGTH, read_buf); - CHECK(ret, FAIL, "H5Aget_name"); + size = H5Aget_name(attr_id, (size_t)MAX_STRING_LENGTH, read_buf); + CHECK(size, FAIL, "H5Aget_name"); ret = strcmp(read_buf, string); VERIFY(ret, 0, "strcmp"); read_buf[0] = '\0'; @@ -740,25 +742,25 @@ static hid_t mkstr(size_t len, H5T_str_t strpad) unsigned int write_char(unsigned int c, char * test_string, unsigned int cur_pos) { if (c < 0x80) { - test_string[cur_pos] = c; + test_string[cur_pos] = (char)c; cur_pos++; } else if (c < 0x800) { - test_string[cur_pos] = (0xC0 | c>>6); - test_string[cur_pos+1] = (0x80 | (c & 0x3F)); + test_string[cur_pos] = (char)(0xC0 | c >> 6); + test_string[cur_pos + 1] = (char)(0x80 | (c & 0x3F)); cur_pos += 2; } else if (c < 0x10000) { - test_string[cur_pos] = (0xE0 | c>>12); - test_string[cur_pos+1] = (0x80 | (c>>6 & 0x3F)); - test_string[cur_pos+2] = (0x80 | (c & 0x3F)); + test_string[cur_pos] = (char)(0xE0 | c >> 12); + test_string[cur_pos + 1] = (char)(0x80 | (c >> 6 & 0x3F)); + test_string[cur_pos + 2] = (char)(0x80 | (c & 0x3F)); cur_pos += 3; } else if (c < 0x200000) { - test_string[cur_pos] = (0xF0 | c>>18); - test_string[cur_pos+1] = (0x80 | (c>>12 & 0x3F)); - test_string[cur_pos+2] = (0x80 | (c>>6 & 0x3F)); - test_string[cur_pos+3] = (0x80 | (c & 0x3F)); + test_string[cur_pos] = (char)(0xF0 | c >> 18); + test_string[cur_pos + 1] = (char)(0x80 | (c >> 12 & 0x3F)); + test_string[cur_pos + 2] = (char)(0x80 | (c >> 6 & 0x3F)); + test_string[cur_pos + 3] = (char)(0x80 | (c & 0x3F)); cur_pos += 4; } @@ -771,13 +773,13 @@ unsigned int write_char(unsigned int c, char * test_string, unsigned int cur_pos * could confuse printf (e.g., '\n'). */ void dump_string(const char * string) { - unsigned int length; - unsigned int x; + size_t length; + size_t x; printf("The string was:\n %s", string); printf("Or in hex:\n"); - length = strlen(string); + length = HDstrlen(string); for(x=0; x<length; x++) printf("%x ", string[x] & (0x000000FF)); @@ -810,7 +812,7 @@ void test_unicode(void) /* We need to avoid unprintable characters (codes 0-31) and the * . and / characters, since they aren't allowed in path names. */ - unicode_point = (HDrandom() % (MAX_CODE_POINT-32)) + 32; + unicode_point = (unsigned)(HDrandom() % (MAX_CODE_POINT-32)) + 32; if(unicode_point != 46 && unicode_point != 47) cur_pos = write_char(unicode_point, test_string, cur_pos); } |