diff options
author | Larry Knox <lrknox@hdfgroup.org> | 2022-04-05 13:20:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-05 13:20:19 (GMT) |
commit | bddd148fd29deb18439767c416199914845431b8 (patch) | |
tree | 9afaa591016c2ae1fe1978d4573c80303420d922 /test | |
parent | 99ba670f6add3bf83c0361537230e686f3976d1e (diff) | |
download | hdf5-bddd148fd29deb18439767c416199914845431b8.zip hdf5-bddd148fd29deb18439767c416199914845431b8.tar.gz hdf5-bddd148fd29deb18439767c416199914845431b8.tar.bz2 |
Misc fixes from develop nov21 - feb22 (#1580)
* Make default to build high-level tools the same as default for (#1234)
high-level library.
* Updated README.txt to README.md (#1375)
* H5Lexists docs: Removed reference to 1.8.16 since the change is the 1.8.x releases, HDFFV-11289
* H5Oget_info_by_name, name can be any object, not just a group
* Converted README.txt to README.md and updated files referring to README.txt to README.md.
* removed references to README.txt
* updated MANIFEST
* 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>
* Replaced several uses of sprintf with safer snprintf (#1383)
* Replaced several uses of sprintf with safer snprintf
* Committing clang-format changes
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Used clang-tidy to change all floating point f suffixes to F (#1359)
* Added another missing override keyword on a dtor (#1384)
* Creating FUNDING.yml (#1427)
* Creating FUNDING.yml
Will add sponsor this project widget to the repo's page.
* Correct file name
Add sponsor widget; filename typo fixed.
* Update MANIFEST
* Fixed AbstractDs::getVarLenType documentation (#1441)
* Committing clang-format changes
* Open bsd fixes (#1195)
* Fix end of line alignment.
Co-authored-by: Scot Breitenfeld <brtnfld@hdfgroup.org>
Co-authored-by: Sean McBride <sean@rogue-research.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: loricooperhdf <lori.cooper@hdfgroup.org>
Co-authored-by: myd7349 <myd7349@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/app_ref.c | 4 | ||||
-rw-r--r-- | test/cache_api.c | 2 | ||||
-rw-r--r-- | test/cache_common.c | 148 | ||||
-rw-r--r-- | test/cache_image.c | 16 | ||||
-rw-r--r-- | test/chunk_info.c | 2 | ||||
-rw-r--r-- | test/cmpd_dset.c | 12 | ||||
-rw-r--r-- | test/del_many_dense_attrs.c | 4 | ||||
-rw-r--r-- | test/dtypes.c | 8 | ||||
-rw-r--r-- | test/earray.c | 9 | ||||
-rw-r--r-- | test/enc_dec_plist.c | 4 | ||||
-rw-r--r-- | test/external.c | 4 | ||||
-rw-r--r-- | test/external_common.c | 8 | ||||
-rw-r--r-- | test/fheap.c | 5 | ||||
-rw-r--r-- | test/flush1.c | 2 | ||||
-rw-r--r-- | test/flush2.c | 2 | ||||
-rw-r--r-- | test/genall5.c | 90 | ||||
-rw-r--r-- | test/page_buffer.c | 16 | ||||
-rw-r--r-- | test/reserved.c | 6 | ||||
-rw-r--r-- | test/tattr.c | 153 | ||||
-rw-r--r-- | test/tmisc.c | 6 | ||||
-rw-r--r-- | test/tselect.c | 36 | ||||
-rw-r--r-- | test/tvlstr.c | 10 | ||||
-rw-r--r-- | test/unregister.c | 2 | ||||
-rw-r--r-- | test/vds_env.c | 5 |
24 files changed, 287 insertions, 267 deletions
diff --git a/test/app_ref.c b/test/app_ref.c index 09cfb72..90cb089 100644 --- a/test/app_ref.c +++ b/test/app_ref.c @@ -69,8 +69,10 @@ Abrt_Handler(int H5_ATTR_UNUSED sig) { int i, n; + const char *string = " ID reference count: "; for (i = 0; i < T_NUMCLASSES; i++) { - HDfprintf(stderr, "%s ID reference count: %n", IDNAME[i], &n); + HDfprintf(stderr, "%s%s", IDNAME[i], string); + n = (int)(strlen(IDNAME[i]) + strlen(string)); HDfprintf(stderr, "%*d\n", (n < ERR_WIDTH) ? (ERR_WIDTH - n) : 0, rc[i]); } } diff --git a/test/cache_api.c b/test/cache_api.c index 248a91d..55aaa0a 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -1082,7 +1082,7 @@ mdc_api_call_smoke_check(int express_test, unsigned paged, hid_t fcpl_id) /* create the dataset */ if (pass) { - HDsprintf(dset_name, "/dset%03d", i); + HDsnprintf(dset_name, sizeof(dset_name), "/dset%03d", i); dataset_ids[i] = H5Dcreate2(file_id, dset_name, H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, properties, H5P_DEFAULT); diff --git a/test/cache_common.c b/test/cache_common.c index 7269c49..59fda94 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -2329,8 +2329,8 @@ verify_clean(void) void verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_entry_status expected[]) { - static char msg[256]; - int i; + char msg[256]; + int i; i = 0; while ((pass) && (i < num_entries)) { @@ -2342,14 +2342,15 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if ((!expected[i].in_cache) && ((expected[i].is_protected) || (expected[i].is_pinned))) { pass = FALSE; - HDsprintf(msg, "%d: Contradictory data in expected[%d].\n", tag, i); + HDsnprintf(msg, sizeof(msg), "%d: Contradictory data in expected[%d].\n", tag, i); failure_mssg = msg; } if ((!expected[i].in_cache) && (expected[i].is_dirty) && (!entry_ptr->expunged)) { pass = FALSE; - HDsprintf(msg, "%d: expected[%d] specs non-expunged, dirty, non-resident.\n", tag, i); + HDsnprintf(msg, sizeof(msg), "%d: expected[%d] specs non-expunged, dirty, non-resident.\n", tag, + i); failure_mssg = msg; } @@ -2360,9 +2361,9 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (in_cache != expected[i].in_cache) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) in cache actual/expected = %d/%d.\n", tag, - (int)expected[i].entry_type, (int)expected[i].entry_index, (int)in_cache, - (int)expected[i].in_cache); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) in cache actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, (int)in_cache, + (int)expected[i].in_cache); failure_mssg = msg; } } @@ -2372,9 +2373,9 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (entry_ptr->size != expected[i].size) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) size actual/expected = %ld/%ld.\n", tag, - (int)expected[i].entry_type, (int)expected[i].entry_index, (long)(entry_ptr->size), - (long)expected[i].size); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) size actual/expected = %ld/%ld.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, (long)(entry_ptr->size), + (long)expected[i].size); failure_mssg = msg; } } @@ -2384,9 +2385,9 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (entry_ptr->header.size != expected[i].size) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) header size actual/expected = %ld/%ld.\n", tag, - (int)expected[i].entry_type, (int)expected[i].entry_index, - (long)(entry_ptr->header.size), (long)expected[i].size); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) header size actual/expected = %ld/%ld.\n", + tag, (int)expected[i].entry_type, (int)expected[i].entry_index, + (long)(entry_ptr->header.size), (long)expected[i].size); failure_mssg = msg; } } @@ -2396,9 +2397,9 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (entry_ptr->at_main_addr != expected[i].at_main_addr) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) at main addr actual/expected = %d/%d.\n", tag, - (int)expected[i].entry_type, (int)expected[i].entry_index, - (int)(entry_ptr->at_main_addr), (int)expected[i].at_main_addr); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) at main addr actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->at_main_addr), (int)expected[i].at_main_addr); failure_mssg = msg; } } @@ -2408,9 +2409,9 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (entry_ptr->is_dirty != expected[i].is_dirty) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) is_dirty actual/expected = %d/%d.\n", tag, - (int)expected[i].entry_type, (int)expected[i].entry_index, - (int)(entry_ptr->is_dirty), (int)expected[i].is_dirty); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) is_dirty actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->is_dirty), (int)expected[i].is_dirty); failure_mssg = msg; } } @@ -2420,9 +2421,9 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (entry_ptr->header.is_dirty != expected[i].is_dirty) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) header is_dirty actual/expected = %d/%d.\n", tag, - (int)expected[i].entry_type, (int)expected[i].entry_index, - (int)(entry_ptr->header.is_dirty), (int)expected[i].is_dirty); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) header is_dirty actual/expected = %d/%d.\n", + tag, (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->header.is_dirty), (int)expected[i].is_dirty); failure_mssg = msg; } } @@ -2432,9 +2433,9 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (entry_ptr->is_protected != expected[i].is_protected) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) is_protected actual/expected = %d/%d.\n", tag, - (int)expected[i].entry_type, (int)expected[i].entry_index, - (int)(entry_ptr->is_protected), (int)expected[i].is_protected); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) is_protected actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->is_protected), (int)expected[i].is_protected); failure_mssg = msg; } } @@ -2444,9 +2445,10 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (entry_ptr->header.is_protected != expected[i].is_protected) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) header is_protected actual/expected = %d/%d.\n", tag, - (int)expected[i].entry_type, (int)expected[i].entry_index, - (int)(entry_ptr->header.is_protected), (int)expected[i].is_protected); + HDsnprintf(msg, sizeof(msg), + "%d entry (%d, %d) header is_protected actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->header.is_protected), (int)expected[i].is_protected); failure_mssg = msg; } } @@ -2456,9 +2458,9 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (entry_ptr->is_pinned != expected[i].is_pinned) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) is_pinned actual/expected = %d/%d.\n", tag, - (int)expected[i].entry_type, (int)expected[i].entry_index, - (int)(entry_ptr->is_pinned), (int)expected[i].is_pinned); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) is_pinned actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->is_pinned), (int)expected[i].is_pinned); failure_mssg = msg; } } @@ -2468,9 +2470,9 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (entry_ptr->is_corked != expected[i].is_corked) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) is_corked actual/expected = %d/%d.\n", tag, - (int)expected[i].entry_type, (int)expected[i].entry_index, - (int)(entry_ptr->is_corked), (int)expected[i].is_corked); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) is_corked actual/expected = %d/%d.\n", tag, + (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->is_corked), (int)expected[i].is_corked); failure_mssg = msg; } } @@ -2480,9 +2482,9 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (entry_ptr->header.is_pinned != expected[i].is_pinned) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) header is_pinned actual/expected = %d/%d.\n", tag, - (int)expected[i].entry_type, (int)expected[i].entry_index, - (int)(entry_ptr->header.is_pinned), (int)expected[i].is_pinned); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) header is_pinned actual/expected = %d/%d.\n", + tag, (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->header.is_pinned), (int)expected[i].is_pinned); failure_mssg = msg; } } @@ -2494,11 +2496,12 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ (entry_ptr->destroyed != expected[i].destroyed)) { pass = FALSE; - HDsprintf(msg, "%d entry (%d,%d) deserialized = %d(%d), serialized = %d(%d), dest = %d(%d)\n", - tag, (int)expected[i].entry_type, (int)expected[i].entry_index, - (int)(entry_ptr->deserialized), (int)(expected[i].deserialized), - (int)(entry_ptr->serialized), (int)(expected[i].serialized), - (int)(entry_ptr->destroyed), (int)(expected[i].destroyed)); + HDsnprintf(msg, sizeof(msg), + "%d entry (%d,%d) deserialized = %d(%d), serialized = %d(%d), dest = %d(%d)\n", + tag, (int)expected[i].entry_type, (int)expected[i].entry_index, + (int)(entry_ptr->deserialized), (int)(expected[i].deserialized), + (int)(entry_ptr->serialized), (int)(expected[i].serialized), + (int)(entry_ptr->destroyed), (int)(expected[i].destroyed)); failure_mssg = msg; } } @@ -2509,18 +2512,19 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (pass) { if (entry_ptr->flush_dep_npar != expected[i].flush_dep_npar) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) flush_dep_npar actual/expected = %u/%u.\n", tag, - expected[i].entry_type, expected[i].entry_index, entry_ptr->flush_dep_npar, - expected[i].flush_dep_npar); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) flush_dep_npar actual/expected = %u/%u.\n", + tag, expected[i].entry_type, expected[i].entry_index, entry_ptr->flush_dep_npar, + expected[i].flush_dep_npar); failure_mssg = msg; } /* end if */ } /* end if */ if ((pass) && (in_cache)) { if (entry_ptr->header.flush_dep_nparents != expected[i].flush_dep_npar) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) header flush_dep_nparents actual/expected = %u/%u.\n", tag, - expected[i].entry_type, expected[i].entry_index, - entry_ptr->header.flush_dep_nparents, expected[i].flush_dep_npar); + HDsnprintf(msg, sizeof(msg), + "%d entry (%d, %d) header flush_dep_nparents actual/expected = %u/%u.\n", tag, + expected[i].entry_type, expected[i].entry_index, + entry_ptr->header.flush_dep_nparents, expected[i].flush_dep_npar); failure_mssg = msg; } /* end if */ } /* end if */ @@ -2531,9 +2535,10 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ for (u = 0; u < entry_ptr->flush_dep_npar; u++) { if (entry_ptr->flush_dep_par_type[u] != expected[i].flush_dep_par_type[u]) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) flush_dep_par_type[%u] actual/expected = %d/%d.\n", tag, - expected[i].entry_type, expected[i].entry_index, u, - entry_ptr->flush_dep_par_type[u], expected[i].flush_dep_par_type[u]); + HDsnprintf(msg, sizeof(msg), + "%d entry (%d, %d) flush_dep_par_type[%u] actual/expected = %d/%d.\n", tag, + expected[i].entry_type, expected[i].entry_index, u, + entry_ptr->flush_dep_par_type[u], expected[i].flush_dep_par_type[u]); failure_mssg = msg; } /* end if */ } /* end for */ @@ -2542,9 +2547,10 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ for (u = 0; u < entry_ptr->flush_dep_npar; u++) { if (entry_ptr->flush_dep_par_idx[u] != expected[i].flush_dep_par_idx[u]) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) flush_dep_par_idx[%u] actual/expected = %d/%d.\n", tag, - expected[i].entry_type, expected[i].entry_index, u, - entry_ptr->flush_dep_par_idx[u], expected[i].flush_dep_par_idx[u]); + HDsnprintf(msg, sizeof(msg), + "%d entry (%d, %d) flush_dep_par_idx[%u] actual/expected = %d/%d.\n", tag, + expected[i].entry_type, expected[i].entry_index, u, + entry_ptr->flush_dep_par_idx[u], expected[i].flush_dep_par_idx[u]); failure_mssg = msg; } /* end if */ } /* end for */ @@ -2554,37 +2560,39 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (pass) { if (entry_ptr->flush_dep_nchd != expected[i].flush_dep_nchd) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) flush_dep_nchd actual/expected = %u/%u.\n", tag, - expected[i].entry_type, expected[i].entry_index, entry_ptr->flush_dep_nchd, - expected[i].flush_dep_nchd); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) flush_dep_nchd actual/expected = %u/%u.\n", + tag, expected[i].entry_type, expected[i].entry_index, entry_ptr->flush_dep_nchd, + expected[i].flush_dep_nchd); failure_mssg = msg; } /* end if */ } /* end if */ if ((pass) && (in_cache)) { if (entry_ptr->header.flush_dep_nchildren != expected[i].flush_dep_nchd) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) header flush_dep_nchildren actual/expected = %u/%u.\n", tag, - expected[i].entry_type, expected[i].entry_index, - entry_ptr->header.flush_dep_nchildren, expected[i].flush_dep_nchd); + HDsnprintf(msg, sizeof(msg), + "%d entry (%d, %d) header flush_dep_nchildren actual/expected = %u/%u.\n", tag, + expected[i].entry_type, expected[i].entry_index, + entry_ptr->header.flush_dep_nchildren, expected[i].flush_dep_nchd); failure_mssg = msg; } /* end if */ } /* end if */ if (pass) { if (entry_ptr->flush_dep_ndirty_chd != expected[i].flush_dep_ndirty_chd) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) flush_dep_ndirty_chd actual/expected = %u/%u.\n", tag, - expected[i].entry_type, expected[i].entry_index, entry_ptr->flush_dep_ndirty_chd, - expected[i].flush_dep_ndirty_chd); + HDsnprintf(msg, sizeof(msg), + "%d entry (%d, %d) flush_dep_ndirty_chd actual/expected = %u/%u.\n", tag, + expected[i].entry_type, expected[i].entry_index, entry_ptr->flush_dep_ndirty_chd, + expected[i].flush_dep_ndirty_chd); failure_mssg = msg; } /* end if */ } /* end if */ if ((pass) && (in_cache)) { if (entry_ptr->header.flush_dep_ndirty_children != expected[i].flush_dep_ndirty_chd) { pass = FALSE; - HDsprintf(msg, - "%d entry (%d, %d) header flush_dep_ndirty_children actual/expected = %u/%u.\n", - tag, expected[i].entry_type, expected[i].entry_index, - entry_ptr->header.flush_dep_ndirty_children, expected[i].flush_dep_ndirty_chd); + HDsnprintf(msg, sizeof(msg), + "%d entry (%d, %d) header flush_dep_ndirty_children actual/expected = %u/%u.\n", + tag, expected[i].entry_type, expected[i].entry_index, + entry_ptr->header.flush_dep_ndirty_children, expected[i].flush_dep_ndirty_chd); failure_mssg = msg; } /* end if */ } /* end if */ @@ -2593,9 +2601,9 @@ verify_entry_status(H5C_t *cache_ptr, int tag, int num_entries, struct expected_ if (pass) { if (expected[i].flush_order >= 0 && entry_ptr->flush_order != (unsigned)expected[i].flush_order) { pass = FALSE; - HDsprintf(msg, "%d entry (%d, %d) flush_order actual/expected = %u/%d.\n", tag, - expected[i].entry_type, expected[i].entry_index, entry_ptr->flush_order, - expected[i].flush_order); + HDsnprintf(msg, sizeof(msg), "%d entry (%d, %d) flush_order actual/expected = %u/%d.\n", tag, + expected[i].entry_type, expected[i].entry_index, entry_ptr->flush_order, + expected[i].flush_order); failure_mssg = msg; } /* end if */ } /* end if */ diff --git a/test/cache_image.c b/test/cache_image.c index 40d6f05..90fe7af 100644 --- a/test/cache_image.c +++ b/test/cache_image.c @@ -164,7 +164,7 @@ create_datasets(hid_t file_id, int min_dset, int max_dset) /* create the dataset */ if (pass) { - HDsprintf(dset_name, "/dset%03d", i); + HDsnprintf(dset_name, sizeof(dset_name), "/dset%03d", i); dataset_ids[i] = H5Dcreate2(file_id, dset_name, H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, properties, H5P_DEFAULT); @@ -443,7 +443,7 @@ delete_datasets(hid_t file_id, int min_dset, int max_dset) i = min_dset; while ((pass) && (i <= max_dset)) { - HDsprintf(dset_name, "/dset%03d", i); + HDsnprintf(dset_name, sizeof(dset_name), "/dset%03d", i); if (H5Ldelete(file_id, dset_name, H5P_DEFAULT) < 0) { @@ -1019,7 +1019,7 @@ verify_datasets(hid_t file_id, int min_dset, int max_dset) /* open the dataset */ if (pass) { - HDsprintf(dset_name, "/dset%03d", i); + HDsnprintf(dset_name, sizeof(dset_name), "/dset%03d", i); dataset_ids[i] = H5Dopen2(file_id, dset_name, H5P_DEFAULT); if (dataset_ids[i] < 0) { @@ -4624,7 +4624,7 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) /* 2) Create a process specific group. */ if (pass) { - HDsprintf(process_group_name, "/process_%d", min_group); + HDsnprintf(process_group_name, sizeof(process_group_name), "/process_%d", min_group); proc_gid = H5Gcreate2(file_id, process_group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -4728,7 +4728,7 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) if (pass) { max_group++; - HDsprintf(process_group_name, "/process_%d", max_group); + HDsnprintf(process_group_name, sizeof(process_group_name), "/process_%d", max_group); proc_gid = H5Gcreate2(file_id, process_group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -4802,7 +4802,7 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) /* 11) Validate all the zoos. */ i = min_group; while (pass && i <= max_group) { - HDsprintf(process_group_name, "/process_%d", i); + HDsnprintf(process_group_name, sizeof(process_group_name), "/process_%d", i); validate_zoo(file_id, process_group_name, i++); } @@ -4854,7 +4854,7 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) i = min_group; while ((pass) && (i <= max_group)) { - HDsprintf(process_group_name, "/process_%d", i); + HDsnprintf(process_group_name, sizeof(process_group_name), "/process_%d", i); validate_zoo(file_id, process_group_name, i++); } @@ -4914,7 +4914,7 @@ cache_image_smoke_check_5(hbool_t single_file_vfd) */ i = min_group; while ((pass) && (i <= max_group)) { - HDsprintf(process_group_name, "/process_%d", i); + HDsnprintf(process_group_name, sizeof(process_group_name), "/process_%d", i); validate_zoo(file_id, process_group_name, i++); } diff --git a/test/chunk_info.c b/test/chunk_info.c index cdbd762..5c16a7d 100644 --- a/test/chunk_info.c +++ b/test/chunk_info.c @@ -421,7 +421,7 @@ verify_idx_nchunks(hid_t dset, hid_t dspace, H5D_chunk_index_t exp_idx_type, hsi /* Ensure the correct chunk indexing scheme is used */ if (idx_type != exp_idx_type) { char msg[256]; - HDsprintf(msg, "Should be using %s.\n", index_type_str(idx_type)); + HDsnprintf(msg, sizeof(msg), "Should be using %s.\n", index_type_str(idx_type)); FAIL_PUTS_ERROR(msg); } diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index 8777096..3235056 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -1766,7 +1766,7 @@ test_pack_ooo(void) /* Insert the compound members in the random order previously generated */ for (i = 0; i < PACK_NMEMBS; i++) { - HDsprintf(name, "%05d", i); + HDsnprintf(name, sizeof(name), "%05d", i); if (i == sub_cmpd_order) { if (H5Tinsert(cmpd, name, (size_t)(4 * order[i]), sub_cmpd) < 0) PACK_OOO_ERROR @@ -1799,7 +1799,7 @@ test_pack_ooo(void) /* Insert the compound members in the random order previously generated */ for (i = 0; i < PACK_NMEMBS; i++) { - HDsprintf(name, "%05d", i); + HDsnprintf(name, sizeof(name), "%05d", i); if (i == sub_cmpd_order) { if (H5Tinsert(cmpd, name, (size_t)(4 * order[i]), sub_cmpd) < 0) PACK_OOO_ERROR @@ -1834,7 +1834,7 @@ test_pack_ooo(void) /* Insert the compound members in reverse order, with compound last */ for (i = 0; i < PACK_NMEMBS; i++) { - HDsprintf(name, "%05d", i); + HDsnprintf(name, sizeof(name), "%05d", i); if (i == PACK_NMEMBS - 1) { if (H5Tinsert(cmpd, name, (size_t)(4 * (PACK_NMEMBS - i - 1)), sub_cmpd) < 0) PACK_OOO_ERROR @@ -1867,7 +1867,7 @@ test_pack_ooo(void) /* Insert the compound members in reverse order, with compound last */ for (i = 0; i < PACK_NMEMBS; i++) { - HDsprintf(name, "%05d", i); + HDsnprintf(name, sizeof(name), "%05d", i); if (i == PACK_NMEMBS - 1) { if (H5Tinsert(cmpd, name, (size_t)(4 * (PACK_NMEMBS - i - 1)), sub_cmpd) < 0) PACK_OOO_ERROR @@ -1902,7 +1902,7 @@ test_pack_ooo(void) /* Insert the compound members in forward order, with compound first */ for (i = 0; i < PACK_NMEMBS; i++) { - HDsprintf(name, "%05d", i); + HDsnprintf(name, sizeof(name), "%05d", i); if (i == 0) { if (H5Tinsert(cmpd, name, (size_t)(4 * i), sub_cmpd) < 0) PACK_OOO_ERROR @@ -1935,7 +1935,7 @@ test_pack_ooo(void) /* Insert the compound members in forward order */ for (i = 0; i < PACK_NMEMBS; i++) { - HDsprintf(name, "%05d", i); + HDsnprintf(name, sizeof(name), "%05d", i); if (i == 0) { if (H5Tinsert(cmpd, name, (size_t)(4 * i), sub_cmpd) < 0) PACK_OOO_ERROR diff --git a/test/del_many_dense_attrs.c b/test/del_many_dense_attrs.c index cf7f607..78aba3b 100644 --- a/test/del_many_dense_attrs.c +++ b/test/del_many_dense_attrs.c @@ -119,7 +119,7 @@ main(void) /* Create attributes in the group */ for (i = ATTR_COUNT; i >= 0; i--) { /* Set up the attribute name */ - HDsprintf(aname, "%s%d", basename, i); + HDsnprintf(aname, sizeof(aname), "%s%d", basename, i); /* Create the attribute */ if ((aid = H5Acreate2(gid, aname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -165,7 +165,7 @@ main(void) /* Delete the attributes */ for (i = 0; i <= ATTR_COUNT; i++) { /* Set up the attribute name */ - HDsprintf(aname, "%s%d", basename, i); + HDsnprintf(aname, sizeof(aname), "%s%d", basename, i); /* Delete the attribute */ if (H5Adelete(gid, aname) < 0) diff --git a/test/dtypes.c b/test/dtypes.c index 628507e..6c1a440 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -2635,7 +2635,7 @@ test_compound_13(void) HDmemset(&data_out, 0, sizeof(data_out)); for (u = 0; u < COMPOUND13_ARRAY_SIZE + 1; u++) data_out.x[u] = (unsigned char)u; - data_out.y = 99.99f; + data_out.y = 99.99F; /* Set latest_format in access propertly list to enable the latest * compound datatype format. @@ -4967,7 +4967,7 @@ test_conv_str_2(void) } /* end for */ /* Do the conversions */ - HDsprintf(s, "Testing random string conversion speed"); + HDsnprintf(s, sizeof(s), "Testing random string conversion speed"); HDprintf("%-70s", s); HDfflush(stdout); if (H5Tconvert(c_type, f_type, nelmts, buf, NULL, H5P_DEFAULT) < 0) @@ -5182,14 +5182,14 @@ test_conv_enum_1(void) buf[u] = HDrand() % 26; /* Conversions */ - HDsprintf(s, "Testing random enum conversion O(N)"); + HDsnprintf(s, sizeof(s), "Testing random enum conversion O(N)"); HDprintf("%-70s", s); HDfflush(stdout); if (H5Tconvert(t1, t2, nelmts, buf, NULL, H5P_DEFAULT) < 0) goto error; PASSED(); - HDsprintf(s, "Testing random enum conversion O(N log N)"); + HDsnprintf(s, sizeof(s), "Testing random enum conversion O(N log N)"); HDprintf("%-70s", s); HDfflush(stdout); if (H5Tconvert(t2, t1, nelmts, buf, NULL, H5P_DEFAULT) < 0) diff --git a/test/earray.c b/test/earray.c index 7cbc842..65664fb 100644 --- a/test/earray.c +++ b/test/earray.c @@ -2543,15 +2543,16 @@ main(void) /* Test first element in data block */ nelmts = (hsize_t)((hsize_t)1 + cparam.idx_blk_elmts + tparam.sblk_info[sblk].start_idx + (tparam.sblk_info[sblk].dblk_nelmts * dblk)); - HDsprintf(test_str, "setting first element of array's data block #%llu", - (unsigned long long)ndblks); + HDsnprintf(test_str, sizeof(test_str), + "setting first element of array's data block #%llu", + (unsigned long long)ndblks); nerrors += test_set_elmts(fapl, &cparam, &tparam, nelmts, test_str); /* Test all elements in data block */ nelmts = (hsize_t)(cparam.idx_blk_elmts + tparam.sblk_info[sblk].start_idx + (tparam.sblk_info[sblk].dblk_nelmts * (dblk + 1))); - HDsprintf(test_str, "setting all elements of array's data block #%llu", - (unsigned long long)ndblks); + HDsnprintf(test_str, sizeof(test_str), "setting all elements of array's data block #%llu", + (unsigned long long)ndblks); nerrors += test_set_elmts(fapl, &cparam, &tparam, nelmts, test_str); /* Increment data block being tested */ diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c index 60b229a..0a73273 100644 --- a/test/enc_dec_plist.c +++ b/test/enc_dec_plist.c @@ -199,8 +199,8 @@ main(void) /* Display testing info */ low_string = h5_get_version_string(low); high_string = h5_get_version_string(high); - HDsprintf(msg, "Testing ENCODE/DECODE with file version bounds: (%s, %s):", low_string, - high_string); + HDsnprintf(msg, sizeof(msg), + "Testing ENCODE/DECODE with file version bounds: (%s, %s):", low_string, high_string); HDputs(msg); if (VERBOSE_MED) diff --git a/test/external.c b/test/external.c index c31701d..1e4e32a 100644 --- a/test/external.c +++ b/test/external.c @@ -890,8 +890,8 @@ test_write_file_set(hid_t fapl) for (i = 0; i < N_EXT_FILES; i++) { char name1[64], name2[64]; - HDsprintf(name1, "extern_%dr.raw", i + 1); - HDsprintf(name2, "extern_%dw.raw", i + 1); + HDsnprintf(name1, sizeof(name1), "extern_%dr.raw", i + 1); + HDsnprintf(name2, sizeof(name2), "extern_%dw.raw", i + 1); if (!files_have_same_contents(name1, name2)) FAIL_PUTS_ERROR(" Output differs from expected value.") } /* end for */ diff --git a/test/external_common.c b/test/external_common.c index c37fd16..3f04260 100644 --- a/test/external_common.c +++ b/test/external_common.c @@ -59,9 +59,9 @@ reset_raw_data_files(hbool_t is_env) /* Open file */ if (is_env) - HDsprintf(filename, "extern_env_%lur.raw", (unsigned long)i + 1); + HDsnprintf(filename, sizeof(filename), "extern_env_%lur.raw", (unsigned long)i + 1); else - HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); + HDsnprintf(filename, sizeof(filename), "extern_%lur.raw", (unsigned long)i + 1); if ((fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; @@ -96,9 +96,9 @@ reset_raw_data_files(hbool_t is_env) /* Open file */ if (is_env) - HDsprintf(filename, "extern_env_%luw.raw", (unsigned long)i + 1); + HDsnprintf(filename, sizeof(filename), "extern_env_%luw.raw", (unsigned long)i + 1); else - HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); + HDsnprintf(filename, sizeof(filename), "extern_%luw.raw", (unsigned long)i + 1); if ((fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) goto error; diff --git a/test/fheap.c b/test/fheap.c index 96293fa..c98034f 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -565,8 +565,9 @@ begin_test(fheap_test_param_t *tparam, const char *base_desc, fheap_heap_ids_t * */ del_str = get_del_string(tparam); HDassert(del_str); - test_desc = (char *)H5MM_malloc(HDstrlen(del_str) + HDstrlen(base_desc)); - HDsprintf(test_desc, base_desc, del_str); + size_t test_desc_len = HDstrlen(del_str) + HDstrlen(base_desc); + test_desc = (char *)H5MM_malloc(test_desc_len); + HDsnprintf(test_desc, test_desc_len, base_desc, del_str); TESTING(test_desc); H5MM_xfree(del_str); H5MM_xfree(test_desc); diff --git a/test/flush1.c b/test/flush1.c index 456f5f4..4eb57b2 100644 --- a/test/flush1.c +++ b/test/flush1.c @@ -81,7 +81,7 @@ create_file(const char *filename, hid_t fapl_id, hbool_t swmr) if ((top_gid = H5Gcreate2(fid, "top_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) STACK_ERROR for (i = 0; i < NGROUPS; i++) { - HDsprintf(group_name, "group%02d", i); + HDsnprintf(group_name, sizeof(group_name), "group%02d", i); if ((gid = H5Gcreate2(top_gid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) STACK_ERROR if (H5Gclose(gid) < 0) diff --git a/test/flush2.c b/test/flush2.c index 3262b14..531c9c8 100644 --- a/test/flush2.c +++ b/test/flush2.c @@ -144,7 +144,7 @@ file_ok(const char *filename, hid_t fapl_id, hbool_t check_second_dset) if ((top_gid = H5Gopen2(fid, "top_group", H5P_DEFAULT)) < 0) goto error; for (i = 0; i < NGROUPS; i++) { - HDsprintf(group_name, "group%02d", i); + HDsnprintf(group_name, sizeof(group_name), "group%02d", i); if ((gid = H5Gopen2(top_gid, group_name, H5P_DEFAULT)) < 0) goto error; if (H5Gclose(gid) < 0) diff --git a/test/genall5.c b/test/genall5.c index 05ad4a2..4fa6c01 100644 --- a/test/genall5.c +++ b/test/genall5.c @@ -306,7 +306,7 @@ ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) while ((pass) && (u < nlinks)) { char linkname[16]; - HDsprintf(linkname, "%u", u); + HDsnprintf(linkname, sizeof(linkname), "%u", u); if (0 == (u % 3)) { ret = H5Lcreate_soft(group_name, gid, linkname, H5P_DEFAULT, H5P_DEFAULT); @@ -474,7 +474,7 @@ vrfy_ns_grp_c(hid_t fid, const char *group_name, unsigned nlinks) char linkname[16]; htri_t link_exists; - HDsprintf(linkname, "%u", u); + HDsnprintf(linkname, sizeof(linkname), "%u", u); link_exists = H5Lexists(gid, linkname, H5P_DEFAULT); if (link_exists < 0) { @@ -715,7 +715,7 @@ ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) while ((pass) && (u < nlinks)) { char linkname[16]; - HDsprintf(linkname, "%u", u); + HDsnprintf(linkname, sizeof(linkname), "%u", u); if (0 == (u % 3)) { ret = H5Lcreate_soft(group_name, gid, linkname, H5P_DEFAULT, H5P_DEFAULT); @@ -883,7 +883,7 @@ vrfy_ns_grp_d(hid_t fid, const char *group_name, unsigned nlinks) char linkname[16]; htri_t link_exists; - HDsprintf(linkname, "%u", u); + HDsnprintf(linkname, sizeof(linkname), "%u", u); link_exists = H5Lexists(gid, linkname, H5P_DEFAULT); if (link_exists < 0) { @@ -1321,7 +1321,7 @@ os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) while ((pass) && (u < nlinks)) { char linkname[32]; - HDsprintf(linkname, "ln%d_%u", proc_num, u); + HDsnprintf(linkname, sizeof(linkname), "ln%d_%u", proc_num, u); if (0 == (u % 2)) { ret = H5Lcreate_soft(group_name, gid, linkname, H5P_DEFAULT, H5P_DEFAULT); @@ -1479,7 +1479,7 @@ vrfy_os_grp_n(hid_t fid, const char *group_name, int proc_num, unsigned nlinks) char linkname[32]; htri_t link_exists; - HDsprintf(linkname, "ln%d_%u", proc_num, u); + HDsnprintf(linkname, sizeof(linkname), "ln%d_%u", proc_num, u); link_exists = H5Lexists(gid, linkname, H5P_DEFAULT); if (link_exists < 0) { @@ -3056,26 +3056,26 @@ create_zoo(hid_t fid, const char *base_path, int proc_num) /* Add & verify an empty "new style" group */ if (pass) { - HDsprintf(full_path, "%s/A", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/A", base_path); HDassert(HDstrlen(full_path) < 1024); ns_grp_0(fid, full_path); } if (pass) { - HDsprintf(full_path, "%s/A", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/A", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ns_grp_0(fid, full_path); } /* Add & verify a compact "new style" group (3 link messages) */ if (pass) { - HDsprintf(full_path, "%s/B", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/B", base_path); HDassert(HDstrlen(full_path) < 1024); ns_grp_c(fid, full_path, 3); } if (pass) { - HDsprintf(full_path, "%s/B", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/B", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ns_grp_c(fid, full_path, 3); } @@ -3084,26 +3084,26 @@ create_zoo(hid_t fid, const char *base_path, int proc_num) * fractal heap) */ if (pass) { - HDsprintf(full_path, "%s/C", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/C", base_path); HDassert(HDstrlen(full_path) < 1024); ns_grp_d(fid, full_path, 300); } if (pass) { - HDsprintf(full_path, "%s/C", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/C", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ns_grp_d(fid, full_path, 300); } /* Add & verify an empty "old style" group to file */ if (pass) { - HDsprintf(full_path, "%s/D", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/D", base_path); HDassert(HDstrlen(full_path) < 1024); os_grp_0(fid, full_path); } if (pass) { - HDsprintf(full_path, "%s/D", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/D", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_os_grp_0(fid, full_path); } @@ -3112,13 +3112,13 @@ create_zoo(hid_t fid, const char *base_path, int proc_num) * local heap) to file */ if (pass) { - HDsprintf(full_path, "%s/E", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/E", base_path); HDassert(HDstrlen(full_path) < 1024); os_grp_n(fid, full_path, proc_num, 300); } if (pass) { - HDsprintf(full_path, "%s/E", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/E", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_os_grp_n(fid, full_path, proc_num, 300); } @@ -3127,13 +3127,13 @@ create_zoo(hid_t fid, const char *base_path, int proc_num) * to file */ if (pass) { - HDsprintf(full_path, "%s/F", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/F", base_path); HDassert(HDstrlen(full_path) < 1024); ds_ctg_i(fid, full_path, FALSE); } if (pass) { - HDsprintf(full_path, "%s/F", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/F", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_ctg_i(fid, full_path, FALSE); } @@ -3142,13 +3142,13 @@ create_zoo(hid_t fid, const char *base_path, int proc_num) * to file */ if (pass) { - HDsprintf(full_path, "%s/G", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/G", base_path); HDassert(HDstrlen(full_path) < 1024); ds_ctg_i(fid, full_path, TRUE); } if (pass) { - HDsprintf(full_path, "%s/G", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/G", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_ctg_i(fid, full_path, TRUE); } @@ -3157,13 +3157,13 @@ create_zoo(hid_t fid, const char *base_path, int proc_num) * to file */ if (pass) { - HDsprintf(full_path, "%s/H", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/H", base_path); HDassert(HDstrlen(full_path) < 1024); ds_chk_i(fid, full_path, FALSE); } if (pass) { - HDsprintf(full_path, "%s/H", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/H", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_chk_i(fid, full_path, FALSE); } @@ -3172,13 +3172,13 @@ create_zoo(hid_t fid, const char *base_path, int proc_num) * to file */ if (pass) { - HDsprintf(full_path, "%s/I", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/I", base_path); HDassert(HDstrlen(full_path) < 1024); ds_chk_i(fid, full_path, TRUE); } if (pass) { - HDsprintf(full_path, "%s/I", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/I", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_chk_i(fid, full_path, TRUE); } @@ -3187,13 +3187,13 @@ create_zoo(hid_t fid, const char *base_path, int proc_num) * to file */ if (pass) { - HDsprintf(full_path, "%s/J", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/J", base_path); HDassert(HDstrlen(full_path) < 1024); ds_cpt_i(fid, full_path, FALSE); } if (pass) { - HDsprintf(full_path, "%s/J", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/J", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_cpt_i(fid, full_path, FALSE); } @@ -3202,13 +3202,13 @@ create_zoo(hid_t fid, const char *base_path, int proc_num) * to file */ if (pass) { - HDsprintf(full_path, "%s/K", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/K", base_path); HDassert(HDstrlen(full_path) < 1024); ds_cpt_i(fid, full_path, TRUE); } if (pass) { - HDsprintf(full_path, "%s/K", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/K", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_cpt_i(fid, full_path, TRUE); } @@ -3217,13 +3217,13 @@ create_zoo(hid_t fid, const char *base_path, int proc_num) * (but no data) to file */ if (pass) { - HDsprintf(full_path, "%s/L", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/L", base_path); HDassert(HDstrlen(full_path) < 1024); ds_ctg_v(fid, full_path, FALSE); } if (pass) { - HDsprintf(full_path, "%s/L", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/L", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_ctg_v(fid, full_path, FALSE); } @@ -3232,13 +3232,13 @@ create_zoo(hid_t fid, const char *base_path, int proc_num) * (and data) to file */ if (pass) { - HDsprintf(full_path, "%s/M", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/M", base_path); HDassert(HDstrlen(full_path) < 1024); ds_ctg_v(fid, full_path, TRUE); } if (pass) { - HDsprintf(full_path, "%s/M", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/M", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_ctg_v(fid, full_path, TRUE); } @@ -3281,14 +3281,14 @@ validate_zoo(hid_t fid, const char *base_path, int proc_num) /* validate an empty "new style" group */ if (pass) { - HDsprintf(full_path, "%s/A", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/A", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ns_grp_0(fid, full_path); } /* validate a compact "new style" group (3 link messages) */ if (pass) { - HDsprintf(full_path, "%s/B", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/B", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ns_grp_c(fid, full_path, 3); } @@ -3297,14 +3297,14 @@ validate_zoo(hid_t fid, const char *base_path, int proc_num) * fractal heap) */ if (pass) { - HDsprintf(full_path, "%s/C", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/C", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ns_grp_d(fid, full_path, 300); } /* validate an empty "old style" group in file */ if (pass) { - HDsprintf(full_path, "%s/D", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/D", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_os_grp_0(fid, full_path); } @@ -3313,7 +3313,7 @@ validate_zoo(hid_t fid, const char *base_path, int proc_num) * local heap) */ if (pass) { - HDsprintf(full_path, "%s/E", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/E", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_os_grp_n(fid, full_path, proc_num, 300); } @@ -3322,7 +3322,7 @@ validate_zoo(hid_t fid, const char *base_path, int proc_num) * in file. */ if (pass) { - HDsprintf(full_path, "%s/F", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/F", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_ctg_i(fid, full_path, FALSE); } @@ -3331,7 +3331,7 @@ validate_zoo(hid_t fid, const char *base_path, int proc_num) * in file. */ if (pass) { - HDsprintf(full_path, "%s/G", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/G", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_ctg_i(fid, full_path, TRUE); } @@ -3340,7 +3340,7 @@ validate_zoo(hid_t fid, const char *base_path, int proc_num) * in file */ if (pass) { - HDsprintf(full_path, "%s/H", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/H", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_chk_i(fid, full_path, FALSE); } @@ -3349,7 +3349,7 @@ validate_zoo(hid_t fid, const char *base_path, int proc_num) * in file */ if (pass) { - HDsprintf(full_path, "%s/I", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/I", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_chk_i(fid, full_path, TRUE); } @@ -3358,7 +3358,7 @@ validate_zoo(hid_t fid, const char *base_path, int proc_num) * in file */ if (pass) { - HDsprintf(full_path, "%s/J", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/J", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_cpt_i(fid, full_path, FALSE); } @@ -3367,7 +3367,7 @@ validate_zoo(hid_t fid, const char *base_path, int proc_num) * in file */ if (pass) { - HDsprintf(full_path, "%s/K", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/K", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_cpt_i(fid, full_path, TRUE); } @@ -3376,7 +3376,7 @@ validate_zoo(hid_t fid, const char *base_path, int proc_num) * (but no data) to file */ if (pass) { - HDsprintf(full_path, "%s/L", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/L", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_ctg_v(fid, full_path, FALSE); } @@ -3385,7 +3385,7 @@ validate_zoo(hid_t fid, const char *base_path, int proc_num) * (and data) to file */ if (pass) { - HDsprintf(full_path, "%s/M", base_path); + HDsnprintf(full_path, sizeof(full_path), "%s/M", base_path); HDassert(HDstrlen(full_path) < 1024); vrfy_ds_ctg_v(fid, full_path, TRUE); } diff --git a/test/page_buffer.c b/test/page_buffer.c index 8299de8..37f2acc 100644 --- a/test/page_buffer.c +++ b/test/page_buffer.c @@ -120,28 +120,28 @@ create_file(char *filename, hid_t fcpl, hid_t fapl) for (i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "D1dset%d", i); + HDsnprintf(dset_name, sizeof(dset_name), "D1dset%d", i); if ((dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, filespace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; if (H5Dclose(dset_id) < 0) FAIL_STACK_ERROR; - HDsprintf(dset_name, "D2dset%d", i); + HDsnprintf(dset_name, sizeof(dset_name), "D2dset%d", i); if ((dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, filespace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; if (H5Dclose(dset_id) < 0) FAIL_STACK_ERROR; - HDsprintf(dset_name, "D3dset%d", i); + HDsnprintf(dset_name, sizeof(dset_name), "D3dset%d", i); if ((dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, filespace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; if (H5Dclose(dset_id) < 0) FAIL_STACK_ERROR; - HDsprintf(dset_name, "dset%d", i); + HDsnprintf(dset_name, sizeof(dset_name), "dset%d", i); if ((dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, filespace, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; @@ -166,13 +166,13 @@ create_file(char *filename, hid_t fcpl, hid_t fapl) } } - HDsprintf(dset_name, "D1dset%d", i); + HDsnprintf(dset_name, sizeof(dset_name), "D1dset%d", i); if (H5Ldelete(grp_id, dset_name, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; - HDsprintf(dset_name, "D2dset%d", i); + HDsnprintf(dset_name, sizeof(dset_name), "D2dset%d", i); if (H5Ldelete(grp_id, dset_name, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; - HDsprintf(dset_name, "D3dset%d", i); + HDsnprintf(dset_name, sizeof(dset_name), "D3dset%d", i); if (H5Ldelete(grp_id, dset_name, H5P_DEFAULT) < 0) FAIL_STACK_ERROR; } @@ -259,7 +259,7 @@ open_file(char *filename, hid_t fapl, hsize_t page_size, size_t page_buffer_size for (i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dset%d", i); + HDsnprintf(dset_name, sizeof(dset_name), "dset%d", i); if ((dset_id = H5Dopen2(grp_id, dset_name, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; diff --git a/test/reserved.c b/test/reserved.c index 6e41a16..57a9ca6 100644 --- a/test/reserved.c +++ b/test/reserved.c @@ -71,7 +71,7 @@ rsrv_heap(void) } H5E_END_TRY - HDsprintf(dset_name, "Dset %d", i); + HDsnprintf(dset_name, sizeof(dset_name), "Dset %d", i); H5E_BEGIN_TRY { @@ -115,7 +115,7 @@ rsrv_heap(void) if (H5open() < 0) TEST_ERROR; - HDsprintf(dset_name, "Dset %d", i - 2); + HDsnprintf(dset_name, sizeof(dset_name), "Dset %d", i - 2); file_id = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT); if (file_id < 0) @@ -218,7 +218,7 @@ rsrv_ohdr(void) } /* end for */ for (i = 0; i < 2000; i++) { - HDsprintf(attrname, "attr %d", i); + HDsnprintf(attrname, sizeof(attrname), "attr %d", i); H5E_BEGIN_TRY { aid = H5Screate_simple(2, dims, NULL); diff --git a/test/tattr.c b/test/tattr.c index 756e139..e75eeb5 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"); @@ -2359,7 +2359,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"); @@ -2382,7 +2382,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"); @@ -2515,7 +2515,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"); @@ -2560,7 +2560,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"); @@ -2574,7 +2574,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"); @@ -2587,7 +2587,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"); @@ -2710,7 +2710,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"); @@ -2776,7 +2776,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"); @@ -2894,7 +2894,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"); @@ -3035,7 +3035,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"); @@ -3055,7 +3055,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"); @@ -3085,7 +3085,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"); @@ -3192,7 +3192,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"); @@ -3215,7 +3215,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"); @@ -3498,7 +3498,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"); @@ -3566,7 +3566,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"); @@ -3732,7 +3732,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"); @@ -3750,7 +3750,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"); @@ -3768,7 +3768,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"); @@ -3791,7 +3791,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"); @@ -3813,7 +3813,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"); @@ -3827,7 +3827,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"); @@ -3841,7 +3841,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"); @@ -3855,7 +3855,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"); @@ -4250,7 +4250,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"); @@ -4302,7 +4302,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"); @@ -4550,7 +4550,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"); @@ -4639,7 +4639,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"); @@ -4754,7 +4754,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"); @@ -4777,7 +4777,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"); @@ -4870,7 +4870,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"); @@ -5143,7 +5143,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"); @@ -5166,7 +5166,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"); @@ -5194,7 +5194,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"); @@ -5214,7 +5214,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"); @@ -5230,7 +5230,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"); @@ -5317,7 +5317,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"); @@ -5337,7 +5337,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"); @@ -5353,7 +5353,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"); @@ -5382,11 +5382,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 */ @@ -5526,7 +5526,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"); @@ -5869,7 +5869,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"); @@ -5909,7 +5909,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"); @@ -6353,7 +6353,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"); @@ -6428,9 +6428,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 */ @@ -6466,7 +6466,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"); @@ -6556,9 +6556,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 */ @@ -6600,7 +6601,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"); @@ -6669,9 +6670,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 */ @@ -6721,9 +6723,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 */ @@ -6804,7 +6807,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); @@ -7314,7 +7317,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"); @@ -7386,7 +7389,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"); @@ -7678,7 +7681,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"); @@ -7737,7 +7740,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"); @@ -7842,7 +7845,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"); @@ -8011,7 +8014,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"); @@ -8077,7 +8080,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"); @@ -8260,7 +8263,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"); @@ -8317,7 +8320,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"); @@ -8542,7 +8545,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) { @@ -8877,7 +8880,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) { @@ -9322,7 +9325,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) { @@ -9430,7 +9433,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); @@ -9692,7 +9695,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) { @@ -9816,7 +9819,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); diff --git a/test/tmisc.c b/test/tmisc.c index 3199ae1..3655bed 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -1083,7 +1083,7 @@ test_misc6(void) /* Loop through adding attributes to each dataset */ for (u = 0; u < MISC6_NUMATTR; u++) { /* Create name for attribute */ - HDsprintf(attr_name, "Attr#%u", u); + HDsnprintf(attr_name, sizeof(attr_name), "Attr#%u", u); /* Open the file */ loc_id = H5Fopen(MISC6_FILE, H5F_ACC_RDWR, H5P_DEFAULT); @@ -3034,7 +3034,7 @@ test_misc18(void) /* Loop creating attributes on each dataset, flushing them to the file each time */ for (u = 0; u < 10; u++) { /* Set up attribute name */ - HDsprintf(attr_name, "Attr %u", u); + HDsnprintf(attr_name, sizeof(attr_name), "Attr %u", u); /* Create & close attribute on first dataset */ aid = H5Acreate2(did1, attr_name, H5T_STD_U32LE, sid, H5P_DEFAULT, H5P_DEFAULT); @@ -5504,7 +5504,7 @@ test_misc30(void) CHECK(ret, FAIL, "test_misc30_get_info"); } - HDsprintf(gname, "/g0/group%d", i); + HDsnprintf(gname, sizeof(gname), "/g0/group%d", i); gid = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid, FAIL, "H5Gcreate2"); diff --git a/test/tselect.c b/test/tselect.c index 1bfb663..31bb9c4 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -10862,13 +10862,15 @@ test_shape_same_dr__full_space_vs_slice(int test_num, int small_rank, int large_ HDassert(edge_size > 0); HDassert(edge_size <= 1000); - HDsprintf(test_desc_0, "\tn-cube slice through m-cube (n <= m) test %d.\n", test_num); + HDsnprintf(test_desc_0, sizeof(test_desc_0), "\tn-cube slice through m-cube (n <= m) test %d.\n", + test_num); MESSAGE(7, (test_desc_0)); /* This statement must be updated if SS_DR_MAX_RANK is changed */ - HDsprintf(test_desc_1, "\t\tranks: %d/%d offset: %d dim_selected: %d/%d/%d/%d/%d.\n", small_rank, - large_rank, offset, (int)dim_selected[0], (int)dim_selected[1], (int)dim_selected[2], - (int)dim_selected[3], (int)dim_selected[4]); + HDsnprintf(test_desc_1, sizeof(test_desc_1), + "\t\tranks: %d/%d offset: %d dim_selected: %d/%d/%d/%d/%d.\n", small_rank, large_rank, offset, + (int)dim_selected[0], (int)dim_selected[1], (int)dim_selected[2], (int)dim_selected[3], + (int)dim_selected[4]); MESSAGE(7, (test_desc_1)); /* copy the edge size into the dims array */ @@ -11120,15 +11122,16 @@ test_shape_same_dr__checkerboard(int test_num, int small_rank, int large_rank, i HDassert(dims_selected >= 0); HDassert(dims_selected <= large_rank); - HDsprintf(test_desc_0, "\tcheckerboard n-cube slice through m-cube (n <= m) test %d.\n", test_num); + HDsnprintf(test_desc_0, sizeof(test_desc_0), + "\tcheckerboard n-cube slice through m-cube (n <= m) test %d.\n", test_num); MESSAGE(7, (test_desc_0)); /* This statement must be updated if SS_DR_MAX_RANK is changed */ - HDsprintf(test_desc_1, - "\tranks: %d/%d edge/chkr size: %d/%d offset: %d dim_selected: %d/%d/%d/%d/%d:%d.\n", - small_rank, large_rank, (int)edge_size, (int)checker_size, offset, (int)dim_selected[0], - (int)dim_selected[1], (int)dim_selected[2], (int)dim_selected[3], (int)dim_selected[4], - dims_selected); + HDsnprintf(test_desc_1, sizeof(test_desc_1), + "\tranks: %d/%d edge/chkr size: %d/%d offset: %d dim_selected: %d/%d/%d/%d/%d:%d.\n", + small_rank, large_rank, (int)edge_size, (int)checker_size, offset, (int)dim_selected[0], + (int)dim_selected[1], (int)dim_selected[2], (int)dim_selected[3], (int)dim_selected[4], + dims_selected); MESSAGE(7, (test_desc_1)); /* copy the edge size into the dims array */ @@ -11664,15 +11667,16 @@ test_shape_same_dr__irregular(int test_num, int small_rank, int large_rank, int HDassert(dims_selected >= 0); HDassert(dims_selected <= large_rank); - HDsprintf(test_desc_0, "\tirregular sub set of n-cube slice through m-cube (n <= m) test %d.\n", - test_num); + HDsnprintf(test_desc_0, sizeof(test_desc_0), + "\tirregular sub set of n-cube slice through m-cube (n <= m) test %d.\n", test_num); MESSAGE(7, (test_desc_0)); /* This statement must be updated if SS_DR_MAX_RANK is changed */ - HDsprintf(test_desc_1, "\tranks: %d/%d edge: %d s/p offset: %d/%d dim_selected: %d/%d/%d/%d/%d:%d.\n", - small_rank, large_rank, edge_size, slice_offset, pattern_offset, (int)dim_selected[0], - (int)dim_selected[1], (int)dim_selected[2], (int)dim_selected[3], (int)dim_selected[4], - dims_selected); + HDsnprintf(test_desc_1, sizeof(test_desc_1), + "\tranks: %d/%d edge: %d s/p offset: %d/%d dim_selected: %d/%d/%d/%d/%d:%d.\n", small_rank, + large_rank, edge_size, slice_offset, pattern_offset, (int)dim_selected[0], + (int)dim_selected[1], (int)dim_selected[2], (int)dim_selected[3], (int)dim_selected[4], + dims_selected); MESSAGE(7, (test_desc_1)); /* copy the edge size into the dims array */ diff --git a/test/tvlstr.c b/test/tvlstr.c index 68f6124..5168d39 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -817,33 +817,33 @@ test_vl_rewrite(void) /* Create in file 1 */ for (i = 0; i < REWRITE_NDATASETS; i++) { - HDsprintf(name, "/set_%d", i); + HDsnprintf(name, sizeof(name), "/set_%d", i); write_scalar_dset(file1, type, space, name, name); } /* Effectively copy data from file 1 to 2 */ for (i = 0; i < REWRITE_NDATASETS; i++) { - HDsprintf(name, "/set_%d", i); + HDsnprintf(name, sizeof(name), "/set_%d", i); read_scalar_dset(file1, type, space, name, name); write_scalar_dset(file2, type, space, name, name); } /* Read back from file 2 */ for (i = 0; i < REWRITE_NDATASETS; i++) { - HDsprintf(name, "/set_%d", i); + HDsnprintf(name, sizeof(name), "/set_%d", i); read_scalar_dset(file2, type, space, name, name); } /* end for */ /* Remove from file 2. */ for (i = 0; i < REWRITE_NDATASETS; i++) { - HDsprintf(name, "/set_%d", i); + HDsnprintf(name, sizeof(name), "/set_%d", i); ret = H5Ldelete(file2, name, H5P_DEFAULT); CHECK(ret, FAIL, "H5Ldelete"); } /* end for */ /* Effectively copy from file 1 to file 2 */ for (i = 0; i < REWRITE_NDATASETS; i++) { - HDsprintf(name, "/set_%d", i); + HDsnprintf(name, sizeof(name), "/set_%d", i); read_scalar_dset(file1, type, space, name, name); write_scalar_dset(file2, type, space, name, name); } /* end for */ diff --git a/test/unregister.c b/test/unregister.c index c6da4df..a3a4482 100644 --- a/test/unregister.c +++ b/test/unregister.c @@ -136,7 +136,7 @@ test_unregister_filters(hid_t fapl_id) /* Create multiple groups under the main group */ for (i = 0; i < GROUP_ITERATION; i++) { - HDsprintf(group_name, "group_%d", i); + HDsnprintf(group_name, sizeof(group_name), "group_%d", i); if ((gid_loop = H5Gcreate2(gid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; if (H5Gclose(gid_loop) < 0) diff --git a/test/vds_env.c b/test/vds_env.c index 58d90fc..1f00444 100644 --- a/test/vds_env.c +++ b/test/vds_env.c @@ -331,8 +331,9 @@ main(void) /* Display testing info */ low_string = h5_get_version_string(low); high_string = h5_get_version_string(high); - HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, - high_string); + HDsnprintf(msg, sizeof(msg), + "Testing virtual dataset with file version bounds: (%s, %s):", low_string, + high_string); HDputs(msg); for (bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { |