From bddd148fd29deb18439767c416199914845431b8 Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Tue, 5 Apr 2022 08:20:19 -0500 Subject: 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 Co-authored-by: Sean McBride Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: loricooperhdf Co-authored-by: myd7349 --- .github/FUNDING.yml | 3 + CMakeInstallation.cmake | 2 +- README.md | 85 ++++++++++++++++ README.txt | 80 --------------- bin/h5vers | 12 +-- c++/src/H5AbstractDs.cpp | 2 +- c++/src/H5Location.h | 2 +- c++/test/tattr.cpp | 8 +- c++/test/th5s.cpp | 2 +- c++/test/titerate.cpp | 2 +- c++/test/tvlstr.cpp | 10 +- config/cmake/README.md.cmake.in | 80 +++++++++++++++ config/cmake/README.txt.cmake.in | 80 --------------- config/cmake_ext_mod/ConfigureChecks.cmake | 116 +++++++++++----------- config/cmake_ext_mod/HDFMacros.cmake | 6 +- config/cmake_ext_mod/HDFTests.c | 4 +- configure.ac | 9 +- hl/c++/test/ptableTest.cpp | 6 +- hl/test/test_file_image.c | 5 +- hl/test/test_image.c | 6 +- hl/test/test_packet_vlen.c | 16 +-- hl/tools/gif2h5/writehdf.c | 2 +- hl/tools/h5watch/h5watch.c | 4 +- java/src/jni/h5util.c | 151 +++++++++++++++------------- src/H5AC.c | 2 +- src/H5Dchunk.c | 4 +- src/H5Dearray.c | 4 +- src/H5Dfarray.c | 4 +- src/H5EAdbg.c | 6 +- src/H5EAtest.c | 2 +- src/H5FAtest.c | 2 +- src/H5Odtype.c | 38 +++---- src/H5PLpath.c | 7 +- src/H5Tconv.c | 2 +- src/H5VLpassthru.c | 13 +-- src/H5private.h | 2 +- test/app_ref.c | 4 +- test/cache_api.c | 2 +- test/cache_common.c | 148 +++++++++++++++------------- test/cache_image.c | 16 +-- test/chunk_info.c | 2 +- test/cmpd_dset.c | 12 +-- test/del_many_dense_attrs.c | 4 +- test/dtypes.c | 8 +- test/earray.c | 9 +- test/enc_dec_plist.c | 4 +- test/external.c | 4 +- test/external_common.c | 8 +- test/fheap.c | 5 +- test/flush1.c | 2 +- test/flush2.c | 2 +- test/genall5.c | 90 ++++++++--------- test/page_buffer.c | 16 +-- test/reserved.c | 6 +- test/tattr.c | 153 +++++++++++++++-------------- test/tmisc.c | 6 +- test/tselect.c | 36 ++++--- test/tvlstr.c | 10 +- test/unregister.c | 2 +- test/vds_env.c | 5 +- testpar/t_cache.c | 2 +- testpar/t_cache_image.c | 14 +-- testpar/t_dset.c | 6 +- testpar/t_file.c | 16 +-- testpar/t_pflush1.c | 8 +- testpar/t_pflush2.c | 8 +- testpar/t_prop.c | 2 +- tools/src/h5dump/h5dump_ddl.c | 4 +- tools/src/h5dump/h5dump_xml.c | 4 +- tools/src/h5import/h5import.c | 2 +- tools/src/h5perf/pio_engine.c | 6 +- tools/test/h5repack/h5repackgentest.c | 2 +- tools/test/misc/h5clear_gentest.c | 4 +- tools/test/perform/direct_write_perf.c | 2 +- tools/test/perform/perf_meta.c | 14 +-- 75 files changed, 736 insertions(+), 691 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 README.md delete mode 100644 README.txt create mode 100644 config/cmake/README.md.cmake.in delete mode 100644 config/cmake/README.txt.cmake.in diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..7c4daaf --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +custom: "https://hdfgroup.org/about-us/donate-to-the-hdf-group/" diff --git a/CMakeInstallation.cmake b/CMakeInstallation.cmake index a4183e2..cd1f986 100644 --- a/CMakeInstallation.cmake +++ b/CMakeInstallation.cmake @@ -178,7 +178,7 @@ if (HDF5_PACK_EXAMPLES) endif () #----------------------------------------------------------------------------- -# Configure the README.txt file for the binary package +# Configure the README.md file for the binary package #----------------------------------------------------------------------------- HDF_README_PROPERTIES(HDF5_BUILD_FORTRAN) diff --git a/README.md b/README.md new file mode 100644 index 0000000..9db1dc4 --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ +HDF5 version 1.12.2-2 currently under development + +![HDF5 Logo](doxygen/img/HDF5.png) + +*Please refer to the release_docs/INSTALL file for installation instructions.* + +THE HDF GROUP +--------------- + +The HDF Group is the developer of HDF5®, a high-performance software library and +data format that has been adopted across multiple industries and has become a +de facto standard in scientific and research communities. + +More information about The HDF Group, the HDF5 Community and the HDF5 software +project, tools and services can be found at the Group's website. + + https://www.hdfgroup.org/ + + +DOCUMENTATION +------------- +This release is fully functional for the API described in the documentation. + + https://portal.hdfgroup.org/display/HDF5/The+HDF5+API + +Full Documentation and Programming Resources for this release can be found at + + https://portal.hdfgroup.org/display/HDF5 + +See the RELEASE.txt file in the release_docs/ directory for information specific +to the features and updates included in this release of the library. + +Several more files are located within the release_docs/ directory with specific +details for several common platforms and configurations. + + INSTALL - Start Here. General instructions for compiling and installing the library + INSTALL_CMAKE - instructions for building with CMake (Kitware.com) + INSTALL_parallel - instructions for building and configuring Parallel HDF5 + INSTALL_Windows and INSTALL_Cygwin - MS Windows installations. + + + +HELP AND SUPPORT +---------------- +Information regarding Help Desk and Support services is available at + + https://portal.hdfgroup.org/display/support/The+HDF+Help+Desk + + + +FORUM and NEWS +-------------- +The following public forums are provided for public announcements and discussions +of interest to the general HDF5 Community. + + - Homepage of the Forum + https://forum.hdfgroup.org + + - News and Announcement + https://forum.hdfgroup.org/c/news-and-announcements-from-the-hdf-group + + - HDF5 and HDF4 Topics + https://forum.hdfgroup.org/c/hdf5 + +These forums are provided as an open and public service for searching and reading. +Posting requires completing a simple registration and allows one to join in the +conversation. Please read the following instructions pertaining to the Forum's +use and configuration + https://forum.hdfgroup.org/t/quickstart-guide-welcome-to-the-new-hdf-forum + + +SNAPSHOTS, PREVIOUS RELEASES AND SOURCE CODE +-------------------------------------------- +Periodically development code snapshots are provided at the following URL: + + https://gamma.hdfgroup.org/ftp/pub/outgoing/hdf5/snapshots/ + +Source packages for current and previous releases are located at: + + https://portal.hdfgroup.org/display/support/Downloads + +Development code is available at our Github location: + + https://github.com/HDFGroup/hdf5.git + diff --git a/README.txt b/README.txt deleted file mode 100644 index da7d0fa..0000000 --- a/README.txt +++ /dev/null @@ -1,80 +0,0 @@ -HDF5 version 1.12.2-2 currently under development - ------------------------------------------------------------------------------- -Please refer to the release_docs/INSTALL file for installation instructions. ------------------------------------------------------------------------------- - -THE HDF GROUP ---------------- - -The HDF Group is the developer of HDF5®, a high-performance software library and -data format that has been adopted across multiple industries and has become a -de facto standard in scientific and research communities. - -More information about The HDF Group, the HDF5 Community and the HDF5 software -project, tools and services can be found at the Group's website. - - https://www.hdfgroup.org/ - - -DOCUMENTATION -------------- -This release is fully functional for the API described in the documentation. - https://portal.hdfgroup.org/display/HDF5/The+HDF5+API - -Full Documentation and Programming Resources for this release can be found at - https://portal.hdfgroup.org/display/HDF5 - -See the RELEASE.txt file in the release_docs/ directory for information specific -to the features and updates included in this release of the library. - -Several more files are located within the release_docs/ directory with specific -details for several common platforms and configurations. - - INSTALL - Start Here. General instructions for compiling and installing the library - INSTALL_CMAKE - instructions for building with CMake (Kitware.com) - INSTALL_parallel - instructions for building and configuring Parallel HDF5 - INSTALL_Windows and INSTALL_Cygwin - MS Windows installations. - - - -HELP AND SUPPORT ----------------- -Information regarding Help Desk and Support services is available at - - https://portal.hdfgroup.org/display/support/The+HDF+Help+Desk - - - -FORUM and NEWS --------------- -The following public forums are provided for public announcements and discussions -of interest to the general HDF5 Community. - - Homepage of the Forum - https://forum.hdfgroup.org - - News and Announcement - https://forum.hdfgroup.org/c/news-and-announcements-from-the-hdf-group - - HDF5 and HDF4 Topics - https://forum.hdfgroup.org/c/hdf5 - -These forums are provided as an open and public service for searching and reading. -Posting requires completing a simple registration and allows one to join in the -conversation. Please read the following instructions pertaining to the Forum's -use and configuration - https://forum.hdfgroup.org/t/quickstart-guide-welcome-to-the-new-hdf-forum - - -SNAPSHOTS, PREVIOUS RELEASES AND SOURCE CODE --------------------------------------------- -Periodically development code snapshots are provided at the following URL: - https://gamma.hdfgroup.org/ftp/pub/outgoing/hdf5/snapshots/ - -Source packages for current and previous releases are located at: - https://portal.hdfgroup.org/display/support/Downloads - -Development code is available at our Github location: - https://github.com/HDFGroup/hdf5.git - diff --git a/bin/h5vers b/bin/h5vers index 8f75df1..04d5d03 100755 --- a/bin/h5vers +++ b/bin/h5vers @@ -66,7 +66,7 @@ use strict; # ./H5public.h or ./src/H5public.h. # # If the version number is changed (either `-s' or `-i' was used on -# the command line) then the first line of the README.txt and RELEASE.txt files +# the command line) then the version line of the README.md and RELEASE.txt files # one directory above the H5public.h file is also modified so it looks # something like: This is hdf5-1.2.3-pre1 currently under development. # The AC_INIT macro in configure.ac will also change in this case to be @@ -156,10 +156,10 @@ while ($_ = shift) { } die "mutually exclusive options given\n" if $set && $inc; -# Determine file to use as H5public.h, README.txt, +# Determine file to use as H5public.h, README.md, # release_docs/RELEASE.txt, configure.ac, windows/src/H5pubconf.h # config/lt_vers.am and config/cmake/scripts/HDF5config.cmake. -# The README.txt, release_docs/RELEASE.txt, configure.ac, +# The README.md, release_docs/RELEASE.txt, configure.ac, # windows/src/H5pubconf.h, config/lt_vers.am and # config/cmake/scripts/HDF5config.cmake # files are always in the directory above H5public.h @@ -178,9 +178,9 @@ die "unable to read file: $LT_VERS\n" unless -r $file; my $HDF5CONFIGCMAKE = $file; $HDF5CONFIGCMAKE =~ s/[^\/]*$/..\/config\/cmake\/scripts\/HDF5config.cmake/; die "unable to read file: $HDF5CONFIGCMAKE\n" unless -r $file; -# README.txt +# README.md my $README = $file; -$README =~ s/[^\/]*$/..\/README.txt/; +$README =~ s/[^\/]*$/..\/README.md/; die "unable to read file: $README\n" unless -r $file; # release_docs/RELEASE.txt my $RELEASE = $file; @@ -303,7 +303,7 @@ if ($LT_VERS && $version_increased) { # close FILE; } -# Update the README.txt file +# Update the README.md file if ($README) { open FILE, $README or die "$README: $!\n"; my @contents = ; diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index eeb0155..70d8531 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -302,7 +302,7 @@ AbstractDs::getStrType() const //-------------------------------------------------------------------------- // Function: AbstractDs::getVarLenType -///\brief Returns the floating-point datatype of this abstract dataset, +///\brief Returns the variable length datatype of this abstract dataset, /// which can be a dataset or an attribute. ///\return VarLenType instance ///\exception H5::DataTypeIException diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index 740d0ce..27ddd54 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -334,7 +334,7 @@ class H5_DLLCPP H5Location : public IdComponent { #endif // DOXYGEN_SHOULD_SKIP_THIS // Noop destructor. - virtual ~H5Location(); + virtual ~H5Location() override; }; // end of H5Location } // namespace H5 diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index adaa237..bd6a8c0 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -93,7 +93,7 @@ struct attr4_struct { const H5std_string ATTR5_NAME("Attr5"); const int ATTR5_RANK = 0; -float attr_data5 = (float)-5.123; // Test data for 5th attribute +float attr_data5 = -5.123F; // Test data for 5th attribute /* Info for another attribute */ const H5std_string ATTR1A_NAME("Attr1_a"); @@ -1741,7 +1741,7 @@ test_attr_dense_create(FileCreatPropList &fcpl, FileAccPropList &fapl) unsigned attr_num; for (attr_num = 0; attr_num < max_compact; attr_num++) { // Create attribute - sprintf(attr_name, "attr %02u", attr_num); + snprintf(attr_name, sizeof(attr_name), "attr %02u", attr_num); Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); // Write data to the attribute @@ -1753,7 +1753,7 @@ test_attr_dense_create(FileCreatPropList &fcpl, FileAccPropList &fapl) { // Add one more attribute, to push into "dense" storage // Create another attribute - sprintf(attr_name, "attr %02u", attr_num); + snprintf(attr_name, sizeof(attr_name), "attr %02u", attr_num); Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); // Write data to the attribute @@ -1763,7 +1763,7 @@ test_attr_dense_create(FileCreatPropList &fcpl, FileAccPropList &fapl) // Attempt to add attribute again, which should fail try { // Create another attribute - sprintf(attr_name, "attr %02u", attr_num); + snprintf(attr_name, sizeof(attr_name), "attr %02u", attr_num); Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); // continuation here, that means no exception has been thrown diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp index 9952e68..9dd92fa 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -73,7 +73,7 @@ struct space4_struct { unsigned u; float f; char c2; -} space4_data = {'v', 987123, (float)-3.14, 'g'}; /* Test data for 4th dataspace */ +} space4_data = {'v', 987123, -3.14F, 'g'}; /* Test data for 4th dataspace */ /* Null dataspace */ int space5_data = 7; diff --git a/c++/test/titerate.cpp b/c++/test/titerate.cpp index 7fb64c4..5b8039f 100644 --- a/c++/test/titerate.cpp +++ b/c++/test/titerate.cpp @@ -161,7 +161,7 @@ test_iter_group(FileAccPropList &fapl) DataSpace filespace; for (i = 0; i < NDATASETS; i++) { - sprintf(name, "Dataset %d", i); + snprintf(name, sizeof(name), "Dataset %d", i); // Create a dataset in the file DataSet dataset = file.createDataSet(name, datatype, filespace); diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index b371518..7a7b854 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -911,32 +911,32 @@ test_vl_rewrite() int i; char name[256]; // Buffer for names & data for (i = 0; i < REWRITE_NDATASETS; i++) { - sprintf(name, "/set_%d", i); + snprintf(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++) { - sprintf(name, "/set_%d", i); + snprintf(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++) { - sprintf(name, "/set_%d", i); + snprintf(name, sizeof(name), "/set_%d", i); read_scalar_dset(file2, type, space, name, name); } // Remove from file 2. for (i = 0; i < REWRITE_NDATASETS; i++) { - sprintf(name, "/set_%d", i); + snprintf(name, sizeof(name), "/set_%d", i); file2.unlink(name); } // Effectively copy from file 1 to file 2. for (i = 0; i < REWRITE_NDATASETS; i++) { - sprintf(name, "/set_%d", i); + snprintf(name, sizeof(name), "/set_%d", i); read_scalar_dset(file1, type, space, name, name); write_scalar_dset(file2, type, space, name, name); } diff --git a/config/cmake/README.md.cmake.in b/config/cmake/README.md.cmake.in new file mode 100644 index 0000000..b60e729 --- /dev/null +++ b/config/cmake/README.md.cmake.in @@ -0,0 +1,80 @@ +@HDF5_PACKAGE_NAME@ version @HDF5_PACKAGE_VERSION_STRING@ +------------------------------------------------------------------------------ + +This directory contains the binary (release) distribution of +@HDF5_PACKAGE_NAME@ @HDF5_PACKAGE_VERSION_MAJOR@ that was compiled on; + @BINARY_PLATFORM@. + +It was built with the following options: + -- @LIB_TYPE@ C/C++/Fortran libraries + -- SZIP (encoder enabled) and ZLIB + -- @LIB_TYPE@ HDF5 tools + -- Java @Java_VERSION@ + +The contents of this directory are: + + COPYING - Copyright notice + README.md - This file + @HDF5_PACKAGE_NAME@-@HDF5_PACKAGE_VERSION@-@BINARY_SYSTEM_NAME@.@BINARY_INSTALL_ENDING@ - HDF5 Install Package + +This binary was built with the ZLIB and SZIP/Libaec external libraries and are +included for convenience. Libaec is an unrestricted open-source replacement for SZIP +(version 1.0.4, Encoder ENABLED). + +The official ZLIB and SZIP/Libaec pages are at: + + ZLIB: https://git.savannah.gnu.org/cgit/gzip.git/ + https://git.savannah.gnu.org/cgit/gzip.git/tree/COPYING + SZIP/Libaec: https://gitlab.dkrz.de/k202009/libaec + https://gitlab.dkrz.de/k202009/libaec/-/blob/master/Copyright.txt + + +Installation +=========================================================================== +1. Execute @HDF5_PACKAGE_NAME@-@HDF5_PACKAGE_VERSION@-@BINARY_SYSTEM_NAME@.@BINARY_INSTALL_ENDING@ +2. Follow prompts +=========================================================================== + +After Installation +=========================================================================== +The examples folder, HDF5Examples, located in the +HDF5 install folder, can be built and tested with CMake and the supplied +HDF5_Examples.cmake file. The HDF5_Examples.cmake expects HDF5 to have +been installed in the default location with above compilers (see the +libhdf5.settings file in the lib install folder). Also, the CMake +utility should be installed. + +To test the installation with the examples; + Create a directory to run the examples. + Copy HDF5Examples folder to this directory. + Copy CTestScript.cmake to this directory. + Copy HDF5_Examples.cmake to this directory. + Copy HDF5_Examples_options.cmake to this directory. + The default source folder is defined as "HDF5Examples". It can be changed + with the CTEST_SOURCE_NAME script option. + The default installation folder is defined as "@CMAKE_INSTALL_PREFIX@". + It can be changed with the INSTALLDIR script option. + The default ctest configuration is defined as "Release". It can be changed + with the CTEST_CONFIGURATION_TYPE script option. Note that this must + be the same as the value used with the -C command line option. + The default build configuration is defined to build and use static libraries. + Shared libraries can be used with the STATICONLYLIBRARIES script option set to "NO". + Other options can be changed by editing the HDF5_Examples_options.cmake file. + + If the defaults are okay, execute from this directory: + ctest -S HDF5_Examples.cmake -C Release -V -O test.log + If the defaults need change, execute from this directory: + ctest -S HDF5_Examples.cmake,CTEST_SOURCE_NAME=MyExamples,INSTALLDIR=MyLocation -C Release -V -O test.log + +When executed, the ctest script will save the results to the log file, test.log, as +indicated by the ctest command. If you wish the to see more build and test information, +add "-VV" to the ctest command. The output should show; + 100% tests passed, 0 tests failed out of 156. + +For more information see USING_CMake_Examples.txt in the install folder. +=========================================================================== + +Documentation for this release can be found at the following URL: + https://portal.hdfgroup.org/display/HDF5/HDF5 + +Bugs should be reported to help@hdfgroup.org. diff --git a/config/cmake/README.txt.cmake.in b/config/cmake/README.txt.cmake.in deleted file mode 100644 index 9289870..0000000 --- a/config/cmake/README.txt.cmake.in +++ /dev/null @@ -1,80 +0,0 @@ -@HDF5_PACKAGE_NAME@ version @HDF5_PACKAGE_VERSION_STRING@ ------------------------------------------------------------------------------- - -This directory contains the binary (release) distribution of -@HDF5_PACKAGE_NAME@ @HDF5_PACKAGE_VERSION_MAJOR@ that was compiled on; - @BINARY_PLATFORM@. - -It was built with the following options: - -- @LIB_TYPE@ C/C++/Fortran libraries - -- SZIP (encoder enabled) and ZLIB - -- @LIB_TYPE@ HDF5 tools - -- Java @Java_VERSION@ - -The contents of this directory are: - - COPYING - Copyright notice - README.txt - This file - @HDF5_PACKAGE_NAME@-@HDF5_PACKAGE_VERSION@-@BINARY_SYSTEM_NAME@.@BINARY_INSTALL_ENDING@ - HDF5 Install Package - -This binary was built with the ZLIB and SZIP/Libaec external libraries and are -included for convenience. Libaec is an unrestricted open-source replacement for SZIP -(version 1.0.4, Encoder ENABLED). - -The official ZLIB and SZIP/Libaec pages are at: - - ZLIB: https://git.savannah.gnu.org/cgit/gzip.git/ - https://git.savannah.gnu.org/cgit/gzip.git/tree/COPYING - SZIP/Libaec: https://gitlab.dkrz.de/k202009/libaec - https://gitlab.dkrz.de/k202009/libaec/-/blob/master/Copyright.txt - - -Installation -=========================================================================== -1. Execute @HDF5_PACKAGE_NAME@-@HDF5_PACKAGE_VERSION@-@BINARY_SYSTEM_NAME@.@BINARY_INSTALL_ENDING@ -2. Follow prompts -=========================================================================== - -After Installation -=========================================================================== -The examples folder, HDF5Examples, located in the -HDF5 install folder, can be built and tested with CMake and the supplied -HDF5_Examples.cmake file. The HDF5_Examples.cmake expects HDF5 to have -been installed in the default location with above compilers (see the -libhdf5.settings file in the lib install folder). Also, the CMake -utility should be installed. - -To test the installation with the examples; - Create a directory to run the examples. - Copy HDF5Examples folder to this directory. - Copy CTestScript.cmake to this directory. - Copy HDF5_Examples.cmake to this directory. - Copy HDF5_Examples_options.cmake to this directory. - The default source folder is defined as "HDF5Examples". It can be changed - with the CTEST_SOURCE_NAME script option. - The default installation folder is defined as "@CMAKE_INSTALL_PREFIX@". - It can be changed with the INSTALLDIR script option. - The default ctest configuration is defined as "Release". It can be changed - with the CTEST_CONFIGURATION_TYPE script option. Note that this must - be the same as the value used with the -C command line option. - The default build configuration is defined to build and use static libraries. - Shared libraries can be used with the STATICONLYLIBRARIES script option set to "NO". - Other options can be changed by editing the HDF5_Examples_options.cmake file. - - If the defaults are okay, execute from this directory: - ctest -S HDF5_Examples.cmake -C Release -V -O test.log - If the defaults need change, execute from this directory: - ctest -S HDF5_Examples.cmake,CTEST_SOURCE_NAME=MyExamples,INSTALLDIR=MyLocation -C Release -V -O test.log - -When executed, the ctest script will save the results to the log file, test.log, as -indicated by the ctest command. If you wish the to see more build and test information, -add "-VV" to the ctest command. The output should show; - 100% tests passed, 0 tests failed out of 156. - -For more information see USING_CMake_Examples.txt in the install folder. -=========================================================================== - -Documentation for this release can be found at the following URL: - https://portal.hdfgroup.org/display/HDF5/HDF5 - -Bugs should be reported to help@hdfgroup.org. diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index f022a4c..56957f9 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -253,65 +253,63 @@ set (LINUX_LFS 0) set (HDF_EXTRA_C_FLAGS) set (HDF_EXTRA_FLAGS) if (MINGW OR NOT WINDOWS) - # Might want to check explicitly for Linux and possibly Cygwin - # instead of checking for not Solaris or Darwin. - if (NOT ${HDF_PREFIX}_HAVE_SOLARIS AND NOT ${HDF_PREFIX}_HAVE_DARWIN) - # Linux Specific flags - # This was originally defined as _POSIX_SOURCE which was updated to - # _POSIX_C_SOURCE=199506L to expose a greater amount of POSIX - # functionality so clock_gettime and CLOCK_MONOTONIC are defined - # correctly. This was later updated to 200112L so that - # posix_memalign() is visible for the direct VFD code on Linux - # systems. - # POSIX feature information can be found in the gcc manual at: - # http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html - set (HDF_EXTRA_C_FLAGS -D_POSIX_C_SOURCE=200809L) - - # Need to add this so that O_DIRECT is visible for the direct - # VFD on Linux systems. - set (HDF_EXTRA_C_FLAGS ${HDF_EXTRA_C_FLAGS} -D_GNU_SOURCE) - - option (HDF_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON) - if (HDF_ENABLE_LARGE_FILE AND NOT DEFINED TEST_LFS_WORKS_RUN) - set (msg "Performing TEST_LFS_WORKS") - try_run (TEST_LFS_WORKS_RUN TEST_LFS_WORKS_COMPILE - ${CMAKE_BINARY_DIR} - ${HDF_RESOURCES_EXT_DIR}/HDFTests.c - COMPILE_DEFINITIONS "-DTEST_LFS_WORKS" - ) - - # The LARGEFILE definitions were from the transition period - # and are probably no longer needed. The FILE_OFFSET_BITS - # check should be generalized for all POSIX systems as it - # is in the Autotools. - if (TEST_LFS_WORKS_COMPILE) - if (TEST_LFS_WORKS_RUN MATCHES 0) - set (TEST_LFS_WORKS 1 CACHE INTERNAL ${msg}) - set (LARGEFILE 1) - set (HDF_EXTRA_FLAGS ${HDF_EXTRA_FLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "${msg}... yes") - endif () - else () - set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg}) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "${msg}... no") - endif () - file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Test TEST_LFS_WORKS Run failed with the following exit code:\n ${TEST_LFS_WORKS_RUN}\n" - ) - endif () - else () - set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg}) - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") - message (VERBOSE "${msg}... no") - endif () - file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Test TEST_LFS_WORKS Compile failed\n" - ) - endif () - endif () - set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${HDF_EXTRA_FLAGS}) + if (CMAKE_SYSTEM_NAME MATCHES "Linux") + # Linux Specific flags + # This was originally defined as _POSIX_SOURCE which was updated to + # _POSIX_C_SOURCE=199506L to expose a greater amount of POSIX + # functionality so clock_gettime and CLOCK_MONOTONIC are defined + # correctly. This was later updated to 200112L so that + # posix_memalign() is visible for the direct VFD code on Linux + # systems. + # POSIX feature information can be found in the gcc manual at: + # http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html + set (HDF_EXTRA_C_FLAGS -D_POSIX_C_SOURCE=200809L) + + # Need to add this so that O_DIRECT is visible for the direct + # VFD on Linux systems. + set (HDF_EXTRA_C_FLAGS ${HDF_EXTRA_C_FLAGS} -D_GNU_SOURCE) + + option (HDF_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON) + if (HDF_ENABLE_LARGE_FILE AND NOT DEFINED TEST_LFS_WORKS_RUN) + set (msg "Performing TEST_LFS_WORKS") + try_run (TEST_LFS_WORKS_RUN TEST_LFS_WORKS_COMPILE + ${CMAKE_BINARY_DIR} + ${HDF_RESOURCES_EXT_DIR}/HDFTests.c + COMPILE_DEFINITIONS "-DTEST_LFS_WORKS" + ) + + # The LARGEFILE definitions were from the transition period + # and are probably no longer needed. The FILE_OFFSET_BITS + # check should be generalized for all POSIX systems as it + # is in the Autotools. + if (TEST_LFS_WORKS_COMPILE) + if (TEST_LFS_WORKS_RUN MATCHES 0) + set (TEST_LFS_WORKS 1 CACHE INTERNAL ${msg}) + set (LARGEFILE 1) + set (HDF_EXTRA_FLAGS ${HDF_EXTRA_FLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... yes") + endif () + else () + set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg}) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... no") + endif () + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Test TEST_LFS_WORKS Run failed with the following exit code:\n ${TEST_LFS_WORKS_RUN}\n" + ) + endif () + else () + set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg}) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "${msg}... no") + endif () + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Test TEST_LFS_WORKS Compile failed\n" + ) + endif () + endif () + set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${HDF_EXTRA_FLAGS}) endif () endif () diff --git a/config/cmake_ext_mod/HDFMacros.cmake b/config/cmake_ext_mod/HDFMacros.cmake index 53e9f8f..0f9b367 100644 --- a/config/cmake_ext_mod/HDFMacros.cmake +++ b/config/cmake_ext_mod/HDFMacros.cmake @@ -223,7 +223,7 @@ macro (TARGET_C_PROPERTIES wintarget libtype) endmacro () #----------------------------------------------------------------------------- -# Configure the README.txt file for the binary package +# Configure the README.md file for the binary package #----------------------------------------------------------------------------- macro (HDF_README_PROPERTIES target_fortran) set (BINARY_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}) @@ -301,8 +301,8 @@ macro (HDF_README_PROPERTIES target_fortran) endif () configure_file ( - ${HDF_RESOURCES_DIR}/README.txt.cmake.in - ${CMAKE_BINARY_DIR}/README.txt @ONLY + ${HDF_RESOURCES_DIR}/README.md.cmake.in + ${CMAKE_BINARY_DIR}/README.md @ONLY ) endmacro () diff --git a/config/cmake_ext_mod/HDFTests.c b/config/cmake_ext_mod/HDFTests.c index 2d7e1b4..133540b 100644 --- a/config/cmake_ext_mod/HDFTests.c +++ b/config/cmake_ext_mod/HDFTests.c @@ -188,8 +188,8 @@ int main(void) for (currentArg = llwidthArgs; *currentArg != NULL; currentArg++) { char formatString[64]; - sprintf(formatString, "%%%sd", *currentArg); - sprintf(s, formatString, x); + snprintf(formatString, sizeof(formatString), "%%%sd", *currentArg); + snprintf(s, 128, formatString, x); if (strcmp(s, "1099511627776") == 0) { printf("PRINTF_LL_WIDTH=[%s]\n", *currentArg); diff --git a/configure.ac b/configure.ac index ea6a811..d033599 100644 --- a/configure.ac +++ b/configure.ac @@ -843,7 +843,8 @@ AC_LANG_POP(C++) AC_SUBST([HDF5_HL]) AC_SUBST([HDF5_HL_TOOLS]) -## The high-level library is enabled unless the build mode is clean. +## The high-level library and high-level tools are enabled unless the build mode +## is clean. if test "X-$BUILD_MODE" = "X-clean" ; then HDF5_HL=no HDF5_HL_TOOLS=no @@ -2298,7 +2299,7 @@ for hdf5_cv_printf_ll in ll l L q unknown; do ],[[ char *s = malloc(128); long long x = (long long)1048576 * (long long)1048576; - sprintf(s,"%${hdf5_cv_printf_ll}d",x); + snprintf(s,128,"%${hdf5_cv_printf_ll}d",x); exit(strcmp(s,"1099511627776")); ]])] , [break],,[continue]) @@ -3691,8 +3692,8 @@ fi ## and installed with the libraries (used to generate libhdf5.settings). ## -## HDF5 version from the first line of the README.txt file. -H5_VERSION="`cut -d' ' -f3 $srcdir/README.txt | head -1`" +## HDF5 version from the first line of the README.md file. +H5_VERSION="`cut -d' ' -f3 $srcdir/README.md | head -1`" AC_SUBST([H5_VERSION]) ## Configuration date diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp index 2600367..9616c1b 100644 --- a/hl/c++/test/ptableTest.cpp +++ b/hl/c++/test/ptableTest.cpp @@ -620,9 +620,9 @@ TestHDFFV_9758() for (hsize_t i = 0; i < NUM_PACKETS; i++) { s1[i].a = static_cast(i); - s1[i].b = 1.f * static_cast(i * i); - s1[i].c = 1. / (i + 1); - HDsprintf(s1[i].d, "string%d", (int)i); + s1[i].b = 1.0F * static_cast(i * i); + s1[i].c = 1.0 / static_cast(i + 1); + HDsnprintf(s1[i].d, STRING_LENGTH, "string%" PRIuHSIZE "", i); s1[i].e = static_cast(100 + i); } diff --git a/hl/test/test_file_image.c b/hl/test/test_file_image.c index bde8adc..36d4db3 100644 --- a/hl/test/test_file_image.c +++ b/hl/test/test_file_image.c @@ -109,12 +109,13 @@ test_file_image(size_t open_images, size_t nflags, const unsigned *flags) input_flags[i] = flags[(nflags + i) % nflags]; /* allocate name buffer for image i */ - filename[i] = (char *)HDmalloc(sizeof(char) * 32); + size_t filenamelength = sizeof(char) * 32; + filename[i] = (char *)HDmalloc(filenamelength); if (!filename[i]) FAIL_PUTS_ERROR("HDmalloc() failed"); /* create file name */ - HDsprintf(filename[i], "image_file%d.h5", (int)i); + HDsnprintf(filename[i], filenamelength, "image_file%d.h5", (int)i); /* create file */ if ((file_id[i] = H5Fcreate(filename[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) diff --git a/hl/test/test_image.c b/hl/test/test_image.c index 81340c1..e54875e 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -650,7 +650,7 @@ test_generate(void) HL_TESTING2("make indexed image from land data"); for (i = 0; i < n_elements; i++) { - if (data[i] < 0.0f) + if (data[i] < 0.0F) image_data[i] = 0; else image_data[i] = (unsigned char)((255 * data[i]) / xmax); @@ -671,10 +671,10 @@ test_generate(void) HL_TESTING2("make indexed image from sea data"); for (i = 0; i < n_elements; i++) { - if (data[i] > 0.0f) + if (data[i] > 0.0F) image_data[i] = 0; else { - image_data[i] = (unsigned char)((255.0f * (data[i] - xmin)) / (xmax - xmin)); + image_data[i] = (unsigned char)((255.0F * (data[i] - xmin)) / (xmax - xmin)); } } diff --git a/hl/test/test_packet_vlen.c b/hl/test/test_packet_vlen.c index 6d6bf34..c33479e 100644 --- a/hl/test/test_packet_vlen.c +++ b/hl/test/test_packet_vlen.c @@ -109,7 +109,7 @@ test_VLof_atomic(void) if (ret < 0) goto error; - HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsnprintf(msg, sizeof(msg), "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ @@ -246,7 +246,7 @@ test_VLof_comptype(void) if (ret < 0) goto error; - HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsnprintf(msg, sizeof(msg), "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ @@ -418,7 +418,7 @@ test_compound_VL_VLtype(void) if (ret < 0) goto error; - HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsnprintf(msg, sizeof(msg), "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ @@ -582,7 +582,7 @@ test_VLof_VLtype(void) if (ret < 0) goto error; - HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsnprintf(msg, sizeof(msg), "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ @@ -1144,7 +1144,7 @@ testfl_VLof_atomic(void) if (ret < 0) goto error; - HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsnprintf(msg, sizeof(msg), "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ @@ -1281,7 +1281,7 @@ testfl_VLof_comptype(void) if (ret < 0) goto error; - HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsnprintf(msg, sizeof(msg), "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ @@ -1453,7 +1453,7 @@ testfl_compound_VL_VLtype(void) if (ret < 0) goto error; - HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsnprintf(msg, sizeof(msg), "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ @@ -1617,7 +1617,7 @@ testfl_VLof_VLtype(void) if (ret < 0) goto error; - HDsprintf(msg, "The number of packets in the packet table must be %u\n", NRECORDS); + HDsnprintf(msg, sizeof(msg), "The number of packets in the packet table must be %u\n", NRECORDS); VERIFY(count == NRECORDS, msg); /* Read all five packets back */ diff --git a/hl/tools/gif2h5/writehdf.c b/hl/tools/gif2h5/writehdf.c index 6ec6af4..a444cf7 100644 --- a/hl/tools/gif2h5/writehdf.c +++ b/hl/tools/gif2h5/writehdf.c @@ -100,7 +100,7 @@ WriteHDF(GIFTOMEM GifMemoryStruct, char *HDFName) dims[1] = gifImageDesc->ImageWidth; /* create the image name */ - sprintf(ImageName, "Image%d", i); + snprintf(ImageName, sizeof(ImageName), "Image%d", i); /* write image */ if (H5IMmake_image_8bit(file_id, ImageName, dims[1], dims[0], (gifImageDesc->Image)) < 0) diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c index aae670a..ce4a112 100644 --- a/hl/tools/h5watch/h5watch.c +++ b/hl/tools/h5watch/h5watch.c @@ -174,9 +174,9 @@ doprint(hid_t did, const hsize_t *start, const hsize_t *block, int rank) } /* end else */ /* Floating point types should display full precision */ - sprintf(fmt_float, "%%1.%dg", FLT_DIG); + snprintf(fmt_float, sizeof(fmt_float), "%%1.%dg", FLT_DIG); info.fmt_float = fmt_float; - sprintf(fmt_double, "%%1.%dg", DBL_DIG); + snprintf(fmt_double, sizeof(fmt_double), "%%1.%dg", DBL_DIG); info.fmt_double = fmt_double; info.dset_format = "DSET-%s "; diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index 02e99af..5a01dc9 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -182,7 +182,7 @@ size_t h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_buf, size_t out_buf_offset) { unsigned char *ucptr = NULL; - static char fmt_llong[8], fmt_ullong[8]; + char fmt_llong[8], fmt_ullong[8]; H5T_class_t tclass = H5T_NO_CLASS; const char delimiter[] = " ," H5_COMPOUND_BEGIN_INDICATOR H5_COMPOUND_END_INDICATOR H5_ARRAY_BEGIN_INDICATOR H5_ARRAY_END_INDICATOR H5_VLEN_BEGIN_INDICATOR H5_VLEN_END_INDICATOR; @@ -211,10 +211,10 @@ h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_ /* Build default formats for long long types */ if (!fmt_llong[0]) { - if (HDsprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: HDsprintf failure"); - if (HDsprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: HDsprintf failure"); + if (HDsnprintf(fmt_llong, sizeof(fmt_llong), "%%%sd", H5_PRINTF_LL_WIDTH) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: HDsnprintf failure"); + if (HDsnprintf(fmt_ullong, sizeof(fmt_ullong), "%%%su", H5_PRINTF_LL_WIDTH) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: HDsnprintf failure"); } /* end if */ switch (tclass) { @@ -759,7 +759,7 @@ size_t h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *in_buf, int expand_data) { unsigned char *ucptr = (unsigned char *)in_buf; - static char fmt_llong[8], fmt_ullong[8]; + char fmt_llong[8], fmt_ullong[8]; H5T_class_t tclass = H5T_NO_CLASS; size_t typeSize = 0; H5T_sign_t nsign = H5T_SGN_ERROR; @@ -794,11 +794,12 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i HDmemcpy(&tmp_float, cptr, sizeof(float)); - if (NULL == (this_str = (char *)HDmalloc(25))) + size_t this_len = 25; + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%g", tmp_float) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%g", tmp_float) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); break; } @@ -808,11 +809,12 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i HDmemcpy(&tmp_double, cptr, sizeof(double)); - if (NULL == (this_str = (char *)HDmalloc(25))) + size_t this_len = 25; + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%g", tmp_double) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, "%g", this_len, tmp_double) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); break; } @@ -822,11 +824,12 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i HDmemcpy(&tmp_ldouble, cptr, sizeof(long double)); - if (NULL == (this_str = (char *)HDmalloc(27))) + size_t this_len = 27; + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%Lg", tmp_ldouble) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%Lg", tmp_ldouble) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); break; } @@ -888,25 +891,26 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i unsigned char tmp_uchar = 0; char tmp_char = 0; + size_t this_len = 7; if (H5T_SGN_NONE == nsign) { HDmemcpy(&tmp_uchar, cptr, sizeof(unsigned char)); - if (NULL == (this_str = (char *)HDmalloc(7))) + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%hhu", tmp_uchar) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%hhu", tmp_uchar) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } else { HDmemcpy(&tmp_char, cptr, sizeof(char)); - if (NULL == (this_str = (char *)HDmalloc(7))) + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%hhd", tmp_char) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%hhd", tmp_char) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } break; @@ -916,25 +920,26 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i unsigned short tmp_ushort = 0; short tmp_short = 0; + size_t this_len = 9; if (H5T_SGN_NONE == nsign) { HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short)); - if (NULL == (this_str = (char *)HDmalloc(9))) + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%hu", tmp_ushort) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%hu", tmp_ushort) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } else { HDmemcpy(&tmp_short, cptr, sizeof(short)); - if (NULL == (this_str = (char *)HDmalloc(9))) + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%hd", tmp_short) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%hd", tmp_short) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } break; @@ -944,25 +949,26 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i unsigned int tmp_uint = 0; int tmp_int = 0; + size_t this_len = 14; if (H5T_SGN_NONE == nsign) { HDmemcpy(&tmp_uint, cptr, sizeof(unsigned int)); - if (NULL == (this_str = (char *)HDmalloc(14))) + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%u", tmp_uint) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%u", tmp_uint) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } else { HDmemcpy(&tmp_int, cptr, sizeof(int)); - if (NULL == (this_str = (char *)HDmalloc(14))) + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%d", tmp_int) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%d", tmp_int) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } break; @@ -972,25 +978,26 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i unsigned long tmp_ulong = 0; long tmp_long = 0; + size_t this_len = 23; if (H5T_SGN_NONE == nsign) { HDmemcpy(&tmp_ulong, cptr, sizeof(unsigned long)); - if (NULL == (this_str = (char *)HDmalloc(23))) + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%lu", tmp_ulong) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%lu", tmp_ulong) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } else { HDmemcpy(&tmp_long, cptr, sizeof(long)); - if (NULL == (this_str = (char *)HDmalloc(23))) + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%ld", tmp_long) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%ld", tmp_long) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } break; @@ -1001,25 +1008,26 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i unsigned long long tmp_ullong = 0; long long tmp_llong = 0; + size_t this_len = 25; if (H5T_SGN_NONE == nsign) { HDmemcpy(&tmp_ullong, cptr, sizeof(unsigned long long)); - if (NULL == (this_str = (char *)HDmalloc(25))) + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, fmt_ullong, tmp_ullong) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, fmt_ullong, tmp_ullong) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } else { HDmemcpy(&tmp_llong, cptr, sizeof(long long)); - if (NULL == (this_str = (char *)HDmalloc(25))) + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, fmt_llong, tmp_llong) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, fmt_llong, tmp_llong) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } break; @@ -1079,17 +1087,18 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i else { size_t i; - if (NULL == (this_str = (char *)HDmalloc(4 * (typeSize + 1)))) + size_t this_len = 4 * (typeSize + 1); + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (1 == typeSize) { - if (HDsprintf(this_str, "%#02x", ucptr[0]) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%#02x", ucptr[0]) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } else { for (i = 0; i < typeSize; i++) - if (HDsprintf(this_str, "%s%02x", i ? ":" : "", ucptr[i]) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%s%02x", i ? ":" : "", ucptr[i]) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } } @@ -1134,11 +1143,12 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i else H5_LIBRARY_ERROR(ENVONLY); - if (NULL == (this_str = (char *)HDmalloc(14))) + size_t this_len = 14; + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR( ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%u-", (unsigned)oi.type) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%u-", (unsigned)oi.type) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); if (!h5str_append(out_str, this_str)) H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); HDfree(this_str); @@ -1150,11 +1160,13 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i H5Otoken_to_str(tid, &oi.token, &token_str); - if (NULL == (this_str = (char *)HDmalloc(64 + strlen(token_str) + 1))) + size_t this_len = 64 + strlen(token_str) + 1; + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR( ENVONLY, "h5str_sprintf: failed to allocate string buffer"); - if (HDsprintf(this_str, "%lu:%s", oi.fileno, token_str) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%lu:%s", oi.fileno, token_str) < + 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); H5free_memory(token_str); } @@ -1307,17 +1319,18 @@ h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *i /* All other types get printed as hexadecimal */ - if (NULL == (this_str = (char *)HDmalloc(4 * (typeSize + 1)))) + size_t this_len = 4 * (typeSize + 1); + if (NULL == (this_str = (char *)HDmalloc(this_len))) H5_OUT_OF_MEMORY_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); if (1 == typeSize) { - if (HDsprintf(this_str, "%#02x", ucptr[0]) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%#02x", ucptr[0]) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } else { for (i = 0; i < typeSize; i++) - if (HDsprintf(this_str, "%s%02x", i ? ":" : "", ucptr[i]) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + if (HDsnprintf(this_str, this_len, "%s%02x", i ? ":" : "", ucptr[i]) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsnprintf failure"); } break; @@ -1519,8 +1532,9 @@ h5str_dump_region_blocks(JNIEnv *env, h5str_t *str, hid_t region_space, hid_t re for (j = 0; j < ndims; j++) { tmp_str[0] = '\0'; - if (HDsprintf(tmp_str, "%s%lu", j ? "," : "(", (unsigned long)ptdata[i * 2 * ndims + j]) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: HDsprintf failure"); + if (HDsnprintf(tmp_str, sizeof(tmp_str), "%s%lu", j ? "," : "(", + (unsigned long)ptdata[i * 2 * ndims + j]) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: HDsnprintf failure"); if (!h5str_append(str, tmp_str)) H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); @@ -1529,9 +1543,9 @@ h5str_dump_region_blocks(JNIEnv *env, h5str_t *str, hid_t region_space, hid_t re for (j = 0; j < ndims; j++) { tmp_str[0] = '\0'; - if (HDsprintf(tmp_str, "%s%lu", j ? "," : ")-(", - (unsigned long)ptdata[i * 2 * ndims + j + ndims]) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: HDsprintf failure"); + if (HDsnprintf(tmp_str, sizeof(tmp_str), "%s%lu", j ? "," : ")-(", + (unsigned long)ptdata[i * 2 * ndims + j + ndims]) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: HDsnprintf failure"); if (!h5str_append(str, tmp_str)) H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); @@ -1696,8 +1710,9 @@ h5str_dump_region_points(JNIEnv *env, h5str_t *str, hid_t region_space, hid_t re for (j = 0; j < ndims; j++) { tmp_str[0] = '\0'; - if (HDsprintf(tmp_str, "%s%lu", j ? "," : "(", (unsigned long)(ptdata[i * ndims + j])) < 0) - H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_points: HDsprintf failure"); + if (HDsnprintf(tmp_str, sizeof(tmp_str), "%s%lu", j ? "," : "(", + (unsigned long)(ptdata[i * ndims + j])) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_points: HDsnprintf failure"); if (!h5str_append(str, tmp_str)) H5_ASSERTION_ERROR(ENVONLY, "Unable to append string."); diff --git a/src/H5AC.c b/src/H5AC.c index 0f35f7f..87ea0b7 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -333,7 +333,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co aux_ptr->sync_point_done = NULL; aux_ptr->p0_image_len = 0; - HDsprintf(prefix, "%d:", mpi_rank); + HDsnprintf(prefix, sizeof(prefix), "%d:", mpi_rank); if (mpi_rank == 0) { if (NULL == (aux_ptr->d_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 9d51fee..6d4887e 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -6773,10 +6773,10 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers) miss_rate = 0.0; } if (miss_rate > 100) { - HDsprintf(ascii, "%7d%%", (int)(miss_rate + 0.5)); + HDsnprintf(ascii, sizeof(ascii), "%7d%%", (int)(miss_rate + 0.5)); } else { - HDsprintf(ascii, "%7.2f%%", miss_rate); + HDsnprintf(ascii, sizeof(ascii), "%7.2f%%", miss_rate); } HDfprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", "raw data chunks", rdcc->stats.nhits, diff --git a/src/H5Dearray.c b/src/H5Dearray.c index abce233..cd52b66 100644 --- a/src/H5Dearray.c +++ b/src/H5Dearray.c @@ -417,7 +417,7 @@ H5D__earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx); + HDsnprintf(temp_str, sizeof(temp_str), "Element #%" PRIuHSIZE ":", idx); HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, temp_str, *(const haddr_t *)elmt); FUNC_LEAVE_NOAPI(SUCCEED) @@ -573,7 +573,7 @@ H5D__earray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx); + HDsnprintf(temp_str, sizeof(temp_str), "Element #%" PRIuHSIZE ":", idx); HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %u, %0x}\n", indent, "", fwidth, temp_str, elmt->addr, elmt->nbytes, elmt->filter_mask); diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c index 0741e8f..ab0f0f8 100644 --- a/src/H5Dfarray.c +++ b/src/H5Dfarray.c @@ -415,7 +415,7 @@ H5D__farray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx); + HDsnprintf(temp_str, sizeof(temp_str), "Element #%" PRIuHSIZE ":", idx); HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", indent, "", fwidth, temp_str, *(const haddr_t *)elmt); FUNC_LEAVE_NOAPI(SUCCEED) @@ -675,7 +675,7 @@ H5D__farray_filt_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%" PRIuHSIZE ":", idx); + HDsnprintf(temp_str, sizeof(temp_str), "Element #%" PRIuHSIZE ":", idx); HDfprintf(stream, "%*s%-*s {%" PRIuHADDR ", %u, %0x}\n", indent, "", fwidth, temp_str, elmt->addr, elmt->nbytes, elmt->filter_mask); diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c index b0e564c..b377422 100644 --- a/src/H5EAdbg.c +++ b/src/H5EAdbg.c @@ -237,7 +237,7 @@ H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int inde HDfprintf(stream, "%*sData Block Addresses in Index Block:\n", indent, ""); for (u = 0; u < iblock->ndblk_addrs; u++) { /* Print address */ - HDsprintf(temp_str, "Address #%u:", u); + HDsnprintf(temp_str, sizeof(temp_str), "Address #%u:", u); HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str, iblock->dblk_addrs[u]); } /* end for */ @@ -252,7 +252,7 @@ H5EA__iblock_debug(H5F_t *f, haddr_t H5_ATTR_UNUSED addr, FILE *stream, int inde HDfprintf(stream, "%*sSuper Block Addresses in Index Block:\n", indent, ""); for (u = 0; u < iblock->nsblk_addrs; u++) { /* Print address */ - HDsprintf(temp_str, "Address #%u:", u); + HDsnprintf(temp_str, sizeof(temp_str), "Address #%u:", u); HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str, iblock->sblk_addrs[u]); } /* end for */ @@ -341,7 +341,7 @@ H5EA__sblock_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth, HDfprintf(stream, "%*sData Block Addresses in Super Block:\n", indent, ""); for (u = 0; u < sblock->ndblks; u++) { /* Print address */ - HDsprintf(temp_str, "Address #%u:", u); + HDsnprintf(temp_str, sizeof(temp_str), "Address #%u:", u); HDfprintf(stream, "%*s%-*s %" PRIuHADDR "\n", (indent + 3), "", MAX(0, (fwidth - 3)), temp_str, sblock->dblk_addrs[u]); } /* end for */ diff --git a/src/H5EAtest.c b/src/H5EAtest.c index 7924eaa..24efbc2 100644 --- a/src/H5EAtest.c +++ b/src/H5EAtest.c @@ -322,7 +322,7 @@ H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void * HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); + HDsnprintf(temp_str, sizeof(temp_str), "Element #%llu:", (unsigned long long)idx); HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str, (unsigned long long)*(const uint64_t *)elmt); diff --git a/src/H5FAtest.c b/src/H5FAtest.c index 384a657..b57f562 100644 --- a/src/H5FAtest.c +++ b/src/H5FAtest.c @@ -303,7 +303,7 @@ H5FA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void * HDassert(elmt); /* Print element */ - HDsprintf(temp_str, "Element #%llu:", (unsigned long long)idx); + HDsnprintf(temp_str, sizeof(temp_str), "Element #%llu:", (unsigned long long)idx); HDfprintf(stream, "%*s%-*s %llu\n", indent, "", fwidth, temp_str, (unsigned long long)*(const uint64_t *)elmt); diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 1be9522..d17e3d0 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -1731,7 +1731,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_NO_CLASS: case H5T_NCLASSES: default: - HDsprintf(buf, "H5T_CLASS_%d", (int)(dt->shared->type)); + HDsnprintf(buf, sizeof(buf), "H5T_CLASS_%d", (int)(dt->shared->type)); s = buf; break; } /* end switch */ @@ -1746,7 +1746,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of members:", dt->shared->u.compnd.nmembs); for (i = 0; i < dt->shared->u.compnd.nmembs; i++) { - HDsprintf(buf, "Member %u:", i); + HDsnprintf(buf, sizeof(buf), "Member %u:", i); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, dt->shared->u.compnd.memb[i].name); HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3), "Byte offset:", (unsigned long)(dt->shared->u.compnd.memb[i].offset)); @@ -1759,7 +1759,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of members:", dt->shared->u.enumer.nmembs); for (i = 0; i < dt->shared->u.enumer.nmembs; i++) { - HDsprintf(buf, "Member %u:", i); + HDsnprintf(buf, sizeof(buf), "Member %u:", i); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, buf, dt->shared->u.enumer.name[i]); HDfprintf(stream, "%*s%-*s 0x", indent, "", fwidth, "Raw bytes of value:"); for (k = 0; k < dt->shared->parent->shared->size; k++) @@ -1799,13 +1799,14 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_CSET_RESERVED_13: case H5T_CSET_RESERVED_14: case H5T_CSET_RESERVED_15: - HDsprintf(buf, "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.cset)); + HDsnprintf(buf, sizeof(buf), "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.cset)); s = buf; break; case H5T_CSET_ERROR: default: - HDsprintf(buf, "Unknown character set: %d", (int)(dt->shared->u.atomic.u.s.cset)); + HDsnprintf(buf, sizeof(buf), "Unknown character set: %d", + (int)(dt->shared->u.atomic.u.s.cset)); s = buf; break; } /* end switch */ @@ -1837,13 +1838,14 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_STR_RESERVED_13: case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: - HDsprintf(buf, "H5T_STR_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.pad)); + HDsnprintf(buf, sizeof(buf), "H5T_STR_RESERVED_%d", (int)(dt->shared->u.atomic.u.s.pad)); s = buf; break; case H5T_STR_ERROR: default: - HDsprintf(buf, "Unknown string padding: %d", (int)(dt->shared->u.atomic.u.s.pad)); + HDsnprintf(buf, sizeof(buf), "Unknown string padding: %d", + (int)(dt->shared->u.atomic.u.s.pad)); s = buf; break; } /* end switch */ @@ -1862,7 +1864,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_VLEN_BADTYPE: case H5T_VLEN_MAXTYPE: default: - HDsprintf(buf, "H5T_VLEN_%d", dt->shared->u.vlen.type); + HDsnprintf(buf, sizeof(buf), "H5T_VLEN_%d", dt->shared->u.vlen.type); s = buf; break; } /* end switch */ @@ -1880,7 +1882,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_LOC_BADLOC: case H5T_LOC_MAXLOC: default: - HDsprintf(buf, "H5T_LOC_%d", (int)dt->shared->u.vlen.loc); + HDsnprintf(buf, sizeof(buf), "H5T_LOC_%d", (int)dt->shared->u.vlen.loc); s = buf; break; } /* end switch */ @@ -1911,13 +1913,13 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_CSET_RESERVED_13: case H5T_CSET_RESERVED_14: case H5T_CSET_RESERVED_15: - HDsprintf(buf, "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.vlen.cset)); + HDsnprintf(buf, sizeof(buf), "H5T_CSET_RESERVED_%d", (int)(dt->shared->u.vlen.cset)); s = buf; break; case H5T_CSET_ERROR: default: - HDsprintf(buf, "Unknown character set: %d", (int)(dt->shared->u.vlen.cset)); + HDsnprintf(buf, sizeof(buf), "Unknown character set: %d", (int)(dt->shared->u.vlen.cset)); s = buf; break; } /* end switch */ @@ -1949,13 +1951,13 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_STR_RESERVED_13: case H5T_STR_RESERVED_14: case H5T_STR_RESERVED_15: - HDsprintf(buf, "H5T_STR_RESERVED_%d", (int)(dt->shared->u.vlen.pad)); + HDsnprintf(buf, sizeof(buf), "H5T_STR_RESERVED_%d", (int)(dt->shared->u.vlen.pad)); s = buf; break; case H5T_STR_ERROR: default: - HDsprintf(buf, "Unknown string padding: %d", (int)(dt->shared->u.vlen.pad)); + HDsnprintf(buf, sizeof(buf), "Unknown string padding: %d", (int)(dt->shared->u.vlen.pad)); s = buf; break; } /* end switch */ @@ -1995,7 +1997,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_ORDER_ERROR: default: - HDsprintf(buf, "H5T_ORDER_%d", dt->shared->u.atomic.order); + HDsnprintf(buf, sizeof(buf), "H5T_ORDER_%d", dt->shared->u.atomic.order); s = buf; break; } /* end switch */ @@ -2069,9 +2071,9 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_NPAD: default: if (dt->shared->u.atomic.u.f.pad < 0) - HDsprintf(buf, "H5T_PAD_%d", -(dt->shared->u.atomic.u.f.pad)); + HDsnprintf(buf, sizeof(buf), "H5T_PAD_%d", -(dt->shared->u.atomic.u.f.pad)); else - HDsprintf(buf, "bit-%d", dt->shared->u.atomic.u.f.pad); + HDsnprintf(buf, sizeof(buf), "bit-%d", dt->shared->u.atomic.u.f.pad); s = buf; break; } /* end switch */ @@ -2092,7 +2094,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_NORM_ERROR: default: - HDsprintf(buf, "H5T_NORM_%d", (int)(dt->shared->u.atomic.u.f.norm)); + HDsnprintf(buf, sizeof(buf), "H5T_NORM_%d", (int)(dt->shared->u.atomic.u.f.norm)); s = buf; } /* end switch */ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Normalization:", s); @@ -2129,7 +2131,7 @@ H5O__dtype_debug(H5F_t *f, const void *mesg, FILE *stream, int indent, int fwidt case H5T_SGN_ERROR: case H5T_NSGN: default: - HDsprintf(buf, "H5T_SGN_%d", (int)(dt->shared->u.atomic.u.i.sign)); + HDsnprintf(buf, sizeof(buf), "H5T_SGN_%d", (int)(dt->shared->u.atomic.u.i.sign)); s = buf; break; } /* end switch */ diff --git a/src/H5PLpath.c b/src/H5PLpath.c index 39a7d0d..d16d8b2 100644 --- a/src/H5PLpath.c +++ b/src/H5PLpath.c @@ -706,8 +706,9 @@ H5PL__path_table_iterate_process_path(const char *plugin_path, H5PL_iterate_type HDassert(plugin_path); HDassert(iter_op); - /* Specify a file mask. *.* = We want everything! */ - HDsprintf(service, "%s\\*.dll", plugin_path); + /* Specify a file mask. *.* = We want everything! - + * skip the path if the directory can't be opened */ + HDsnprintf(service, sizeof(service), "%s\\*.dll", plugin_path); if ((hFind = FindFirstFileA(service, &fdFile)) == INVALID_HANDLE_VALUE) HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, H5_ITER_ERROR, "can't open directory") @@ -931,7 +932,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo *found = FALSE; /* Specify a file mask. *.* = We want everything! */ - HDsprintf(service, "%s\\*.dll", dir); + HDsnprintf(service, sizeof(service), "%s\\*.dll", dir); if ((hFind = FindFirstFileA(service, &fdFile)) == INVALID_HANDLE_VALUE) HGOTO_ERROR(H5E_PLUGIN, H5E_OPENERROR, FAIL, "can't open directory") diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 58987ab..ff3a53f 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -2753,7 +2753,7 @@ H5T__conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata) HDassert(domain[1] >= domain[0]); length = (unsigned)(domain[1] - domain[0]) + 1; if (src->shared->u.enumer.nmembs < 2 || - (double)length / src->shared->u.enumer.nmembs < (double)(1.2f)) { + (double)length / src->shared->u.enumer.nmembs < (double)(1.2F)) { priv->base = domain[0]; priv->length = length; if (NULL == (map = (int *)H5MM_malloc(length * sizeof(int)))) diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c index 434fd43..85f36d4 100644 --- a/src/H5VLpassthru.c +++ b/src/H5VLpassthru.c @@ -660,16 +660,13 @@ H5VL_pass_through_info_to_str(const void *_info, char **str) under_vol_str_len = strlen(under_vol_string); /* Allocate space for our info */ - *str = (char *)H5allocate_memory(32 + under_vol_str_len, (hbool_t)0); + size_t strSize = 32 + under_vol_str_len; + *str = (char *)H5allocate_memory(strSize, (hbool_t)0); assert(*str); - /* Encode our info - * Normally we'd use snprintf() here for a little extra safety, but that - * call had problems on Windows until recently. So, to be as platform-independent - * as we can, we're using sprintf() instead. - */ - sprintf(*str, "under_vol=%u;under_info={%s}", (unsigned)under_value, - (under_vol_string ? under_vol_string : "")); + /* Encode our info */ + snprintf(*str, strSize, "under_vol=%u;under_info={%s}", (unsigned)under_value, + (under_vol_string ? under_vol_string : "")); return 0; } /* end H5VL_pass_through_info_to_str() */ diff --git a/src/H5private.h b/src/H5private.h index de451f6..b560d62 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -232,7 +232,7 @@ */ #define BEGIN_MPE_LOG \ if (H5_MPEinit_g) { \ - sprintf(p_event_start, "start %s", FUNC); \ + snprintf(p_event_start, sizeof(p_event_start), "start %s", FUNC); \ if (eventa(FUNC) == -1 && eventb(FUNC) == -1) { \ const char *p_color = "red"; \ eventa(FUNC) = MPE_Log_get_event_number(); \ 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++) { diff --git a/testpar/t_cache.c b/testpar/t_cache.c index 39c5721..a5c8039 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -6482,7 +6482,7 @@ trace_file_check(int metadata_write_strategy) } /* end if */ if (nerrors == 0) { - HDsprintf(trace_file_name, "t_cache_trace.txt.%d", (int)file_mpi_rank); + HDsnprintf(trace_file_name, sizeof(trace_file_name), "t_cache_trace.txt.%d", (int)file_mpi_rank); if ((trace_file_ptr = HDfopen(trace_file_name, "r")) == NULL) { diff --git a/testpar/t_cache_image.c b/testpar/t_cache_image.c index 91f6e16..642cace 100644 --- a/testpar/t_cache_image.c +++ b/testpar/t_cache_image.c @@ -480,7 +480,7 @@ create_data_sets(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); @@ -769,7 +769,7 @@ delete_data_sets(hid_t file_id, int min_dset, int max_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) { @@ -1337,7 +1337,7 @@ par_create_dataset(int dset_num, hid_t file_id, int mpi_rank, int mpi_size) show_progress = (show_progress && (mpi_rank == 0)); verbose = (verbose && (mpi_rank == 0)); - HDsprintf(dset_name, "/dset%03d", dset_num); + HDsnprintf(dset_name, sizeof(dset_name), "/dset%03d", dset_num); if (show_progress) { HDfprintf(stdout, "%s: dset name = \"%s\".\n", fcn_name, dset_name); @@ -1710,7 +1710,7 @@ par_delete_dataset(int dset_num, hid_t file_id, int mpi_rank) show_progress = (show_progress && (mpi_rank == 0)); - HDsprintf(dset_name, "/dset%03d", dset_num); + HDsnprintf(dset_name, sizeof(dset_name), "/dset%03d", dset_num); if (show_progress) { HDfprintf(stdout, "%s: dset name = \"%s\".\n", fcn_name, dset_name); @@ -1908,7 +1908,7 @@ par_verify_dataset(int dset_num, hid_t file_id, int mpi_rank) show_progress = (show_progress && (mpi_rank == 0)); verbose = (verbose && (mpi_rank == 0)); - HDsprintf(dset_name, "/dset%03d", dset_num); + HDsnprintf(dset_name, sizeof(dset_name), "/dset%03d", dset_num); if (show_progress) { HDfprintf(stdout, "%s: dset name = \"%s\".\n", fcn_name, dset_name); @@ -2276,7 +2276,7 @@ serial_verify_dataset(int dset_num, hid_t file_id, int mpi_size) hid_t dset_id = -1; hid_t filespace_id = -1; - HDsprintf(dset_name, "/dset%03d", dset_num); + HDsnprintf(dset_name, sizeof(dset_name), "/dset%03d", dset_num); if (show_progress) { HDfprintf(stdout, "%s: dset name = \"%s\".\n", fcn_name, dset_name); @@ -2680,7 +2680,7 @@ verify_data_sets(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) { diff --git a/testpar/t_dset.c b/testpar/t_dset.c index 06e0572..f5746e1 100644 --- a/testpar/t_dset.c +++ b/testpar/t_dset.c @@ -3667,10 +3667,12 @@ test_no_collective_cause_mode(int selection_mode) /* Test values */ HDmemset(message, 0, sizeof(message)); - HDsprintf(message, "Local cause of Broken Collective I/O has the correct value for %s.\n", test_name); + HDsnprintf(message, sizeof(message), + "Local cause of Broken Collective I/O has the correct value for %s.\n", test_name); VRFY((no_collective_cause_local_write == no_collective_cause_local_expected), message); HDmemset(message, 0, sizeof(message)); - HDsprintf(message, "Global cause of Broken Collective I/O has the correct value for %s.\n", test_name); + HDsnprintf(message, sizeof(message), + "Global cause of Broken Collective I/O has the correct value for %s.\n", test_name); VRFY((no_collective_cause_global_write == no_collective_cause_global_expected), message); /* Release some resources */ diff --git a/testpar/t_file.c b/testpar/t_file.c index 8bef7ae..a3be81d 100644 --- a/testpar/t_file.c +++ b/testpar/t_file.c @@ -514,25 +514,25 @@ create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_str VRFY((mem_dataspace >= 0), ""); for (k = 0; k < NUM_DSETS; k++) { - HDsprintf(dset_name, "D1dset%d", k); + HDsnprintf(dset_name, sizeof(dset_name), "D1dset%d", k); dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dset_id >= 0), ""); ret = H5Dclose(dset_id); VRFY((ret == 0), ""); - HDsprintf(dset_name, "D2dset%d", k); + HDsnprintf(dset_name, sizeof(dset_name), "D2dset%d", k); dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dset_id >= 0), ""); ret = H5Dclose(dset_id); VRFY((ret == 0), ""); - HDsprintf(dset_name, "D3dset%d", k); + HDsnprintf(dset_name, sizeof(dset_name), "D3dset%d", k); dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dset_id >= 0), ""); ret = H5Dclose(dset_id); VRFY((ret == 0), ""); - HDsprintf(dset_name, "dset%d", k); + HDsnprintf(dset_name, sizeof(dset_name), "dset%d", k); dset_id = H5Dcreate2(grp_id, dset_name, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dset_id >= 0), ""); @@ -555,13 +555,13 @@ create_file(const char *filename, hid_t fcpl, hid_t fapl, int metadata_write_str for (i = 0; i < num_elements; i++) VRFY((data_array[i] == mpi_rank + 1), "Dataset Verify failed"); - HDsprintf(dset_name, "D1dset%d", k); + HDsnprintf(dset_name, sizeof(dset_name), "D1dset%d", k); ret = H5Ldelete(grp_id, dset_name, H5P_DEFAULT); VRFY((ret == 0), ""); - HDsprintf(dset_name, "D2dset%d", k); + HDsnprintf(dset_name, sizeof(dset_name), "D2dset%d", k); ret = H5Ldelete(grp_id, dset_name, H5P_DEFAULT); VRFY((ret == 0), ""); - HDsprintf(dset_name, "D3dset%d", k); + HDsnprintf(dset_name, sizeof(dset_name), "D3dset%d", k); ret = H5Ldelete(grp_id, dset_name, H5P_DEFAULT); VRFY((ret == 0), ""); } @@ -667,7 +667,7 @@ open_file(const char *filename, hid_t fapl, int metadata_write_strategy, hsize_t VRFY((mem_dataspace >= 0), ""); for (k = 0; k < NUM_DSETS; k++) { - HDsprintf(dset_name, "dset%d", k); + HDsnprintf(dset_name, sizeof(dset_name), "dset%d", k); dset_id = H5Dopen2(grp_id, dset_name, H5P_DEFAULT); VRFY((dset_id >= 0), ""); diff --git a/testpar/t_pflush1.c b/testpar/t_pflush1.c index 2a80f4a..7d02959 100644 --- a/testpar/t_pflush1.c +++ b/testpar/t_pflush1.c @@ -43,7 +43,7 @@ static int data_g[100][100]; *------------------------------------------------------------------------- */ static hid_t -create_test_file(char *name, hid_t fapl_id) +create_test_file(char *name, size_t name_length, hid_t fapl_id) { hid_t fid = H5I_INVALID_HID; hid_t dcpl_id = H5I_INVALID_HID; @@ -86,7 +86,7 @@ create_test_file(char *name, hid_t fapl_id) if ((top_level_gid = H5Gcreate2(fid, "some_groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; for (i = 0; i < N_GROUPS; i++) { - HDsprintf(name, "grp%02u", (unsigned)i); + HDsnprintf(name, name_length, "grp%02u", (unsigned)i); if ((gid = H5Gcreate2(top_level_gid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; if (H5Gclose(gid) < 0) @@ -153,7 +153,7 @@ main(int argc, char *argv[]) /* Create the file */ h5_fixname(FILENAME[0], fapl_id, name, sizeof(name)); - if ((fid1 = create_test_file(name, fapl_id)) < 0) + if ((fid1 = create_test_file(name, sizeof(name), fapl_id)) < 0) goto error; /* Flush and exit without closing the library */ if (H5Fflush(fid1, H5F_SCOPE_GLOBAL) < 0) @@ -161,7 +161,7 @@ main(int argc, char *argv[]) /* Create the other file which will not be flushed */ h5_fixname(FILENAME[1], fapl_id, name, sizeof(name)); - if ((fid2 = create_test_file(name, fapl_id)) < 0) + if ((fid2 = create_test_file(name, sizeof(name), fapl_id)) < 0) goto error; if (mpi_rank == 0) diff --git a/testpar/t_pflush2.c b/testpar/t_pflush2.c index c96233a..032d914 100644 --- a/testpar/t_pflush2.c +++ b/testpar/t_pflush2.c @@ -43,7 +43,7 @@ static int data_g[100][100]; *------------------------------------------------------------------------- */ static herr_t -check_test_file(char *name, hid_t fapl_id) +check_test_file(char *name, size_t name_length, hid_t fapl_id) { hid_t fid = H5I_INVALID_HID; hid_t sid = H5I_INVALID_HID; @@ -89,7 +89,7 @@ check_test_file(char *name, hid_t fapl_id) if ((top_level_gid = H5Gopen2(fid, "some_groups", H5P_DEFAULT)) < 0) goto error; for (i = 0; i < N_GROUPS; i++) { - HDsprintf(name, "grp%02u", (unsigned)i); + HDsnprintf(name, name_length, "grp%02u", (unsigned)i); if ((gid = H5Gopen2(top_level_gid, name, H5P_DEFAULT)) < 0) goto error; if (H5Gclose(gid) < 0) @@ -182,7 +182,7 @@ main(int argc, char *argv[]) /* Check the case where the file was flushed */ h5_fixname(FILENAME[0], fapl_id1, name, sizeof(name)); - if (check_test_file(name, fapl_id1)) { + if (check_test_file(name, sizeof(name), fapl_id1)) { H5_FAILED() goto error; } @@ -199,7 +199,7 @@ main(int argc, char *argv[]) H5Eset_auto2(H5E_DEFAULT, NULL, NULL); h5_fixname(FILENAME[1], fapl_id2, name, sizeof(name)); - if (check_test_file(name, fapl_id2)) { + if (check_test_file(name, sizeof(name), fapl_id2)) { if (mpi_rank == 0) PASSED(); } diff --git a/testpar/t_prop.c b/testpar/t_prop.c index a3f1859..b6adffd 100644 --- a/testpar/t_prop.c +++ b/testpar/t_prop.c @@ -556,7 +556,7 @@ external_links(void) /* test opening a group that is to an external link, the external linked file should inherit the source file's access properties */ - HDsprintf(link_path, "%s%s%s", group_path, "/", link_name); + HDsnprintf(link_path, sizeof(link_path), "%s%s%s", group_path, "/", link_name); group = H5Gopen2(fid, link_path, H5P_DEFAULT); VRFY((group >= 0), "H5Gopen succeeded"); ret = H5Gclose(group); diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c index dd95b3c..bb495f2 100644 --- a/tools/src/h5dump/h5dump_ddl.c +++ b/tools/src/h5dump/h5dump_ddl.c @@ -838,7 +838,7 @@ dump_group(hid_t gid, const char *name) type = H5Dget_type(dset); H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str); - HDsprintf(type_name, "#%s", obj_tok_str); + HDsnprintf(type_name, sizeof(type_name), "#%s", obj_tok_str); H5free_memory(obj_tok_str); dump_function_table->dump_named_datatype_function(type, type_name); @@ -1970,7 +1970,7 @@ handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED *data, int pe, /* unnamed datatype */ H5Otoken_to_str(fid, &type_table->objs[idx].obj_token, &obj_tok_str); - HDsprintf(name, "/#%s", obj_tok_str); + HDsnprintf(name, sizeof(name), "/#%s", obj_tok_str); H5free_memory(obj_tok_str); if (!HDstrcmp(name, real_name)) diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index e9006b6..ccf4156 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -2804,7 +2804,7 @@ xml_dump_group(hid_t gid, const char *name) type = H5Dget_type(dset); H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str); - HDsprintf(type_name, "#%s", obj_tok_str); + HDsnprintf(type_name, sizeof(type_name), "#%s", obj_tok_str); H5free_memory(obj_tok_str); dump_function_table->dump_named_datatype_function(type, type_name); @@ -2897,7 +2897,7 @@ xml_dump_group(hid_t gid, const char *name) type = H5Dget_type(dset); H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str); - HDsprintf(type_name, "#%s", obj_tok_str); + HDsnprintf(type_name, sizeof(type_name), "#%s", obj_tok_str); H5free_memory(obj_tok_str); dump_function_table->dump_named_datatype_function(type, type_name); diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c index a1895e6..ddd34ce 100644 --- a/tools/src/h5import/h5import.c +++ b/tools/src/h5import/h5import.c @@ -3784,7 +3784,7 @@ setDefaultValues(struct Input *in, int count) in->path.count = 1; HDstrcpy(temp, "dataset"); - HDsprintf(num, "%d", count); + HDsnprintf(num, sizeof(num), "%d", count); HDstrcat(temp, num); HDstrcpy(in->path.group[0], temp); diff --git a/tools/src/h5perf/pio_engine.c b/tools/src/h5perf/pio_engine.c index 65194b0..4eaa284 100644 --- a/tools/src/h5perf/pio_engine.c +++ b/tools/src/h5perf/pio_engine.c @@ -284,7 +284,7 @@ do_pio(parameters param) /* Open file for write */ char base_name[256]; - HDsprintf(base_name, "#pio_tmp_%lu", nf); + HDsnprintf(base_name, sizeof(base_name), "#pio_tmp_%lu", nf); pio_create_filename(iot, base_name, fname, sizeof(fname)); if (pio_debug_level > 0) HDfprintf(output, "rank %d: data filename=%s\n", pio_mpi_rank_g, fname); @@ -900,7 +900,7 @@ do_write(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nby } /* end if */ } /* end else */ - HDsprintf(dname, "Dataset_%ld", ndset); + HDsnprintf(dname, sizeof(dname), "Dataset_%ld", ndset); h5ds_id = H5DCREATE(fd->h5fd, dname, ELMT_H5_TYPE, h5dset_space_id, h5dcpl); if (h5ds_id < 0) { @@ -1881,7 +1881,7 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nbyt break; case PHDF5: - HDsprintf(dname, "Dataset_%ld", ndset); + HDsnprintf(dname, sizeof(dname), "Dataset_%ld", ndset); h5ds_id = H5DOPEN(fd->h5fd, dname); if (h5ds_id < 0) { HDfprintf(stderr, "HDF5 Dataset open failed\n"); diff --git a/tools/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c index 576b1c7..a22af3d 100644 --- a/tools/test/h5repack/h5repackgentest.c +++ b/tools/test/h5repack/h5repackgentest.c @@ -307,7 +307,7 @@ generate_f32le(hbool_t external) /* Generate values */ for (i = 0, k = 0, n = 0; (hsize_t)i < dims[0]; i++) { for (j = 0; (hsize_t)j < dims[1]; j++, k++, n++) { - wdata[k] = n * 801.1f * ((k % 5 == 1) ? (-1) : (1)); + wdata[k] = n * 801.1F * ((k % 5 == 1) ? (-1) : (1)); } } diff --git a/tools/test/misc/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c index 53fbc42..999611a 100644 --- a/tools/test/misc/h5clear_gentest.c +++ b/tools/test/misc/h5clear_gentest.c @@ -426,7 +426,7 @@ main(void) if ((my_fapl = H5Pcopy(fapl2)) < 0) goto error; /* Create the file */ - HDsprintf(fname, "%s%s", new_format ? "latest_" : "", FILENAME[0]); + HDsnprintf(fname, sizeof(fname), "%s%s", new_format ? "latest_" : "", FILENAME[0]); if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, my_fapl)) < 0) goto error; @@ -451,7 +451,7 @@ main(void) goto error; /* Create the file */ - HDsprintf(fname, "%s%s", new_format ? "latest_" : "", FILENAME[1]); + HDsnprintf(fname, sizeof(fname), "%s%s", new_format ? "latest_" : "", FILENAME[1]); if ((fid = H5Fcreate(fname, H5F_ACC_TRUNC | (new_format ? 0 : H5F_ACC_SWMR_WRITE), H5P_DEFAULT, my_fapl)) < 0) goto error; diff --git a/tools/test/perform/direct_write_perf.c b/tools/test/perform/direct_write_perf.c index b3ae54d..762cd61 100644 --- a/tools/test/perform/direct_write_perf.c +++ b/tools/test/perform/direct_write_perf.c @@ -660,7 +660,7 @@ main(void) hid_t fapl = H5P_DEFAULT; int i; - sprintf(filename, "%s.h5", FILENAME[0]); + snprintf(filename, sizeof(filename), "%s.h5", FILENAME[0]); create_file(fapl); test_direct_write_uncompressed_data(fapl); diff --git a/tools/test/perform/perf_meta.c b/tools/test/perform/perf_meta.c index d8ed9ec..ad76711 100644 --- a/tools/test/perform/perf_meta.c +++ b/tools/test/perform/perf_meta.c @@ -304,7 +304,7 @@ create_dsets(hid_t file) * Create a dataset using the default dataset creation properties. */ for (i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dataset %d", i); + HDsnprintf(dset_name, sizeof(dset_name), "dataset %d", i); if ((dataset = H5Dcreate2(file, dset_name, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; @@ -366,14 +366,14 @@ create_attrs_1(void) * Create all(user specifies the number) attributes for each dataset */ for (i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dataset %d", i); + HDsnprintf(dset_name, sizeof(dset_name), "dataset %d", i); open_t.start = retrieve_time(); if ((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) goto error; perf(&open_t, open_t.start, retrieve_time()); for (j = 0; j < NUM_ATTRS; j++) { - HDsprintf(attr_name, "all attrs for each dset %d", j); + HDsnprintf(attr_name, sizeof(attr_name), "all attrs for each dset %d", j); attr_t.start = retrieve_time(); if ((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -468,7 +468,7 @@ create_attrs_2(void) * Create all(user specifies the number) attributes for each new dataset */ for (i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dataset %d", i); + HDsnprintf(dset_name, sizeof(dset_name), "dataset %d", i); create_t.start = retrieve_time(); if ((dataset = H5Dcreate2(file, dset_name, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -476,7 +476,7 @@ create_attrs_2(void) perf(&create_t, create_t.start, retrieve_time()); for (j = 0; j < NUM_ATTRS; j++) { - HDsprintf(attr_name, "all attrs for each dset %d", j); + HDsnprintf(attr_name, sizeof(attr_name), "all attrs for each dset %d", j); attr_t.start = retrieve_time(); if ((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -579,14 +579,14 @@ create_attrs_3(void) for (i = 0; i < loop_num; i++) { for (j = 0; j < NUM_DSETS; j++) { - HDsprintf(dset_name, "dataset %d", j); + HDsnprintf(dset_name, sizeof(dset_name), "dataset %d", j); open_t.start = retrieve_time(); if ((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) goto error; perf(&open_t, open_t.start, retrieve_time()); for (k = 0; k < BATCH_ATTRS; k++) { - HDsprintf(attr_name, "some attrs for each dset %d %d", i, k); + HDsnprintf(attr_name, sizeof(attr_name), "some attrs for each dset %d %d", i, k); attr_t.start = retrieve_time(); if ((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) -- cgit v0.12