summaryrefslogtreecommitdiffstats
path: root/testpar
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2022-06-22 18:58:18 (GMT)
committerGitHub <noreply@github.com>2022-06-22 18:58:18 (GMT)
commitc064d3481b582653c1e0d0043a17527fd73e8c4d (patch)
tree396a5e13954c19b803aa80465938cde15140b176 /testpar
parentd6f05069c1a3642bbebf7ec27e7df809f0675f13 (diff)
downloadhdf5-c064d3481b582653c1e0d0043a17527fd73e8c4d.zip
hdf5-c064d3481b582653c1e0d0043a17527fd73e8c4d.tar.gz
hdf5-c064d3481b582653c1e0d0043a17527fd73e8c4d.tar.bz2
sprintf to snprintf (#1815)
* Straightforward conversion of sprintf to the safer snprintf * Trickier conversion of sprintf to safer snprintf This involved minor changes to private function signatures to take the size of the buffer. * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'testpar')
-rw-r--r--testpar/t_2Gio.c11
-rw-r--r--testpar/t_dset.c5
-rw-r--r--testpar/t_mdset.c30
-rw-r--r--testpar/t_vfd.c99
4 files changed, 91 insertions, 54 deletions
diff --git a/testpar/t_2Gio.c b/testpar/t_2Gio.c
index 63d6b69..ad8a15e 100644
--- a/testpar/t_2Gio.c
+++ b/testpar/t_2Gio.c
@@ -3704,9 +3704,10 @@ test_actual_io_mode(int selection_mode)
/* Test values */
if (actual_chunk_opt_mode_expected != (H5D_mpio_actual_chunk_opt_mode_t)-1 &&
actual_io_mode_expected != (H5D_mpio_actual_io_mode_t)-1) {
- HDsprintf(message, "Actual Chunk Opt Mode has the correct value for %s.\n", test_name);
+ HDsnprintf(message, sizeof(message), "Actual Chunk Opt Mode has the correct value for %s.\n",
+ test_name);
VRFY((actual_chunk_opt_mode_write == actual_chunk_opt_mode_expected), message);
- HDsprintf(message, "Actual IO Mode has the correct value for %s.\n", test_name);
+ HDsnprintf(message, sizeof(message), "Actual IO Mode has the correct value for %s.\n", test_name);
VRFY((actual_io_mode_write == actual_io_mode_expected), message);
}
else {
@@ -4100,10 +4101,12 @@ test_no_collective_cause_mode(int selection_mode)
/* Test values */
HDmemset(message, 0, sizeof(message));
- HDsprintf(message, "Local cause of Broken Collective I/O has the correct value for %s.\n", test_name);
+ HDsnprintf(message, sizeof(message),
+ "Local cause of Broken Collective I/O has the correct value for %s.\n", test_name);
VRFY((no_collective_cause_local_write == no_collective_cause_local_expected), message);
HDmemset(message, 0, sizeof(message));
- HDsprintf(message, "Global cause of Broken Collective I/O has the correct value for %s.\n", test_name);
+ HDsnprintf(message, sizeof(message),
+ "Global cause of Broken Collective I/O has the correct value for %s.\n", test_name);
VRFY((no_collective_cause_global_write == no_collective_cause_global_expected), message);
/* Release some resources */
diff --git a/testpar/t_dset.c b/testpar/t_dset.c
index eb11b32..f34cc1d 100644
--- a/testpar/t_dset.c
+++ b/testpar/t_dset.c
@@ -3262,9 +3262,10 @@ test_actual_io_mode(int selection_mode)
/* Test values */
if (actual_chunk_opt_mode_expected != (H5D_mpio_actual_chunk_opt_mode_t)-1 &&
actual_io_mode_expected != (H5D_mpio_actual_io_mode_t)-1) {
- HDsprintf(message, "Actual Chunk Opt Mode has the correct value for %s.\n", test_name);
+ HDsnprintf(message, sizeof(message), "Actual Chunk Opt Mode has the correct value for %s.\n",
+ test_name);
VRFY((actual_chunk_opt_mode_write == actual_chunk_opt_mode_expected), message);
- HDsprintf(message, "Actual IO Mode has the correct value for %s.\n", test_name);
+ HDsnprintf(message, sizeof(message), "Actual IO Mode has the correct value for %s.\n", test_name);
VRFY((actual_io_mode_write == actual_io_mode_expected), message);
}
else {
diff --git a/testpar/t_mdset.c b/testpar/t_mdset.c
index 339ca33..54d75e6 100644
--- a/testpar/t_mdset.c
+++ b/testpar/t_mdset.c
@@ -183,7 +183,7 @@ multiple_dset_write(void)
VRFY((ret >= 0), "set fill-value succeeded");
for (n = 0; n < ndatasets; n++) {
- HDsprintf(dname, "dataset %d", n);
+ HDsnprintf(dname, sizeof(dname), "dataset %d", n);
dataset = H5Dcreate2(iof, dname, H5T_NATIVE_DOUBLE, filespace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
VRFY((dataset > 0), dname);
@@ -878,11 +878,11 @@ collective_group_write(void)
/* creates ngroups groups under the root group, writes chunked
* datasets in parallel. */
for (m = 0; m < ngroups; m++) {
- HDsprintf(gname, "group%d", m);
+ HDsnprintf(gname, sizeof(gname), "group%d", m);
gid = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
VRFY((gid > 0), gname);
- HDsprintf(dname, "dataset%d", m);
+ HDsnprintf(dname, sizeof(dname), "dataset%d", m);
did = H5Dcreate2(gid, dname, H5T_NATIVE_INT, filespace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
VRFY((did > 0), dname);
@@ -979,12 +979,12 @@ group_dataset_read(hid_t fid, int mpi_rank, int m)
VRFY((outdata != NULL), "HDmalloc succeeded for outdata");
/* open every group under root group. */
- HDsprintf(gname, "group%d", m);
+ HDsnprintf(gname, sizeof(gname), "group%d", m);
gid = H5Gopen2(fid, gname, H5P_DEFAULT);
VRFY((gid > 0), gname);
/* check the data. */
- HDsprintf(dname, "dataset%d", m);
+ HDsnprintf(dname, sizeof(dname), "dataset%d", m);
did = H5Dopen2(gid, dname, H5P_DEFAULT);
VRFY((did > 0), dname);
@@ -1080,7 +1080,7 @@ multiple_group_write(void)
/* creates ngroups groups under the root group, writes datasets in
* parallel. */
for (m = 0; m < ngroups; m++) {
- HDsprintf(gname, "group%d", m);
+ HDsnprintf(gname, sizeof(gname), "group%d", m);
gid = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
VRFY((gid > 0), gname);
@@ -1136,7 +1136,7 @@ write_dataset(hid_t memspace, hid_t filespace, hid_t gid)
VRFY((outme != NULL), "HDmalloc succeeded for outme");
for (n = 0; n < NDATASET; n++) {
- HDsprintf(dname, "dataset%d", n);
+ HDsnprintf(dname, sizeof(dname), "dataset%d", n);
did = H5Dcreate2(gid, dname, H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
VRFY((did > 0), dname);
@@ -1174,7 +1174,7 @@ create_group_recursive(hid_t memspace, hid_t filespace, hid_t gid, int counter)
}
#endif /* BARRIER_CHECKS */
- HDsprintf(gname, "%dth_child_group", counter + 1);
+ HDsnprintf(gname, sizeof(gname), "%dth_child_group", counter + 1);
child_gid = H5Gcreate2(gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
VRFY((child_gid > 0), gname);
@@ -1228,7 +1228,7 @@ multiple_group_read(void)
/* open every group under root group. */
for (m = 0; m < ngroups; m++) {
- HDsprintf(gname, "group%d", m);
+ HDsnprintf(gname, sizeof(gname), "group%d", m);
gid = H5Gopen2(fid, gname, H5P_DEFAULT);
VRFY((gid > 0), gname);
@@ -1285,7 +1285,7 @@ read_dataset(hid_t memspace, hid_t filespace, hid_t gid)
VRFY((outdata != NULL), "HDmalloc succeeded for outdata");
for (n = 0; n < NDATASET; n++) {
- HDsprintf(dname, "dataset%d", n);
+ HDsnprintf(dname, sizeof(dname), "dataset%d", n);
did = H5Dopen2(gid, dname, H5P_DEFAULT);
VRFY((did > 0), dname);
@@ -1336,7 +1336,7 @@ recursive_read_group(hid_t memspace, hid_t filespace, hid_t gid, int counter)
nerrors += err_num;
if (counter < GROUP_DEPTH) {
- HDsprintf(gname, "%dth_child_group", counter + 1);
+ HDsnprintf(gname, sizeof(gname), "%dth_child_group", counter + 1);
child_gid = H5Gopen2(gid, gname, H5P_DEFAULT);
VRFY((child_gid > 0), gname);
recursive_read_group(memspace, filespace, child_gid, counter + 1);
@@ -1358,7 +1358,7 @@ write_attribute(hid_t obj_id, int this_type, int num)
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
if (this_type == is_group) {
- HDsprintf(attr_name, "Group Attribute %d", num);
+ HDsnprintf(attr_name, sizeof(attr_name), "Group Attribute %d", num);
sid = H5Screate(H5S_SCALAR);
aid = H5Acreate2(obj_id, attr_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT);
H5Awrite(aid, H5T_NATIVE_INT, &num);
@@ -1366,7 +1366,7 @@ write_attribute(hid_t obj_id, int this_type, int num)
H5Sclose(sid);
} /* end if */
else if (this_type == is_dset) {
- HDsprintf(attr_name, "Dataset Attribute %d", num);
+ HDsnprintf(attr_name, sizeof(attr_name), "Dataset Attribute %d", num);
for (i = 0; i < 8; i++)
attr_data[i] = i;
sid = H5Screate_simple(dspace_rank, dspace_dims, NULL);
@@ -1389,14 +1389,14 @@ read_attribute(hid_t obj_id, int this_type, int num)
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
if (this_type == is_group) {
- HDsprintf(attr_name, "Group Attribute %d", num);
+ HDsnprintf(attr_name, sizeof(attr_name), "Group Attribute %d", num);
aid = H5Aopen(obj_id, attr_name, H5P_DEFAULT);
H5Aread(aid, H5T_NATIVE_INT, &in_num);
vrfy_errors = dataset_vrfy(NULL, NULL, NULL, group_block, &in_num, &num);
H5Aclose(aid);
}
else if (this_type == is_dset) {
- HDsprintf(attr_name, "Dataset Attribute %d", num);
+ HDsnprintf(attr_name, sizeof(attr_name), "Dataset Attribute %d", num);
for (i = 0; i < 8; i++)
out_data[i] = i;
aid = H5Aopen(obj_id, attr_name, H5P_DEFAULT);
diff --git a/testpar/t_vfd.c b/testpar/t_vfd.c
index 81e4983..ad296ad 100644
--- a/testpar/t_vfd.c
+++ b/testpar/t_vfd.c
@@ -571,17 +571,20 @@ vector_read_test_1(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer_
if (xfer_mode == H5FD_MPIO_INDEPENDENT) {
- sprintf(test_title, "parallel vector read test 1 -- %s / independent", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 1 -- %s / independent",
+ vfd_name);
}
else if (coll_opt_mode == H5FD_MPIO_INDIVIDUAL_IO) {
- sprintf(test_title, "parallel vector read test 1 -- %s / col op / ind I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 1 -- %s / col op / ind I/O",
+ vfd_name);
}
else {
HDassert(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO);
- sprintf(test_title, "parallel vector read test 1 -- %s / col op / col I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 1 -- %s / col op / col I/O",
+ vfd_name);
}
TESTING(test_title);
@@ -817,17 +820,20 @@ vector_read_test_2(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer_
if (xfer_mode == H5FD_MPIO_INDEPENDENT) {
- sprintf(test_title, "parallel vector read test 2 -- %s / independent", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 2 -- %s / independent",
+ vfd_name);
}
else if (coll_opt_mode == H5FD_MPIO_INDIVIDUAL_IO) {
- sprintf(test_title, "parallel vector read test 2 -- %s / col op / ind I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 2 -- %s / col op / ind I/O",
+ vfd_name);
}
else {
HDassert(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO);
- sprintf(test_title, "parallel vector read test 2 -- %s / col op / col I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 2 -- %s / col op / col I/O",
+ vfd_name);
}
TESTING(test_title);
@@ -1139,17 +1145,20 @@ vector_read_test_3(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer_
if (xfer_mode == H5FD_MPIO_INDEPENDENT) {
- sprintf(test_title, "parallel vector read test 3 -- %s / independent", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 3 -- %s / independent",
+ vfd_name);
}
else if (coll_opt_mode == H5FD_MPIO_INDIVIDUAL_IO) {
- sprintf(test_title, "parallel vector read test 3 -- %s / col op / ind I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 3 -- %s / col op / ind I/O",
+ vfd_name);
}
else {
HDassert(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO);
- sprintf(test_title, "parallel vector read test 3 -- %s / col op / col I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 3 -- %s / col op / col I/O",
+ vfd_name);
}
TESTING(test_title);
@@ -1508,17 +1517,20 @@ vector_read_test_4(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer_
if (xfer_mode == H5FD_MPIO_INDEPENDENT) {
- sprintf(test_title, "parallel vector read test 4 -- %s / independent", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 4 -- %s / independent",
+ vfd_name);
}
else if (coll_opt_mode == H5FD_MPIO_INDIVIDUAL_IO) {
- sprintf(test_title, "parallel vector read test 4 -- %s / col op / ind I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 4 -- %s / col op / ind I/O",
+ vfd_name);
}
else {
HDassert(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO);
- sprintf(test_title, "parallel vector read test 4 -- %s / col op / col I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 4 -- %s / col op / col I/O",
+ vfd_name);
}
TESTING(test_title);
@@ -1951,17 +1963,20 @@ vector_read_test_5(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer_
if (xfer_mode == H5FD_MPIO_INDEPENDENT) {
- sprintf(test_title, "parallel vector read test 5 -- %s / independent", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 5 -- %s / independent",
+ vfd_name);
}
else if (coll_opt_mode == H5FD_MPIO_INDIVIDUAL_IO) {
- sprintf(test_title, "parallel vector read test 5 -- %s / col op / ind I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 5 -- %s / col op / ind I/O",
+ vfd_name);
}
else {
HDassert(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO);
- sprintf(test_title, "parallel vector read test 5 -- %s / col op / col I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector read test 5 -- %s / col op / col I/O",
+ vfd_name);
}
TESTING(test_title);
@@ -2204,17 +2219,20 @@ vector_write_test_1(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer
if (xfer_mode == H5FD_MPIO_INDEPENDENT) {
- sprintf(test_title, "parallel vector write test 1 -- %s / independent", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 1 -- %s / independent",
+ vfd_name);
}
else if (coll_opt_mode == H5FD_MPIO_INDIVIDUAL_IO) {
- sprintf(test_title, "parallel vector write test 1 -- %s / col op / ind I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 1 -- %s / col op / ind I/O",
+ vfd_name);
}
else {
HDassert(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO);
- sprintf(test_title, "parallel vector write test 1 -- %s / col op / col I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 1 -- %s / col op / col I/O",
+ vfd_name);
}
TESTING(test_title);
@@ -2403,17 +2421,20 @@ vector_write_test_2(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer
if (xfer_mode == H5FD_MPIO_INDEPENDENT) {
- sprintf(test_title, "parallel vector write test 2 -- %s / independent", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 2 -- %s / independent",
+ vfd_name);
}
else if (coll_opt_mode == H5FD_MPIO_INDIVIDUAL_IO) {
- sprintf(test_title, "parallel vector write test 2 -- %s / col op / ind I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 2 -- %s / col op / ind I/O",
+ vfd_name);
}
else {
HDassert(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO);
- sprintf(test_title, "parallel vector write test 2 -- %s / col op / col I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 2 -- %s / col op / col I/O",
+ vfd_name);
}
TESTING(test_title);
@@ -2668,17 +2689,20 @@ vector_write_test_3(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer
if (xfer_mode == H5FD_MPIO_INDEPENDENT) {
- sprintf(test_title, "parallel vector write test 3 -- %s / independent", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 3 -- %s / independent",
+ vfd_name);
}
else if (coll_opt_mode == H5FD_MPIO_INDIVIDUAL_IO) {
- sprintf(test_title, "parallel vector write test 3 -- %s / col op / ind I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 3 -- %s / col op / ind I/O",
+ vfd_name);
}
else {
HDassert(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO);
- sprintf(test_title, "parallel vector write test 3 -- %s / col op / col I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 3 -- %s / col op / col I/O",
+ vfd_name);
}
TESTING(test_title);
@@ -2950,17 +2974,20 @@ vector_write_test_4(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer
if (xfer_mode == H5FD_MPIO_INDEPENDENT) {
- sprintf(test_title, "parallel vector write test 4 -- %s / independent", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 4 -- %s / independent",
+ vfd_name);
}
else if (coll_opt_mode == H5FD_MPIO_INDIVIDUAL_IO) {
- sprintf(test_title, "parallel vector write test 4 -- %s / col op / ind I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 4 -- %s / col op / ind I/O",
+ vfd_name);
}
else {
HDassert(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO);
- sprintf(test_title, "parallel vector write test 4 -- %s / col op / col I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 4 -- %s / col op / col I/O",
+ vfd_name);
}
TESTING(test_title);
@@ -3269,17 +3296,20 @@ vector_write_test_5(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer
if (xfer_mode == H5FD_MPIO_INDEPENDENT) {
- sprintf(test_title, "parallel vector write test 5 -- %s / independent", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 5 -- %s / independent",
+ vfd_name);
}
else if (coll_opt_mode == H5FD_MPIO_INDIVIDUAL_IO) {
- sprintf(test_title, "parallel vector write test 5 -- %s / col op / ind I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 5 -- %s / col op / ind I/O",
+ vfd_name);
}
else {
HDassert(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO);
- sprintf(test_title, "parallel vector write test 5 -- %s / col op / col I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 5 -- %s / col op / col I/O",
+ vfd_name);
}
TESTING(test_title);
@@ -3701,17 +3731,20 @@ vector_write_test_6(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer
if (xfer_mode == H5FD_MPIO_INDEPENDENT) {
- sprintf(test_title, "parallel vector write test 6 -- %s / independent", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 6 -- %s / independent",
+ vfd_name);
}
else if (coll_opt_mode == H5FD_MPIO_INDIVIDUAL_IO) {
- sprintf(test_title, "parallel vector write test 6 -- %s / col op / ind I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 6 -- %s / col op / ind I/O",
+ vfd_name);
}
else {
HDassert(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO);
- sprintf(test_title, "parallel vector write test 6 -- %s / col op / col I/O", vfd_name);
+ snprintf(test_title, sizeof(test_title), "parallel vector write test 6 -- %s / col op / col I/O",
+ vfd_name);
}
TESTING(test_title);