summaryrefslogtreecommitdiffstats
path: root/test/objcopy.c
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 /test/objcopy.c
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 'test/objcopy.c')
-rw-r--r--test/objcopy.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/test/objcopy.c b/test/objcopy.c
index cc8f428..62fb22e 100644
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -646,7 +646,7 @@ test_copy_attach_attributes(hid_t loc_id, hid_t type_id)
goto done;
for (u = 0; u < num_attributes_g; u++) {
- HDsprintf(attr_name, "%u attr", u);
+ HDsnprintf(attr_name, sizeof(attr_name), "%u attr", u);
/* Set attribute data */
attr_data[0] = (int)(100 * u);
@@ -715,7 +715,7 @@ test_copy_attach_paired_attributes(hid_t loc_id, hid_t loc_id2, hid_t type_id)
goto done;
for (u = 0; u < num_attributes_g; u++) {
- HDsprintf(attr_name, "%u attr", u);
+ HDsnprintf(attr_name, sizeof(attr_name), "%u attr", u);
/* Set attribute data */
attr_data[0] = (int)(100 * u);
@@ -7933,17 +7933,17 @@ test_copy_group_deep(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_f
/* create nested sub-groups & datasets */
for (i = 0; i < NUM_SUB_GROUPS; i++) {
- HDsprintf(objname, "Group #%d", i);
+ HDsnprintf(objname, sizeof(objname), "Group #%d", i);
if ((gid_sub = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
for (j = 0; j < NUM_SUB_GROUPS; j++) {
- HDsprintf(objname, "Group #%d", j);
+ HDsnprintf(objname, sizeof(objname), "Group #%d", j);
if ((gid_sub2 = H5Gcreate2(gid_sub, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
for (k = 0; k < NUM_DATASETS; k++) {
- HDsprintf(objname, "Dataset #%d", k);
+ HDsnprintf(objname, sizeof(objname), "Dataset #%d", k);
/* add a dataset to the group */
if ((did = H5Dcreate2(gid_sub2, objname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT,
@@ -8222,12 +8222,12 @@ test_copy_group_wide_loop(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t
/* create wide sub-group hierarchy, with multiple links to higher groups */
for (u = 0; u < NUM_WIDE_LOOP_GROUPS; u++) {
- HDsprintf(objname, "%s-%u", NAME_GROUP_SUB, u);
+ HDsnprintf(objname, sizeof(objname), "%s-%u", NAME_GROUP_SUB, u);
if ((gid_sub = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
for (v = 0; v < NUM_WIDE_LOOP_GROUPS; v++) {
- HDsprintf(objname, "%s-%u", NAME_GROUP_SUB_SUB2, v);
+ HDsnprintf(objname, sizeof(objname), "%s-%u", NAME_GROUP_SUB_SUB2, v);
if ((gid_sub2 = H5Gcreate2(gid_sub, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;