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 /test/testmeta.c | |
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 'test/testmeta.c')
-rw-r--r-- | test/testmeta.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/testmeta.c b/test/testmeta.c index a3b5160..a62977b 100644 --- a/test/testmeta.c +++ b/test/testmeta.c @@ -83,7 +83,7 @@ main(void) for (i = 0; i < NEXTARRAYS; i++) { /* Create dataset */ - HDsprintf(name, "/ExtArray%06d", i); + HDsnprintf(name, sizeof(name), "/ExtArray%06d", i); dataset_id = H5Dcreate2(file_id, name, H5T_NATIVE_FLOAT, dataspace_id, H5P_DEFAULT, prop_id, H5P_DEFAULT); @@ -108,7 +108,7 @@ main(void) floatval = (float)j; /* Create group to hold data arrays for this object */ - HDsprintf(name, "/DataArray/%06d", j); + HDsnprintf(name, sizeof(name), "/DataArray/%06d", j); group_id = H5Gcreate2(file_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (group_id < 0) { HDfprintf(stderr, "Failed to create DataArray group.\n"); @@ -124,7 +124,7 @@ main(void) dataspace_id = H5Screate_simple(1, dims, maxdims); /* Create dataset */ - HDsprintf(name, "DataArray%06d", i); + HDsnprintf(name, sizeof(name), "DataArray%06d", i); dataset_id = H5Dcreate2(group_id, name, H5T_NATIVE_FLOAT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (dataset_id < 0) { @@ -170,7 +170,7 @@ main(void) /* Extend attribute arrays */ for (i = 0; i < NEXTARRAYS; i++) { /* Open extendable dataset */ - HDsprintf(name, "/ExtArray%06d", i); + HDsnprintf(name, sizeof(name), "/ExtArray%06d", i); dataset_id = H5Dopen2(file_id, name, H5P_DEFAULT); if (dataset_id < 0) { HDfprintf(stderr, "Failed to open ExtArray dataset.\n"); |