summaryrefslogtreecommitdiffstats
path: root/tools/test/h5stat
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 /tools/test/h5stat
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 'tools/test/h5stat')
-rw-r--r--tools/test/h5stat/h5stat_gentest.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/test/h5stat/h5stat_gentest.c b/tools/test/h5stat/h5stat_gentest.c
index c775d6a..4d21a43 100644
--- a/tools/test/h5stat/h5stat_gentest.c
+++ b/tools/test/h5stat/h5stat_gentest.c
@@ -88,7 +88,7 @@ gen_newgrat_file(const char *fname)
/* Create NUM_GRPS groups in the root group */
for (i = 1; i <= NUM_GRPS; i++) {
- HDsprintf(name, "%s%d", GROUP_NAME, i);
+ HDsnprintf(name, sizeof(name), "%s%d", GROUP_NAME, i);
if ((gid = H5Gcreate2(fid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
if (H5Gclose(gid) < 0)
@@ -109,7 +109,7 @@ gen_newgrat_file(const char *fname)
/* Create NUM_ATTRS for the dataset */
for (i = 1; i <= NUM_ATTRS; i++) {
- HDsprintf(attrname, "%s%d", ATTR_NAME, i);
+ HDsnprintf(attrname, sizeof(attrname), "%s%d", ATTR_NAME, i);
if ((attr_id = H5Acreate2(did, attrname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
if (H5Aclose(attr_id) < 0)
@@ -211,7 +211,7 @@ gen_threshold_file(const char *fname)
/* Create 11 attributes for the dataset */
for (i = 1; i <= (THRES_NUM + 1); i++) {
- HDsprintf(name, "%s%d", THRES_ATTR_NAME, i);
+ HDsnprintf(name, sizeof(name), "%s%d", THRES_ATTR_NAME, i);
if ((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
if (H5Aclose(attr_id) < 0)
@@ -240,7 +240,7 @@ gen_threshold_file(const char *fname)
/* Create 10 attributes for the 2-D dataset */
for (i = 1; i <= THRES_NUM; i++) {
- HDsprintf(name, "%s%d", THRES_ATTR_NAME, i);
+ HDsnprintf(name, sizeof(name), "%s%d", THRES_ATTR_NAME, i);
if ((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
if (H5Aclose(attr_id) < 0)
@@ -264,7 +264,7 @@ gen_threshold_file(const char *fname)
/* Create 10 1-D datasets with non-zero dimension size for the group */
for (i = 1; i <= THRES_NUM; i++) {
/* set up dataset name */
- HDsprintf(name, "%s%d", THRES_DSET_NAME, i);
+ HDsnprintf(name, sizeof(name), "%s%d", THRES_DSET_NAME, i);
/* Create the dataset */
if ((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
@@ -286,7 +286,7 @@ gen_threshold_file(const char *fname)
/* Create 25 attributes for the group */
for (i = 1; i <= THRES_NUM_25; i++) {
/* Set up attribute name */
- HDsprintf(name, "%s%d", THRES_ATTR_GRP_NAME, i);
+ HDsnprintf(name, sizeof(name), "%s%d", THRES_ATTR_GRP_NAME, i);
/* Create the attribute */
if ((attr_id = H5Acreate2(gid, name, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT)) < 0)
@@ -308,7 +308,7 @@ gen_threshold_file(const char *fname)
/* Create 9 1-D datasets with non-zero dimension size for the group */
for (i = 1; i < THRES_NUM; i++) {
/* set up dataset name */
- HDsprintf(name, "%s%d", THRES_DSET_NAME, i);
+ HDsnprintf(name, sizeof(name), "%s%d", THRES_DSET_NAME, i);
/* Create the dataset */
if ((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)