diff options
author | jhendersonHDF <jhenderson@hdfgroup.org> | 2022-05-03 17:57:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 17:57:19 (GMT) |
commit | 493846dbf4793b7e9f6ce5e1d8b8cfc29705ecca (patch) | |
tree | 9053e2f8881464c63630dddee33bc9ba9dafe53c /testpar | |
parent | 5f00066eacdf2b2ddb3cf92635bea99eb1aee85e (diff) | |
download | hdf5-493846dbf4793b7e9f6ce5e1d8b8cfc29705ecca.zip hdf5-493846dbf4793b7e9f6ce5e1d8b8cfc29705ecca.tar.gz hdf5-493846dbf4793b7e9f6ce5e1d8b8cfc29705ecca.tar.bz2 |
[1.12 Merge]Hdf5 1 12 warnings fixes (#1715)
* Warnings fixes (#1680)
* Clean stack size warnings in sio_engine (#1687)
* Fixes stack size warnings in tcoords.c (#1688)
* Address some warnings from casting away of const (#1684)
* Fixes stack size warnings in ntypes (#1695)
* Fixes stack size warnings in dtransform (#1696)
* Fixes stack size warnings in set_extent test (#1698)
* Be a bit safer with signed arithmetic, thus quieting some signed-overflow warnings from GCC (#1706)
* Avoid a signed overflow: check the range of `entry_ptr->age` before
increasing it instead of increasing it and then checking the range.
This quiets a GCC warning.
* Avoid the potential for signed overflow by rewriting expressions
`MAX(0, fwidth - n)` as `MAX(n, fwidth) - n` for various `n`.
This change quiets some GCC warnings.
* Change some local variables that cannot take sensible negative values
from signed to unsigned. This quiets GCC warnings about potential
signed overflow.
* In a handful of instances, check the range of a signed integer before
increasing/decreasing it, just in case the increase/decrease overflows.
This quiets a handful of GCC signed-overflow warnings.
* Committing clang-format changes
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Fix object size warnings in cache.c test (#1701)
* Fix some const cast and stack/static object size warnings (#1700)
* Fix various warnings
* Move HDfree_const to H5private.h for wider use
* Print output from all ranks in parallel tests on allocation failure
* Move const pointer freeing macro to h5test.h for now
* Stop lying about H5S_t const-ness (#1209)
Hyperslabs can be reworked inside several H5S callbacks, making H5S_t
non-const in some places where it is marked const. This change switches
these incorrectly const H5S_t pointer parameters and variables to
non-const where appropriate.
* Fix a few warnings after recent H5S const-related changes (#1225)
* Adjustments for HDF5 1.12
Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com>
Co-authored-by: David Young <dyoung@hdfgroup.org>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'testpar')
-rw-r--r-- | testpar/t_2Gio.c | 20 | ||||
-rw-r--r-- | testpar/t_bigio.c | 4 | ||||
-rw-r--r-- | testpar/t_cache.c | 34 | ||||
-rw-r--r-- | testpar/t_filters_parallel.c | 6 | ||||
-rw-r--r-- | testpar/t_mdset.c | 6 | ||||
-rw-r--r-- | testpar/t_mpi.c | 34 | ||||
-rw-r--r-- | testpar/t_pflush1.c | 16 | ||||
-rw-r--r-- | testpar/t_pflush2.c | 18 | ||||
-rw-r--r-- | testpar/t_shapesame.c | 17 | ||||
-rw-r--r-- | testpar/testphdf5.c | 17 |
10 files changed, 139 insertions, 33 deletions
diff --git a/testpar/t_2Gio.c b/testpar/t_2Gio.c index 4570fbc..8b548ed 100644 --- a/testpar/t_2Gio.c +++ b/testpar/t_2Gio.c @@ -78,7 +78,7 @@ void * old_client_data; /* previous error handler arg.*/ #define NFILENAME 3 #define PARATESTFILE filenames[0] const char *FILENAME[NFILENAME] = {"ParaTest", "Hugefile", NULL}; -char filenames[NFILENAME][PATH_MAX]; +char * filenames[NFILENAME]; hid_t fapl; /* file access property list */ MPI_Comm test_comm = MPI_COMM_WORLD; @@ -224,7 +224,7 @@ parse_options(int argc, char **argv) n = sizeof(FILENAME) / sizeof(FILENAME[0]) - 1; /* exclude the NULL */ for (i = 0; i < n; i++) - if (h5_fixname(FILENAME[i], fapl, filenames[i], sizeof(filenames[i])) == NULL) { + if (h5_fixname(FILENAME[i], fapl, filenames[i], PATH_MAX) == NULL) { HDprintf("h5_fixname failed\n"); nerrors++; return (1); @@ -4585,6 +4585,8 @@ main(int argc, char **argv) MPI_Comm_size(test_comm, &mpi_size); MPI_Comm_rank(test_comm, &mpi_rank); + HDmemset(filenames, 0, sizeof(filenames)); + dim0 = BIG_X_FACTOR; dim1 = BIG_Y_FACTOR; dim2 = BIG_Z_FACTOR; @@ -4601,6 +4603,15 @@ main(int argc, char **argv) HDprintf("Failed to turn off atexit processing. Continue.\n"); }; H5open(); + + HDmemset(filenames, 0, sizeof(filenames)); + for (int i = 0; i < NFILENAME; i++) { + if (NULL == (filenames[i] = HDmalloc(PATH_MAX))) { + HDprintf("couldn't allocate filename array\n"); + MPI_Abort(MPI_COMM_WORLD, -1); + } + } + /* Set the internal transition size to allow use of derived datatypes * without having to actually read or write large datasets (>2GB). */ @@ -4665,6 +4676,11 @@ main(int argc, char **argv) if (mpi_rank == 0) HDremove(FILENAME[0]); + for (int i = 0; i < NFILENAME; i++) { + HDfree(filenames[i]); + filenames[i] = NULL; + } + H5close(); if (test_comm != MPI_COMM_WORLD) { MPI_Comm_free(&test_comm); diff --git a/testpar/t_bigio.c b/testpar/t_bigio.c index 0a971c5..406e7bf 100644 --- a/testpar/t_bigio.c +++ b/testpar/t_bigio.c @@ -1151,14 +1151,14 @@ single_rank_independent_io(void) VRFY_G((mspace_id >= 0), "H5Screate_simple mspace_id succeeded"); /* Write data */ - H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, H5P_DEFAULT, data); + ret = H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, H5P_DEFAULT, data); VRFY_G((ret >= 0), "H5Dwrite succeeded"); /* Wipe buffer */ HDmemset(data, 0, LARGE_DIM * sizeof(int)); /* Read data back */ - H5Dread(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, H5P_DEFAULT, data); + ret = H5Dread(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, H5P_DEFAULT, data); VRFY_G((ret >= 0), "H5Dread succeeded"); /* Verify data */ diff --git a/testpar/t_cache.c b/testpar/t_cache.c index 83c1dc3..216028a 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -41,7 +41,7 @@ const char *FILENAME[NFILENAME] = {"CacheTestDummy", NULL}; #ifndef PATH_MAX #define PATH_MAX 512 #endif /* !PATH_MAX */ -char filenames[NFILENAME][PATH_MAX]; +char * filenames[NFILENAME]; hid_t fapl; /* file access property list */ haddr_t max_addr = 0; /* used to store the end of * the address space used by @@ -192,7 +192,7 @@ struct datum { #define NUM_DATA_ENTRIES 100000 -struct datum data[NUM_DATA_ENTRIES]; +struct datum *data = NULL; /* Many tests use the size of data array as the size of test loops. * On some machines, this results in unacceptably long test runs. @@ -231,7 +231,7 @@ int virt_num_data_entries = NUM_DATA_ENTRIES; * *****************************************************************************/ -int data_index[NUM_DATA_ENTRIES]; +int *data_index = NULL; /***************************************************************************** * The following two #defines are used to control code that is in turn used @@ -2252,13 +2252,13 @@ datum_deserialize(const void H5_ATTR_NDEBUG_UNUSED *image_ptr, H5_ATTR_UNUSED si static herr_t datum_image_len(const void *thing, size_t *image_len) { - int idx; - struct datum *entry_ptr; + int idx; + const struct datum *entry_ptr; HDassert(thing); HDassert(image_len); - entry_ptr = (struct datum *)thing; + entry_ptr = (const struct datum *)thing; idx = addr_to_datum_index(entry_ptr->base_addr); @@ -6923,6 +6923,23 @@ main(int argc, char **argv) goto finish; } + if (NULL == (data = HDmalloc(NUM_DATA_ENTRIES * sizeof(*data)))) { + HDprintf(" Couldn't allocate data array. Exiting.\n"); + MPI_Abort(MPI_COMM_WORLD, -1); + } + if (NULL == (data_index = HDmalloc(NUM_DATA_ENTRIES * sizeof(*data_index)))) { + HDprintf(" Couldn't allocate data index array. Exiting.\n"); + MPI_Abort(MPI_COMM_WORLD, -1); + } + + HDmemset(filenames, 0, sizeof(filenames)); + for (int i = 0; i < NFILENAME; i++) { + if (NULL == (filenames[i] = HDmalloc(PATH_MAX))) { + HDprintf("couldn't allocate filename array\n"); + MPI_Abort(MPI_COMM_WORLD, -1); + } + } + set_up_file_communicator(); setup_derived_types(); @@ -7037,6 +7054,11 @@ main(int argc, char **argv) #endif finish: + if (data_index) + HDfree(data_index); + if (data) + HDfree(data); + /* make sure all processes are finished before final report, cleanup * and exit. */ diff --git a/testpar/t_filters_parallel.c b/testpar/t_filters_parallel.c index 731f493..d7e3123 100644 --- a/testpar/t_filters_parallel.c +++ b/testpar/t_filters_parallel.c @@ -7857,8 +7857,10 @@ test_edge_chunks_overlap(const char *parent_group, H5Z_filter_t filter_id, hid_t * edge chunk and writes to just a portion of the edge chunk. */ static void -test_edge_chunks_partial_write(const char *parent_group, H5Z_filter_t filter_id, hid_t fapl_id, hid_t dcpl_id, - hid_t dxpl_id) +test_edge_chunks_partial_write(const char H5_ATTR_PARALLEL_UNUSED * parent_group, + H5Z_filter_t H5_ATTR_PARALLEL_UNUSED filter_id, + hid_t H5_ATTR_PARALLEL_UNUSED fapl_id, hid_t H5_ATTR_PARALLEL_UNUSED dcpl_id, + hid_t H5_ATTR_PARALLEL_UNUSED dxpl_id) { /* TODO */ } diff --git a/testpar/t_mdset.c b/testpar/t_mdset.c index 97d5966..339ca33 100644 --- a/testpar/t_mdset.c +++ b/testpar/t_mdset.c @@ -1977,6 +1977,7 @@ rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) /* Tell the reader to check the file up to steps. */ steps++; Reader_check(mrc, steps, steps_done); + VRFY((MPI_SUCCESS == mrc), "Reader_check failed"); /* * Step 2: write attributes to each dataset @@ -2031,6 +2032,7 @@ rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) /* Tell the reader to check the file up to steps. */ steps++; Reader_check(mrc, steps, steps_done); + VRFY((MPI_SUCCESS == mrc), "Reader_check failed"); /* * Step 3: write large attributes to each dataset @@ -2078,6 +2080,7 @@ rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) /* Tell the reader to check the file up to steps. */ steps++; Reader_check(mrc, steps, steps_done); + VRFY((MPI_SUCCESS == mrc), "Reader_check failed"); /* * Step 4: write different large attributes to each dataset @@ -2111,6 +2114,7 @@ rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) /* Tell the reader to check the file up to steps. */ steps++; Reader_check(mrc, steps, steps_done); + VRFY((MPI_SUCCESS == mrc), "Reader_check failed"); /* Step 5: Close all objects and the file */ @@ -2165,10 +2169,12 @@ rr_obj_hdr_flush_confusion_writer(MPI_Comm comm) /* Tell the reader to check the file up to steps. */ steps++; Reader_check(mrc, steps, steps_done); + VRFY((MPI_SUCCESS == mrc), "Reader_check failed"); /* All done. Inform reader to end. */ steps = 0; Reader_check(mrc, steps, steps_done); + VRFY((MPI_SUCCESS == mrc), "Reader_check failed"); if (verbose) HDfprintf(stdout, "%0d:%s: Done.\n", mpi_rank, fcn_name); diff --git a/testpar/t_mpi.c b/testpar/t_mpi.c index 96cbc4b..1e685d3 100644 --- a/testpar/t_mpi.c +++ b/testpar/t_mpi.c @@ -41,18 +41,18 @@ static int errors_sum(int nerrs); static int test_mpio_overlap_writes(char *filename) { - int mpi_size, mpi_rank; - MPI_Comm comm; - MPI_Info info = MPI_INFO_NULL; - int color, mrc; - MPI_File fh; - int i; - int vrfyerrs, nerrs; - unsigned char buf[4093]; /* use some prime number for size */ - int bufsize = sizeof(buf); - MPI_Offset stride; - MPI_Offset mpi_off; - MPI_Status mpi_stat; + int mpi_size, mpi_rank; + MPI_Comm comm; + MPI_Info info = MPI_INFO_NULL; + int color, mrc; + MPI_File fh; + int i; + int vrfyerrs, nerrs; + unsigned char *buf = NULL; + int bufsize; + MPI_Offset stride; + MPI_Offset mpi_off; + MPI_Status mpi_stat; if (VERBOSE_MED) HDprintf("MPIO independent overlapping writes test on file %s\n", filename); @@ -70,6 +70,13 @@ test_mpio_overlap_writes(char *filename) return 0; } + bufsize = 4093; /* use some prime number for size */ + if (NULL == (buf = HDmalloc((size_t)bufsize))) { + if (MAINPROCESS) + HDprintf("couldn't allocate buffer\n"); + return 1; + } + /* splits processes 0 to n-2 into one comm. and the last one into another */ color = ((mpi_rank < (mpi_size - 1)) ? 0 : 1); mrc = MPI_Comm_split(MPI_COMM_WORLD, color, mpi_rank, &comm); @@ -159,6 +166,9 @@ test_mpio_overlap_writes(char *filename) */ mrc = MPI_Barrier(MPI_COMM_WORLD); VRFY((mrc == MPI_SUCCESS), "Sync before leaving test"); + + HDfree(buf); + return (nerrs); } diff --git a/testpar/t_pflush1.c b/testpar/t_pflush1.c index 7d02959..49b6ec9 100644 --- a/testpar/t_pflush1.c +++ b/testpar/t_pflush1.c @@ -25,7 +25,7 @@ const char *FILENAME[] = {"flush", "noflush", NULL}; -static int data_g[100][100]; +static int *data_g = NULL; #define N_GROUPS 100 @@ -77,7 +77,7 @@ create_test_file(char *name, size_t name_length, hid_t fapl_id) /* Write some data */ for (i = 0; i < dims[0]; i++) for (j = 0; j < dims[1]; j++) - data_g[i][j] = (int)(i + (i * j) + j); + data_g[(i * 100) + j] = (int)(i + (i * j) + j); if (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, dxpl_id, data_g) < 0) goto error; @@ -146,6 +146,9 @@ main(int argc, char *argv[]) HDexit(EXIT_FAILURE); } + if (NULL == (data_g = HDmalloc(100 * 100 * sizeof(*data_g)))) + goto error; + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; if (H5Pset_fapl_mpio(fapl_id, comm, info) < 0) @@ -192,6 +195,11 @@ main(int argc, char *argv[]) HDfflush(stdout); HDfflush(stderr); + if (data_g) { + HDfree(data_g); + data_g = NULL; + } + /* Always exit with a failure code! * * In accordance with the standard, not having all processes @@ -207,5 +215,9 @@ error: HDfflush(stderr); HDprintf("*** ERROR ***\n"); HDprintf("THERE WAS A REAL ERROR IN t_pflush1.\n"); + + if (data_g) + HDfree(data_g); + HD_exit(EXIT_FAILURE); } /* end main() */ diff --git a/testpar/t_pflush2.c b/testpar/t_pflush2.c index f4e6602..6f06055 100644 --- a/testpar/t_pflush2.c +++ b/testpar/t_pflush2.c @@ -26,7 +26,7 @@ const char *FILENAME[] = {"flush", "noflush", NULL}; -static int data_g[100][100]; +static int *data_g = NULL; #define N_GROUPS 100 @@ -77,9 +77,10 @@ check_test_file(char *name, size_t name_length, hid_t fapl_id) for (i = 0; i < dims[0]; i++) { for (j = 0; j < dims[1]; j++) { val = (int)(i + (i * j) + j); - if (data_g[i][j] != val) { + if (data_g[(i * 100) + j] != val) { H5_FAILED(); - HDprintf(" data_g[%lu][%lu] = %d\n", (unsigned long)i, (unsigned long)j, data_g[i][j]); + HDprintf(" data_g[%lu][%lu] = %d\n", (unsigned long)i, (unsigned long)j, + data_g[(i * 100) + j]); HDprintf(" should be %d\n", val); } } @@ -170,6 +171,9 @@ main(int argc, char *argv[]) HDexit(EXIT_SUCCESS); } + if (NULL == (data_g = HDmalloc(100 * 100 * sizeof(*data_g)))) + goto error; + if ((fapl_id1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; if (H5Pset_fapl_mpio(fapl_id1, comm, info) < 0) @@ -213,10 +217,18 @@ main(int argc, char *argv[]) h5_clean_files(&FILENAME[0], fapl_id1); h5_clean_files(&FILENAME[1], fapl_id2); + if (data_g) { + HDfree(data_g); + data_g = NULL; + } + MPI_Finalize(); HDexit(EXIT_SUCCESS); error: + if (data_g) + HDfree(data_g); + HDexit(EXIT_FAILURE); } /* end main() */ diff --git a/testpar/t_shapesame.c b/testpar/t_shapesame.c index 0a18781..d265761 100644 --- a/testpar/t_shapesame.c +++ b/testpar/t_shapesame.c @@ -3956,7 +3956,7 @@ void * old_client_data; /* previous error handler arg.*/ #define NFILENAME 2 #define PARATESTFILE filenames[0] const char *FILENAME[NFILENAME] = {"ShapeSameTest", NULL}; -char filenames[NFILENAME][PATH_MAX]; +char * filenames[NFILENAME]; hid_t fapl; /* file access property list */ #ifdef USE_PAUSE @@ -4144,7 +4144,7 @@ parse_options(int argc, char **argv) n = sizeof(FILENAME) / sizeof(FILENAME[0]) - 1; /* exclude the NULL */ for (i = 0; i < n; i++) - if (h5_fixname(FILENAME[i], fapl, filenames[i], sizeof(filenames[i])) == NULL) { + if (h5_fixname(FILENAME[i], fapl, filenames[i], PATH_MAX) == NULL) { HDprintf("h5_fixname failed\n"); nerrors++; return (1); @@ -4302,6 +4302,14 @@ main(int argc, char **argv) H5open(); h5_show_hostname(); + HDmemset(filenames, 0, sizeof(filenames)); + for (int i = 0; i < NFILENAME; i++) { + if (NULL == (filenames[i] = HDmalloc(PATH_MAX))) { + HDprintf("couldn't allocate filename array\n"); + MPI_Abort(MPI_COMM_WORLD, -1); + } + } + /* Initialize testing framework */ TestInit(argv[0], usage, parse_options); @@ -4366,6 +4374,11 @@ main(int argc, char **argv) HDprintf("===================================\n"); } + for (int i = 0; i < NFILENAME; i++) { + HDfree(filenames[i]); + filenames[i] = NULL; + } + /* close HDF5 library */ H5close(); diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c index e24e1e4..288c7b2 100644 --- a/testpar/testphdf5.c +++ b/testpar/testphdf5.c @@ -43,7 +43,7 @@ int dxfer_coll_type = DXFER_COLLECTIVE_IO; #define NFILENAME 2 #define PARATESTFILE filenames[0] const char *FILENAME[NFILENAME] = {"ParaTest", NULL}; -char filenames[NFILENAME][PATH_MAX]; +char * filenames[NFILENAME]; hid_t fapl; /* file access property list */ #ifdef USE_PAUSE @@ -231,7 +231,7 @@ parse_options(int argc, char **argv) n = sizeof(FILENAME) / sizeof(FILENAME[0]) - 1; /* exclude the NULL */ for (i = 0; i < n; i++) - if (h5_fixname(FILENAME[i], fapl, filenames[i], sizeof(filenames[i])) == NULL) { + if (h5_fixname(FILENAME[i], fapl, filenames[i], PATH_MAX) == NULL) { HDprintf("h5_fixname failed\n"); nerrors++; return (1); @@ -336,6 +336,14 @@ main(int argc, char **argv) H5open(); h5_show_hostname(); + HDmemset(filenames, 0, sizeof(filenames)); + for (int i = 0; i < NFILENAME; i++) { + if (NULL == (filenames[i] = HDmalloc(PATH_MAX))) { + HDprintf("couldn't allocate filename array\n"); + MPI_Abort(MPI_COMM_WORLD, -1); + } + } + /* Initialize testing framework */ TestInit(argv[0], usage, parse_options); @@ -542,6 +550,11 @@ main(int argc, char **argv) HDprintf("===================================\n"); } + for (int i = 0; i < NFILENAME; i++) { + HDfree(filenames[i]); + filenames[i] = NULL; + } + /* close HDF5 library */ H5close(); |