summaryrefslogtreecommitdiffstats
path: root/test/istore.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/istore.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/istore.c')
-rw-r--r--test/istore.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/test/istore.c b/test/istore.c
index f198aad..144355e 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -271,20 +271,21 @@ test_extend(hid_t f, const char *prefix, size_t nx, size_t ny, size_t nz)
if (!ny) {
ndims = 1;
ny = nz = 1;
- HDsprintf(dims, "%lu", (unsigned long)nx);
+ HDsnprintf(dims, sizeof(dims), "%lu", (unsigned long)nx);
}
else {
ndims = 2;
nz = 1;
- HDsprintf(dims, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
+ HDsnprintf(dims, sizeof(dims), "%lux%lu", (unsigned long)nx, (unsigned long)ny);
}
}
else {
ndims = 3;
- HDsprintf(dims, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
+ HDsnprintf(dims, sizeof(dims), "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny,
+ (unsigned long)nz);
}
- HDsprintf(s, "istore extend: %s", dims);
+ HDsnprintf(s, sizeof(s), "istore extend: %s", dims);
TESTING(s);
buf = (uint8_t *)HDmalloc(nx * ny * nz);
check = (uint8_t *)HDmalloc(nx * ny * nz);
@@ -298,7 +299,7 @@ test_extend(hid_t f, const char *prefix, size_t nx, size_t ny, size_t nz)
max_corner[2] = 0;
/* Build the new empty object */
- HDsprintf(name, "%s_%s", prefix, dims);
+ HDsnprintf(name, sizeof(name), "%s_%s", prefix, dims);
if ((dataset = new_object(f, name, ndims, whole_size, whole_size)) < 0) {
HDfprintf(stderr, " Cannot create %u-d object `%s'\n", ndims, name);
goto error;
@@ -468,20 +469,21 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks, size_t nx, size_t ny, s
if (!ny) {
ndims = 1;
ny = nz = 1;
- HDsprintf(dims, "%lu", (unsigned long)nx);
+ HDsnprintf(dims, sizeof(dims), "%lu", (unsigned long)nx);
}
else {
ndims = 2;
nz = 1;
- HDsprintf(dims, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
+ HDsnprintf(dims, sizeof(dims), "%lux%lu", (unsigned long)nx, (unsigned long)ny);
}
}
else {
ndims = 3;
- HDsprintf(dims, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
+ HDsnprintf(dims, sizeof(dims), "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny,
+ (unsigned long)nz);
}
- HDsprintf(s, "istore sparse: %s", dims);
+ HDsnprintf(s, sizeof(s), "istore sparse: %s", dims);
TESTING(s);
if (skip_test) {
SKIPPED();
@@ -500,7 +502,7 @@ test_sparse(hid_t f, const char *prefix, size_t nblocks, size_t nx, size_t ny, s
size[2] = nz;
/* Build the new empty object */
- HDsprintf(name, "%s_%s", prefix, dims);
+ HDsnprintf(name, sizeof(name), "%s_%s", prefix, dims);
if ((dataset = new_object(f, name, ndims, whole_size, chunk_dims)) < 0) {
HDprintf(" Cannot create %u-d object `%s'\n", ndims, name);
goto error;