summaryrefslogtreecommitdiffstats
path: root/testpar/t_pflush1.c
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/t_pflush1.c
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/t_pflush1.c')
-rw-r--r--testpar/t_pflush1.c15
1 files changed, 13 insertions, 2 deletions
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() */