diff options
author | Kimmy Mu <kmu@hdfgroup.org> | 2020-01-23 22:21:06 (GMT) |
---|---|---|
committer | Kimmy Mu <kmu@hdfgroup.org> | 2020-01-23 22:21:06 (GMT) |
commit | f3a4e8164f99d733e6804acddfe1b3b0dfe63634 (patch) | |
tree | 73215fc5e017510c1aafe91d514069619cc96eca /test | |
parent | a9aaad9be317ed92150ccc6b4e8574e596447dba (diff) | |
parent | af5c33afabdae2e39bb45eb1b3e9c8366da01145 (diff) | |
download | hdf5-f3a4e8164f99d733e6804acddfe1b3b0dfe63634.zip hdf5-f3a4e8164f99d733e6804acddfe1b3b0dfe63634.tar.gz hdf5-f3a4e8164f99d733e6804acddfe1b3b0dfe63634.tar.bz2 |
Merge pull request #2300 in HDFFV/hdf5 from ~KMU/hdf5:squashed_cast to develop
* commit 'af5c33afabdae2e39bb45eb1b3e9c8366da01145':
remove unnecessary stuff
squash cast warning fix
Diffstat (limited to 'test')
-rw-r--r-- | test/dsets.c | 24 | ||||
-rw-r--r-- | test/swmr_common.c | 24 | ||||
-rw-r--r-- | test/trefer.c | 6 | ||||
-rw-r--r-- | test/use_disable_mdc_flushes.c | 21 | ||||
-rw-r--r-- | test/vds_swmr.h | 24 | ||||
-rw-r--r-- | test/vds_swmr_gen.c | 6 | ||||
-rw-r--r-- | test/vds_swmr_reader.c | 6 |
7 files changed, 64 insertions, 47 deletions
diff --git a/test/dsets.c b/test/dsets.c index 061642a..bbe2d0f 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -7269,8 +7269,8 @@ test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) /* Generate random point coordinates. Only one point is selected per chunk */ for(i=0; i<NPOINTS; i++){ - chunk_row = (int)(ofs / cols); - chunk_col = (int)(ofs % cols); + H5_CHECKED_ASSIGN(chunk_row, int, ofs / cols, long); + H5_CHECKED_ASSIGN(chunk_col, int, ofs % cols, long); ofs = (ofs + inc) % (rows * cols); HDassert(!check2[chunk_row][chunk_col]); @@ -7390,14 +7390,14 @@ test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) for(j = 0; j < nsize[1] / csize[1]; j++) check2[i][j] = 0; - rows = (long)(nsize[0] / csize[0]); - cols = (long)(nsize[1] / csize[1]); + H5_CHECKED_ASSIGN(rows, int, nsize[0] / csize[0], long); + H5_CHECKED_ASSIGN(cols, int, nsize[1] / csize[1], long); make_random_offset_and_increment(rows * cols, &ofs, &inc); /* Generate random point coordinates. Only one point is selected per chunk */ for(i = 0; i < NPOINTS; i++){ - chunk_row = (int)(ofs / cols); - chunk_col = (int)(ofs % cols); + H5_CHECKED_ASSIGN(chunk_row, int, ofs / cols, long); + H5_CHECKED_ASSIGN(chunk_col, int, ofs % cols, long); ofs = (ofs + inc) % (rows * cols); HDassert(!check2[chunk_row][chunk_col]); @@ -7506,8 +7506,8 @@ test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) /* Generate random point coordinates. Only one point is selected per chunk */ for(i = 0; i < NPOINTS; i++){ - chunk_row = (int)(ofs / cols); - chunk_col = (int)(ofs % cols); + H5_CHECKED_ASSIGN(chunk_row, int, ofs / cols, long); + H5_CHECKED_ASSIGN(chunk_col, int, ofs % cols, long); ofs = (ofs + inc) % (rows * cols); HDassert(!check2[chunk_row][chunk_col]); @@ -9732,8 +9732,8 @@ test_fixed_array(hid_t fapl) /* Generate random point coordinates. Only one point is selected per chunk */ for(i = 0; i < POINTS; i++){ - chunk_row = (int)(ofs / cols); - chunk_col = (int)(ofs % cols); + H5_CHECKED_ASSIGN(chunk_row, int, ofs / cols, long); + H5_CHECKED_ASSIGN(chunk_col, int, ofs % cols, long); ofs = (ofs + inc) % (rows * cols); HDassert(!chunks[chunk_row][chunk_col]); @@ -9861,8 +9861,8 @@ test_fixed_array(hid_t fapl) /* Generate random point coordinates. Only one point is selected per chunk */ for(i = 0; i < POINTS_BIG; i++){ - chunk_row = (int)(ofs / cols); - chunk_col = (int)(ofs % cols); + H5_CHECKED_ASSIGN(chunk_row, int, ofs / cols, long); + H5_CHECKED_ASSIGN(chunk_col, int, ofs % cols, long); ofs = (ofs + inc) % (rows * cols); HDassert(!chunks_big[chunk_row][chunk_col]); diff --git a/test/swmr_common.c b/test/swmr_common.c index b323769..925dc33 100644 --- a/test/swmr_common.c +++ b/test/swmr_common.c @@ -26,7 +26,8 @@ #include "h5test.h" #include "swmr_common.h" - +#include "vds_swmr.h" + /*******************/ /* Local Variables */ /*******************/ @@ -73,6 +74,27 @@ unsigned symbol_count[NLEVELS] = {100, 200, 400, 800, 1600}; /* Array of dataset information entries (1 per dataset) */ symbol_info_t *symbol_info[NLEVELS]; +hsize_t PLANES[N_SOURCES][RANK] = { + {1, SM_HEIGHT, WIDTH}, + {1, LG_HEIGHT, WIDTH}, + {1, SM_HEIGHT, WIDTH}, + {1, LG_HEIGHT, WIDTH}, + {1, SM_HEIGHT, WIDTH}, + {1, LG_HEIGHT, WIDTH} +}; + +char FILE_NAMES[N_SOURCES][NAME_LEN] = { + {"vds_swmr_src_a.h5"}, + {"vds_swmr_src_b.h5"}, + {"vds_swmr_src_c.h5"}, + {"vds_swmr_src_d.h5"}, + {"vds_swmr_src_e.h5"}, + {"vds_swmr_src_f.h5"} +}; + +char VDS_FILE_NAME[NAME_LEN] = "vds_swmr.h5"; +char SOURCE_DSET_PATH[NAME_LEN] = "/source_dset"; +char VDS_DSET_NAME[NAME_LEN] = "vds_dset"; /*------------------------------------------------------------------------- * Function: choose_dataset diff --git a/test/trefer.c b/test/trefer.c index 441b7aa..fe237d7 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -566,8 +566,8 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) hsize_t *coords; /* Coordinate buffer */ hsize_t low[SPACE2_RANK]; /* Selection bounds */ hsize_t high[SPACE2_RANK]; /* Selection bounds */ - H5R_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ + H5R_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ H5R_ref_t nvrbuf[3]={{{{0}}},{{{101}}},{{{255}}}}; /* buffer with non-valid refs */ uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ *drbuf; /* Buffer for reading numeric data from disk */ @@ -580,7 +580,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) hid_t dset_NA; /* Dataset id for undefined reference */ hid_t space_NA; /* Dataspace id for undefined reference */ hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */ - H5R_ref_t rdata_NA[1]; /* Read buffer */ + H5R_ref_t rdata_NA[1]; /* Read buffer */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataset Region Reference Functions\n")); diff --git a/test/use_disable_mdc_flushes.c b/test/use_disable_mdc_flushes.c index 9cd202c..32a8244 100644 --- a/test/use_disable_mdc_flushes.c +++ b/test/use_disable_mdc_flushes.c @@ -108,7 +108,7 @@ parse_option(int argc, char * const argv[]) filename_g = optarg; break; case 'n': /* number of planes to write/read */ - if ((nplanes_g = HDatoi(optarg)) <= 0){ + if ((nplanes_g = (hsize_t)HDatoi(optarg)) <= 0){ HDfprintf(stderr, "bad number of planes %s, must be a positive integer\n", optarg); usage(progname_g); Hgoto_error(-1); @@ -193,17 +193,17 @@ setup_parameters(int argc, char * const argv[]) return(-1); } /* set chunk dims */ - chunkdims_g[0] = chunkplanes_g; - chunkdims_g[1]= chunkdims_g[2] = chunksize_g; + chunkdims_g[0] = (hsize_t)chunkplanes_g; + chunkdims_g[1]= chunkdims_g[2] = (hsize_t)chunksize_g; /* set dataset initial and max dims */ dims_g[0] = 0; max_dims_g[0] = H5S_UNLIMITED; - dims_g[1] = dims_g[2] = max_dims_g[1] = max_dims_g[2] = chunksize_g; + dims_g[1] = dims_g[2] = max_dims_g[1] = max_dims_g[2] = (hsize_t)chunksize_g; /* set nplanes */ if (nplanes_g == 0) - nplanes_g = chunksize_g; + nplanes_g = (hsize_t)chunksize_g; /* show parameters and return */ show_parameters(); @@ -299,7 +299,7 @@ write_file(void) hid_t dcpl; /* Dataset creation property list */ char *name; UC_CTYPE *buffer, *bufptr; /* data buffer */ - hsize_t cz=chunksize_g; /* Chunk size */ + hsize_t cz=(hsize_t)chunksize_g; /* Chunk size */ hid_t f_sid; /* dataset file space id */ hid_t m_sid; /* memory space id */ int rank; /* rank */ @@ -413,8 +413,13 @@ write_file(void) /* fill buffer with value i+1 */ bufptr = buffer; for (j=0; j<dims[1]; j++) - for (k=0; k<dims[2]; k++) - *bufptr++ = i; + for (k=0; k<dims[2]; k++) { + if(i > SHRT_MAX) { + HDfprintf(stderr, "rank(%d) of dataset overflow\n", rank); + return -1; + } + *bufptr++ = (short)i; + } /* extend the dataset by one for new plane */ dims[0]=i+1; diff --git a/test/vds_swmr.h b/test/vds_swmr.h index 43c78a4..edb01bc 100644 --- a/test/vds_swmr.h +++ b/test/vds_swmr.h @@ -84,31 +84,17 @@ #define N_PLANES_TO_WRITE 25 /* Planes */ -H5TEST_DLLVAR hsize_t PLANES[N_SOURCES][RANK] = { - {1, SM_HEIGHT, WIDTH}, - {1, LG_HEIGHT, WIDTH}, - {1, SM_HEIGHT, WIDTH}, - {1, LG_HEIGHT, WIDTH}, - {1, SM_HEIGHT, WIDTH}, - {1, LG_HEIGHT, WIDTH} -}; +H5TEST_DLLVAR hsize_t PLANES[N_SOURCES][RANK]; /* File names for source datasets */ -H5TEST_DLLVAR char FILE_NAMES[N_SOURCES][NAME_LEN] = { - {"vds_swmr_src_a.h5"}, - {"vds_swmr_src_b.h5"}, - {"vds_swmr_src_c.h5"}, - {"vds_swmr_src_d.h5"}, - {"vds_swmr_src_e.h5"}, - {"vds_swmr_src_f.h5"} -}; +H5TEST_DLLVAR char FILE_NAMES[N_SOURCES][NAME_LEN]; /* VDS file name */ -H5TEST_DLLVAR char VDS_FILE_NAME[NAME_LEN] = "vds_swmr.h5"; +H5TEST_DLLVAR char VDS_FILE_NAME[NAME_LEN]; /* Dataset names */ -H5TEST_DLLVAR char SOURCE_DSET_PATH[NAME_LEN] = "/source_dset"; -H5TEST_DLLVAR char VDS_DSET_NAME[NAME_LEN] = "vds_dset"; +H5TEST_DLLVAR char SOURCE_DSET_PATH[NAME_LEN]; +H5TEST_DLLVAR char VDS_DSET_NAME[NAME_LEN]; /* Fill values */ #endif /* VDS_SWMR_H */ diff --git a/test/vds_swmr_gen.c b/test/vds_swmr_gen.c index 2589653..b14ecc2 100644 --- a/test/vds_swmr_gen.c +++ b/test/vds_swmr_gen.c @@ -145,11 +145,13 @@ main(void) if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, MAX_DIMS[i], NULL) < 0) TEST_ERROR - start[1] = map_start; + start[1] = (hsize_t)map_start; if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, NULL, MAX_DIMS[i], NULL) < 0) TEST_ERROR - map_start += PLANES[i][1]; + if(PLANES[i][1] > INT_MAX) + TEST_ERROR + map_start += (int)PLANES[i][1]; /* Add VDS mapping */ if(H5Pset_virtual(vds_dcplid, vds_sid, FILE_NAMES[i], diff --git a/test/vds_swmr_reader.c b/test/vds_swmr_reader.c index eb9a82b..1ee65a0 100644 --- a/test/vds_swmr_reader.c +++ b/test/vds_swmr_reader.c @@ -45,8 +45,10 @@ main(void) TEST_ERROR /* Create the read buffer */ - n_elements = VDS_PLANE[1] * VDS_PLANE[2]; - size = n_elements * sizeof(int); + if(VDS_PLANE[1] * VDS_PLANE[2] > INT_MAX) + TEST_ERROR + n_elements = (int)(VDS_PLANE[1] * VDS_PLANE[2]); + size = (size_t)n_elements * sizeof(int); if(NULL == (buffer = (int *)HDmalloc(size))) TEST_ERROR |