summaryrefslogtreecommitdiffstats
path: root/testpar
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2022-05-01 20:54:41 (GMT)
committerGitHub <noreply@github.com>2022-05-01 20:54:41 (GMT)
commit2ba7a01bfff451b043e2ec00811c0aad78921545 (patch)
tree31dc785e35a95578ea9fbb491fbc931e62234302 /testpar
parent5eba258d90aa89c3d1d58f1b5ef93c1cf9821c29 (diff)
downloadhdf5-2ba7a01bfff451b043e2ec00811c0aad78921545.zip
hdf5-2ba7a01bfff451b043e2ec00811c0aad78921545.tar.gz
hdf5-2ba7a01bfff451b043e2ec00811c0aad78921545.tar.bz2
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
Diffstat (limited to 'testpar')
-rw-r--r--testpar/t_2Gio.c20
-rw-r--r--testpar/t_cache.c34
-rw-r--r--testpar/t_mdset.c6
-rw-r--r--testpar/t_mpi.c34
-rw-r--r--testpar/t_pflush1.c15
-rw-r--r--testpar/t_pflush2.c18
-rw-r--r--testpar/t_shapesame.c17
-rw-r--r--testpar/testphdf5.c17
8 files changed, 132 insertions, 29 deletions
diff --git a/testpar/t_2Gio.c b/testpar/t_2Gio.c
index 79241c6..554d4ec 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_cache.c b/testpar/t_cache.c
index d889b3b..5d1cfdc 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
@@ -2264,13 +2264,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);
@@ -6938,6 +6938,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();
@@ -7053,6 +7070,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_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 39d7722..47cb6af 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 0500a2d..7e90cd2 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
@@ -209,5 +217,8 @@ error:
HDprintf("THERE WAS A REAL ERROR IN t_pflush1.\n");
HDfflush(stdout);
+ 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 8cf40d0..af2e57d 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 1ead1b8..d7b5305 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);
@@ -544,6 +552,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();