diff options
author | Sean McBride <sean@rogue-research.com> | 2022-06-22 18:58:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-22 18:58:18 (GMT) |
commit | c064d3481b582653c1e0d0043a17527fd73e8c4d (patch) | |
tree | 396a5e13954c19b803aa80465938cde15140b176 /hl/test | |
parent | d6f05069c1a3642bbebf7ec27e7df809f0675f13 (diff) | |
download | hdf5-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 'hl/test')
-rw-r--r-- | hl/test/test_ds.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index 12b6840..cc716aa 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -1220,14 +1220,14 @@ test_detachscales(void) /* make datasets; they are three dimensional*/ for (i = 0; i < 2; i++) { - HDsprintf(dname, "D%d", i); + HDsnprintf(dname, sizeof(dname), "D%d", i); if (H5LTmake_dataset_int(fid, dname, rank3, dims, buf) < 0) goto out; } /* create datasets and make them dim. scales */ for (i = 0; i < 4; i++) { - HDsprintf(dname, "DS%d", i); + HDsnprintf(dname, sizeof(dname), "DS%d", i); if (H5LTmake_dataset_int(fid, dname, rank1, dims, buf) < 0) goto out; } @@ -1235,7 +1235,7 @@ test_detachscales(void) two scales attached */ if ((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) { for (i = 0; i < 4; i++) { - HDsprintf(dname, "DS%d", i); + HDsnprintf(dname, sizeof(dname), "DS%d", i); if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) goto out; if (H5DSattach_scale(did, dsid, (unsigned int)i % 3) < 0) @@ -1252,7 +1252,7 @@ test_detachscales(void) /* attach scales to the second dataset */ if ((did = H5Dopen2(fid, "D1", H5P_DEFAULT)) >= 0) { for (i = 0; i < 3; i++) { - HDsprintf(dname, "DS%d", i); + HDsnprintf(dname, sizeof(dname), "DS%d", i); if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) goto out; if (H5DSattach_scale(did, dsid, (unsigned int)i) < 0) @@ -1273,7 +1273,7 @@ test_detachscales(void) goto out; for (i = 0; i < 2; i++) { - HDsprintf(dname, "D%d", i); + HDsnprintf(dname, sizeof(dname), "D%d", i); if ((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) goto out; if (H5DSdetach_scale(did, dsid, (unsigned int)0) < 0) @@ -1303,7 +1303,7 @@ test_detachscales(void) sure that attribute "DIMENSION_LIST" doesn't exist anymore */ if ((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) { for (i = 1; i < 4; i++) { - HDsprintf(dname, "DS%d", i); + HDsnprintf(dname, sizeof(dname), "DS%d", i); if ((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) goto out; if (H5DSdetach_scale(did, dsid, (unsigned int)i % 3) < 0) @@ -2984,10 +2984,10 @@ test_simple(void) if ((sid = H5Screate_simple(rank, dims, NULL)) < 0) goto out; for (i = 0; i < 5; i++) { - HDsprintf(dname, "dset_%d", i); + HDsnprintf(dname, sizeof(dname), "dset_%d", i); if ((did = H5Dcreate2(gid, dname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; - HDsprintf(sname, "ds_%d", i); + HDsnprintf(sname, sizeof(sname), "ds_%d", i); if ((dsid = H5Dcreate2(gid, sname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; if (H5DSset_scale(dsid, "scale") < 0) @@ -3004,11 +3004,11 @@ test_simple(void) */ for (i = 0; i < 5; i++) { - HDsprintf(dname, "dset_%d", i); + HDsnprintf(dname, sizeof(dname), "dset_%d", i); if ((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0) goto out; for (j = 0; j < 5; j++) { - HDsprintf(sname, "ds_%d", j); + HDsnprintf(sname, sizeof(sname), "ds_%d", j); if ((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0) goto out; if (H5DSattach_scale(did, dsid, DIM0) < 0) @@ -3026,11 +3026,11 @@ test_simple(void) */ for (i = 0; i < 5; i++) { - HDsprintf(dname, "dset_%d", i); + HDsnprintf(dname, sizeof(dname), "dset_%d", i); if ((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0) goto out; for (j = 0; j < 5; j++) { - HDsprintf(sname, "ds_%d", j); + HDsnprintf(sname, sizeof(sname), "ds_%d", j); if ((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0) goto out; if (H5DSdetach_scale(did, dsid, DIM0) < 0) @@ -3048,11 +3048,11 @@ test_simple(void) */ for (i = 0; i < 5; i++) { - HDsprintf(dname, "dset_%d", i); + HDsnprintf(dname, sizeof(dname), "dset_%d", i); if ((did = H5Dopen2(gid, dname, H5P_DEFAULT)) < 0) goto out; for (j = 0; j < 5; j++) { - HDsprintf(sname, "ds_%d", j); + HDsnprintf(sname, sizeof(sname), "ds_%d", j); if ((dsid = H5Dopen2(gid, sname, H5P_DEFAULT)) < 0) goto out; if (H5DSattach_scale(did, dsid, DIM0) < 0) @@ -4292,7 +4292,7 @@ test_iterators(void) for (i = 0; i < 100; i++) { /* make a DS */ - HDsprintf(dname, "ds_%d", i); + HDsnprintf(dname, sizeof(dname), "ds_%d", i); if (H5LTmake_dataset_int(fid, dname, rankds, s1_dim, NULL) < 0) goto out; /* open */ @@ -4442,7 +4442,7 @@ test_rank(void) goto out; for (i = 0; i < 3; i++) { - HDsprintf(name, "ds_a_%d", i); + HDsnprintf(name, sizeof(name), "ds_a_%d", i); if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) goto out; if (H5DSattach_scale(did, dsid, (unsigned)i) < 0) @@ -4469,7 +4469,7 @@ test_rank(void) goto out; for (i = 0; i < 3; i++) { - HDsprintf(name, "ds_a_%d", i); + HDsnprintf(name, sizeof(name), "ds_a_%d", i); if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) goto out; if (H5DSdetach_scale(did, dsid, (unsigned)i) < 0) @@ -4495,7 +4495,7 @@ test_rank(void) goto out; for (i = 0; i < 3; i++) { - HDsprintf(name, "ds_a_%d", i); + HDsnprintf(name, sizeof(name), "ds_a_%d", i); if ((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) goto out; if (H5DSset_scale(dsid, name) < 0) |