summaryrefslogtreecommitdiffstats
path: root/test/tattr.c
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2022-01-28 22:43:48 (GMT)
committerGitHub <noreply@github.com>2022-01-28 22:43:48 (GMT)
commit4ac6ccc0213767be935b2686524937ae93c46e3f (patch)
tree9cd332106bd623c05f8e6837bed0d1ceab5ad7e9 /test/tattr.c
parentad71539d30c799c497953c18352df37d83a75310 (diff)
downloadhdf5-4ac6ccc0213767be935b2686524937ae93c46e3f.zip
hdf5-4ac6ccc0213767be935b2686524937ae93c46e3f.tar.gz
hdf5-4ac6ccc0213767be935b2686524937ae93c46e3f.tar.bz2
Snprintf2 (#1399)
* Replaced many uses of sprintf with safer snprintf Many very straightforward, but in a few cases added a length parameter to some private functions, because buffer length was otherwise unknowable. * Removed unnecessary use of static on small buffers This improves thread safety. * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test/tattr.c')
-rw-r--r--test/tattr.c153
1 files changed, 78 insertions, 75 deletions
diff --git a/test/tattr.c b/test/tattr.c
index d66fcc3..2859f4c 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -2094,7 +2094,7 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr)
/* Re-open all the attributes by name and verify the data */
for (u = 0; u < max_attr; u++) {
/* Open attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Aopen(loc_id, attrname, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Aopen");
@@ -2119,7 +2119,7 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr)
CHECK(attr, FAIL, "H5Aopen_by_idx");
/* Verify Name */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, check_name);
VERIFY(name_len, HDstrlen(attrname), "H5Aget_name");
if (HDstrcmp(check_name, attrname) != 0)
@@ -2219,7 +2219,7 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl)
/* Add attributes, until just before converting to dense storage */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -2238,7 +2238,7 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl)
/* Add one more attribute, to push into "dense" storage */
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -2361,7 +2361,7 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
/* Add attributes, until just before converting to dense storage */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -2384,7 +2384,7 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl)
/* Add one more attribute, to push into "dense" storage */
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -2523,7 +2523,7 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
/* Add attributes, until well into dense storage */
for (u = 0; u < (max_compact * 2); u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -2568,7 +2568,7 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
/* Delete attributes until the attributes revert to compact storage again */
for (u--; u >= min_dense; u--) {
/* Delete attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -2582,7 +2582,7 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
/* Delete one more attribute, which should cause reversion to compact storage */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -2595,7 +2595,7 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "test_attr_dense_verify");
/* Delete another attribute, to verify deletion in compact storage */
- HDsprintf(attrname, "attr %02u", (u - 1));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (u - 1));
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -2724,7 +2724,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
/* Add attributes, until well into dense storage */
for (u = 0; u < (max_compact * 2); u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, H5I_INVALID_HID, "H5Acreate2");
@@ -2790,7 +2790,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
unsigned value; /* Attribute value */
/* Open attribute */
- HDsprintf(attrname, "new attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "new attr %02u", u);
attr = H5Aopen(dataset, attrname, H5P_DEFAULT);
CHECK(attr, H5I_INVALID_HID, "H5Aopen");
@@ -2914,7 +2914,7 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl)
/* Add attributes, until well into dense storage */
for (u = 0; u < (max_compact * 2); u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3057,7 +3057,7 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
/* Create attribute */
u = 0;
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3077,7 +3077,7 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
/* Create attribute */
u = 1;
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3107,7 +3107,7 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl)
/* Delete attribute */
u = 0;
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -3216,7 +3216,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
/* Add attributes, until just before converting to dense storage */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3239,7 +3239,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
CHECK(sid2, FAIL, "H5Screate_simple");
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3522,7 +3522,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
/* Delete a few attributes until the storage switches to compact */
for (u = min_dense - 1; u <= max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
add_attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(add_attr, FAIL, "H5Acreate2");
@@ -3590,7 +3590,7 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl)
/* Add attributes, until just before converting to dense storage */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(gid1, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3756,7 +3756,7 @@ test_attr_big(hid_t fcpl, hid_t fapl)
/* Create attribute */
u = 0;
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3774,7 +3774,7 @@ test_attr_big(hid_t fcpl, hid_t fapl)
/* Create attribute */
u = 1;
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3792,7 +3792,7 @@ test_attr_big(hid_t fcpl, hid_t fapl)
/* Create attribute */
u = 2;
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, big_sid, H5P_DEFAULT, H5P_DEFAULT);
if (low == H5F_LIBVER_LATEST) {
CHECK(attr, FAIL, "H5Acreate2");
@@ -3815,7 +3815,7 @@ test_attr_big(hid_t fcpl, hid_t fapl)
/* Create attribute */
u = 3;
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, big_sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -3837,7 +3837,7 @@ test_attr_big(hid_t fcpl, hid_t fapl)
/* Delete attribute */
u = 1;
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -3851,7 +3851,7 @@ test_attr_big(hid_t fcpl, hid_t fapl)
/* Delete attribute */
u = 3;
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -3865,7 +3865,7 @@ test_attr_big(hid_t fcpl, hid_t fapl)
/* Delete attribute */
u = 2;
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -3879,7 +3879,7 @@ test_attr_big(hid_t fcpl, hid_t fapl)
/* Delete attribute */
u = 0;
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -4278,7 +4278,7 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create many attributes */
for (u = 0; u < nattr; u++) {
- HDsprintf(attrname, "a-%06u", u);
+ HDsnprintf(attrname, sizeof(attrname), "a-%06u", u);
exists = H5Aexists(gid, attrname);
VERIFY(exists, FALSE, "H5Aexists");
@@ -4330,7 +4330,7 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl)
for (u = 0; u < nattr; u++) {
unsigned value; /* Attribute value */
- HDsprintf(attrname, "a-%06u", u);
+ HDsnprintf(attrname, sizeof(attrname), "a-%06u", u);
exists = H5Aexists(gid, attrname);
VERIFY(exists, TRUE, "H5Aexists");
@@ -4578,7 +4578,7 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
/* Create several attributes, but keep storage in compact form */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -4667,7 +4667,7 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl)
H5A_info_t ainfo; /* Attribute information */
/* Retrieve information for attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Aget_info_by_name(my_dataset, ".", attrname, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
@@ -4782,7 +4782,7 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
/* Create several attributes, but keep storage in compact form */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -4805,7 +4805,7 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
} /* end for */
/* Create another attribute, to push into dense storage */
- HDsprintf(attrname, "attr %02u", max_compact);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", max_compact);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -4898,7 +4898,7 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl)
H5A_info_t ainfo; /* Attribute information */
/* Retrieve information for attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Aget_info_by_name(my_dataset, ".", attrname, &ainfo, H5P_DEFAULT);
CHECK(ret, FAIL, "H5Aget_info_by_name");
@@ -5171,7 +5171,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
/* Create several attributes, but keep storage in compact form */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5194,7 +5194,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
} /* end for */
/* Create another attribute, to push into dense storage */
- HDsprintf(attrname, "attr %02u", max_compact);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", max_compact);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5222,7 +5222,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
/* Delete several attributes from object, until attribute storage resumes compact form */
for (u = max_compact; u >= min_dense; u--) {
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(my_dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -5242,7 +5242,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
} /* end for */
/* Delete another attribute, to push attribute storage into compact form */
- HDsprintf(attrname, "attr %02u", (min_dense - 1));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (min_dense - 1));
ret = H5Adelete(my_dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -5258,7 +5258,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
/* Re-add attributes to get back into dense form */
for (u = (min_dense - 1); u < (max_compact + 1); u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5345,7 +5345,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
/* Delete several attributes from object, until attribute storage resumes compact form */
for (u = max_compact; u >= min_dense; u--) {
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(my_dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -5365,7 +5365,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
} /* end for */
/* Delete another attribute, to push attribute storage into compact form */
- HDsprintf(attrname, "attr %02u", (min_dense - 1));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (min_dense - 1));
ret = H5Adelete(my_dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
@@ -5381,7 +5381,7 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
/* Re-add attributes to get back into dense form */
for (u = (min_dense - 1); u < (max_compact + 1); u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5410,11 +5410,11 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl)
/* Delete all attributes */
for (u = max_compact; u > 0; u--) {
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
ret = H5Adelete(my_dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
} /* end for */
- HDsprintf(attrname, "attr %02u", 0);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", 0);
ret = H5Adelete(my_dataset, attrname);
CHECK(ret, FAIL, "H5Adelete");
} /* end for */
@@ -5554,7 +5554,7 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl)
/* Create attributes, until attribute storage is in dense form */
for (u = 0; u < max_compact * 2; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5897,7 +5897,7 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create attributes, up to limit of compact form */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -5937,7 +5937,7 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create more attributes, to push into dense form */
for (; u < (max_compact * 2); u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -6381,7 +6381,7 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create attributes, up to limit of compact form */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr =
H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -6456,9 +6456,9 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0,
tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
if (order == H5_ITER_INC)
- HDsprintf(attrname, "attr %02u", (u + 1));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (u + 1));
else
- HDsprintf(attrname, "attr %02u", (max_compact - (u + 2)));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (max_compact - (u + 2)));
ret = HDstrcmp(attrname, tmpname);
VERIFY(ret, 0, "H5Aget_name_by_idx");
} /* end for */
@@ -6494,7 +6494,7 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create more attributes, to push into dense form */
for (u = 0; u < (max_compact * 2); u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr =
H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -6584,9 +6584,10 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0,
tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
if (order == H5_ITER_INC)
- HDsprintf(attrname, "attr %02u", (u + 1));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (u + 1));
else
- HDsprintf(attrname, "attr %02u", ((max_compact * 2) - (u + 2)));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u",
+ ((max_compact * 2) - (u + 2)));
ret = HDstrcmp(attrname, tmpname);
VERIFY(ret, 0, "H5Aget_name_by_idx");
} /* end for */
@@ -6628,7 +6629,7 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create attributes, to push into dense form */
for (u = 0; u < (max_compact * 2); u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr =
H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -6697,9 +6698,10 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)u,
tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
if (order == H5_ITER_INC)
- HDsprintf(attrname, "attr %02u", ((u * 2) + 1));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", ((u * 2) + 1));
else
- HDsprintf(attrname, "attr %02u", ((max_compact * 2) - ((u * 2) + 2)));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u",
+ ((max_compact * 2) - ((u * 2) + 2)));
ret = HDstrcmp(attrname, tmpname);
VERIFY(ret, 0, "H5Aget_name_by_idx");
} /* end for */
@@ -6749,9 +6751,10 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
ret = (herr_t)H5Aget_name_by_idx(my_dataset, ".", idx_type, order, (hsize_t)0,
tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT);
if (order == H5_ITER_INC)
- HDsprintf(attrname, "attr %02u", ((u * 2) + 3));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", ((u * 2) + 3));
else
- HDsprintf(attrname, "attr %02u", ((max_compact * 2) - ((u * 2) + 4)));
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u",
+ ((max_compact * 2) - ((u * 2) + 4)));
ret = HDstrcmp(attrname, tmpname);
VERIFY(ret, 0, "H5Aget_name_by_idx");
} /* end for */
@@ -6832,7 +6835,7 @@ attr_iterate2_cb(hid_t loc_id, const char *attr_name, const H5A_info_t *info, vo
} /* end if */
/* Verify name of link */
- HDsprintf(attrname, "attr %02u", (unsigned)my_info.corder);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", (unsigned)my_info.corder);
if (HDstrcmp(attr_name, attrname) != 0)
return (H5_ITER_ERROR);
@@ -7342,7 +7345,7 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create attributes, up to limit of compact form */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr =
H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -7414,7 +7417,7 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create more attributes, to push into dense form */
for (u = max_compact; u < (max_compact * 2); u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr =
H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -7706,7 +7709,7 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create attributes, up to limit of compact form */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr =
H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -7765,7 +7768,7 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create more attributes, to push into dense form */
for (u = max_compact; u < (max_compact * 2); u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr =
H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -7870,7 +7873,7 @@ attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id, unsigned max_attr
/* Open each attribute on object by index and check that it's the correct one */
for (u = 0; u < max_attrs; u++) {
/* Open the attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr_id = H5Aopen(obj_id, attrname, H5P_DEFAULT);
CHECK(attr_id, FAIL, "H5Aopen");
@@ -8039,7 +8042,7 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create attributes, up to limit of compact form */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -8105,7 +8108,7 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create more attributes, to push into dense form */
for (u = max_compact; u < (max_compact * 2); u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate2(my_dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate2");
@@ -8288,7 +8291,7 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create attributes, up to limit of compact form */
for (u = 0; u < max_compact; u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate_by_name(fid, dsetname, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT,
H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate_by_name");
@@ -8345,7 +8348,7 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl)
/* Create more attributes, to push into dense form */
for (u = max_compact; u < (max_compact * 2); u++) {
/* Create attribute */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
attr = H5Acreate_by_name(fid, dsetname, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT,
H5P_DEFAULT, H5P_DEFAULT);
CHECK(attr, FAIL, "H5Acreate_by_name");
@@ -8570,7 +8573,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl)
/* Add attributes to each dataset, until after converting to dense storage */
for (u = 0; u < max_compact * 2; u++) {
/* Create attribute name */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
/* Alternate between creating "small" & "big" attributes */
if (u % 2) {
@@ -8907,7 +8910,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl)
/* Add attributes to each dataset, until after converting to dense storage */
for (u = 0; u < max_compact * 2; u++) {
/* Create attribute name */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
/* Alternate between creating "small" & "big" attributes */
if (u % 2) {
@@ -9354,7 +9357,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
/* Add attributes to each dataset, until after converting to dense storage */
for (u = 0; u < max_compact * 2; u++) {
/* Create attribute name */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
/* Alternate between creating "small" & "big" attributes */
if (u % 2) {
@@ -9462,7 +9465,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl)
/* Delete attributes from second dataset */
for (u = 0; u < max_compact * 2; u++) {
/* Create attribute name */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
/* Delete second dataset's attribute */
ret = H5Adelete_by_name(fid, DSET2_NAME, attrname, H5P_DEFAULT);
@@ -9726,7 +9729,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
/* Add attributes to each dataset, until after converting to dense storage */
for (u = 0; u < max_compact * 2; u++) {
/* Create attribute name */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
/* Alternate between creating "small" & "big" attributes */
if (u % 2) {
@@ -9850,7 +9853,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl)
/* Check ref count on attributes of first dataset */
for (u = 0; u < max_compact * 2; u++) {
/* Create attribute name */
- HDsprintf(attrname, "attr %02u", u);
+ HDsnprintf(attrname, sizeof(attrname), "attr %02u", u);
/* Open attribute on first dataset */
attr = H5Aopen(dataset, attrname, H5P_DEFAULT);