summaryrefslogtreecommitdiffstats
path: root/test
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
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')
-rw-r--r--test/cache_tagging.c8
-rw-r--r--test/cork.c6
-rw-r--r--test/dtypes.c2
-rw-r--r--test/fheap.c4
-rw-r--r--test/filter_plugin.c18
-rw-r--r--test/h5test.c2
-rw-r--r--test/hyperslab.c55
-rw-r--r--test/istore.c22
-rw-r--r--test/lheap.c4
-rw-r--r--test/mf.c12
-rw-r--r--test/objcopy.c14
-rw-r--r--test/objcopy_ref.c2
-rw-r--r--test/ohdr.c2
-rw-r--r--test/stab.c29
-rw-r--r--test/swmr_common.c9
-rw-r--r--test/swmr_common.h8
-rw-r--r--test/swmr_generator.c2
-rw-r--r--test/tattr.c14
-rw-r--r--test/testmeta.c8
-rw-r--r--test/tfile.c16
-rw-r--r--test/th5o.c2
-rw-r--r--test/titerate.c8
-rw-r--r--test/unlink.c78
-rw-r--r--test/vfd.c20
24 files changed, 176 insertions, 169 deletions
diff --git a/test/cache_tagging.c b/test/cache_tagging.c
index 4d07116..f1571f0 100644
--- a/test/cache_tagging.c
+++ b/test/cache_tagging.c
@@ -839,7 +839,7 @@ check_multi_group_creation_tags(void)
for (i = 0; i < MULTIGROUPS; i++) {
- HDsprintf(gname, "%d", i);
+ HDsnprintf(gname, sizeof(gname), "%d", i);
if ((gid = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
if (H5Gclose(gid) < 0)
@@ -861,7 +861,7 @@ check_multi_group_creation_tags(void)
for (i = 0; i < MULTIGROUPS; i++) {
/* Re-open the group */
- HDsprintf(gname, "%d", i);
+ HDsnprintf(gname, sizeof(gname), "%d", i);
if ((gid = H5Gopen2(fid, gname, H5P_DEFAULT)) < 0)
TEST_ERROR;
@@ -988,7 +988,7 @@ check_link_iteration_tags(void)
/* Create many datasets in root group */
for (i = 0; i < 500; i++) {
- HDsprintf(dsetname, "Dset %d", i);
+ HDsnprintf(dsetname, sizeof(dsetname), "Dset %d", i);
if ((did = H5Dcreate2(fid, dsetname, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) <
0)
TEST_ERROR;
@@ -1151,7 +1151,7 @@ check_dense_attribute_tags(void)
for (i = 0; i < 50; i++) {
- HDsprintf(attrname, "attr %d", i);
+ HDsnprintf(attrname, sizeof(attrname), "attr %d", i);
if ((aid = H5Acreate2(did, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
if (H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0)
diff --git a/test/cork.c b/test/cork.c
index 7628d28..53d9065 100644
--- a/test/cork.c
+++ b/test/cork.c
@@ -396,7 +396,7 @@ verify_obj_dset_cork(hbool_t swmr)
/* Attach 8 attributes to the dataset */
for (i = 0; i < 8; i++) {
- HDsprintf(attrname, "attr %d", i);
+ HDsnprintf(attrname, sizeof(attrname), "attr %d", i);
if ((aid = H5Acreate2(did2, attrname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
if (H5Awrite(aid, H5T_NATIVE_INT, &i) < 0)
@@ -864,7 +864,7 @@ verify_group_cork(hbool_t swmr)
/* Attach 8 attributes to the third group: GRP3 */
for (i = 0; i < 8; i++) {
- HDsprintf(attrname, "attr %d", i);
+ HDsnprintf(attrname, sizeof(attrname), "attr %d", i);
if ((aid = H5Acreate2(gid3, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
if (H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0)
@@ -1081,7 +1081,7 @@ verify_named_cork(hbool_t swmr)
/* Attach 8 attributes to datatype: DT3 */
for (i = 0; i < 8; i++) {
- HDsprintf(attrname, "attr %d", i);
+ HDsnprintf(attrname, sizeof(attrname), "attr %d", i);
if ((aid = H5Acreate2(tid3, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
if (H5Awrite(aid, H5T_NATIVE_UINT, &i) < 0)
diff --git a/test/dtypes.c b/test/dtypes.c
index 218c019..f322d03 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -2322,7 +2322,7 @@ test_compound_11(void)
((big_t *)buf)[u].s1 = (char *)HDmalloc((size_t)32);
if (!((big_t *)buf)[u].s1)
TEST_ERROR;
- HDsprintf(((big_t *)buf)[u].s1, "%u", (unsigned)u);
+ HDsnprintf(((big_t *)buf)[u].s1, 32, "%u", (unsigned)u);
} /* end for */
/* Make copy of buffer before conversion */
diff --git a/test/fheap.c b/test/fheap.c
index 01de37f..7fec567 100644
--- a/test/fheap.c
+++ b/test/fheap.c
@@ -7669,7 +7669,7 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_
if (H5HF_remove(fh, heap_id[j]) < 0)
FAIL_STACK_ERROR;
- HDsprintf(obj2.b, "%s%2d", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", j);
+ HDsnprintf(obj2.b, sizeof(obj2.b), "%s%2d", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", j);
if (H5HF_insert(fh, (sizeof(obj2)), &obj2, heap_id[j]) < 0)
FAIL_STACK_ERROR;
} /* end for */
@@ -7680,7 +7680,7 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_
/* Insert object */
HDmemset(heap_id[i], 0, id_len);
- HDsprintf(obj1.b, "%s%2d", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", i);
+ HDsnprintf(obj1.b, sizeof(obj1.b), "%s%2d", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", i);
if (H5HF_insert(fh, (sizeof(obj1)), &obj1, heap_id[i]) < 0)
FAIL_STACK_ERROR;
} /* end for */
diff --git a/test/filter_plugin.c b/test/filter_plugin.c
index abbcc26..4dcf74a 100644
--- a/test/filter_plugin.c
+++ b/test/filter_plugin.c
@@ -847,7 +847,7 @@ test_creating_groups_using_plugins(hid_t fid)
for (i = 0; i < N_SUBGROUPS; i++) {
char *sp = subgroup_name;
- sp += HDsprintf(subgroup_name, SUBGROUP_PREFIX);
+ sp += HDsnprintf(subgroup_name, sizeof(subgroup_name), SUBGROUP_PREFIX);
HDsprintf(sp, "%d", i);
if ((sub_gid = H5Gcreate2(gid, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
@@ -906,7 +906,7 @@ test_opening_groups_using_plugins(hid_t fid)
for (i = 0; i < N_SUBGROUPS; i++) {
char *sp = subgroup_name;
- sp += HDsprintf(subgroup_name, SUBGROUP_PREFIX);
+ sp += HDsnprintf(subgroup_name, sizeof(subgroup_name), SUBGROUP_PREFIX);
HDsprintf(sp, "%d", i);
if ((sub_gid = H5Gopen2(gid, subgroup_name, H5P_DEFAULT)) < 0)
@@ -1015,7 +1015,7 @@ test_path_api_calls(void)
/* Add a bunch of paths to the path table */
for (u = 0; u < n_starting_paths; u++) {
- HDsprintf(path, "a_path_%u", u);
+ HDsnprintf(path, sizeof(path), "a_path_%u", u);
if (H5PLappend(path) < 0) {
HDfprintf(stderr, " at %u: %s\n", u, path);
TEST_ERROR;
@@ -1081,7 +1081,7 @@ test_path_api_calls(void)
/* Get path at the last index */
if ((path_len = H5PLget(n_starting_paths - 1, path, 256)) <= 0)
TEST_ERROR;
- HDsprintf(temp_name, "a_path_%u", n_starting_paths - 1);
+ HDsnprintf(temp_name, sizeof(temp_name), "a_path_%u", n_starting_paths - 1);
if (HDstrcmp(path, temp_name) != 0) {
HDfprintf(stderr, " get %u: %s\n", n_starting_paths - 1, path);
TEST_ERROR;
@@ -1135,7 +1135,7 @@ test_path_api_calls(void)
TESTING(" prepend");
/* Prepend one path */
- HDsprintf(path, "a_path_%d", n_starting_paths + 1);
+ HDsnprintf(path, sizeof(path), "a_path_%d", n_starting_paths + 1);
if (H5PLprepend(path) < 0) {
HDfprintf(stderr, " prepend %u: %s\n", n_starting_paths + 1, path);
TEST_ERROR;
@@ -1158,7 +1158,7 @@ test_path_api_calls(void)
/* Verify that the path was inserted at index zero */
if (H5PLget(0, path, 256) <= 0)
TEST_ERROR;
- HDsprintf(temp_name, "a_path_%d", n_starting_paths + 1);
+ HDsnprintf(temp_name, sizeof(temp_name), "a_path_%d", n_starting_paths + 1);
if (HDstrcmp(path, temp_name) != 0) {
HDfprintf(stderr, " get 0: %s\n", path);
TEST_ERROR;
@@ -1173,7 +1173,7 @@ test_path_api_calls(void)
TESTING(" replace");
/* Replace one path at index 1 */
- HDsprintf(path, "a_path_%u", n_starting_paths + 4);
+ HDsnprintf(path, sizeof(path), "a_path_%u", n_starting_paths + 4);
if (H5PLreplace(path, 1) < 0) {
HDfprintf(stderr, " replace 1: %s\n", path);
TEST_ERROR;
@@ -1192,7 +1192,7 @@ test_path_api_calls(void)
/* Check path at index 0 */
if (H5PLget(0, path, 256) <= 0)
TEST_ERROR;
- HDsprintf(temp_name, "a_path_%u", n_starting_paths + 1);
+ HDsnprintf(temp_name, sizeof(temp_name), "a_path_%u", n_starting_paths + 1);
if (HDstrcmp(path, temp_name) != 0) {
HDfprintf(stderr, " get 0: %s\n", path);
TEST_ERROR;
@@ -1240,7 +1240,7 @@ test_path_api_calls(void)
TESTING(" insert");
/* Insert one path at index 3*/
- HDsprintf(path, "a_path_%d", n_starting_paths + 5);
+ HDsnprintf(path, sizeof(path), "a_path_%d", n_starting_paths + 5);
if (H5PLinsert(path, 3) < 0) {
HDfprintf(stderr, " insert 3: %s\n", path);
TEST_ERROR;
diff --git a/test/h5test.c b/test/h5test.c
index ac15043..f39825c 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -355,7 +355,7 @@ h5_reset(void)
* Cause the library to emit some diagnostics early so they don't
* interfere with other formatted output.
*/
- HDsprintf(filename, "/tmp/h5emit-%05d.h5", HDgetpid());
+ HDsnprintf(filename, sizeof(filename), "/tmp/h5emit-%05d.h5", HDgetpid());
H5E_BEGIN_TRY
{
hid_t file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
diff --git a/test/hyperslab.c b/test/hyperslab.c
index 36e6b65..b816aae 100644
--- a/test/hyperslab.c
+++ b/test/hyperslab.c
@@ -163,19 +163,19 @@ test_fill(size_t nx, size_t ny, size_t nz, size_t di, size_t dj, size_t dk, size
if (0 == ny) {
ndims = 1;
ny = nz = 1;
- HDsprintf(dim, "%lu", (unsigned long)nx);
+ HDsnprintf(dim, sizeof(dim), "%lu", (unsigned long)nx);
} /* end if */
else {
ndims = 2;
nz = 1;
- HDsprintf(dim, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
+ HDsnprintf(dim, sizeof(dim), "%lux%lu", (unsigned long)nx, (unsigned long)ny);
} /* end else */
} /* end if */
else {
ndims = 3;
- HDsprintf(dim, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
+ HDsnprintf(dim, sizeof(dim), "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
} /* end else */
- HDsprintf(s, "Testing hyperslab fill %-11s variable hyperslab", dim);
+ HDsnprintf(s, sizeof(s), "Testing hyperslab fill %-11s variable hyperslab", dim);
HDprintf("%-70s", s);
HDfflush(stdout);
@@ -321,17 +321,17 @@ test_copy(int mode, size_t nx, size_t ny, size_t nz, size_t di, size_t dj, size_
if (0 == ny) {
ndims = 1;
ny = nz = 1;
- HDsprintf(dim, "%lu", (unsigned long)nx);
+ HDsnprintf(dim, sizeof(dim), "%lu", (unsigned long)nx);
} /* end if */
else {
ndims = 2;
nz = 1;
- HDsprintf(dim, "%lux%lu", (unsigned long)nx, (unsigned long)ny);
+ HDsnprintf(dim, sizeof(dim), "%lux%lu", (unsigned long)nx, (unsigned long)ny);
} /* end else */
} /* end if */
else {
ndims = 3;
- HDsprintf(dim, "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
+ HDsnprintf(dim, sizeof(dim), "%lux%lux%lu", (unsigned long)nx, (unsigned long)ny, (unsigned long)nz);
} /* end else */
switch (mode) {
@@ -364,7 +364,7 @@ test_copy(int mode, size_t nx, size_t ny, size_t nz, size_t di, size_t dj, size_
HDabort();
} /* end switch */
- HDsprintf(s, "Testing hyperslab copy %-11s %s", dim, sub);
+ HDsnprintf(s, sizeof(s), "Testing hyperslab copy %-11s %s", dim, sub);
HDprintf("%-70s", s);
HDfflush(stdout);
@@ -618,15 +618,15 @@ test_multifill(size_t nx)
s[0] = '\0';
for (i = 0; i < nx; i++) {
if (dst[i].left != 3333333)
- HDsprintf(s, "bad dst[%lu].left", (unsigned long)i);
+ HDsnprintf(s, sizeof(s), "bad dst[%lu].left", (unsigned long)i);
else if (!H5_DBL_ABS_EQUAL(dst[i].mid, fill.mid))
/* Check if two DOUBLE values are equal. If their difference
* is smaller than the EPSILON value for double, they are
* considered equal. See the definition in h5test.h.
*/
- HDsprintf(s, "bad dst[%lu].mid", (unsigned long)i);
+ HDsnprintf(s, sizeof(s), "bad dst[%lu].mid", (unsigned long)i);
else if (dst[i].right != 4444444)
- HDsprintf(s, "bad dst[%lu].right", (unsigned long)i);
+ HDsnprintf(s, sizeof(s), "bad dst[%lu].right", (unsigned long)i);
if (s[0]) {
H5_FAILED();
if (!HDisatty(1)) {
@@ -771,7 +771,8 @@ test_transpose(size_t nx, size_t ny)
char s[256];
hsize_t i, j;
- HDsprintf(s, "Testing 2d transpose by stride %4lux%-lud", (unsigned long)nx, (unsigned long)ny);
+ HDsnprintf(s, sizeof(s), "Testing 2d transpose by stride %4lux%-lud", (unsigned long)nx,
+ (unsigned long)ny);
HDprintf("%-70s", s);
HDfflush(stdout);
@@ -869,8 +870,8 @@ test_sub_super(size_t nx, size_t ny)
hsize_t i, j;
char s[256];
- HDsprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", (unsigned long)(2 * nx),
- (unsigned long)(2 * ny), (unsigned long)nx, (unsigned long)ny);
+ HDsnprintf(s, sizeof(s), "Testing image sampling %4lux%-4lu to %4lux%-4lu ", (unsigned long)(2 * nx),
+ (unsigned long)(2 * ny), (unsigned long)nx, (unsigned long)ny);
HDprintf("%-70s", s);
HDfflush(stdout);
@@ -919,8 +920,8 @@ test_sub_super(size_t nx, size_t ny)
* Test replicating pixels to produce an image twice as large in each
* dimension.
*/
- HDsprintf(s, "Testing image sampling %4lux%-4lu to %4lux%-4lu ", (unsigned long)nx, (unsigned long)ny,
- (unsigned long)(2 * nx), (unsigned long)(2 * ny));
+ HDsnprintf(s, sizeof(s), "Testing image sampling %4lux%-4lu to %4lux%-4lu ", (unsigned long)nx,
+ (unsigned long)ny, (unsigned long)(2 * nx), (unsigned long)(2 * ny));
HDprintf("%-70s", s);
HDfflush(stdout);
@@ -946,17 +947,17 @@ test_sub_super(size_t nx, size_t ny)
for (i = 0; i < nx; i++) {
for (j = 0; j < ny; j++) {
if (half[i * ny + j] != twice[4 * i * ny + 2 * j])
- HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j,
- (unsigned long)i * 2, (unsigned long)j * 2);
+ HDsnprintf(s, sizeof(s), "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i,
+ (unsigned long)j, (unsigned long)i * 2, (unsigned long)j * 2);
else if (half[i * ny + j] != twice[4 * i * ny + 2 * j + 1])
- HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j,
- (unsigned long)i * 2, (unsigned long)j * 2 + 1);
+ HDsnprintf(s, sizeof(s), "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i,
+ (unsigned long)j, (unsigned long)i * 2, (unsigned long)j * 2 + 1);
else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j])
- HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j,
- (unsigned long)i * 2 + 1, (unsigned long)j * 2);
+ HDsnprintf(s, sizeof(s), "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i,
+ (unsigned long)j, (unsigned long)i * 2 + 1, (unsigned long)j * 2);
else if (half[i * ny + j] != twice[(2 * i + 1) * 2 * ny + 2 * j + 1])
- HDsprintf(s, "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i, (unsigned long)j,
- (unsigned long)i * 2 + 1, (unsigned long)j * 2 + 1);
+ HDsnprintf(s, sizeof(s), "half[%lu][%lu] != twice[%lu][%lu]", (unsigned long)i,
+ (unsigned long)j, (unsigned long)i * 2 + 1, (unsigned long)j * 2 + 1);
if (s[0]) {
H5_FAILED();
if (!HDisatty(1)) {
@@ -1014,7 +1015,7 @@ test_array_fill(size_t lo, size_t hi)
size_t u, v, w; /* Local index variables */
char s[256];
- HDsprintf(s, "array filling %4lu-%-4lu elements", (unsigned long)lo, (unsigned long)hi);
+ HDsnprintf(s, sizeof(s), "array filling %4lu-%-4lu elements", (unsigned long)lo, (unsigned long)hi);
TESTING(s);
/* Initialize */
@@ -1078,8 +1079,8 @@ test_array_offset_n_calc(size_t n, size_t x, size_t y, size_t z)
hsize_t new_coords[ARRAY_OFFSET_NDIMS]; /* X, Y & X coordinates of offset */
char s[256];
- HDsprintf(s, "array offset %4lux%4lux%4lu elements", (unsigned long)z, (unsigned long)y,
- (unsigned long)x);
+ HDsnprintf(s, sizeof(s), "array offset %4lux%4lux%4lu elements", (unsigned long)z, (unsigned long)y,
+ (unsigned long)x);
TESTING(s);
/* Initialize */
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;
diff --git a/test/lheap.c b/test/lheap.c
index 1c6a6df..c9c6ca9 100644
--- a/test/lheap.c
+++ b/test/lheap.c
@@ -97,7 +97,7 @@ main(void)
goto error;
}
for (i = 0; i < NOBJS; i++) {
- HDsprintf(buf, "%03d-", i);
+ HDsnprintf(buf, sizeof(buf), "%03d-", i);
for (j = 4; j < i; j++)
buf[j] = (char)('0' + j % 10);
if (j > 4)
@@ -137,7 +137,7 @@ main(void)
goto error;
}
for (i = 0; i < NOBJS; i++) {
- HDsprintf(buf, "%03d-", i);
+ HDsnprintf(buf, sizeof(buf), "%03d-", i);
for (j = 4; j < i; j++)
buf[j] = (char)('0' + j % 10);
if (j > 4)
diff --git a/test/mf.c b/test/mf.c
index ce9d667..bed92e3 100644
--- a/test/mf.c
+++ b/test/mf.c
@@ -6586,22 +6586,22 @@ error:
memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; \
memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP; \
memb_map[H5FD_MEM_LHEAP] = H5FD_MEM_LHEAP; \
- HDsprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's'); \
+ HDsnprintf(sv[H5FD_MEM_SUPER], 64, "%%s-%c.h5", 's'); \
memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER]; \
memb_addr[H5FD_MEM_SUPER] = 0; \
- HDsprintf(sv[H5FD_MEM_BTREE], "%%s-%c.h5", 'b'); \
+ HDsnprintf(sv[H5FD_MEM_BTREE], 64, "%%s-%c.h5", 'b'); \
memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE]; \
memb_addr[H5FD_MEM_BTREE] = HADDR_MAX / 6; \
- HDsprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r'); \
+ HDsnprintf(sv[H5FD_MEM_DRAW], 64, "%%s-%c.h5", 'r'); \
memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; \
memb_addr[H5FD_MEM_DRAW] = HADDR_MAX / 3; \
- HDsprintf(sv[H5FD_MEM_GHEAP], "%%s-%c.h5", 'g'); \
+ HDsnprintf(sv[H5FD_MEM_GHEAP], 64, "%%s-%c.h5", 'g'); \
memb_name[H5FD_MEM_GHEAP] = sv[H5FD_MEM_GHEAP]; \
memb_addr[H5FD_MEM_GHEAP] = HADDR_MAX / 2; \
- HDsprintf(sv[H5FD_MEM_LHEAP], "%%s-%c.h5", 'l'); \
+ HDsnprintf(sv[H5FD_MEM_LHEAP], 64, "%%s-%c.h5", 'l'); \
memb_name[H5FD_MEM_LHEAP] = sv[H5FD_MEM_LHEAP]; \
memb_addr[H5FD_MEM_LHEAP] = HADDR_MAX * 2 / 3; \
- HDsprintf(sv[H5FD_MEM_OHDR], "%%s-%c.h5", 'o'); \
+ HDsnprintf(sv[H5FD_MEM_OHDR], 64, "%%s-%c.h5", 'o'); \
memb_name[H5FD_MEM_OHDR] = sv[H5FD_MEM_OHDR]; \
memb_addr[H5FD_MEM_OHDR] = HADDR_MAX * 5 / 6; \
}
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;
diff --git a/test/objcopy_ref.c b/test/objcopy_ref.c
index adc1a84..d10adf6 100644
--- a/test/objcopy_ref.c
+++ b/test/objcopy_ref.c
@@ -509,7 +509,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);
diff --git a/test/ohdr.c b/test/ohdr.c
index 6b31334..dc0497f 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -1883,7 +1883,7 @@ main(void)
/* Display info about testing */
low_string = h5_get_version_string(low);
high_string = h5_get_version_string(high);
- HDsprintf(msg, "Using file format version: (%s, %s)", low_string, high_string);
+ HDsnprintf(msg, sizeof(msg), "Using file format version: (%s, %s)", low_string, high_string);
HDputs(msg);
/* test on object continuation block */
diff --git a/test/stab.c b/test/stab.c
index d08ebca..b4c92a4 100644
--- a/test/stab.c
+++ b/test/stab.c
@@ -219,8 +219,9 @@ test_long(hid_t fcpl, hid_t fapl, hbool_t new_format)
for (i = 0; i < LONG_NAME_LEN; i++)
name1[i] = (char)('A' + i % 26);
name1[LONG_NAME_LEN - 1] = '\0';
- name2 = (char *)HDmalloc((size_t)((2 * LONG_NAME_LEN) + 2));
- HDsprintf(name2, "%s/%s", name1, name1);
+ size_t name2Len = (2 * LONG_NAME_LEN) + 2;
+ name2 = (char *)HDmalloc(name2Len);
+ HDsnprintf(name2, name2Len, "%s/%s", name1, name1);
/* Create groups */
if ((g1 = H5Gcreate2(fid, name1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
@@ -310,7 +311,7 @@ test_large(hid_t fcpl, hid_t fapl, hbool_t new_format)
if (H5G__has_stab_test(cwg) != FALSE)
TEST_ERROR;
for (i = 0; i < LARGE_NOBJS; i++) {
- HDsprintf(name, "%05d%05d", (HDrandom() % 100000), i);
+ HDsnprintf(name, sizeof(name), "%05d%05d", (HDrandom() % 100000), i);
if ((dir = H5Gcreate2(cwg, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
if (H5Gclose(dir) < 0)
@@ -452,7 +453,7 @@ lifecycle(hid_t fcpl, hid_t fapl2)
TEST_ERROR;
/* Create first "bottom" group */
- HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, (unsigned)0);
+ HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, (unsigned)0);
if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
@@ -475,7 +476,7 @@ lifecycle(hid_t fcpl, hid_t fapl2)
/* Create several more bottom groups, to push the top group almost to a symbol table */
/* (Start counting at '1', since we've already created one bottom group */
for (u = 1; u < LIFECYCLE_MAX_COMPACT; u++) {
- HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u);
+ HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, u);
if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
@@ -511,7 +512,7 @@ lifecycle(hid_t fcpl, hid_t fapl2)
TEST_ERROR;
/* Create one more "bottom" group, which should push top group into using a symbol table */
- HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u);
+ HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, u);
if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
@@ -545,7 +546,7 @@ lifecycle(hid_t fcpl, hid_t fapl2)
/* Unlink objects from top group */
while (u >= LIFECYCLE_MIN_DENSE) {
- HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u);
+ HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, u);
if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
@@ -562,7 +563,7 @@ lifecycle(hid_t fcpl, hid_t fapl2)
TEST_ERROR;
/* Unlink one more object from the group, which should transform back to using links */
- HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u);
+ HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, u);
if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
u--;
@@ -576,11 +577,11 @@ lifecycle(hid_t fcpl, hid_t fapl2)
TEST_ERROR;
/* Unlink last two objects from top group */
- HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u);
+ HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, u);
if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
u--;
- HDsprintf(objname, LIFECYCLE_BOTTOM_GROUP, u);
+ HDsnprintf(objname, sizeof(objname), LIFECYCLE_BOTTOM_GROUP, u);
if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
@@ -841,7 +842,7 @@ read_old(void)
/* Create a bunch of objects in the group */
for (u = 0; u < READ_OLD_NGROUPS; u++) {
- HDsprintf(objname, "Group %u", u);
+ HDsnprintf(objname, sizeof(objname), "Group %u", u);
if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
@@ -865,7 +866,7 @@ read_old(void)
/* Delete new objects from old group */
for (u = 0; u < READ_OLD_NGROUPS; u++) {
- HDsprintf(objname, "Group %u", u);
+ HDsnprintf(objname, sizeof(objname), "Group %u", u);
if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
@@ -977,7 +978,7 @@ no_compact(hid_t fcpl, hid_t fapl2)
TEST_ERROR;
/* Create first "bottom" group */
- HDsprintf(objname, NO_COMPACT_BOTTOM_GROUP, (unsigned)0);
+ HDsnprintf(objname, sizeof(objname), NO_COMPACT_BOTTOM_GROUP, (unsigned)0);
if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
@@ -998,7 +999,7 @@ no_compact(hid_t fcpl, hid_t fapl2)
TEST_ERROR;
/* Unlink object from top group */
- HDsprintf(objname, NO_COMPACT_BOTTOM_GROUP, (unsigned)0);
+ HDsnprintf(objname, sizeof(objname), NO_COMPACT_BOTTOM_GROUP, (unsigned)0);
if (H5Ldelete(gid, objname, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
diff --git a/test/swmr_common.c b/test/swmr_common.c
index b359bc6..9063ddd 100644
--- a/test/swmr_common.c
+++ b/test/swmr_common.c
@@ -162,6 +162,9 @@ create_symbol_datatype(void)
* Buffer for the created name. Must be pre-allocated.
* Since the name is formulaic, this isn't considered an issue.
*
+ * size_t name_buf_length
+ * The length in bytes of the name_buf buffer
+ *
* unsigned level
* The dataset's level
*
@@ -175,11 +178,11 @@ create_symbol_datatype(void)
*-------------------------------------------------------------------------
*/
int
-generate_name(char *name_buf, unsigned level, unsigned count)
+generate_name(char *name_buf, size_t name_buf_length, unsigned level, unsigned count)
{
HDassert(name_buf);
- HDsprintf(name_buf, "%u-%04u", level, count);
+ HDsnprintf(name_buf, name_buf_length, "%u-%04u", level, count);
return 0;
} /* end generate_name() */
@@ -206,7 +209,7 @@ generate_symbols(void)
for (v = 0; v < symbol_count[u]; v++) {
char name_buf[64];
- generate_name(name_buf, u, v);
+ generate_name(name_buf, sizeof(name_buf), u, v);
symbol_info[u][v].name = HDstrdup(name_buf);
symbol_info[u][v].dsid = -1;
symbol_info[u][v].nrecords = 0;
diff --git a/test/swmr_common.h b/test/swmr_common.h
index d0d829d..5fcf923 100644
--- a/test/swmr_common.h
+++ b/test/swmr_common.h
@@ -66,10 +66,10 @@ extern "C" {
H5TEST_DLL symbol_info_t *choose_dataset(void);
H5TEST_DLL hid_t create_symbol_datatype(void);
-H5TEST_DLL int generate_name(char *name_buf, unsigned level, unsigned count);
-H5TEST_DLL int generate_symbols(void);
-H5TEST_DLL int shutdown_symbols(void);
-H5TEST_DLL int print_metadata_retries_info(hid_t fid);
+H5TEST_DLL int generate_name(char *name_buf, size_t name_buf_length, unsigned level, unsigned count);
+H5TEST_DLL int generate_symbols(void);
+H5TEST_DLL int shutdown_symbols(void);
+H5TEST_DLL int print_metadata_retries_info(hid_t fid);
#ifdef __cplusplus
}
diff --git a/test/swmr_generator.c b/test/swmr_generator.c
index 93cfa0f..51caa27 100644
--- a/test/swmr_generator.c
+++ b/test/swmr_generator.c
@@ -188,7 +188,7 @@ gen_skeleton(const char *filename, hbool_t verbose, hbool_t swmr_write, int comp
hbool_t move_dataspace_message =
FALSE; /* Whether to move the dataspace message out of object header chunk #0 */
- generate_name(name_buf, u, v);
+ generate_name(name_buf, sizeof(name_buf), u, v);
if ((dsid = H5Dcreate2(fid, name_buf, tid, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
return -1;
diff --git a/test/tattr.c b/test/tattr.c
index 2859f4c..d214719 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -2737,7 +2737,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Aclose");
/* Rename attribute */
- HDsprintf(new_attrname, "new attr %02u", u);
+ HDsnprintf(new_attrname, sizeof(new_attrname), "new attr %02u", u);
/* Rename attribute */
ret = H5Arename_by_name(fid, DSET1_NAME, attrname, new_attrname, H5P_DEFAULT);
@@ -9015,7 +9015,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Create new attribute name */
- HDsprintf(attrname2, "new attr %02u", u);
+ HDsnprintf(attrname2, sizeof(attrname2), "new attr %02u", u);
/* Change second dataset's attribute's name */
ret = H5Arename_by_name(fid, DSET2_NAME, attrname, attrname2, H5P_DEFAULT);
@@ -10126,7 +10126,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
/* Create attributes on group */
for (i = 0; i < BUG2_NATTR; i++) {
- HDsprintf(aname, "%03u", i);
+ HDsnprintf(aname, sizeof(aname), "%03u", i);
aid = H5Acreate2(gid, aname, H5T_STD_I32LE, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(aid, FAIL, "H5Acreate2");
@@ -10136,7 +10136,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
/* Delete every other attribute */
for (i = 1; i < BUG2_NATTR; i += 2) {
- HDsprintf(aname, "%03u", i);
+ HDsnprintf(aname, sizeof(aname), "%03u", i);
ret = H5Adelete(gid, aname);
CHECK(ret, FAIL, "H5Adelete");
}
@@ -10160,7 +10160,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
/* Open an attribute in the middle */
i = (BUG2_NATTR / 4) * 2;
- HDsprintf(aname, "%03u", i);
+ HDsnprintf(aname, sizeof(aname), "%03u", i);
aid = H5Aopen(gid, aname, H5P_DEFAULT);
CHECK(aid, FAIL, "H5Aopen");
@@ -10203,7 +10203,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
/* Create attributes on group */
for (i = 0; i < BUG2_NATTR2; i++) {
- HDsprintf(aname, "%03u", i);
+ HDsnprintf(aname, sizeof(aname), "%03u", i);
aid = H5Acreate2(gid, aname, H5T_STD_I32LE, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(aid, FAIL, "H5Acreate2");
@@ -10213,7 +10213,7 @@ test_attr_bug2(hid_t fcpl, hid_t fapl)
/* Delete every other attribute */
for (i = 0; i < BUG2_NATTR2; i++) {
- HDsprintf(aname, "%03u", i);
+ HDsnprintf(aname, sizeof(aname), "%03u", i);
ret = H5Adelete(gid, aname);
CHECK(ret, FAIL, "H5Adelete");
}
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");
diff --git a/test/tfile.c b/test/tfile.c
index 717eb91..caf9c62 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -1111,14 +1111,14 @@ test_get_obj_ids(void)
/* creates NGROUPS groups under the root group */
for (m = 0; m < NGROUPS; m++) {
- HDsprintf(gname, "group%d", m);
+ HDsnprintf(gname, sizeof(gname), "group%d", m);
gid[m] = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(gid[m], FAIL, "H5Gcreate2");
}
/* create NDSETS datasets under the root group */
for (n = 0; n < NDSETS; n++) {
- HDsprintf(dname, "dataset%d", n);
+ HDsnprintf(dname, sizeof(dname), "dataset%d", n);
dset[n] = H5Dcreate2(fid, dname, H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(dset[n], FAIL, "H5Dcreate2");
}
@@ -1178,7 +1178,7 @@ test_get_obj_ids(void)
/* Open NDSETS datasets under the root group */
for (n = 0; n < NDSETS; n++) {
- HDsprintf(dname, "dataset%d", n);
+ HDsnprintf(dname, sizeof(dname), "dataset%d", n);
dset[n] = H5Dopen2(fid, dname, H5P_DEFAULT);
CHECK(dset[n], FAIL, "H5Dcreate2");
}
@@ -4473,7 +4473,7 @@ test_file_freespace(const char *env_h5_drvr)
/* Create datasets in file */
for (u = 0; u < 10; u++) {
- HDsprintf(name, "Dataset %u", u);
+ HDsnprintf(name, sizeof(name), "Dataset %u", u);
dset = H5Dcreate2(file, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
CHECK(dset, FAIL, "H5Dcreate2");
@@ -4496,7 +4496,7 @@ test_file_freespace(const char *env_h5_drvr)
/* Delete datasets in file */
for (k = 9; k >= 0; k--) {
- HDsprintf(name, "Dataset %u", (unsigned)k);
+ HDsnprintf(name, sizeof(name), "Dataset %u", (unsigned)k);
ret = H5Ldelete(file, name, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Ldelete");
} /* end for */
@@ -4624,7 +4624,7 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format)
/* Create datasets in file */
for (u = 0; u < 10; u++) {
- HDsprintf(name, "Dataset %u", u);
+ HDsnprintf(name, sizeof(name), "Dataset %u", u);
dset = H5Dcreate2(file, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
CHECK(dset, FAIL, "H5Dcreate2");
@@ -4642,7 +4642,7 @@ test_sects_freespace(const char *env_h5_drvr, hbool_t new_format)
/* Delete odd-numbered datasets in file */
for (u = 0; u < 10; u++) {
- HDsprintf(name, "Dataset %u", u);
+ HDsnprintf(name, sizeof(name), "Dataset %u", u);
if (u % 2) {
ret = H5Ldelete(file, name, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Ldelete");
@@ -7590,7 +7590,7 @@ test_incr_filesize(void)
/* Create datasets in file */
for (u = 0; u < 10; u++) {
- HDsprintf(name, "Dataset %u", u);
+ HDsnprintf(name, sizeof(name), "Dataset %u", u);
dset = H5Dcreate2(fid, name, H5T_STD_U32LE, dspace, H5P_DEFAULT, dcpl, H5P_DEFAULT);
CHECK(dset, FAIL, "H5Dcreate2");
diff --git a/test/th5o.c b/test/th5o.c
index 9504f7a..4ffcbef 100644
--- a/test/th5o.c
+++ b/test/th5o.c
@@ -1738,7 +1738,7 @@ test_h5o_getinfo_visit(void)
/* Attach 10 attributes to "group1" */
for (j = 0; j < 10; j++) {
/* Create the attribute name */
- HDsprintf(attrname, "attr%u", j);
+ HDsnprintf(attrname, sizeof(attrname), "attr%u", j);
/* Create the attribute */
aid = H5Acreate2(gid1, attrname, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(aid, FAIL, "H5Acreate2");
diff --git a/test/titerate.c b/test/titerate.c
index 1d87343..5796f11 100644
--- a/test/titerate.c
+++ b/test/titerate.c
@@ -156,7 +156,7 @@ test_iter_group(hid_t fapl, hbool_t new_format)
CHECK(filespace, FAIL, "H5Screate");
for (i = 0; i < NDATASETS; i++) {
- HDsprintf(name, "Dataset %d", i);
+ HDsnprintf(name, sizeof(name), "Dataset %d", i);
dataset = H5Dcreate2(file, name, datatype, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
@@ -436,7 +436,7 @@ test_iter_attr(hid_t fapl, hbool_t new_format)
CHECK(dataset, FAIL, "H5Dcreate2");
for (i = 0; i < NATTR; i++) {
- HDsprintf(name, "Attribute %02d", i);
+ HDsnprintf(name, sizeof(name), "Attribute %02d", i);
attribute = H5Acreate2(dataset, name, H5T_NATIVE_INT, filespace, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attribute, FAIL, "H5Acreate2");
@@ -649,7 +649,7 @@ test_iter_group_large(hid_t fapl)
/* Create a bunch of groups */
for (i = 0; i < ITER_NGROUPS; i++) {
- HDsprintf(gname, "Group_%d", i);
+ HDsnprintf(gname, sizeof(gname), "Group_%d", i);
/* Add the name to the list of objects in the root group */
HDstrcpy(names[i].name, gname);
@@ -766,7 +766,7 @@ test_grp_memb_funcs(hid_t fapl)
CHECK(filespace, FAIL, "H5Screate");
for (i = 0; i < NDATASETS; i++) {
- HDsprintf(name, "Dataset %d", i);
+ HDsnprintf(name, sizeof(name), "Dataset %d", i);
dataset = H5Dcreate2(file, name, datatype, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
CHECK(dataset, FAIL, "H5Dcreate2");
diff --git a/test/unlink.c b/test/unlink.c
index 2527e94..265c497 100644
--- a/test/unlink.c
+++ b/test/unlink.c
@@ -179,12 +179,12 @@ test_many(hid_t file)
/* Create a bunch of names and unlink them in order */
TESTING("forward unlink");
for (i = 0; i < how_many; i++) {
- HDsprintf(name, "obj_%05d", i);
+ HDsnprintf(name, sizeof(name), "obj_%05d", i);
if (H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
for (i = 0; i < how_many; i++) {
- HDsprintf(name, "obj_%05d", i);
+ HDsnprintf(name, sizeof(name), "obj_%05d", i);
if (H5Ldelete(work, name, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
@@ -193,12 +193,12 @@ test_many(hid_t file)
/* Create a bunch of names and unlink them in reverse order */
TESTING("backward unlink");
for (i = 0; i < how_many; i++) {
- HDsprintf(name, "obj_%05d", i);
+ HDsnprintf(name, sizeof(name), "obj_%05d", i);
if (H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
for (i = (how_many - 1); i >= 0; --i) {
- HDsprintf(name, "obj_%05d", i);
+ HDsnprintf(name, sizeof(name), "obj_%05d", i);
if (H5Ldelete(work, name, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
@@ -207,15 +207,15 @@ test_many(hid_t file)
/* Create a bunch of names and unlink them from both directions */
TESTING("inward unlink");
for (i = 0; i < how_many; i++) {
- HDsprintf(name, "obj_%05d", i);
+ HDsnprintf(name, sizeof(name), "obj_%05d", i);
if (H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
for (i = 0; i < how_many; i++) {
if (i % 2)
- HDsprintf(name, "obj_%05d", how_many - (1 + i / 2));
+ HDsnprintf(name, sizeof(name), "obj_%05d", how_many - (1 + i / 2));
else
- HDsprintf(name, "obj_%05d", i / 2);
+ HDsnprintf(name, sizeof(name), "obj_%05d", i / 2);
if (H5Ldelete(work, name, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
@@ -224,15 +224,15 @@ test_many(hid_t file)
/* Create a bunch of names and unlink them from the midle */
TESTING("outward unlink");
for (i = 0; i < how_many; i++) {
- HDsprintf(name, "obj_%05d", i);
+ HDsnprintf(name, sizeof(name), "obj_%05d", i);
if (H5Lcreate_hard(work, "/test_many_foo", H5L_SAME_LOC, name, H5P_DEFAULT, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
for (i = (how_many - 1); i >= 0; --i) {
if (i % 2)
- HDsprintf(name, "obj_%05d", how_many - (1 + i / 2));
+ HDsnprintf(name, sizeof(name), "obj_%05d", how_many - (1 + i / 2));
else
- HDsprintf(name, "obj_%05d", i / 2);
+ HDsnprintf(name, sizeof(name), "obj_%05d", i / 2);
if (H5Ldelete(work, name, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
@@ -938,7 +938,7 @@ test_filespace(hid_t fapl)
/* Alternate adding attributes to each one */
for (u = 0; u < FILESPACE_NATTR; u++) {
/* Set the name of the attribute to create */
- HDsprintf(objname, "%s %u", ATTRNAME, u);
+ HDsnprintf(objname, sizeof(objname), "%s %u", ATTRNAME, u);
/* Create an attribute on the first dataset */
if ((attr = H5Acreate2(dataset, objname, H5T_NATIVE_INT, attr_space, H5P_DEFAULT, H5P_DEFAULT)) < 0)
@@ -1070,7 +1070,7 @@ test_filespace(hid_t fapl)
/* Create a many groups to remove */
for (u = 0; u < UNLINK_NGROUPS; u++) {
- HDsprintf(objname, "%s %u", GROUPNAME, u);
+ HDsnprintf(objname, sizeof(objname), "%s %u", GROUPNAME, u);
if ((group = H5Gcreate2(file, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
if (H5Gclose(group) < 0)
@@ -1080,7 +1080,7 @@ test_filespace(hid_t fapl)
/* Remove the all the groups */
/* (Remove them in reverse order just to make file size calculation easier -QAK) */
for (u = UNLINK_NGROUPS; u > 0; u--) {
- HDsprintf(objname, "%s %u", GROUPNAME, (u - 1));
+ HDsnprintf(objname, sizeof(objname), "%s %u", GROUPNAME, (u - 1));
if (H5Ldelete(file, objname, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
@@ -1148,21 +1148,21 @@ test_filespace(hid_t fapl)
/* Create a complex group hierarchy to remove */
for (u = 0; u < FILESPACE_TOP_GROUPS; u++) {
/* Create group */
- HDsprintf(objname, "%s %u", GROUPNAME, u);
+ HDsnprintf(objname, sizeof(objname), "%s %u", GROUPNAME, u);
if ((group = H5Gcreate2(file, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
/* Create nested groups inside top groups */
for (v = 0; v < FILESPACE_NESTED_GROUPS; v++) {
/* Create group */
- HDsprintf(objname, "%s %u", GROUP2NAME, v);
+ HDsnprintf(objname, sizeof(objname), "%s %u", GROUP2NAME, v);
if ((group2 = H5Gcreate2(group, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
/* Create datasets inside nested groups */
for (w = 0; w < FILESPACE_NDATASETS; w++) {
/* Create & close a dataset */
- HDsprintf(objname, "%s %u", DATASETNAME, w);
+ HDsnprintf(objname, sizeof(objname), "%s %u", DATASETNAME, w);
if ((dataset = H5Dcreate2(group2, objname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
@@ -1184,21 +1184,21 @@ test_filespace(hid_t fapl)
/* (Remove them in reverse order just to make file size calculation easier -QAK) */
for (u = FILESPACE_TOP_GROUPS; u > 0; u--) {
/* Open group */
- HDsprintf(objname, "%s %u", GROUPNAME, (u - 1));
+ HDsnprintf(objname, sizeof(objname), "%s %u", GROUPNAME, (u - 1));
if ((group = H5Gopen2(file, objname, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
/* Open nested groups inside top groups */
for (v = 0; v < FILESPACE_NESTED_GROUPS; v++) {
/* Create group */
- HDsprintf(objname, "%s %u", GROUP2NAME, v);
+ HDsnprintf(objname, sizeof(objname), "%s %u", GROUP2NAME, v);
if ((group2 = H5Gopen2(group, objname, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
/* Remove datasets inside nested groups */
for (w = 0; w < FILESPACE_NDATASETS; w++) {
/* Remove dataset */
- HDsprintf(objname, "%s %u", DATASETNAME, w);
+ HDsnprintf(objname, sizeof(objname), "%s %u", DATASETNAME, w);
if (H5Ldelete(group2, objname, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
@@ -1208,7 +1208,7 @@ test_filespace(hid_t fapl)
FAIL_STACK_ERROR;
/* Remove nested group */
- HDsprintf(objname, "%s %u", GROUP2NAME, v);
+ HDsnprintf(objname, sizeof(objname), "%s %u", GROUP2NAME, v);
if (H5Ldelete(group, objname, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
@@ -1218,7 +1218,7 @@ test_filespace(hid_t fapl)
FAIL_STACK_ERROR;
/* Remove top group */
- HDsprintf(objname, "%s %u", GROUPNAME, (u - 1));
+ HDsnprintf(objname, sizeof(objname), "%s %u", GROUPNAME, (u - 1));
if (H5Ldelete(file, objname, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
@@ -1502,7 +1502,7 @@ test_create_unlink(const char *msg, hid_t fapl)
/* Create a many groups to remove */
for (u = 0; u < UNLINK_NGROUPS; u++) {
- HDsprintf(groupname, "%s %u", GROUPNAME, u);
+ HDsnprintf(groupname, sizeof(groupname), "%s %u", GROUPNAME, u);
if ((group = H5Gcreate2(file, groupname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
H5_FAILED();
HDprintf("group %s creation failed\n", groupname);
@@ -1517,7 +1517,7 @@ test_create_unlink(const char *msg, hid_t fapl)
/* Remove the all the groups */
for (u = 0; u < UNLINK_NGROUPS; u++) {
- HDsprintf(groupname, "%s %u", GROUPNAME, u);
+ HDsnprintf(groupname, sizeof(groupname), "%s %u", GROUPNAME, u);
if (H5Ldelete(file, groupname, H5P_DEFAULT) < 0) {
H5_FAILED();
HDprintf("Unlinking group %s failed\n", groupname);
@@ -1765,7 +1765,7 @@ test_unlink_rightleaf(hid_t fid)
/* Create all the groups */
for (n = 0; n < ngroups; n++) {
- HDsprintf(name, "Zone%d", n + 1);
+ HDsnprintf(name, sizeof(name), "Zone%d", n + 1);
if ((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
} /* end for */
@@ -1774,7 +1774,7 @@ test_unlink_rightleaf(hid_t fid)
for (n = 0; n < ngroups; n++) {
if (delete_node(rootid, gids[n]) < 0)
TEST_ERROR;
- HDsprintf(name, "Zone%d", n + 1);
+ HDsnprintf(name, sizeof(name), "Zone%d", n + 1);
if ((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
} /* end for */
@@ -1854,7 +1854,7 @@ test_unlink_rightnode(hid_t fid)
/* Create all the groups */
for (n = 0; n < ngroups; n++) {
- HDsprintf(name, "ZoneB%d", n + 1);
+ HDsnprintf(name, sizeof(name), "ZoneB%d", n + 1);
if ((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
} /* end for */
@@ -1946,7 +1946,7 @@ test_unlink_middlenode(hid_t fid)
/* Create all the groups */
for (n = 0; n < ngroups; n++) {
- HDsprintf(name, "ZoneC%d", n + 1);
+ HDsnprintf(name, sizeof(name), "ZoneC%d", n + 1);
if ((gids[n] = H5Gcreate2(rootid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
} /* end for */
@@ -2676,7 +2676,7 @@ test_full_group_compact(hid_t fapl)
/* Create several objects to link to */
for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) {
- HDsprintf(objname, "keep %u\n", u);
+ HDsnprintf(objname, sizeof(objname), "keep %u\n", u);
if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
if (H5Gclose(gid2) < 0)
@@ -2713,15 +2713,15 @@ test_full_group_compact(hid_t fapl)
/* Create hard links to objects in group to keep */
for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) {
- HDsprintf(objname, "/keep/keep %u\n", u);
- HDsprintf(objname2, "keep %u\n", u);
+ HDsnprintf(objname, sizeof(objname), "/keep/keep %u\n", u);
+ HDsnprintf(objname2, sizeof(objname2), "keep %u\n", u);
if (H5Lcreate_hard(file_id, objname, gid, objname2, H5P_DEFAULT, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
/* Create several objects to delete */
for (u = 0; u < FULL_GROUP_NUM_DELETE_COMPACT; u++) {
- HDsprintf(objname, "delete %u\n", u);
+ HDsnprintf(objname, sizeof(objname), "delete %u\n", u);
if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
if (H5Gclose(gid2) < 0)
@@ -2742,7 +2742,7 @@ test_full_group_compact(hid_t fapl)
/* Check reference count on objects to keep */
for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) {
- HDsprintf(objname, "/keep/keep %u\n", u);
+ HDsnprintf(objname, sizeof(objname), "/keep/keep %u\n", u);
if (H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
if (oi.rc != 2)
@@ -2763,7 +2763,7 @@ test_full_group_compact(hid_t fapl)
/* Check reference count on objects to keep */
for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) {
- HDsprintf(objname, "/keep/keep %u\n", u);
+ HDsnprintf(objname, sizeof(objname), "/keep/keep %u\n", u);
if (H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
if (oi.rc != 1)
@@ -2838,7 +2838,7 @@ test_full_group_dense(hid_t fapl)
/* Create several objects to link to */
for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) {
- HDsprintf(objname, "keep %u\n", u);
+ HDsnprintf(objname, sizeof(objname), "keep %u\n", u);
if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
if (H5Gclose(gid2) < 0)
@@ -2890,15 +2890,15 @@ test_full_group_dense(hid_t fapl)
/* Create hard links to objects in group to keep */
for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) {
- HDsprintf(objname, "/keep/keep %u\n", u);
- HDsprintf(objname2, "keep %u\n", u);
+ HDsnprintf(objname, sizeof(objname), "/keep/keep %u\n", u);
+ HDsnprintf(objname2, sizeof(objname2), "keep %u\n", u);
if (H5Lcreate_hard(file_id, objname, gid, objname2, H5P_DEFAULT, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
} /* end for */
/* Create several objects to delete */
for (u = 0; u < FULL_GROUP_NUM_DELETE_DENSE; u++) {
- HDsprintf(objname, "delete %u\n", u);
+ HDsnprintf(objname, sizeof(objname), "delete %u\n", u);
if ((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
FAIL_STACK_ERROR;
if (H5Gclose(gid2) < 0)
@@ -2919,7 +2919,7 @@ test_full_group_dense(hid_t fapl)
/* Check reference count on objects to keep */
for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) {
- HDsprintf(objname, "/keep/keep %u\n", u);
+ HDsnprintf(objname, sizeof(objname), "/keep/keep %u\n", u);
if (H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
if (oi.rc != 2)
@@ -2940,7 +2940,7 @@ test_full_group_dense(hid_t fapl)
/* Check reference count on objects to keep */
for (u = 0; u < FULL_GROUP_NUM_KEEP; u++) {
- HDsprintf(objname, "/keep/keep %u\n", u);
+ HDsnprintf(objname, sizeof(objname), "/keep/keep %u\n", u);
if (H5Oget_info_by_name3(file_id, objname, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0)
FAIL_STACK_ERROR;
if (oi.rc != 1)
diff --git a/test/vfd.c b/test/vfd.c
index d6f6d61..b4fc742 100644
--- a/test/vfd.c
+++ b/test/vfd.c
@@ -1538,19 +1538,19 @@ test_multi(void)
memb_map[H5FD_MEM_BTREE] = H5FD_MEM_BTREE;
memb_map[H5FD_MEM_GHEAP] = H5FD_MEM_GHEAP;
- HDsprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's');
+ HDsnprintf(sv[H5FD_MEM_SUPER], 32, "%%s-%c.h5", 's');
memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER];
memb_addr[H5FD_MEM_SUPER] = 0;
- HDsprintf(sv[H5FD_MEM_BTREE], "%%s-%c.h5", 'b');
+ HDsnprintf(sv[H5FD_MEM_BTREE], 32, "%%s-%c.h5", 'b');
memb_name[H5FD_MEM_BTREE] = sv[H5FD_MEM_BTREE];
memb_addr[H5FD_MEM_BTREE] = HADDR_MAX / 4;
- HDsprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r');
+ HDsnprintf(sv[H5FD_MEM_DRAW], 32, "%%s-%c.h5", 'r');
memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW];
memb_addr[H5FD_MEM_DRAW] = HADDR_MAX / 2;
- HDsprintf(sv[H5FD_MEM_GHEAP], "%%s-%c.h5", 'g');
+ HDsnprintf(sv[H5FD_MEM_GHEAP], 32, "%%s-%c.h5", 'g');
memb_name[H5FD_MEM_GHEAP] = sv[H5FD_MEM_GHEAP];
memb_addr[H5FD_MEM_GHEAP] = (HADDR_MAX / 4) * 3;
@@ -1787,12 +1787,12 @@ test_multi_compat(void)
memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW;
memb_fapl[H5FD_MEM_SUPER] = H5P_DEFAULT;
- HDsprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's');
+ HDsnprintf(sv[H5FD_MEM_SUPER], 32, "%%s-%c.h5", 's');
memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER];
memb_addr[H5FD_MEM_SUPER] = 0;
memb_fapl[H5FD_MEM_DRAW] = H5P_DEFAULT;
- HDsprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r');
+ HDsnprintf(sv[H5FD_MEM_DRAW], 32, "%%s-%c.h5", 'r');
memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW];
memb_addr[H5FD_MEM_DRAW] = HADDR_MAX / 2;
@@ -1804,12 +1804,12 @@ test_multi_compat(void)
/* Make copy for the data file in the build directory, to protect the
* original file in the source directory
*/
- HDsprintf(filename_s, "%s-%c.h5", MULTI_COMPAT_BASENAME, 's');
- HDsprintf(newname_s, "%s-%c.h5", FILENAME[9], 's');
+ HDsnprintf(filename_s, sizeof(filename_s), "%s-%c.h5", MULTI_COMPAT_BASENAME, 's');
+ HDsnprintf(newname_s, sizeof(newname_s), "%s-%c.h5", FILENAME[9], 's');
h5_make_local_copy(filename_s, newname_s);
- HDsprintf(filename_r, "%s-%c.h5", MULTI_COMPAT_BASENAME, 'r');
- HDsprintf(newname_r, "%s-%c.h5", FILENAME[9], 'r');
+ HDsnprintf(filename_r, sizeof(filename_r), "%s-%c.h5", MULTI_COMPAT_BASENAME, 'r');
+ HDsnprintf(newname_r, sizeof(newname_r), "%s-%c.h5", FILENAME[9], 'r');
h5_make_local_copy(filename_r, newname_r);
/* Reopen the file for read only. Verify 1.8 library can open file