diff options
84 files changed, 1934 insertions, 1276 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0346ff3..f4a2451 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,7 +157,11 @@ IF (NOT HDF5_INSTALL_INCLUDE_DIR) SET (HDF5_INSTALL_INCLUDE_DIR include) ENDIF (NOT HDF5_INSTALL_INCLUDE_DIR) IF (NOT HDF5_INSTALL_DATA_DIR) - SET (HDF5_INSTALL_DATA_DIR share) + IF (NOT WIN32) + SET (HDF5_INSTALL_DATA_DIR share) + ELSE (NOT WIN32) + SET (HDF5_INSTALL_DATA_DIR ".") + ENDIF (NOT WIN32) ENDIF (NOT HDF5_INSTALL_DATA_DIR) #----------------------------------------------------------------------------- @@ -201,7 +205,7 @@ ELSE (NOT "${H5_VERS_SUBRELEASE}" STREQUAL "") ENDIF (NOT "${H5_VERS_SUBRELEASE}" STREQUAL "") SET (HDF5_PACKAGE_SOVERSION "${H5_SOVERS_MAJOR}.${H5_SOVERS_MINOR}.${H5_SOVERS_RELEASE}") SET (HDF5_PACKAGE_STRING "${HDF5_PACKAGE_NAME} ${HDF5_PACKAGE_VERSION_STRING}") -SET (HDF5_PACKAGE_TARNAME "hdf5") +SET (HDF5_PACKAGE_TARNAME "${HDF5_PACKAGE}${HDF_PACKAGE_EXT}") SET (HDF5_PACKAGE_URL "http://www.hdfgroup.org") SET (HDF5_PACKAGE_BUGREPORT "help@hdfgroup.org") @@ -268,10 +272,10 @@ SET (H5_ENABLE_SHARED_LIB NO) SET (H5_ENABLE_STATIC_LIB NO) IF (BUILD_SHARED_LIBS) SET (LIB_TYPE SHARED) - SET (H5_BUILT_AS_DYNAMIC_LIB 1) + ADD_DEFINITIONS (-DH5_BUILT_AS_DYNAMIC_LIB) SET (H5_ENABLE_SHARED_LIB YES) ELSE (BUILD_SHARED_LIBS) - SET (H5_BUILT_AS_STATIC_LIB 1) + ADD_DEFINITIONS (-DH5_BUILT_AS_STATIC_LIB) SET (H5_ENABLE_STATIC_LIB YES) IF (NOT WIN32) # should this be a user setting : Everyone uses it anyway ? @@ -461,7 +465,7 @@ ENDIF (CMAKE_COMPILER_IS_GNUCXX) #----------------------------------------------------------------------------- # All libs/tests/examples need the main include directories #----------------------------------------------------------------------------- -INCLUDE_DIRECTORIES (${HDF5_BINARY_DIR} ${HDF5_SRC_DIR}) +INCLUDE_DIRECTORIES (${HDF5_BINARY_DIR} ${HDF5_SRC_DIR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) #----------------------------------------------------------------------------- # Option to Enable MPI Parallel @@ -556,7 +560,7 @@ OPTION (HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" OFF) IF (HDF5_ENABLE_Z_LIB_SUPPORT) IF (NOT H5_ZLIB_HEADER) IF (NOT ZLIB_USE_EXTERNAL) - FIND_PACKAGE (ZLIB) + FIND_PACKAGE (ZLIB NAMES ${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT}) ENDIF (NOT ZLIB_USE_EXTERNAL) IF (ZLIB_FOUND) SET (H5_HAVE_FILTER_DEFLATE 1) @@ -596,7 +600,7 @@ OPTION (HDF5_ENABLE_SZIP_SUPPORT "Use SZip Filter" OFF) IF (HDF5_ENABLE_SZIP_SUPPORT) OPTION (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" OFF) IF (NOT SZIP_USE_EXTERNAL) - FIND_PACKAGE (SZIP) + FIND_PACKAGE (SZIP NAMES ${SZIP_PACKAGE_NAME}${HDF_PACKAGE_EXT}) ENDIF (NOT SZIP_USE_EXTERNAL) IF (SZIP_FOUND) SET (H5_HAVE_FILTER_SZIP 1) @@ -615,7 +619,7 @@ IF (HDF5_ENABLE_SZIP_SUPPORT) ENDIF (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") ENDIF (SZIP_FOUND) SET (LINK_LIBS ${LINK_LIBS} ${SZIP_LIBRARIES}) - INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIRS}) + INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIR}) MESSAGE (STATUS "Filter SZIP is ON") IF (H5_HAVE_FILTER_SZIP) SET (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DECODE") @@ -831,8 +835,8 @@ ENDIF (NOT HDF5_INSTALL_NO_DEVELOPMENT) IF (NOT HDF5_EXTERNALLY_CONFIGURED) INSTALL ( EXPORT ${HDF5_EXPORTED_TARGETS} - DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/hdf5 - FILE hdf5-targets.cmake + DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/${HDF5_PACKAGE} + FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake COMPONENT configinstall ) ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) @@ -843,7 +847,7 @@ ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) IF (NOT HDF5_EXTERNALLY_CONFIGURED) EXPORT ( TARGETS ${HDF5_LIBRARIES_TO_EXPORT} ${HDF5_LIB_DEPENDENCIES} - FILE hdf5-targets.cmake + FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake ) ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) @@ -860,20 +864,35 @@ SET (HDF5_VERSION_MINOR @HDF5_PACKAGE_VERSION_MINOR@) CONFIGURE_FILE ( ${HDF5_RESOURCES_DIR}/hdf5-config.cmake.build.in - ${HDF5_BINARY_DIR}/hdf5-config.cmake @ONLY + ${HDF5_BINARY_DIR}/${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-config.cmake @ONLY ) #----------------------------------------------------------------------------- +# Configure the FindHDF5.cmake file for the install directory +#----------------------------------------------------------------------------- +IF (NOT HDF5_EXTERNALLY_CONFIGURED) + CONFIGURE_FILE ( + ${HDF5_RESOURCES_DIR}/FindHDF5.cmake.in + ${HDF5_BINARY_DIR}/CMakeFiles/FindHDF5${HDF_PACKAGE_EXT}.cmake @ONLY + ) + INSTALL ( + FILES ${HDF5_BINARY_DIR}/CMakeFiles/FindHDF5${HDF_PACKAGE_EXT}.cmake + DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/${HDF5_PACKAGE} + COMPONENT configinstall + ) +ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) + +#----------------------------------------------------------------------------- # Configure the hdf5-config.cmake file for the install directory #----------------------------------------------------------------------------- IF (NOT HDF5_EXTERNALLY_CONFIGURED) CONFIGURE_FILE ( ${HDF5_RESOURCES_DIR}/hdf5-config.cmake.install.in - ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config.cmake @ONLY + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-config.cmake @ONLY ) INSTALL ( - FILES ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config.cmake - DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/hdf5 + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-config.cmake + DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/${HDF5_PACKAGE} COMPONENT configinstall ) ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) @@ -884,11 +903,11 @@ ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) IF (NOT HDF5_EXTERNALLY_CONFIGURED) CONFIGURE_FILE ( ${HDF5_RESOURCES_DIR}/hdf5-config-version.cmake.in - ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config-version.cmake @ONLY + ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-config-version.cmake @ONLY ) INSTALL ( - FILES ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config-version.cmake - DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/hdf5 + FILES ${HDF5_BINARY_DIR}/CMakeFiles/${HDF5_PACKAGE}${HDF5_PACKAGE_EXT}-config-version.cmake + DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/${HDF5_PACKAGE} COMPONENT configinstall ) ENDIF (NOT HDF5_EXTERNALLY_CONFIGURED) @@ -907,7 +926,7 @@ CONFIGURE_FILE ( ) INSTALL ( FILES ${HDF5_BINARY_DIR}/libhdf5.settings - DESTINATION ${HDF5_INSTALL_LIB_DIR} + DESTINATION ${HDF5_INSTALL_DATA_DIR}/cmake/${HDF5_PACKAGE} COMPONENT libraries ) @@ -984,7 +1003,6 @@ IF (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) SET (CPACK_NSIS_PACKAGE_NAME "HDF5 ${HDF5_PACKAGE_VERSION}") ELSE (WIN32) SET (CPACK_PACKAGING_INSTALL_PREFIX "/usr") - SET (CPACK_ARCHIVE_COMPONENT_INSTALL ON) SET (CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON) SET (CPACK_DEBIAN_PACKAGE_SECTION "Libraries") @@ -2297,7 +2297,7 @@ ./config/cmake/CheckTypeSize.cmake ./config/cmake/H5cxx_config.h.in ./config/cmake/H5pubconf.h.in -./config/cmake/FindHDF5.cmake +./config/cmake/FindHDF5.cmake.in ./config/cmake/FindMPI.cmake ./config/cmake/hdf5-config.cmake.build.in ./config/cmake/hdf5-config.cmake.install.in diff --git a/config/cmake/FindHDF5.cmake b/config/cmake/FindHDF5.cmake.in index 33532b0..7be4de3 100644 --- a/config/cmake/FindHDF5.cmake +++ b/config/cmake/FindHDF5.cmake.in @@ -53,18 +53,18 @@ SET (_HDF5_PATHS $ENV{HOME}/.local
$ENV{HDF5_ROOT}
$ENV{HDF5_ROOT_DIR_HINT}
- /usr/lib/hdf5
- /usr/share/hdf5
- /usr/local/hdf5
- /usr/local/hdf5/share
+ /usr/lib/@HDF5_PACKAGE@
+ /usr/share/@HDF5_PACKAGE@
+ /usr/local/@HDF5_PACKAGE@
+ /usr/local/@HDF5_PACKAGE@/share
)
-FIND_PATH (HDF5_ROOT_DIR "hdf5-config.cmake"
+FIND_PATH (HDF5_ROOT_DIR "@HDF5_PACKAGE@@HDF_PACKAGE_EXT@-config.cmake"
HINTS ${_HDF5_HINTS}
PATHS ${_HDF5_PATHS}
PATH_SUFFIXES
- lib/cmake/hdf5
- share/cmake/hdf5
+ lib/cmake/@HDF5_PACKAGE@
+ share/cmake/@HDF5_PACKAGE@
)
FIND_PATH (HDF5_INCLUDE_DIRS "H5public.h"
@@ -81,5 +81,5 @@ SET ( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) IF (HDF5_INCLUDE_DIR)
SET (HDF5_FOUND "YES")
- INCLUDE (${HDF5_ROOT_DIR}/hdf5-config.cmake)
+ INCLUDE (${HDF5_ROOT_DIR}/@HDF5_PACKAGE@@HDF_PACKAGE_EXT@-config.cmake)
ENDIF (HDF5_INCLUDE_DIR)
diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index b965c64..31b2e15 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -15,24 +15,6 @@ /* Define if using a Windows compiler (i.e. Visual Studio) */ #cmakedefine H5_HAVE_VISUAL_STUDIO @H5_HAVE_VISUAL_STUDIO@ -/* Defined if HDF5 was built with CMake AND build as a shared library */ -#cmakedefine H5_BUILT_AS_DYNAMIC_LIB @H5_BUILT_AS_DYNAMIC_LIB@ - -/* Defined if HDF5 was built with CMake AND build as a static library */ -#cmakedefine H5_BUILT_AS_STATIC_LIB @H5_BUILT_AS_STATIC_LIB@ - -/* Defined if HDF5 CPP was built with CMake AND build as a shared library */ -#cmakedefine H5_CPP_BUILT_AS_DYNAMIC_LIB @H5_CPP_BUILT_AS_DYNAMIC_LIB@ - -/* Defined if HDF5 CPP was built with CMake AND build as a static library */ -#cmakedefine H5_CPP_BUILT_AS_STATIC_LIB @H5_CPP_BUILT_AS_STATIC_LIB@ - -/* Defined if HDF5 HL was built with CMake AND build as a shared library */ -#cmakedefine H5_HL_BUILT_AS_DYNAMIC_LIB @H5_HL_BUILT_AS_DYNAMIC_LIB@ - -/* Defined if HDF5 HL was built with CMake AND build as a static library */ -#cmakedefine H5_HL_BUILT_AS_STATIC_LIB @H5_HL_BUILT_AS_STATIC_LIB@ - /* Define if building universal (internal helper macro) */ #cmakedefine H5_AC_APPLE_UNIVERSAL_BUILD @H5_AC_APPLE_UNIVERSAL_BUILD@ diff --git a/config/cmake/HDFLibMacros.cmake b/config/cmake/HDFLibMacros.cmake index 7b54c95..57e6be7 100644 --- a/config/cmake/HDFLibMacros.cmake +++ b/config/cmake/HDFLibMacros.cmake @@ -10,6 +10,7 @@ MACRO (EXTERNAL_JPEG_LIBRARY compress_type libtype jpeg_pic) INSTALL_COMMAND "" CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DHDF_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} -DJPEG_EXTERNALLY_CONFIGURED:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} @@ -25,6 +26,7 @@ MACRO (EXTERNAL_JPEG_LIBRARY compress_type libtype jpeg_pic) INSTALL_COMMAND "" CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DHDF_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} -DJPEG_EXTERNALLY_CONFIGURED:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} @@ -122,6 +124,7 @@ MACRO (EXTERNAL_SZIP_LIBRARY compress_type libtype encoding) INSTALL_COMMAND "" CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DHDF_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} -DSZIP_EXTERNALLY_CONFIGURED:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} @@ -138,6 +141,7 @@ MACRO (EXTERNAL_SZIP_LIBRARY compress_type libtype encoding) INSTALL_COMMAND "" CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DHDF_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} -DSZIP_EXTERNALLY_CONFIGURED:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} @@ -236,6 +240,7 @@ MACRO (EXTERNAL_ZLIB_LIBRARY compress_type libtype) INSTALL_COMMAND "" CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DHDF_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} -DZLIB_EXTERNALLY_CONFIGURED:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} @@ -251,6 +256,7 @@ MACRO (EXTERNAL_ZLIB_LIBRARY compress_type libtype) INSTALL_COMMAND "" CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DHDF_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} -DZLIB_EXTERNALLY_CONFIGURED:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} diff --git a/config/cmake/cacheinit.cmake b/config/cmake/cacheinit.cmake index e7dd19f..d45ef9e 100755 --- a/config/cmake/cacheinit.cmake +++ b/config/cmake/cacheinit.cmake @@ -8,6 +8,8 @@ SET (BUILD_SHARED_LIBS ON CACHE BOOL "Build Shared Libraries" FORCE) SET (BUILD_TESTING ON CACHE BOOL "Build HDF5 Unit Testing" FORCE)
+SET (HDF_PACKAGE_EXT "" CACHE STRING "Name of HDF package extension" FORCE)
+
SET (HDF5_BUILD_CPP_LIB ON CACHE BOOL "Build HDF5 C++ Library" FORCE)
SET (HDF5_BUILD_EXAMPLES ON CACHE BOOL "Build HDF5 Library Examples" FORCE)
@@ -69,3 +71,7 @@ SET (SZIP_SVN_URL "http://svn.hdfgroup.uiuc.edu/szip/trunk" CACHE STRING "Use SZ SET (ZLIB_TGZ_NAME "ZLib.tar.gz" CACHE STRING "Use ZLib from compressed file" FORCE)
SET (SZIP_TGZ_NAME "SZip.tar.gz" CACHE STRING "Use SZip from compressed file" FORCE)
+
+SET (ZLIB_PACKAGE_NAME "zlib" CACHE STRING "Name of ZLIB package" FORCE)
+
+SET (SZIP_PACKAGE_NAME "szip" CACHE STRING "Name of SZIP package" FORCE)
diff --git a/config/cmake/hdf5-config.cmake.build.in b/config/cmake/hdf5-config.cmake.build.in index ccf5e67..881985e 100644 --- a/config/cmake/hdf5-config.cmake.build.in +++ b/config/cmake/hdf5-config.cmake.build.in @@ -42,6 +42,12 @@ IF (HDF5_BUILD_TOOLS) SET (HDF5_INCLUDE_DIR_TOOLS ${HDF5_INCLUDE_DIR} )
ENDIF (HDF5_BUILD_TOOLS)
+IF (HDF5_BUILD_SHARED_LIBS)
+ SET (H5_BUILT_AS_DYNAMIC_LIB 1 )
+ELSE (HDF5_BUILD_SHARED_LIBS)
+ SET (H5_BUILT_AS_STATIC_LIB 1 )
+ENDIF (HDF5_BUILD_SHARED_LIBS)
+
#-----------------------------------------------------------------------------
# Version Strings
#-----------------------------------------------------------------------------
@@ -53,7 +59,7 @@ SET (HDF5_VERSION_MINOR @HDF5_VERSION_MINOR@) # Don't include targets if this file is being picked up by another
# project which has already build hdf5 as a subproject
#-----------------------------------------------------------------------------
-IF (NOT TARGET "hdf5")
- INCLUDE (${SELF_DIR}/hdf5-targets.cmake)
+IF (NOT TARGET "@HDF5_PACKAGE@")
+ INCLUDE (${SELF_DIR}/@HDF5_PACKAGE@@HDF_PACKAGE_EXT@-targets.cmake)
SET (HDF5_LIBRARIES "@HDF5_LIBRARIES_TO_EXPORT@")
-ENDIF (NOT TARGET "hdf5")
+ENDIF (NOT TARGET "@HDF5_PACKAGE@")
diff --git a/config/cmake/hdf5-config.cmake.install.in b/config/cmake/hdf5-config.cmake.install.in index a851915..6b90496 100644 --- a/config/cmake/hdf5-config.cmake.install.in +++ b/config/cmake/hdf5-config.cmake.install.in @@ -4,7 +4,9 @@ GET_FILENAME_COMPONENT (SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${SELF_DIR}" PATH)
GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
-GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+IF (NOT WIN32)
+ GET_FILENAME_COMPONENT(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
+ENDIF (NOT WIN32)
#-----------------------------------------------------------------------------
# User Options
@@ -58,34 +60,14 @@ SET (HDF5_VERSION_MINOR @HDF5_VERSION_MINOR@) # Don't include targets if this file is being picked up by another
# project which has already built hdf5 as a subproject
#-----------------------------------------------------------------------------
-IF (NOT TARGET "hdf5")
+IF (NOT TARGET "@HDF5_PACKAGE@")
IF (HDF5_ENABLE_Z_LIB_SUPPORT AND HDF5_PACKAGE_EXTLIBS AND NOT TARGET "zlib")
- INCLUDE (${SELF_DIR}/../ZLIB/ZLIB-targets.cmake)
+ INCLUDE (${SELF_DIR}/../ZLIB/@ZLIB_PACKAGE_NAME@@HDF_PACKAGE_EXT@-targets.cmake)
ENDIF (HDF5_ENABLE_Z_LIB_SUPPORT AND HDF5_PACKAGE_EXTLIBS AND NOT TARGET "zlib")
IF (HDF5_ENABLE_SZIP_SUPPORT AND HDF5_PACKAGE_EXTLIBS AND NOT TARGET "szip")
- INCLUDE (${SELF_DIR}/../SZIP/SZIP-targets.cmake)
+ INCLUDE (${SELF_DIR}/../SZIP/@SZIP_PACKAGE_NAME@@HDF_PACKAGE_EXT@-targets.cmake)
ENDIF (HDF5_ENABLE_SZIP_SUPPORT AND HDF5_PACKAGE_EXTLIBS AND NOT TARGET "szip")
- INCLUDE (${SELF_DIR}/hdf5-targets.cmake)
+ INCLUDE (${SELF_DIR}/@HDF5_PACKAGE@@HDF_PACKAGE_EXT@-targets.cmake)
SET (HDF5_LIBRARIES "@HDF5_LIBRARIES_TO_EXPORT@")
-ENDIF (NOT TARGET "hdf5")
+ENDIF (NOT TARGET "@HDF5_PACKAGE@")
-#-----------------------------------------------------------------------------
-# Unfinished
-#-----------------------------------------------------------------------------
-#
-# To be continued (maybe) ...
-#
-# XXX_INCLUDE_DIRS no, use one per library as in HDF5_FORTRAN_INCLUDE_DIR
-# XXX_LIBRARIES not needed - see hdf5-targets.cmake
-# XXX_DEFINITIONS Definitions to use when compiling code that uses XXX. This really shouldn't include options such as (-DHAS_JPEG) that a client source-code file uses to decide whether to #include <jpeg.h>
-# XXX_EXECUTABLE Where to find the XXX tool.
-# XXX_YYY_EXECUTABLE Where to find the YYY tool that comes with XXX.
-# XXX_LIBRARY_DIRS Optionally, the final set of library directories listed in one variable for use by client code. This should not be a cache entry.
-# XXX_ROOT_DIR Where to find the base directory of XXX.
-# XXX_VERSION_YY Expect Version YY if true. Make sure at most one of these is ever true.
-# XXX_WRAP_YY If False, do not try to use the relevent CMake wrapping command.
-# XXX_YY_FOUND If False, optional YY part of XXX sytem is not available.
-# XXX_FOUND Set to false, or undefined, if we haven't found, or don't want to use XXX.
-# XXX_RUNTIME_LIBRARY_DIRS Optionally, the runtime library search path for use when running an executable linked to shared libraries.
-# The list should be used by user code to create the PATH on windows or LD_LIBRARY_PATH on unix.
-# This should not be a cache entry.
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 678642f..eed2721 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -3024,8 +3024,11 @@ herr_t H5LTget_attribute_string( hid_t loc_id, return -1; /* Get the attribute */ - if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) - return -1; + if ( H5LT_get_attribute_disk( obj_id, attr_name, data ) < 0 ) + { + H5Oclose(obj_id); + return -1; + } /* Close the object */ if(H5Oclose(obj_id) < 0) @@ -3458,6 +3461,8 @@ static herr_t H5LT_get_attribute_mem(hid_t loc_id, return 0; out: + if(obj_id > 0) + H5Oclose(obj_id); if(attr_id > 0) H5Aclose(attr_id); return -1; diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index 6edc244..8a77f13 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -1298,6 +1298,7 @@ herr_t H5TBdelete_record( hid_t loc_id, hid_t tid=-1; hid_t sid=-1; hid_t m_sid=-1; + hid_t mem_type_id=-1; hsize_t count[1]; hsize_t offset[1]; hsize_t mem_size[1]; @@ -1364,6 +1365,10 @@ herr_t H5TBdelete_record( hid_t loc_id, if ((sid = H5Dget_space( did )) < 0) goto out; + /* create the memory data type. */ + if ((mem_type_id=H5TB_create_type( loc_id, dset_name, src_size, src_offset, src_sizes, tid)) < 0) + goto out; + /* define a hyperslab in the dataset of the size of the records */ offset[0] = start; count[0] = read_nrecords; @@ -1375,12 +1380,14 @@ herr_t H5TBdelete_record( hid_t loc_id, if ((m_sid = H5Screate_simple( 1, mem_size, NULL )) < 0) goto out; - if (H5Dwrite( did, tid, m_sid, sid, H5P_DEFAULT, tmp_buf ) < 0) + if (H5Dwrite( did, mem_type_id, m_sid, sid, H5P_DEFAULT, tmp_buf ) < 0) goto out; /* close */ if (H5Sclose( m_sid ) < 0) goto out; + if (H5Tclose( mem_type_id ) < 0) + goto out; if (H5Sclose( sid ) < 0) goto out; if (H5Tclose( tid ) < 0) @@ -1416,6 +1423,7 @@ out: free( tmp_buf ); H5E_BEGIN_TRY { + H5Tclose(mem_type_id); H5Dclose(did); H5Tclose(tid); H5Sclose(sid); diff --git a/hl/test/test_table.c b/hl/test/test_table.c index e3e040e..cdae768 100644 --- a/hl/test/test_table.c +++ b/hl/test/test_table.c @@ -114,6 +114,27 @@ typedef struct particle3_t int lati; } particle3_t; +/*------------------------------------------------------------------------- + * a particle, used in the delete field test differing memory layout + *------------------------------------------------------------------------- + */ + +/* Push current alignment rule forcing 4-byte alignment boundary + * to the internal stack ... + */ +#pragma pack(push,4) + typedef struct particle4_t { + uint32_t state; + double posx; + double posy; + float atx[3]; + float aty[3]; + float rro[2]; + } particle4_t; +/* + * ... and restore original alignment rules from stack + */ +#pragma pack(pop) /*------------------------------------------------------------------------- @@ -350,6 +371,34 @@ static int test_table(hid_t fid, int do_write) sizeof( rbuf3[0].temperature), sizeof( rbuf3[0].lati)}; + /*------------------------------------------------------------------------- + * initialize table parameters + * size and the offsets of struct members in memory + * these are used for the delete field test with differing memory layout + *------------------------------------------------------------------------- + */ + + /* Calculate the size and the offsets of our struct members in memory */ + size_t tbl_size = sizeof(particle4_t); + size_t tbl_offset[NFIELDS+1] = { HOFFSET(particle4_t, state), + HOFFSET(particle4_t, posx), + HOFFSET(particle4_t, posy), + HOFFSET(particle4_t, atx), + HOFFSET(particle4_t, aty), + HOFFSET(particle4_t, rro) + }; + + /* Define an array of Particles */ + particle4_t p_data[NRECORDS] = { + {12112, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12113, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12114, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12115, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12116, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12117, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12118, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}}, + {12119, 1.4, 2.5, {1,2,3},{4,5,6}, {99,100}} + }; /*------------------------------------------------------------------------- * initialize table parameters @@ -376,10 +425,23 @@ static int test_table(hid_t fid, int do_write) sizeof( rbuf[0].temperature), sizeof( rbuf[0].lati) }; + + const char *field_names4[NFIELDS+1] = + { "F1", "F2", "F3", "F4", "F5", "F6"}; + hid_t field_type4[NFIELDS+1]; + particle4_t fill_data[1] = { {9999999, -9999999, 999999, {999,999,999},{999,999,999}, {999,999}} }; + + hsize_t nfields_out; + hsize_t nrecords_out; + hid_t arry3_32f; + hid_t arry2_32f; + hsize_t dims; + const char *field_names[NFIELDS] = - { "Name","Longitude","Pressure","Temperature","Latitude" }; + { "Name","Longitude","Pressure","Temperature","Latitude" }; hid_t field_type[NFIELDS]; hid_t string_type = H5Tcopy( H5T_C_S1 ); + H5Tset_size( string_type, 16 ); field_type[0] = string_type; field_type[1] = H5T_NATIVE_LONG; @@ -820,6 +882,59 @@ static int test_table(hid_t fid, int do_write) PASSED(); } + /*------------------------------------------------------------------------ + * Functions tested: + * + * H5TBdelete_record -- With differing memory layout from machine memory + * layout. HDFFV-8055 + * + *------------------------------------------------------------------------- + */ + if (do_write) + { + TESTING2("deleting records (differing memory layout)"); + + dims = 3; + arry3_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); + + dims = 2; + arry2_32f = H5Tarray_create2(H5T_NATIVE_FLOAT, 1, &dims); + + /* Initialize the field field_type */ + field_type4[0] = H5T_NATIVE_UINT32; + field_type4[1] = H5T_NATIVE_DOUBLE; + field_type4[2] = H5T_NATIVE_DOUBLE; + field_type4[3] = arry3_32f; + field_type4[4] = arry3_32f; + field_type4[5] = arry2_32f; + + /* Make the table */ + if (H5TBmake_table("Table Title",fid,"table",NFIELDS+1,(hsize_t)NRECORDS, + tbl_size, field_names4, tbl_offset, field_type4, + chunk_size, fill_data, compress, p_data)<0) + goto out; + /* Delete records */ + start = 3; + nrecords = 3; + if (H5TBdelete_record(fid, "table", start, nrecords)<0) + goto out;; + /* Get table info */ + if (H5TBget_table_info(fid,"table", &nfields_out, &nrecords_out)<0) + goto out; + /* check */ + if( (int)nfields_out != (int)NFIELDS+1) + goto out; + + if( (int)nrecords_out != (int)NRECORDS-3) + goto out; + + /* close type */ + H5Tclose(arry3_32f); + H5Tclose(arry2_32f); + + PASSED(); + } + /*------------------------------------------------------------------------- * * Functions tested: diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 338cc61..33599b1 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -378,6 +378,9 @@ Bug Fixes since HDF5-1.8.0 release Library ------- + - Fixed an error that could occur when calling H5Ocopy within an + H5Literate callback (and possibly other situations). + (NAF - 2012/7/25 - HDFFV-5853) - Fixed an error that would occur when copying an object with attribute creation order tracked and indexed. (NAF - 2012/3/28 - HDFFV-7762) - Fixed a bug in H5Ocopy(): When copying an opened object, call the @@ -702,6 +705,14 @@ Bug Fixes since HDF5-1.8.0 release Tools ----- + - ph5diff: Fixed intermittent hang issue on a certain operation in + parallel mode. It was detected by daily test for comparing + non-comparable objects, but it could have occurred in other + operations depend on machine condition. HDFFV-8003 (JKM 2012/08/01) + - h5diff: Fixed test failure for "make check" due to failure of + copying test files when performed in HDF5 source tree. Also applied + to other tools. + HDFFV-8107 (JKM 2012/08/01) - h5diff: Fixed the Function COPY_TESTFILES_TO_TESTDIR() of testh5diff.sh to better report when there is an error in the file copying. HDFFV-8105 (AKC -2012/07/22) diff --git a/src/H5Aint.c b/src/H5Aint.c index b813f76..ba900d9 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -2361,7 +2361,7 @@ H5A_dense_post_copy_file_cb(const H5A_t *attr_src, void *_udata) /* Insert attribute into dense storage */ if(H5A_dense_insert(udata->file, udata->dxpl_id, udata->ainfo, attr_dst) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to add to dense storage") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to add to dense storage") /* Reset metadata tag */ H5_END_TAG(H5_ITER_ERROR); diff --git a/src/H5B2int.c b/src/H5B2int.c index 4355174..8ea8426 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -140,7 +140,7 @@ H5B2_locate_record(const H5B2_class_t *type, unsigned nrec, size_t *rec_off, unsigned my_idx = 0; /* Final index value */ int cmp = -1; /* Key comparison value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR hi = nrec; while(lo < hi && cmp) { diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index dfb4011..93e8869 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -4408,7 +4408,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Insert chunk into the destination index */ if((udata->idx_info_dst->storage->ops->insert)(udata->idx_info_dst, &udata_dst) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert chunk into index") + HGOTO_ERROR_TAG(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert chunk into index") /* Reset metadata tag in dxpl_id */ H5_END_TAG(H5_ITER_ERROR); diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index 2ca48d2..b2ca5eb 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -69,6 +69,17 @@ typedef struct H5E_t H5E_t; } /* + * HGOTO_ERROR_TAG macro, used like HGOTO_ERROR between H5_BEGIN_TAG and + * H5_END_TAG statements. Resets the metadata tag before leaving the function. + */ +#define HGOTO_ERROR_TAG(maj, min, ret_val, ...) { \ + if(H5AC_tag(my_dxpl_id, prv_tag, NULL) < 0) \ + HERROR(H5E_CACHE, H5E_CANTTAG, "unable to apply metadata tag"); \ + HCOMMON_ERROR(maj, min, __VA_ARGS__); \ + HGOTO_DONE(ret_val) \ +} + +/* * HGOTO_DONE macro, used to facilitate normal return between a FUNC_ENTER() * and a FUNC_LEAVE() within a function body. The argument is the return * value which is assigned to the `ret_value' variable. Control branches to @@ -77,6 +88,16 @@ typedef struct H5E_t H5E_t; #define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;} /* + * HGOTO_DONE_TAG macro, used like HGOTO_DONE between H5_BEGIN_TAG and + * H5_END_TAG statements. Resets the metadata tag before leaving the function. + */ +#define HGOTO_DONE_TAG(ret_val, err) { \ + if(H5AC_tag(my_dxpl_id, prv_tag, NULL) < 0) \ + HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, err, "unable to apply metadata tag") \ + HGOTO_DONE(ret_val) \ +} + +/* * Macros handling system error messages as described in C standard. * These macros assume errnum is a valid system error code. */ @@ -1351,7 +1351,7 @@ H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/) { int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(f); HDassert(flags); @@ -1362,7 +1362,6 @@ H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/) else *flags=0; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_query() */ @@ -1388,7 +1387,7 @@ H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) { int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(driver); HDassert(flags); @@ -1399,7 +1398,6 @@ H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/) else *flags = 0; -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_driver_query() */ diff --git a/src/H5FDmpi.c b/src/H5FDmpi.c index afc5536..01c28e6 100644 --- a/src/H5FDmpi.c +++ b/src/H5FDmpi.c @@ -479,11 +479,11 @@ H5FD_mpi_setup_collective(hid_t dxpl_id, MPI_Datatype *btype, MPI_Datatype *ftyp /* Set buffer MPI type */ if(H5P_set(plist, H5FD_MPI_XFER_MEM_MPI_TYPE_NAME, btype) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI-I/O property") /* Set File MPI type */ if(H5P_set(plist, H5FD_MPI_XFER_FILE_MPI_TYPE_NAME, ftype) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set MPI-I/O property") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5FDpublic.h b/src/H5FDpublic.h index 5f70f71..ed50bc7 100644 --- a/src/H5FDpublic.h +++ b/src/H5FDpublic.h @@ -313,7 +313,7 @@ typedef enum { H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, H5FD_FILE_IMAGE_OP_FILE_OPEN, H5FD_FILE_IMAGE_OP_FILE_RESIZE, - H5FD_FILE_IMAGE_OP_FILE_CLOSE, + H5FD_FILE_IMAGE_OP_FILE_CLOSE } H5FD_file_image_op_t; /* Define structure to hold file image callbacks */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index eafb7c3..2f67100 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -82,10 +82,10 @@ typedef struct { *(p) = (uint8_t)(((i) >> 24) & 0xff); (p)++; \ } -/* Encode a 32-bit unsigned integer into a variable-sized buffer */ +/* Encode an unsigned integer into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define UINT32ENCODE_VAR(p, n, l) { \ - uint32_t _n = (n); \ +# define ENCODE_VAR(p, typ, n, l) { \ + typ _n = (n); \ size_t _i; \ uint8_t *_p = (uint8_t*)(p); \ \ @@ -94,6 +94,10 @@ typedef struct { (p) = (uint8_t*)(p) + l; \ } +/* Encode a 32-bit unsigned integer into a variable-sized buffer */ +/* (Assumes that the high bits of the integer are zero) */ +# define UINT32ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint32_t, n, l) + # define INT64ENCODE(p, n) { \ int64_t _n = (n); \ size_t _i; \ @@ -120,15 +124,7 @@ typedef struct { /* Encode a 64-bit unsigned integer into a variable-sized buffer */ /* (Assumes that the high bits of the integer are zero) */ -# define UINT64ENCODE_VAR(p, n, l) { \ - uint64_t _n = (n); \ - size_t _i; \ - uint8_t *_p = (uint8_t*)(p); \ - \ - for(_i = 0; _i < l; _i++, _n >>= 8) \ - *_p++ = (uint8_t)(_n & 0xff); \ - (p) = (uint8_t*)(p) + l; \ -} +# define UINT64ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint64_t, n, l) /* DECODE converts little endian bytes pointed by p to integer values and store * it in i. For signed values, need to do sign-extension when converting @@ -164,12 +160,9 @@ typedef struct { (i) |= ((uint32_t)(*(p) & 0xff) << 24); (p)++; \ } -/* Decode a variable-sized buffer into a 32-bit unsigned integer */ +/* Decode a variable-sized buffer */ /* (Assumes that the high bits of the integer will be zero) */ -/* (Note: this is exactly the same code as the 64-bit variable-length decoder - * and bugs/improvements should be make in both places - QAK) - */ -# define UINT32DECODE_VAR(p, n, l) { \ +# define DECODE_VAR(p, n, l) { \ size_t _i; \ \ n = 0; \ @@ -179,6 +172,10 @@ typedef struct { (p) += l; \ } +/* Decode a variable-sized buffer into a 32-bit unsigned integer */ +/* (Assumes that the high bits of the integer will be zero) */ +# define UINT32DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) + # define INT64DECODE(p, n) { \ /* WE DON'T CHECK FOR OVERFLOW! */ \ size_t _i; \ @@ -203,18 +200,7 @@ typedef struct { /* Decode a variable-sized buffer into a 64-bit unsigned integer */ /* (Assumes that the high bits of the integer will be zero) */ -/* (Note: this is exactly the same code as the 32-bit variable-length decoder - * and bugs/improvements should be make in both places - QAK) - */ -# define UINT64DECODE_VAR(p, n, l) { \ - size_t _i; \ - \ - n = 0; \ - (p) += l; \ - for (_i = 0; _i < l; _i++) \ - n = (n << 8) | *(--p); \ - (p) += l; \ -} +# define UINT64DECODE_VAR(p, n, l) DECODE_VAR(p, n, l) /* Address-related macros */ #define H5F_addr_overflow(X,Z) (HADDR_UNDEF==(X) || \ diff --git a/src/H5Gcache.c b/src/H5Gcache.c index 1d2ad8b..15dbf65 100644 --- a/src/H5Gcache.c +++ b/src/H5Gcache.c @@ -302,7 +302,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5G_node_dest(H5F_t *f, H5G_node_t *sym) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 4d2e045..c0d2885 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -1367,7 +1367,7 @@ H5G__node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr if(H5G__stab_insert_real(udata->dst_file, udata->dst_stab, name, &lnk, obj_type, (obj_type == H5O_TYPE_GROUP ? &gcrt_info : NULL), dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "unable to insert the name") + HGOTO_ERROR_TAG(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "unable to insert the name") /* Reset metadata tag */ H5_END_TAG(H5_ITER_ERROR); diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 79ff06b..bb0fefa 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -400,31 +400,31 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) /* Get the link info */ if(H5G__obj_get_linfo(&(grp->oloc), &linfo, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") + HGOTO_ERROR_TAG(H5E_SYM, H5E_BADMESG, FAIL, "can't get link info") /* Check for 'dense' link storage file addresses being defined */ if(!H5F_addr_defined(linfo.fheap_addr)) - HGOTO_DONE(FAIL) + HGOTO_DONE_TAG(FAIL, FAIL) if(!H5F_addr_defined(linfo.name_bt2_addr)) - HGOTO_DONE(FAIL) + HGOTO_DONE_TAG(FAIL, FAIL) /* Open the name index v2 B-tree */ if(NULL == (bt2_name = H5B2_open(grp->oloc.file, H5AC_dxpl_id, linfo.name_bt2_addr, NULL))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ if(H5B2_get_nrec(bt2_name, name_count) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") /* Check if there is a creation order index */ if(H5F_addr_defined(linfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ if(NULL == (bt2_corder = H5B2_open(grp->oloc.file, H5AC_dxpl_id, linfo.corder_bt2_addr, NULL))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ if(H5B2_get_nrec(bt2_corder, corder_count) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") } /* end if */ else *corder_count = 0; diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 1fd8b1e..abbe1d5 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -856,7 +856,7 @@ H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traver if(H5P_get(lapl, H5L_ACS_NLINKS_NAME, &nlinks) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of links") } /* end else */ - + /* Set up invalid tag. This is a precautionary step only. Setting an invalid tag here will ensure that no metadata accessed while doing the traversal is given an improper tag, unless another one is specifically set up @@ -867,7 +867,7 @@ H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traver /* Go perform "real" traversal */ if(H5G_traverse_real(loc, name, target, &nlinks, op, op_data, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "internal path traversal failed") + HGOTO_ERROR_TAG(H5E_SYM, H5E_NOTFOUND, FAIL, "internal path traversal failed") /* Reset tag after traversal */ H5_END_TAG(FAIL); diff --git a/src/H5HFdbg.c b/src/H5HFdbg.c index caaedc7..76c7b96 100644 --- a/src/H5HFdbg.c +++ b/src/H5HFdbg.c @@ -80,7 +80,7 @@ typedef struct { /* Local Prototypes */ /********************/ -static herr_t H5HF_dtable_debug(H5HF_dtable_t *dtable, FILE *stream, +static herr_t H5HF_dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, int indent, int fwidth); @@ -113,7 +113,7 @@ static herr_t H5HF_dtable_debug(H5HF_dtable_t *dtable, FILE *stream, *------------------------------------------------------------------------- */ static herr_t -H5HF_dtable_debug(H5HF_dtable_t *dtable, FILE *stream, int indent, int fwidth) +H5HF_dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, int indent, int fwidth) { FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5HFsection.c b/src/H5HFsection.c index 87fa069..e9ea7e0 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -651,9 +651,7 @@ herr_t H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *sect, haddr_t *dblock_addr, size_t *dblock_size) { - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* * Check arguments. @@ -678,8 +676,7 @@ H5HF_sect_single_dblock_info(H5HF_hdr_t *hdr, hid_t dxpl_id, *dblock_size = hdr->man_dtable.row_block_size[sect->u.single.par_entry / hdr->man_dtable.cparam.width]; } /* end else */ -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5HF_sect_single_dblock_info() */ @@ -1450,7 +1450,7 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, size_t initial_rc, /* Cache object header */ if(H5AC_insert_entry(f, dxpl_id, H5AC_OHDR, oh_addr, oh, insert_flags) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") oh = NULL; /* Reset metadata tag in dxpl_id */ @@ -1910,7 +1910,7 @@ H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, H5AC_protect_t prot) while(curr_msg < cont_msg_info.nmsgs) { H5O_chunk_proxy_t *chk_proxy; /* Proxy for chunk, to bring it into memory */ #ifndef NDEBUG - unsigned chkcnt = oh->nchunks; /* Count of chunks (for sanity checking) */ + size_t chkcnt = oh->nchunks; /* Count of chunks (for sanity checking) */ #endif /* NDEBUG */ /* Bring the chunk into the cache */ @@ -2200,15 +2200,15 @@ H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force) /* Check version, to determine how to store time information */ if(oh->version == H5O_VERSION_1) { - int idx; /* Index of modification time message to update */ + size_t idx; /* Index of modification time message to update */ /* Look for existing message */ - for(idx = 0; idx < (int)oh->nmesgs; idx++) + for(idx = 0; idx < oh->nmesgs; idx++) if(H5O_MSG_MTIME == oh->mesg[idx].type || H5O_MSG_MTIME_NEW == oh->mesg[idx].type) break; /* Create a new message, if necessary */ - if(idx == (int)oh->nmesgs) { + if(idx == oh->nmesgs) { unsigned mesg_flags = 0; /* Flags for message in object header */ /* If we would have to create a new message, but we aren't 'forcing' it, get out now */ @@ -2216,7 +2216,7 @@ H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force) HGOTO_DONE(SUCCEED); /*nothing to do*/ /* Allocate space for the modification time message */ - if((idx = H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_MTIME_NEW, &mesg_flags, &now)) < 0) + if(H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_MTIME_NEW, &mesg_flags, &now, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for modification time message") /* Set the message's flags if appropriate */ @@ -2323,7 +2323,7 @@ done: herr_t H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned mesg_flags) { - int idx; /* Local index variable */ + size_t idx; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2332,7 +2332,7 @@ H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned mesg_flags) HDassert(oh); /* Look for existing message */ - for(idx = 0; idx < (int)oh->nmesgs; idx++) + for(idx = 0; idx < oh->nmesgs; idx++) if(H5O_MSG_BOGUS == oh->mesg[idx].type) break; @@ -2348,7 +2348,7 @@ H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned mesg_flags) bogus->u = H5O_BOGUS_VALUE; /* Allocate space in the object header for bogus message */ - if((idx = H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_BOGUS, &mesg_flags, bogus)) < 0) + if(H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_BOGUS, &mesg_flags, bogus, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message") /* Point to "bogus" information (take it over) */ @@ -2909,8 +2909,8 @@ H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) hdr->version = oh->version; /* Set the number of messages & chunks */ - hdr->nmesgs = oh->nmesgs; - hdr->nchunks = oh->nchunks; + H5_ASSIGN_OVERFLOW(hdr->nmesgs, oh->nmesgs, size_t, unsigned); + H5_ASSIGN_OVERFLOW(hdr->nchunks, oh->nchunks, size_t, unsigned); /* Set the status flags */ hdr->flags = oh->flags; diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index b207ea2..654163b 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -196,7 +196,7 @@ H5O_ainfo_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void /* The flags for the attribute indices */ flags = ainfo->track_corder ? H5O_AINFO_TRACK_CORDER : 0; - flags |= ainfo->index_corder ? H5O_AINFO_INDEX_CORDER : 0; + flags = (unsigned char)(flags | (ainfo->index_corder ? H5O_AINFO_INDEX_CORDER : 0)); *p++ = flags; /* Max. creation order value for the object */ @@ -284,12 +284,12 @@ H5O_ainfo_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg) FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set return value */ - ret_value = 1 /* Version */ + ret_value = (size_t)(1 /* Version */ + 1 /* Index flags */ + (ainfo->track_corder ? 2 : 0) /* Curr. max. creation order value */ + H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" attributes */ + H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of attributes */ - + (ainfo->index_corder ? H5F_SIZEOF_ADDR(f) : 0); /* Address of v2 B-tree for indexing creation order values of attributes */ + + (ainfo->index_corder ? H5F_SIZEOF_ADDR(f) : 0)); /* Address of v2 B-tree for indexing creation order values of attributes */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_ainfo_size() */ @@ -428,12 +428,12 @@ H5O_ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, if(H5F_addr_defined(ainfo_src->fheap_addr)) { /* copy dense attribute */ - + /* Set copied metadata tag */ H5_BEGIN_TAG(dxpl_id, H5AC__COPIED_TAG, NULL); if(H5A_dense_create(file_dst, dxpl_id, ainfo_dst) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to create dense storage for attributes") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINIT, NULL, "unable to create dense storage for attributes") /* Reset metadata tag */ H5_END_TAG(NULL); diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 05322af..5c00fb2 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -59,14 +59,15 @@ /********************/ static herr_t H5O_add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, - hbool_t *chk_dirtied, unsigned idx, uint8_t *new_gap_loc, size_t new_gap_size); + hbool_t *chk_dirtied, size_t idx, uint8_t *new_gap_loc, size_t new_gap_size); static herr_t H5O_eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, uint8_t *new_gap_loc, size_t new_gap_size); -static herr_t H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx, +static herr_t H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t null_idx, const H5O_msg_class_t *new_type, void *new_native, size_t new_size); static htri_t H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, - unsigned chunkno, size_t size, int *msg_idx); -static int H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size); + unsigned chunkno, size_t size, size_t *msg_idx); +static herr_t H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size, + size_t *new_idx); static htri_t H5O_move_cont(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned cont_u); static htri_t H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh); static htri_t H5O_merge_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh); @@ -109,10 +110,10 @@ H5FL_EXTERN(H5O_cont_t); */ static herr_t H5O_add_gap(H5F_t *f, H5O_t *oh, unsigned chunkno, hbool_t *chk_dirtied, - unsigned idx, uint8_t *new_gap_loc, size_t new_gap_size) + size_t idx, uint8_t *new_gap_loc, size_t new_gap_size) { hbool_t merged_with_null; /* Whether the gap was merged with a null message */ - unsigned u; /* Local index variable */ + size_t u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -335,7 +336,7 @@ H5O_eliminate_gap(H5O_t *oh, hbool_t *chk_dirtied, H5O_mesg_t *mesg, *------------------------------------------------------------------------- */ static herr_t -H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned null_idx, +H5O_alloc_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t null_idx, const H5O_msg_class_t *new_type, void *new_native, size_t new_size) { H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ @@ -505,7 +506,7 @@ done: */ static htri_t H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, - size_t size, int *msg_idx) + size_t size, size_t *msg_idx) { H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ @@ -514,11 +515,12 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, uint8_t *old_image; /* Old address of chunk's image in memory */ size_t old_size; /* Old size of chunk */ htri_t extended; /* If chunk can be extended */ - int extend_msg = -1;/* Index of null message to extend */ + size_t extend_msg; /* Index of null message to extend */ + hbool_t extended_msg = FALSE; /* Whether an existing message was extended */ uint8_t new_size_flags = 0; /* New chunk #0 size flags */ hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ size_t extra_prfx_size = 0; /* Extra bytes added to object header prefix */ - unsigned u; /* Local index variable */ + size_t u; /* Local index variable */ htri_t ret_value = TRUE; /* return value */ FUNC_ENTER_NOAPI_NOINIT @@ -542,13 +544,14 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, == ((oh->chunk[chunkno].image + oh->chunk[chunkno].size) - (oh->chunk[chunkno].gap + H5O_SIZEOF_CHKSUM_OH(oh))))) { - extend_msg = (int)u; + extend_msg = u; + extended_msg = TRUE; break; } /* end if */ } /* end for */ /* If we can extend an existing null message, adjust the delta appropriately */ - if(extend_msg >= 0) { + if(extended_msg) { HDassert(oh->chunk[chunkno].gap == 0); delta = aligned_size - oh->mesg[extend_msg].raw_size; } /* end if */ @@ -598,7 +601,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, /* Adjust object header prefix flags */ if(adjust_size_flags) { - oh->flags &= (uint8_t)~H5O_HDR_CHUNK0_SIZE; + oh->flags = (uint8_t)(oh->flags & ~H5O_HDR_CHUNK0_SIZE); oh->flags |= new_size_flags; /* Mark object header as dirty in cache */ @@ -607,7 +610,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, } /* end if */ /* If we can extend an existing null message, take care of that */ - if(extend_msg >= 0) { + if(extended_msg) { /* Adjust message size of existing null message */ oh->mesg[extend_msg].raw_size += delta; } /* end if */ @@ -619,7 +622,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate more space for messages") /* Set extension message */ - extend_msg = (int)oh->nmesgs++; + extend_msg = oh->nmesgs++; /* Initialize new null message */ oh->mesg[extend_msg].type = H5O_MSG_NULL; @@ -690,7 +693,7 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, if(H5O_chunk_resize(oh, chk_proxy) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize object header chunk") - /* Set return value */ + /* Set new message index */ *msg_idx = extend_msg; done: @@ -737,8 +740,8 @@ done: * *------------------------------------------------------------------------- */ -static int -H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size) +static herr_t +H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size, size_t *new_idx) { /* Struct for storing information about "best" messages to allocate from */ typedef struct { @@ -756,13 +759,13 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size) int found_null = (-1); /* Best fit null message */ alloc_info found_attr = {-1, 0, 0, 0, 0}; /* Best fit attribute message */ alloc_info found_other = {-1, 0, 0, 0, 0}; /* Best fit other message */ - unsigned idx; /*message number */ + size_t idx; /* Message number */ uint8_t *p = NULL; /*ptr into new chunk */ H5O_cont_t *cont = NULL; /*native continuation message */ unsigned chunkno; /* Chunk allocated */ haddr_t new_chunk_addr; unsigned u; /* Local index variable */ - int ret_value; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1089,11 +1092,11 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size) cont->chunkno = chunkno; /* Split the null message and point at continuation message */ - if(H5O_alloc_null(f, dxpl_id, oh, (unsigned)found_null, H5O_MSG_CONT, cont, cont_size) < 0) + if(H5O_alloc_null(f, dxpl_id, oh, (size_t)found_null, H5O_MSG_CONT, cont, cont_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't split null message") - /* Set return value */ - ret_value = (int)idx; + /* Set new message index value */ + *new_idx = idx; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1114,14 +1117,14 @@ done: * *------------------------------------------------------------------------- */ -int +herr_t H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, - const void *mesg) + const void *mesg, size_t *mesg_idx) { - size_t raw_size; /* Raw size of message */ - size_t aligned_size; /* Size of message including alignment */ - int idx; /* Index of message which fits allocation */ - int ret_value; /* Return value */ + size_t raw_size; /* Raw size of message */ + size_t aligned_size; /* Size of message including alignment */ + size_t idx; /* Index of message which fits allocation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1129,6 +1132,7 @@ H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, HDassert(oh); HDassert(type); HDassert(mesg); + HDassert(mesg_idx); /* Compute the size needed to store the message in the object header */ raw_size = (type->raw_size)(f, FALSE, mesg); @@ -1139,12 +1143,12 @@ H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, aligned_size = H5O_ALIGN_OH(oh, raw_size); /* look for a null message which is large enough */ - for(idx = 0; idx < (int)oh->nmesgs; idx++) + for(idx = 0; idx < oh->nmesgs; idx++) if(H5O_NULL_ID == oh->mesg[idx].type->id && oh->mesg[idx].raw_size >= aligned_size) break; /* if we didn't find one, then allocate more header space */ - if(idx >= (int)oh->nmesgs) { + if(idx >= oh->nmesgs) { unsigned chunkno; /* check to see if we can extend one of the chunks. If we can, @@ -1163,22 +1167,22 @@ H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, } /* end for */ /* If we were not able to extend a chunk, create a new one */ - if(idx >= (int)oh->nmesgs) - if((idx = H5O_alloc_new_chunk(f, dxpl_id, oh, raw_size)) < 0) + if(idx >= oh->nmesgs) + if(H5O_alloc_new_chunk(f, dxpl_id, oh, raw_size, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "unable to create a new object header data chunk") } /* end if */ - HDassert(idx >= 0 && idx < (int)oh->nmesgs); + HDassert(idx < oh->nmesgs); /* Split the null message and point at continuation message */ - if(H5O_alloc_null(f, dxpl_id, oh, (unsigned)idx, type, NULL, aligned_size) < 0) + if(H5O_alloc_null(f, dxpl_id, oh, idx, type, NULL, aligned_size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't split null message") /* Mark object header as dirty in cache */ if(H5AC_mark_entry_dirty(oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") - /* Set return value */ - ret_value = (int)idx; + /* Set message index value */ + *mesg_idx = idx; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1296,7 +1300,7 @@ H5O_move_cont(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned cont_u) size_t nonnull_size; /* Total size of nonnull messages in the chunk pointed to by cont message */ H5O_mesg_t *curr_msg; /* Pointer to the current message to operate on */ size_t gap_size; /* Size of gap produced */ - unsigned v; /* Local index variable */ + size_t v; /* Local index variable */ /* Spin through messages */ nonnull_size = 0; @@ -1533,7 +1537,7 @@ H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh) } /* end if */ else { H5O_mesg_t *null_msg; /* Pointer to current message to operate on */ - unsigned v; /* Local index variable */ + size_t v; /* Local index variable */ /* Check if messages in chunk pointed to can replace continuation message */ if(H5O_CONT_ID == curr_msg->type->id) { @@ -1607,7 +1611,7 @@ H5O_move_msgs_forward(H5F_t *f, hid_t dxpl_id, H5O_t *oh) null_chk_dirtied = FALSE; } /* end if */ else { - unsigned new_null_msg; /* Message index for new null message */ + size_t new_null_msg; /* Message index for new null message */ /* Check if null message is large enough to still exist */ if((null_msg->raw_size - curr_msg->raw_size) < (size_t)H5O_SIZEOF_MSGHDR_OH(oh)) { @@ -2135,8 +2139,8 @@ H5O_alloc_shrink_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno) uint8_t new_size_flags = 0; /* New chunk #0 size flags */ hbool_t adjust_size_flags = FALSE; /* Whether to adjust the chunk #0 size flags */ size_t less_prfx_size = 0; /* Bytes removed from object header prefix */ + size_t u; /* Index */ herr_t ret_value = SUCCEED; /* Return value */ - unsigned u; /* Index */ FUNC_ENTER_NOAPI_NOINIT @@ -2237,7 +2241,7 @@ H5O_alloc_shrink_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno) if(adjust_size_flags) { /* Adjust object header prefix flags */ - oh->flags &= (uint8_t)~H5O_HDR_CHUNK0_SIZE; + oh->flags = (uint8_t)(oh->flags & ~H5O_HDR_CHUNK0_SIZE); oh->flags |= new_size_flags; /* Slide chunk 0 data down */ diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 510d64f..b8e6b32 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -300,7 +300,7 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg) if(attr->shared->version >= H5O_ATTR_VERSION_2) { flags = (is_type_shared ? H5O_ATTR_FLAG_TYPE_SHARED : 0 ); flags |= (is_space_shared ? H5O_ATTR_FLAG_SPACE_SHARED : 0); - *p++ = flags; /* Set flags for attribute */ + *p++ = (uint8_t)flags; /* Set flags for attribute */ } /* end if */ else *p++ = 0; /* Reserved, for version <2 */ @@ -723,7 +723,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5O_attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx /*out*/) { const H5A_t *attr = (const H5A_t *)_mesg; @@ -753,7 +753,7 @@ H5O_attr_get_crt_index(const void *_mesg, H5O_msg_crt_idx_t *crt_idx /*out*/) * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5O_attr_set_crt_index(void *_mesg, H5O_msg_crt_idx_t crt_idx) { H5A_t *attr = (H5A_t *)_mesg; diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 2c33ebe..f09f693 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -658,7 +658,7 @@ H5O_size(const H5F_t UNUSED *f, const H5O_t *oh, size_t *size_ptr) /* Report the object header's prefix+first chunk length */ if(oh->chunk0_size) - *size_ptr = H5O_SIZEOF_HDR(oh) + oh->chunk0_size; + *size_ptr = (size_t)H5O_SIZEOF_HDR(oh) + oh->chunk0_size; else *size_ptr = oh->chunk[0].size; @@ -983,7 +983,7 @@ H5O_cache_chk_size(const H5F_t UNUSED *f, const H5O_chunk_proxy_t *chk_proxy, si static herr_t H5O_add_cont_msg(H5O_cont_msgs_t *cont_msg_info, const H5O_cont_t *cont) { - unsigned contno; /* Continuation message index */ + size_t contno; /* Continuation message index */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1034,7 +1034,7 @@ H5O_chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image, { const uint8_t *p; /* Pointer into buffer to decode */ uint8_t *eom_ptr; /* Pointer to end of messages for a chunk */ - unsigned curmesg; /* Current message being decoded in object header */ + size_t curmesg; /* Current message being decoded in object header */ unsigned merged_null_msgs = 0; /* Number of null messages merged together */ unsigned chunkno; /* Current chunk's index */ #ifndef NDEBUG @@ -1104,7 +1104,7 @@ H5O_chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image, nullcnt = 0; #endif /* NDEBUG */ while(p < eom_ptr) { - unsigned mesgno; /* Current message to operate on */ + size_t mesgno; /* Current message to operate on */ size_t mesg_size; /* Size of message read in */ unsigned id; /* ID (type) of current message */ uint8_t flags; /* Flags for current message */ @@ -1166,7 +1166,7 @@ H5O_chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image, /* Combine adjacent null messages */ mesgno = oh->nmesgs - 1; - oh->mesg[mesgno].raw_size += H5O_SIZEOF_MSGHDR_OH(oh) + mesg_size; + oh->mesg[mesgno].raw_size += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + mesg_size; oh->mesg[mesgno].dirty = TRUE; merged_null_msgs++; udata->merged_null_msgs++; diff --git a/src/H5Ocont.c b/src/H5Ocont.c index b609bfd..647532b 100644 --- a/src/H5Ocont.c +++ b/src/H5Ocont.c @@ -179,8 +179,8 @@ H5O_cont_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void UNUSED * FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set return value */ - ret_value = H5F_SIZEOF_ADDR(f) + /* Continuation header address */ - H5F_SIZEOF_SIZE(f); /* Continuation header length */ + ret_value = (size_t)(H5F_SIZEOF_ADDR(f) + /* Continuation header address */ + H5F_SIZEOF_SIZE(f)); /* Continuation header length */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_cont_size() */ diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index aeaad1a..98d8d95 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -382,7 +382,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, void *cpy_udata = NULL; /* User data for passing to message callbacks */ uint64_t dst_oh_size; /* Total size of the destination OH */ size_t dst_oh_null; /* Size of the null message to add to destination OH */ - unsigned dst_oh_gap; /* Size of the gap in chunk #0 of destination OH */ + size_t dst_oh_gap; /* Size of the gap in chunk #0 of destination OH */ uint8_t *current_pos; /* Current position in destination image */ size_t msghdr_size; herr_t ret_value = SUCCEED; @@ -669,14 +669,14 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Compute space for messages. */ dst_oh_size = 0; for(mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) { - dst_oh_size += H5O_SIZEOF_MSGHDR_OH(oh_dst); + dst_oh_size += (uint64_t)H5O_SIZEOF_MSGHDR_OH(oh_dst); dst_oh_size += oh_dst->mesg[mesgno].raw_size; } /* end for */ /* Check if we need to determine correct value for chunk #0 size bits */ if(oh_dst->version > H5O_VERSION_1) { /* Reset destination object header's "chunk 0 size" flags */ - oh_dst->flags &= ~H5O_HDR_CHUNK0_SIZE; + oh_dst->flags = (uint8_t)(oh_dst->flags & ~H5O_HDR_CHUNK0_SIZE); /* Determine correct value for chunk #0 size bits */ if(dst_oh_size > 4294967295) @@ -785,7 +785,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Check if we need to add a NULL message to this header */ if(dst_oh_null > 0) { - unsigned null_idx; /* Index of new NULL message */ + size_t null_idx; /* Index of new NULL message */ /* Make sure we have enough space for new NULL message */ if(oh_dst->nmesgs + 1 > oh_dst->alloc_nmesgs) @@ -902,7 +902,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Insert destination object header in cache */ if(H5AC_insert_entry(oloc_dst->file, dxpl_id, H5AC_OHDR, oloc_dst->addr, oh_dst, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") oh_dst = NULL; inserted = TRUE; @@ -1453,7 +1453,7 @@ H5O_copy_free_comm_dt_cb(void *item, void *_key, void UNUSED *op_data) haddr_t *addr = (haddr_t *)item; H5O_copy_search_comm_dt_key_t *key = (H5O_copy_search_comm_dt_key_t *)_key; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(addr); HDassert(key); @@ -1489,7 +1489,7 @@ H5O_copy_comm_dt_cmp(const void *_key1, const void *_key2) const H5O_copy_search_comm_dt_key_t *key2 = (const H5O_copy_search_comm_dt_key_t *)_key2; int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check fileno. It is unlikely to be different so check if they are equal * first so only one comparison needs to be made. */ diff --git a/src/H5Odbg.c b/src/H5Odbg.c index 5c07b64..5901c61 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -398,7 +398,7 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i if(0 == i) { if(H5F_addr_ne(oh->chunk[i].addr, addr)) HDfprintf(stream, "*** WRONG ADDRESS FOR CHUNK #0!\n"); - chunk_size = oh->chunk[i].size - H5O_SIZEOF_HDR(oh); + chunk_size = oh->chunk[i].size - (size_t)H5O_SIZEOF_HDR(oh); } /* end if */ else chunk_size = oh->chunk[i].size; @@ -424,7 +424,7 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i unsigned chunkno; /* Chunk for message */ /* Accumulate message's size to total */ - mesg_total += H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[i].raw_size; + mesg_total += (size_t)H5O_SIZEOF_MSGHDR_OH(oh) + oh->mesg[i].raw_size; /* For version 2 object header, add size of "OCHK" for continuation chunk */ if (oh->mesg[i].type->id == H5O_CONT_ID) diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 6158fd9..b482115 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -626,6 +626,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) case H5T_ORDER_ERROR: case H5T_ORDER_VAX: + case H5T_ORDER_MIXED: case H5T_ORDER_NONE: default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") @@ -696,6 +697,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) HDassert(dt->shared->version >= H5O_DTYPE_VERSION_3); break; + case H5T_ORDER_MIXED: case H5T_ORDER_ERROR: case H5T_ORDER_NONE: default: @@ -764,7 +766,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "normalization scheme is not supported in file format yet") } /* end switch */ - flags |= (dt->shared->u.atomic.u.f.sign << 8) & 0xff00; + flags = (unsigned)(flags | ((dt->shared->u.atomic.u.f.sign << 8) & 0xff00)); UINT16ENCODE(*pp, dt->shared->u.atomic.offset); UINT16ENCODE(*pp, dt->shared->u.atomic.prec); HDassert(dt->shared->u.atomic.u.f.epos <= 255); @@ -787,8 +789,9 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) flags |= 0x01; break; - case H5T_ORDER_ERROR: case H5T_ORDER_VAX: + case H5T_ORDER_MIXED: + case H5T_ORDER_ERROR: case H5T_ORDER_NONE: default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") @@ -806,8 +809,8 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) HDassert(dt->shared->u.atomic.lsb_pad == H5T_PAD_ZERO); HDassert(dt->shared->u.atomic.msb_pad == H5T_PAD_ZERO); - flags |= (dt->shared->u.atomic.u.s.pad & 0x0f); - flags |= (dt->shared->u.atomic.u.s.cset & 0x0f) << 4; + flags = (unsigned)(flags | (dt->shared->u.atomic.u.s.pad & 0x0f)); + flags = (unsigned)(flags | ((((unsigned)dt->shared->u.atomic.u.s.cset) & 0x0f) << 4)); break; case H5T_BITFIELD: @@ -822,8 +825,9 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) flags |= 0x01; break; - case H5T_ORDER_ERROR: case H5T_ORDER_VAX: + case H5T_ORDER_MIXED: + case H5T_ORDER_ERROR: case H5T_ORDER_NONE: default: HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet") @@ -874,7 +878,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) z = HDstrlen(dt->shared->u.opaque.tag); aligned = (z + 7) & (H5T_OPAQUE_TAG_MAX - 8); - flags |= aligned; + flags = (unsigned)(flags | aligned); HDmemcpy(*pp, dt->shared->u.opaque.tag, MIN(z,aligned)); for(n = MIN(z, aligned); n < aligned; n++) (*pp)[n] = 0; @@ -918,7 +922,7 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) /* Member offset */ /* (starting with version 3 of the datatype message, use the minimum # of bytes required) */ if(dt->shared->version >= H5O_DTYPE_VERSION_3) - UINT32ENCODE_VAR(*pp, dt->shared->u.compnd.memb[i].offset, offset_nbytes) + UINT32ENCODE_VAR(*pp, (uint32_t)dt->shared->u.compnd.memb[i].offset, offset_nbytes) else UINT32ENCODE(*pp, dt->shared->u.compnd.memb[i].offset) @@ -1000,8 +1004,8 @@ H5O_dtype_encode_helper(const H5F_t *f, uint8_t **pp, const H5T_t *dt) flags |= (dt->shared->u.vlen.type & 0x0f); if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { - flags |= (dt->shared->u.vlen.pad & 0x0f) << 4; - flags |= ((unsigned)dt->shared->u.vlen.cset & 0x0f) << 8; + flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.pad & 0x0f) << 4)); + flags = (unsigned)(flags | (((unsigned)dt->shared->u.vlen.cset & 0x0f) << 8)); } /* end if */ /* Encode base type of VL information */ @@ -1599,7 +1603,7 @@ H5O_dtype_shared_post_copy_upd(const H5O_loc_t UNUSED *src_oloc, { H5T_t *dt_dst = (H5T_t *)mesg_dst; /* Destination datatype */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI_NOINIT_NOERR if(dt_dst->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { HDassert(H5T_committed(dt_dst)); @@ -1977,6 +1981,10 @@ H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, s = "none"; break; + case H5T_ORDER_MIXED: + s = "mixed"; + break; + case H5T_ORDER_ERROR: default: sprintf(buf, "H5T_ORDER_%d", dt->shared->u.atomic.order); diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 3630cf4..db9066e 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -230,7 +230,7 @@ H5O_efl_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void * */ HDassert(mesg->slot[u].name_offset); H5F_ENCODE_LENGTH(f, p, mesg->slot[u].name_offset); - H5F_ENCODE_LENGTH(f, p, mesg->slot[u].offset); + H5F_ENCODE_LENGTH(f, p, (hsize_t)mesg->slot[u].offset); H5F_ENCODE_LENGTH(f, p, mesg->slot[u].size); } /* end for */ @@ -351,13 +351,13 @@ H5O_efl_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg) HDassert(f); HDassert(mesg); - ret_value = H5F_SIZEOF_ADDR(f) + /*heap address */ + ret_value = (size_t)H5F_SIZEOF_ADDR(f) + /*heap address */ 2 + /*slots allocated*/ 2 + /*num slots used*/ 4 + /*reserved */ - mesg->nused * (H5F_SIZEOF_SIZE(f) + /*name offset */ - H5F_SIZEOF_SIZE(f) + /*file offset */ - H5F_SIZEOF_SIZE(f)); /*file size */ + mesg->nused * ((size_t)H5F_SIZEOF_SIZE(f) + /*name offset */ + (size_t)H5F_SIZEOF_SIZE(f) + /*file offset */ + (size_t)H5F_SIZEOF_SIZE(f)); /*file size */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_efl_size() */ diff --git a/src/H5Ofill.c b/src/H5Ofill.c index f5569dc..1e8ccb1 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -397,11 +397,11 @@ H5O_fill_new_encode(H5F_t UNUSED *f, uint8_t *p, const void *_fill) /* Encode space allocation time */ HDassert(fill->alloc_time == (H5O_FILL_MASK_ALLOC_TIME & fill->alloc_time)); - flags |= (H5O_FILL_MASK_ALLOC_TIME & fill->alloc_time) << H5O_FILL_SHIFT_ALLOC_TIME; + flags = (uint8_t)(flags | ((H5O_FILL_MASK_ALLOC_TIME & fill->alloc_time) << H5O_FILL_SHIFT_ALLOC_TIME)); /* Encode fill value writing time */ HDassert(fill->fill_time == (H5O_FILL_MASK_FILL_TIME & fill->fill_time)); - flags |= (H5O_FILL_MASK_FILL_TIME & fill->fill_time) << H5O_FILL_SHIFT_FILL_TIME; + flags = (uint8_t)(flags | ((H5O_FILL_MASK_FILL_TIME & fill->fill_time) << H5O_FILL_SHIFT_FILL_TIME)); /* Check if we need to encode a fill value size */ if(fill->size < 0) { @@ -833,10 +833,11 @@ H5O_fill_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_fill, FILE *s fprintf(stream,"Incremental\n"); break; + case H5D_ALLOC_TIME_DEFAULT: + case H5D_ALLOC_TIME_ERROR: default: fprintf(stream,"Unknown!\n"); break; - } /* end switch */ HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Fill Time:"); switch(fill->fill_time) { @@ -852,6 +853,7 @@ H5O_fill_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_fill, FILE *s fprintf(stream,"If Set\n"); break; + case H5D_FILL_TIME_ERROR: default: fprintf(stream,"Unknown!\n"); break; @@ -872,6 +874,7 @@ H5O_fill_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_fill, FILE *s fprintf(stream,"User Defined\n"); break; + case H5D_FILL_VALUE_ERROR: default: fprintf(stream,"Unknown!\n"); break; diff --git a/src/H5Ofsinfo.c b/src/H5Ofsinfo.c index 3f0b15d..11bf43b 100644 --- a/src/H5Ofsinfo.c +++ b/src/H5Ofsinfo.c @@ -105,7 +105,7 @@ H5O_fsinfo_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, if(NULL == (fsinfo = H5FL_CALLOC(H5O_fsinfo_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - fsinfo->strategy = *p++; /* file space strategy */ + fsinfo->strategy = (H5F_file_space_type_t)*p++; /* file space strategy */ H5F_DECODE_LENGTH(f, p, fsinfo->threshold); /* free space section size threshold */ /* Addresses of free space managers: only exist for H5F_FILE_SPACE_ALL_PERSIST */ @@ -231,10 +231,10 @@ H5O_fsinfo_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg /* Addresses of free-space managers exist only for H5F_FILE_SPACE_ALL_PERSIST type */ if(H5F_FILE_SPACE_ALL_PERSIST == fsinfo->strategy) - fs_addr_size = (H5FD_MEM_NTYPES - 1) * H5F_SIZEOF_ADDR(f); + fs_addr_size = (H5FD_MEM_NTYPES - 1) * (size_t)H5F_SIZEOF_ADDR(f); ret_value = 2 /* Version & strategy */ - + H5F_SIZEOF_SIZE(f) /* Threshold */ + + (size_t)H5F_SIZEOF_SIZE(f) /* Threshold */ + fs_addr_size; /* Addresses of free-space managers */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Oginfo.c b/src/H5Oginfo.c index 418b053..d579984 100644 --- a/src/H5Oginfo.c +++ b/src/H5Oginfo.c @@ -184,7 +184,7 @@ H5O_ginfo_encode(H5F_t UNUSED *f, hbool_t UNUSED disable_shared, uint8_t *p, con /* The flags for the group info */ flags = ginfo->store_link_phase_change ? H5O_GINFO_STORE_PHASE_CHANGE : 0; - flags |= ginfo->store_est_entry_info ? H5O_GINFO_STORE_EST_ENTRY_INFO : 0; + flags = (unsigned char)(flags | (ginfo->store_est_entry_info ? H5O_GINFO_STORE_EST_ENTRY_INFO : 0)); *p++ = flags; /* Store the max. # of links to store compactly & the min. # of links to store densely */ @@ -273,12 +273,12 @@ H5O_ginfo_size(const H5F_t UNUSED *f, hbool_t UNUSED disable_shared, const void ret_value = 1 + /* Version */ 1 + /* Flags */ (ginfo->store_link_phase_change ? ( - 2 + /* "Max compact" links */ - 2 /* "Min dense" links */ + (size_t)(2 + /* "Max compact" links */ + 2) /* "Min dense" links */ ) : 0) + /* "Min dense" links */ (ginfo->store_est_entry_info ? ( - 2 + /* Estimated # of entries in group */ - 2 /* Estimated length of name of entry in group */ + (size_t)(2 + /* Estimated # of entries in group */ + 2) /* Estimated length of name of entry in group */ ) : 0); FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Olinfo.c b/src/H5Olinfo.c index e96483a..5d3d75c 100644 --- a/src/H5Olinfo.c +++ b/src/H5Olinfo.c @@ -206,7 +206,7 @@ H5O_linfo_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void /* The flags for the link indices */ index_flags = linfo->track_corder ? H5O_LINFO_TRACK_CORDER : 0; - index_flags |= linfo->index_corder ? H5O_LINFO_INDEX_CORDER : 0; + index_flags = (uint8_t)(index_flags | (linfo->index_corder ? H5O_LINFO_INDEX_CORDER : 0)); *p++ = index_flags; /* Max. link creation order value for the group, if tracked */ @@ -296,10 +296,10 @@ H5O_linfo_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg) /* Set return value */ ret_value = 1 /* Version */ + 1 /* Index flags */ - + (linfo->track_corder ? 8 : 0) /* Curr. max. creation order value */ - + H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" links */ - + H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of links */ - + (linfo->index_corder ? H5F_SIZEOF_ADDR(f) : 0); /* Address of v2 B-tree for indexing creation order values of links */ + + (linfo->track_corder ? (size_t)8 : 0) /* Curr. max. creation order value */ + + (size_t)H5F_SIZEOF_ADDR(f) /* Address of fractal heap to store "dense" links */ + + (size_t)H5F_SIZEOF_ADDR(f) /* Address of v2 B-tree for indexing names of links */ + + (linfo->index_corder ? (size_t)H5F_SIZEOF_ADDR(f) : 0); /* Address of v2 B-tree for indexing creation order values of links */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_linfo_size() */ @@ -474,7 +474,7 @@ H5O_linfo_post_copy_file_cb(const H5O_link_t *src_lnk, void *_udata) /* Insert the new object in the destination file's group */ /* (Doesn't increment the link count - that's already been taken care of for hard links) */ if(H5G__dense_insert(udata->dst_oloc->file, udata->dxpl_id, udata->dst_linfo, &dst_lnk) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert destination link") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert destination link") /* Reset metadata tag in dxpl_id */ H5_END_TAG(FAIL); diff --git a/src/H5Olink.c b/src/H5Olink.c index 88c9e28..4dda5fe 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -226,6 +226,9 @@ H5O_link_decode(H5F_t *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh, break; /* User-defined links */ + case H5L_TYPE_EXTERNAL: + case H5L_TYPE_ERROR: + case H5L_TYPE_MAX: default: if(lnk->type < H5L_TYPE_UD_MIN || lnk->type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unknown link type") @@ -306,9 +309,9 @@ H5O_link_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void link_flags = H5O_LINK_NAME_2; else link_flags = H5O_LINK_NAME_1; - link_flags |= lnk->corder_valid ? H5O_LINK_STORE_CORDER : 0; - link_flags |= (lnk->type != H5L_TYPE_HARD) ? H5O_LINK_STORE_LINK_TYPE : 0; - link_flags |= (lnk->cset != H5T_CSET_ASCII) ? H5O_LINK_STORE_NAME_CSET : 0; + link_flags = (unsigned char)(link_flags | (lnk->corder_valid ? H5O_LINK_STORE_CORDER : 0)); + link_flags = (unsigned char)(link_flags | ((lnk->type != H5L_TYPE_HARD) ? H5O_LINK_STORE_LINK_TYPE : 0)); + link_flags = (unsigned char)(link_flags | ((lnk->cset != H5T_CSET_ASCII) ? H5O_LINK_STORE_NAME_CSET : 0)); *p++ = link_flags; /* Store the type of a non-default link */ @@ -366,6 +369,9 @@ H5O_link_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const void break; /* User-defined links */ + case H5L_TYPE_EXTERNAL: + case H5L_TYPE_ERROR: + case H5L_TYPE_MAX: default: HDassert(lnk->type >= H5L_TYPE_UD_MIN && lnk->type <= H5L_TYPE_MAX); @@ -511,6 +517,9 @@ H5O_link_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void *_mesg) HDstrlen(lnk->u.soft.name); /* Link value */ break; + case H5L_TYPE_ERROR: + case H5L_TYPE_EXTERNAL: + case H5L_TYPE_MAX: default: /* Default is user-defined link type */ HDassert(lnk->type >= H5L_TYPE_UD_MIN); ret_value += 2 + /* User-defined data size */ @@ -837,6 +846,9 @@ H5O_link_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE * "Link Value:", lnk->u.soft.name); break; + case H5L_TYPE_ERROR: + case H5L_TYPE_EXTERNAL: + case H5L_TYPE_MAX: default: if(lnk->type >= H5L_TYPE_UD_MIN) { if(lnk->type == H5L_TYPE_EXTERNAL) { diff --git a/src/H5Omessage.c b/src/H5Omessage.c index c9a0997..1369583 100644 --- a/src/H5Omessage.c +++ b/src/H5Omessage.c @@ -76,7 +76,7 @@ typedef struct { static herr_t H5O_msg_reset_real(const H5O_msg_class_t *type, void *native); static herr_t H5O_msg_remove_cb(H5O_t *oh, H5O_mesg_t *mesg/*in,out*/, unsigned sequence, unsigned *oh_modified, void *_udata/*in,out*/); -static herr_t H5O_copy_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx, +static herr_t H5O_copy_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, const void *mesg, unsigned mesg_flags, unsigned update_flags); @@ -207,7 +207,7 @@ herr_t H5O_msg_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, unsigned mesg_flags, unsigned update_flags, void *mesg) { - int idx; /* Index of message to modify */ + size_t idx; /* Index of message to modify */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -220,11 +220,11 @@ H5O_msg_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *t HDassert(mesg); /* Allocate space for a new message */ - if((idx = H5O_msg_alloc(f, dxpl_id, oh, type, &mesg_flags, mesg)) < 0) + if(H5O_msg_alloc(f, dxpl_id, oh, type, &mesg_flags, mesg, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "unable to create new message") /* Copy the information for the message */ - if(H5O_copy_mesg(f, dxpl_id, oh, (unsigned)idx, type, mesg, mesg_flags, update_flags) < 0) + if(H5O_copy_mesg(f, dxpl_id, oh, idx, type, mesg, mesg_flags, update_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to write message") #ifdef H5O_DEBUG H5O_assert(oh); @@ -364,7 +364,7 @@ H5O_msg_write_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *ty unsigned mesg_flags, unsigned update_flags, void *mesg) { H5O_mesg_t *idx_msg; /* Pointer to message to modify */ - unsigned idx; /* Index of message to modify */ + size_t idx; /* Index of message to modify */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -788,6 +788,7 @@ H5O_msg_count(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) { H5O_t *oh = NULL; /* Object header to operate on */ const H5O_msg_class_t *type; /* Actual H5O class type for the ID */ + unsigned msg_count; /* Message count */ int ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -805,7 +806,8 @@ H5O_msg_count(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") /* Count the messages of the correct type */ - ret_value = H5O_msg_count_real(oh, type); + msg_count = H5O_msg_count_real(oh, type); + H5_ASSIGN_OVERFLOW(ret_value, msg_count, unsigned, int); done: if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) @@ -1431,10 +1433,10 @@ H5O_msg_size_f(const H5F_t *f, hid_t ocpl_id, unsigned type_id, ret_value += extra_raw; /* Adjust size for alignment, if necessary */ - ret_value = H5O_ALIGN_F(f, ret_value); + ret_value = (size_t)H5O_ALIGN_F(f, ret_value); /* Add space for message header */ - ret_value += H5O_SIZEOF_MSGHDR_F(f, + ret_value += (size_t)H5O_SIZEOF_MSGHDR_F(f, (H5F_STORE_MSG_CRT_IDX(f) || oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)); done: @@ -1484,10 +1486,10 @@ H5O_msg_size_oh(const H5F_t *f, const H5O_t *oh, unsigned type_id, ret_value += extra_raw; /* Adjust size for alignment, if necessary */ - ret_value = H5O_ALIGN_OH(oh, ret_value); + ret_value = (size_t)H5O_ALIGN_OH(oh, ret_value); /* Add space for message header */ - ret_value += H5O_SIZEOF_MSGHDR_OH(oh); + ret_value += (size_t)H5O_SIZEOF_MSGHDR_OH(oh); done: FUNC_LEAVE_NOAPI(ret_value) @@ -1894,12 +1896,13 @@ done: * *------------------------------------------------------------------------- */ -int +herr_t H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, - unsigned *mesg_flags, void *native) + unsigned *mesg_flags, void *native, size_t *mesg_idx) { + size_t new_idx; /* New index for message */ htri_t shared_mesg; /* Should this message be stored in the Shared Message table? */ - int ret_value = FAIL; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1910,6 +1913,7 @@ H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, HDassert(!(*mesg_flags & H5O_MSG_FLAG_SHARED)); HDassert(type); HDassert(native); + HDassert(mesg_idx); /* Check if message is already shared */ if((shared_mesg = H5O_msg_is_shared(type->id, native)) < 0) @@ -1927,16 +1931,19 @@ H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, } /* end else */ /* Allocate space in the object header for the message */ - if((ret_value = H5O_alloc(f, dxpl_id, oh, type, native)) < 0) + if(H5O_alloc(f, dxpl_id, oh, type, native, &new_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for message") /* Get the message's "creation index", if it has one */ if(type->get_crt_index) { /* Retrieve the creation index from the native message */ - if((type->get_crt_index)(native, &oh->mesg[ret_value].crt_idx) < 0) + if((type->get_crt_index)(native, &oh->mesg[new_idx].crt_idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve creation index") } /* end if */ + /* Set new message index */ + *mesg_idx = new_idx; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_msg_alloc() */ @@ -1956,7 +1963,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_copy_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx, +H5O_copy_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t idx, const H5O_msg_class_t *type, const void *mesg, unsigned mesg_flags, unsigned update_flags) { @@ -2293,7 +2300,7 @@ H5O_msg_get_chunkno(const H5O_loc_t *loc, unsigned type_id, hid_t dxpl_id) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message type not found") /* Set return value */ - ret_value = idx_msg->chunkno; + H5_ASSIGN_OVERFLOW(ret_value, idx_msg->chunkno, unsigned, int); done: if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) diff --git a/src/H5Opkg.h b/src/H5Opkg.h index b7cca64..9319a28 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -538,8 +538,9 @@ H5_DLL herr_t H5O_visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_typ hid_t dxpl_id); /* Object header message routines */ -H5_DLL int H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, - const H5O_msg_class_t *type, unsigned *mesg_flags, void *mesg); +H5_DLL herr_t H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, + const H5O_msg_class_t *type, unsigned *mesg_flags, void *mesg, + size_t *mesg_idx); H5_DLL herr_t H5O_msg_append_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, unsigned mesg_flags, unsigned update_flags, void *mesg); @@ -573,8 +574,8 @@ H5_DLL herr_t H5O_attr_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh, /* Object header allocation routines */ H5_DLL herr_t H5O_alloc_msgs(H5O_t *oh, size_t min_alloc); -H5_DLL int H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, - const H5O_msg_class_t *type, const void *mesg); +H5_DLL herr_t H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, + const H5O_msg_class_t *type, const void *mesg, size_t *mesg_idx); H5_DLL herr_t H5O_condense_header(H5F_t *f, H5O_t *oh, hid_t dxpl_id); H5_DLL herr_t H5O_release_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_mesg_t *mesg, hbool_t adj_link); diff --git a/src/H5Opline.c b/src/H5Opline.c index f626106..1a2baa0 100644 --- a/src/H5Opline.c +++ b/src/H5Opline.c @@ -250,7 +250,7 @@ H5O_pline_encode(H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg) HDassert(mesg); /* Message header */ - *p++ = pline->version; + *p++ = (uint8_t)pline->version; *p++ = (uint8_t)(pline->nused); if(pline->version == H5O_PLINE_VERSION_1) { *p++ = 0; /*reserved 1*/ @@ -467,7 +467,7 @@ H5O_pline_size(const H5F_t UNUSED *f, const void *mesg) ((pline->version == H5O_PLINE_VERSION_1 || pline->filter[i].id >= H5Z_FILTER_RESERVED) ? 2 : 0) + /*name length */ 2 + /*flags */ 2 + /*number of client data values */ - (pline->version == H5O_PLINE_VERSION_1 ? H5O_ALIGN_OLD(name_len) : name_len); /*length of the filter name */ + (pline->version == H5O_PLINE_VERSION_1 ? (size_t)H5O_ALIGN_OLD(name_len) : name_len); /*length of the filter name */ ret_value += pline->filter[i].cd_nelmts * 4; if(pline->version == H5O_PLINE_VERSION_1) diff --git a/src/H5Oshared.c b/src/H5Oshared.c index c29e2c7..e4a51ee 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -622,7 +622,7 @@ H5O_shared_copy_file(H5F_t *file_src, H5F_t *file_dst, H5_BEGIN_TAG(dxpl_id, H5AC__COPIED_TAG, FAIL); if(H5SM_try_share(file_dst, dxpl_id, NULL, H5SM_DEFER, mesg_type->id, _native_dst, mesg_flags) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to determine if message should be shared") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to determine if message should be shared") /* Reset metadata tag */ H5_END_TAG(FAIL); diff --git a/src/H5Oshmesg.c b/src/H5Oshmesg.c index 69c7d49..2575856 100644 --- a/src/H5Oshmesg.c +++ b/src/H5Oshmesg.c @@ -129,9 +129,9 @@ H5O_shmesg_encode(H5F_t *f, hbool_t UNUSED disable_shared, uint8_t *p, const voi HDassert(mesg); /* Store version, table address, and number of indexes */ - *p++ = mesg->version; + *p++ = (uint8_t)mesg->version; H5F_addr_encode(f, &p, mesg->addr); - *p++ = mesg->nindexes; + *p++ = (uint8_t)mesg->nindexes; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_shmesg_encode() */ @@ -201,9 +201,9 @@ H5O_shmesg_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void UNUSED /* Sanity check */ HDassert(f); - ret_value = 1 + /* Version number */ + ret_value = (size_t)(1 + /* Version number */ H5F_SIZEOF_ADDR(f) + /* Table address */ - 1; /* Number of indexes */ + 1); /* Number of indexes */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_shmesg_size() */ diff --git a/src/H5Ostab.c b/src/H5Ostab.c index d5f5f86..d05c7c2 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -227,7 +227,7 @@ H5O_stab_size(const H5F_t *f, hbool_t UNUSED disable_shared, const void UNUSED * FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set return value */ - ret_value=2 * H5F_SIZEOF_ADDR(f); + ret_value = (size_t)(2 * H5F_SIZEOF_ADDR(f)); FUNC_LEAVE_NOAPI(ret_value) } @@ -336,7 +336,7 @@ H5O_stab_copy_file(H5F_t *file_src, void *native_src, H5F_t *file_dst, /* Create components of symbol table message */ if(H5G__stab_create_components(file_dst, stab_dst, size_hint, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create symbol table components") + HGOTO_ERROR_TAG(H5E_SYM, H5E_CANTINIT, NULL, "can't create symbol table components") /* Reset metadata tag */ H5_END_TAG(NULL); diff --git a/src/H5Otest.c b/src/H5Otest.c index ca1b426..705f716 100644 --- a/src/H5Otest.c +++ b/src/H5Otest.c @@ -193,13 +193,13 @@ H5O_is_attr_empty_test(hid_t oid) if(H5F_addr_defined(ainfo.fheap_addr)) { /* Check for any messages in object header */ HDassert(nattrs == 0); - + /* Set metadata tag in dxpl_id */ H5_BEGIN_TAG(H5AC_ind_dxpl_id, loc->addr, FAIL); /* Open the name index v2 B-tree */ if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Reset metadata tag in dxpl_id */ H5_END_TAG(FAIL); @@ -292,7 +292,7 @@ H5O_num_attrs_test(hid_t oid, hsize_t *nattrs) /* Open the name index v2 B-tree */ if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Reset metadata tag in dxpl_id */ H5_END_TAG(FAIL); @@ -362,39 +362,39 @@ H5O_attr_dense_info_test(hid_t oid, hsize_t *name_count, hsize_t *corder_count) /* Get the object header */ if(NULL == (oh = H5O_protect(loc, H5AC_ind_dxpl_id, H5AC_READ))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") /* Check for attribute info stored */ ainfo.fheap_addr = HADDR_UNDEF; if(oh->version > H5O_VERSION_1) { /* Check for (& retrieve if available) attribute info */ if(H5A_get_ainfo(loc->file, H5AC_ind_dxpl_id, oh, &ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") + HGOTO_ERROR_TAG(H5E_ATTR, H5E_CANTGET, FAIL, "can't check for attribute info message") } /* end if */ /* Check for 'dense' attribute storage file addresses being defined */ if(!H5F_addr_defined(ainfo.fheap_addr)) - HGOTO_DONE(FAIL) + HGOTO_DONE_TAG(FAIL, FAIL) if(!H5F_addr_defined(ainfo.name_bt2_addr)) - HGOTO_DONE(FAIL) + HGOTO_DONE_TAG(FAIL, FAIL) /* Open the name index v2 B-tree */ if(NULL == (bt2_name = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.name_bt2_addr, NULL))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for name index") /* Retrieve # of records in name index */ if(H5B2_get_nrec(bt2_name, name_count) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from name index") /* Check if there is a creation order index */ if(H5F_addr_defined(ainfo.corder_bt2_addr)) { /* Open the creation order index v2 B-tree */ if(NULL == (bt2_corder = H5B2_open(loc->file, H5AC_ind_dxpl_id, ainfo.corder_bt2_addr, NULL))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for creation order index") /* Retrieve # of records in creation order index */ if(H5B2_get_nrec(bt2_corder, corder_count) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTCOUNT, FAIL, "unable to retrieve # of records from creation order index") } /* end if */ else *corder_count = 0; @@ -504,8 +504,8 @@ H5O_expunge_chunks_test(const H5O_loc_t *loc, hid_t dxpl_id) { H5O_t *oh = NULL; /* Object header */ haddr_t chk_addr[16]; /* Array of chunk addresses */ - unsigned nchunks; /* Number of chunks in object header */ - unsigned u; /* Local index variable */ + size_t nchunks; /* Number of chunks in object header */ + size_t u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -45,6 +45,13 @@ /* Local Typedefs */ /******************/ +/* Typedef for property iterator callback */ +typedef struct { + H5P_iterate_t iter_func; /* Iterator callback */ + hid_t id; /* Property list or class ID */ + void *iter_data; /* Iterator callback pointer */ +} H5P_iter_ud_t; + /********************/ /* Local Prototypes */ @@ -1045,6 +1052,45 @@ done: /*-------------------------------------------------------------------------- NAME + H5P__iterate_cb + PURPOSE + Internal callback routine when iterating over properties in property list + or class + USAGE + int H5P__iterate_cb(prop, udata) + H5P_genprop_t *prop; IN: Pointer to the property + void *udata; IN/OUT: Pointer to iteration data from user + RETURNS + Success: Returns the return value of the last call to ITER_FUNC + DESCRIPTION + This routine calls the actual callback routine for the property in the +property list or class. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static int +H5P__iterate_cb(H5P_genprop_t *prop, void *_udata) +{ + H5P_iter_ud_t *udata = (H5P_iter_ud_t *)_udata; /* Pointer to user data */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(prop); + HDassert(udata); + + /* Call the user's callback routine */ + ret_value = (*udata->iter_func)(udata->id, prop->name, udata->iter_data); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__iterate_cb() */ + + +/*-------------------------------------------------------------------------- + NAME H5Piterate PURPOSE Routine to iterate over the properties in a property list or class @@ -1099,6 +1145,7 @@ iteration, the function's behavior is undefined. int H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data) { + H5P_iter_ud_t udata; /* User data for internal iterator callback */ int fake_idx = 0; /* Index when user doesn't provide one */ int ret_value; /* return value */ @@ -1111,15 +1158,20 @@ H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data) if(iter_func == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration callback"); + /* Set up user data */ + udata.iter_func = iter_func; + udata.id = id; + udata.iter_data = iter_data; + if(H5I_GENPROP_LST == H5I_get_type(id)) { /* Iterate over a property list */ - if((ret_value = H5P_iterate_plist(id, (idx ? idx : &fake_idx), iter_func, iter_data)) < 0) + if((ret_value = H5P_iterate_plist(id, (idx ? idx : &fake_idx), H5P__iterate_cb, &udata)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over list"); } /* end if */ else if(H5I_GENPROP_CLS == H5I_get_type(id)) { /* Iterate over a property class */ - if((ret_value = H5P_iterate_pclass(id, (idx ? idx : &fake_idx), iter_func, iter_data)) < 0) + if((ret_value = H5P_iterate_pclass(id, (idx ? idx : &fake_idx), H5P__iterate_cb, &udata)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTREGISTER, FAIL, "unable to iterate over class"); } /* end if */ else diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index 51e62fe..9e75eaa 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -33,12 +33,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ /****************/ @@ -72,7 +72,7 @@ /********************/ /* Property class callbacks */ -static herr_t H5P_dacc_reg_prop(H5P_genclass_t *pclass); +static herr_t H5P__dacc_reg_prop(H5P_genclass_t *pclass); /*********************/ @@ -85,7 +85,7 @@ const H5P_libclass_t H5P_CLS_DACC[1] = {{ &H5P_CLS_LINK_ACCESS_g, /* Parent class ID */ &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class ID */ &H5P_LST_DATASET_ACCESS_g, /* Pointer to default property list ID */ - H5P_dacc_reg_prop, /* Default property registration routine */ + H5P__dacc_reg_prop, /* Default property registration routine */ NULL, /* Class creation callback */ NULL, /* Class creation callback info */ NULL, /* Class copy callback */ @@ -107,7 +107,7 @@ const H5P_libclass_t H5P_CLS_DACC[1] = {{ /*------------------------------------------------------------------------- - * Function: H5P_dacc_reg_prop + * Function: H5P__dacc_reg_prop * * Purpose: Register the dataset access property list class's * properties @@ -119,14 +119,14 @@ const H5P_libclass_t H5P_CLS_DACC[1] = {{ *------------------------------------------------------------------------- */ static herr_t -H5P_dacc_reg_prop(H5P_genclass_t *pclass) +H5P__dacc_reg_prop(H5P_genclass_t *pclass) { size_t rdcc_nslots = H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */ size_t rdcc_nbytes = H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */ double rdcc_w0 = H5D_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Register the size of raw data chunk cache (elements) */ if(H5P_register_real(pclass, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE, &rdcc_nslots, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) @@ -142,7 +142,7 @@ H5P_dacc_reg_prop(H5P_genclass_t *pclass) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dacc_reg_prop() */ +} /* end H5P__dacc_reg_prop() */ /*------------------------------------------------------------------------- @@ -186,24 +186,24 @@ H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, size_t rdcc_nbytes, double /* Check arguments. Note that we allow negative values - they are * considered to "unset" the property. */ - if (rdcc_w0 > 1.0) + if(rdcc_w0 > 1.0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive, or H5D_CHUNK_CACHE_W0_DEFAULT"); /* Get the plist structure */ - if (NULL == (plist = H5P_object_verify(dapl_id,H5P_DATASET_ACCESS))) + if(NULL == (plist = H5P_object_verify(dapl_id,H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set sizes */ - if (H5P_set(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) + if(H5P_set(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache number of chunks"); - if (H5P_set(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) + if(H5P_set(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache byte size"); - if (H5P_set(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) + if(H5P_set(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set preempt read chunks"); done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pset_chunk_cache() */ /*------------------------------------------------------------------------- diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index a6ff3a3..a9b8079 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -65,7 +65,7 @@ /* Note that the compact & chunked layout initialization values are using the * contiguous layout initialization in the union, because the contiguous * layout is first in the union. These values are overridden in the - * H5P_init_def_layout() routine. -QAK + * H5P__init_def_layout() routine. -QAK */ #define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} #define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} @@ -76,7 +76,7 @@ /* Definitions for storage layout property */ #define H5D_CRT_LAYOUT_SIZE sizeof(H5O_layout_t) #define H5D_CRT_LAYOUT_DEF H5D_DEF_LAYOUT_CONTIG -#define H5D_CRT_LAYOUT_CMP H5P_dcrt_layout_cmp +#define H5D_CRT_LAYOUT_CMP H5P__dcrt_layout_cmp /* Definitions for fill value. size=0 means fill value will be 0 as * library default; size=-1 means fill value is undefined. */ #define H5D_CRT_FILL_VALUE_SIZE sizeof(H5O_fill_t) @@ -88,7 +88,7 @@ /* Definitions for external file list */ #define H5D_CRT_EXT_FILE_LIST_SIZE sizeof(H5O_efl_t) #define H5D_CRT_EXT_FILE_LIST_DEF {HADDR_UNDEF, 0, 0, NULL} -#define H5D_CRT_EXT_FILE_LIST_CMP H5P_dcrt_ext_file_list_cmp +#define H5D_CRT_EXT_FILE_LIST_CMP H5P__dcrt_ext_file_list_cmp /******************/ @@ -106,19 +106,19 @@ /********************/ /* General routines */ -static herr_t H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout); +static herr_t H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout); #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER -static herr_t H5P_init_def_layout(void); +static herr_t H5P__init_def_layout(void); #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Property class callbacks */ -static herr_t H5P_dcrt_reg_prop(H5P_genclass_t *pclass); -static herr_t H5P_dcrt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_data); -static herr_t H5P_dcrt_close(hid_t dxpl_id, void *close_data); +static herr_t H5P__dcrt_reg_prop(H5P_genclass_t *pclass); +static herr_t H5P__dcrt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_data); +static herr_t H5P__dcrt_close(hid_t dxpl_id, void *close_data); /* Property callbacks */ -static int H5P_dcrt_layout_cmp(const void *value1, const void *value2, size_t size); -static int H5P_dcrt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); +static int H5P__dcrt_layout_cmp(const void *value1, const void *value2, size_t size); +static int H5P__dcrt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); /*********************/ @@ -131,12 +131,12 @@ const H5P_libclass_t H5P_CLS_DCRT[1] = {{ &H5P_CLS_OBJECT_CREATE_g, /* Parent class ID */ &H5P_CLS_DATASET_CREATE_g, /* Pointer to class ID */ &H5P_LST_DATASET_CREATE_g, /* Pointer to default property list ID */ - H5P_dcrt_reg_prop, /* Default property registration routine */ + H5P__dcrt_reg_prop, /* Default property registration routine */ NULL, /* Class creation callback */ NULL, /* Class creation callback info */ - H5P_dcrt_copy, /* Class copy callback */ + H5P__dcrt_copy, /* Class copy callback */ NULL, /* Class copy callback info */ - H5P_dcrt_close, /* Class close callback */ + H5P__dcrt_close, /* Class close callback */ NULL /* Class close callback info */ }}; @@ -163,7 +163,7 @@ static hbool_t H5P_dcrt_def_layout_init_g = FALSE; /*------------------------------------------------------------------------- - * Function: H5P_dcrt_reg_prop + * Function: H5P__dcrt_reg_prop * * Purpose: Register the dataset creation property list class's properties * @@ -174,7 +174,7 @@ static hbool_t H5P_dcrt_def_layout_init_g = FALSE; *------------------------------------------------------------------------- */ static herr_t -H5P_dcrt_reg_prop(H5P_genclass_t *pclass) +H5P__dcrt_reg_prop(H5P_genclass_t *pclass) { H5O_layout_t layout = H5D_CRT_LAYOUT_DEF; /* Default storage layout */ H5O_fill_t fill = H5D_CRT_FILL_VALUE_DEF; /* Default fill value */ @@ -185,7 +185,7 @@ H5P_dcrt_reg_prop(H5P_genclass_t *pclass) hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Register the storage layout property */ if(H5P_register_real(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &layout, NULL, NULL, NULL, NULL, NULL, H5D_CRT_LAYOUT_CMP, NULL) < 0) @@ -220,11 +220,11 @@ H5P_dcrt_reg_prop(H5P_genclass_t *pclass) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_reg_prop() */ +} /* end H5P__dcrt_reg_prop() */ /*------------------------------------------------------------------------- - * Function: H5P_dcrt_copy + * Function: H5P__dcrt_copy * * Purpose: Callback routine which is called whenever any dataset * creation property list is copied. This routine copies @@ -240,7 +240,7 @@ done: */ /* ARGSUSED */ static herr_t -H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) +H5P__dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) { H5O_fill_t src_fill, dst_fill; /* Source & destination fill values */ H5O_efl_t src_efl, dst_efl; /* Source & destination external file lists */ @@ -249,7 +249,7 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) H5P_genplist_t *dst_plist; /* Pointer to destination property list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Verify property list IDs */ if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_plist_id))) @@ -298,6 +298,8 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) dst_layout.storage.u.chunk.ops = NULL; break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HDassert(0 && "Unknown layout type!"); } /* end switch */ @@ -332,11 +334,11 @@ H5P_dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void UNUSED *copy_data) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_copy() */ +} /* end H5P__dcrt_copy() */ /*------------------------------------------------------------------------- - * Function: H5P_dcrt_close + * Function: H5P__dcrt_close * * Purpose: Callback routine which is called whenever any dataset create * property list is closed. This routine performs any generic @@ -352,14 +354,14 @@ done: */ /* ARGSUSED */ static herr_t -H5P_dcrt_close(hid_t dcpl_id, void UNUSED *close_data) +H5P__dcrt_close(hid_t dcpl_id, void UNUSED *close_data) { H5O_fill_t fill; /* Fill value */ H5O_efl_t efl; /* External file list */ H5P_genplist_t *plist; /* Property list */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check arguments */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) @@ -380,11 +382,11 @@ H5P_dcrt_close(hid_t dcpl_id, void UNUSED *close_data) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_close() */ +} /* end H5P__dcrt_close() */ /*------------------------------------------------------------------------- - * Function: H5P_dcrt_layout_cmp + * Function: H5P__dcrt_layout_cmp * * Purpose: Callback routine which is called whenever the layout * property in the dataset creation property list is @@ -400,13 +402,13 @@ done: *------------------------------------------------------------------------- */ static int -H5P_dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t UNUSED size) +H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t UNUSED size) { const H5O_layout_t *layout1 = (const H5O_layout_t *)_layout1, /* Create local aliases for values */ *layout2 = (const H5O_layout_t *)_layout2; herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(layout1); @@ -443,13 +445,15 @@ H5P_dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t UNUSED si } /* end case */ break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HDassert(0 && "Unknown layout type!"); } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_layout_cmp() */ +} /* end H5P__dcrt_layout_cmp() */ /*------------------------------------------------------------------------- @@ -514,7 +518,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5P_dcrt_ext_file_list_cmp + * Function: H5P__dcrt_ext_file_list_cmp * * Purpose: Callback routine which is called whenever the external file * list property in the dataset creation property list is @@ -530,14 +534,14 @@ done: *------------------------------------------------------------------------- */ static int -H5P_dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, size_t UNUSED size) +H5P__dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, size_t UNUSED size) { const H5O_efl_t *efl1 = (const H5O_efl_t *)_efl1, /* Create local aliases for values */ *efl2 = (const H5O_efl_t *)_efl2; int cmp_value; /* Value from comparison */ herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(efl1); @@ -591,11 +595,11 @@ H5P_dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, size_t UNUSED s done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_dcrt_ext_file_list_cmp() */ +} /* end H5P__dcrt_ext_file_list_cmp() */ /*------------------------------------------------------------------------- - * Function: H5P_set_layout + * Function: H5P__set_layout * * Purpose: Sets the layout of raw data in the file. * @@ -607,12 +611,12 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) +H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) { unsigned alloc_time_state; /* State of allocation time property */ herr_t ret_value = SUCCEED; /* return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Get the allocation time state */ if(H5P_get(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) @@ -640,6 +644,8 @@ H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) fill.alloc_time = H5D_ALLOC_TIME_INCR; break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") } /* end switch */ @@ -655,12 +661,12 @@ H5P_set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_set_layout() */ +} /* end H5P__set_layout() */ #ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER /*------------------------------------------------------------------------- - * Function: H5P_init_def_layout + * Function: H5P__init_def_layout * * Purpose: Set the default layout information for the various types of * dataset layouts @@ -673,13 +679,13 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_init_def_layout(void) +H5P__init_def_layout(void) { const H5O_layout_chunk_t def_layout_chunk = H5D_DEF_LAYOUT_CHUNK_INIT; const H5O_storage_compact_t def_store_compact = H5D_DEF_STORAGE_COMPACT_INIT; const H5O_storage_chunk_t def_store_chunk = H5D_DEF_STORAGE_CHUNK_INIT; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Initialize the default layout info for non-contigous layouts */ H5D_def_layout_compact_g.storage.u.compact = def_store_compact; @@ -690,7 +696,7 @@ H5P_init_def_layout(void) H5P_dcrt_def_layout_init_g = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_init_def_layout() */ +} /* end H5P__init_def_layout() */ #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ @@ -736,7 +742,7 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) * the default layout structs have been initialized yet or not. *ick* -QAK */ if(!H5P_dcrt_def_layout_init_g) - if(H5P_init_def_layout() < 0) + if(H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ @@ -754,12 +760,14 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) layout = &H5D_def_layout_chunk_g; break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") } /* end switch */ /* Set value */ - if(H5P_set_layout(plist, layout) < 0) + if(H5P__set_layout(plist, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout") done: @@ -863,7 +871,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) * the default layout structs have been initialized yet or not. *ick* -QAK */ if(!H5P_dcrt_def_layout_init_g) - if(H5P_init_def_layout() < 0) + if(H5P__init_def_layout() < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ @@ -888,7 +896,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) /* Set chunk information in property list */ chunk_layout.u.chunk.ndims = (unsigned)ndims; - if(H5P_set_layout(plist, &chunk_layout) < 0) + if(H5P__set_layout(plist, &chunk_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") done: @@ -977,18 +985,6 @@ done: * Programmer: Robb Matzke * Tuesday, March 3, 1998 * - * Modifications: - * - * Raymond Lu - * Tuesday, October 2, 2001 - * Changed the way to check parameter and set property for - * generic property list. - * - * Raymond Lu - * 7 April 2011 - * Starting from the 1.8.7 release, we allow dataspace to have - * zero dimension size. So the external storage size for - * dataset can be zero. *------------------------------------------------------------------------- */ herr_t @@ -997,16 +993,16 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) size_t idx; hsize_t total, tmp; H5O_efl_t efl; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*soh", plist_id, name, offset, size); /* Check arguments */ - if (!name || !*name) + if(!name || !*name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if (offset<0) + if(offset < 0) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "negative external file offset") /* Get the plist structure */ @@ -1015,14 +1011,14 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") - if(efl.nused > 0 && H5O_EFL_UNLIMITED==efl.slot[efl.nused-1].size) + if(efl.nused > 0 && H5O_EFL_UNLIMITED == efl.slot[efl.nused - 1].size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "previous file size is unlimited") - if (H5O_EFL_UNLIMITED!=size) { - for (idx=0, total=size; idx<efl.nused; idx++, total=tmp) { + if(H5O_EFL_UNLIMITED != size) { + for(idx = 0, total = size; idx < efl.nused; idx++, total = tmp) { tmp = total + efl.slot[idx].size; - if (tmp <= total) - HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "total external data size overflowed") + if(tmp <= total) + HGOTO_ERROR(H5E_EFL, H5E_OVERFLOW, FAIL, "total external data size overflowed") } /* end for */ } /* end if */ @@ -1033,23 +1029,23 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) H5O_efl_entry_t *x = (H5O_efl_entry_t *)H5MM_realloc(efl.slot, na * sizeof(H5O_efl_entry_t)); if(!x) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "memory allocation failed") efl.nalloc = na; efl.slot = x; } /* end if */ idx = efl.nused; efl.slot[idx].name_offset = 0; /*not entered into heap yet*/ - efl.slot[idx].name = H5MM_xstrdup (name); + efl.slot[idx].name = H5MM_xstrdup(name); efl.slot[idx].offset = offset; efl.slot[idx].size = size; efl.nused++; if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set external file list") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file list") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pset_external() */ /*------------------------------------------------------------------------- @@ -1217,7 +1213,7 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Always set K13 compression (and un-set CHIP compression) */ - options_mask &= (~H5_SZIP_CHIP_OPTION_MASK); + options_mask &= (unsigned)(~H5_SZIP_CHIP_OPTION_MASK); options_mask |= H5_SZIP_ALLOW_K13_OPTION_MASK; /* Always set "raw" (no szip header) flag for data */ @@ -1225,7 +1221,7 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) /* Mask off the LSB and MSB options, if they were given */ /* (The HDF5 library sets them internally, as needed) */ - options_mask &= ~(H5_SZIP_LSB_OPTION_MASK|H5_SZIP_MSB_OPTION_MASK); + options_mask &= (unsigned)(~(H5_SZIP_LSB_OPTION_MASK | H5_SZIP_MSB_OPTION_MASK)); /* Set the parameters for the filter */ cd_values[0]=options_mask; @@ -1823,6 +1819,8 @@ H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) alloc_time = H5D_ALLOC_TIME_INCR; break; + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: default: HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") } /* end switch */ diff --git a/src/H5Pint.c b/src/H5Pint.c index 9de7e4a..d17903f 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -55,6 +55,24 @@ typedef struct { H5P_genclass_t *new_class; /* Pointer to class during path traversal */ } H5P_check_class_t; +/* Typedef for property list iterator callback */ +typedef struct { + H5P_iterate_int_t cb_func; /* Iterator callback */ + void *udata; /* Iterator callback pointer */ + H5P_genplist_t *plist; /* Property list pointer */ + H5SL_t *seen; /* Skip list to hold names of properties already seen */ + int *curr_idx_ptr; /* Pointer to current iteration index */ + int prev_idx; /* Previous iteration index */ +} H5P_iter_plist_ud_t; + +/* Typedef for property list class iterator callback */ +typedef struct { + H5P_iterate_int_t cb_func; /* Iterator callback */ + void *udata; /* Iterator callback pointer */ + int *curr_idx_ptr; /* Pointer to current iteration index */ + int prev_idx; /* Previous iteration index */ +} H5P_iter_pclass_ud_t; + /********************/ /* Local Prototypes */ @@ -977,17 +995,17 @@ H5P_create_prop(const char *name, size_t size, H5P_prop_within_t type, H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close) { - H5P_genprop_t *prop=NULL; /* Pointer to new property copied */ + H5P_genprop_t *prop = NULL; /* Pointer to new property copied */ H5P_genprop_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(name); - HDassert((size>0 && value!=NULL) || (size==0)); - HDassert(type!=H5P_PROP_WITHIN_UNKNOWN); + HDassert((size > 0 && value != NULL) || (size == 0)); + HDassert(type != H5P_PROP_WITHIN_UNKNOWN); /* Allocate the new property */ - if(NULL==(prop = H5FL_MALLOC (H5P_genprop_t))) + if(NULL == (prop = H5FL_MALLOC(H5P_genprop_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Set the property initial values */ @@ -997,37 +1015,37 @@ H5P_create_prop(const char *name, size_t size, H5P_prop_within_t type, prop->type = type; /* Duplicate value, if it exists */ - if(value!=NULL) { - if(NULL==(prop->value = H5MM_malloc (prop->size))) + if(value != NULL) { + if(NULL == (prop->value = H5MM_malloc (prop->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - HDmemcpy(prop->value,value,prop->size); + HDmemcpy(prop->value, value, prop->size); } /* end if */ else - prop->value=NULL; + prop->value = NULL; /* Set the function pointers */ - prop->create=prp_create; - prop->set=prp_set; - prop->get=prp_get; - prop->del=prp_delete; - prop->copy=prp_copy; + prop->create = prp_create; + prop->set = prp_set; + prop->get = prp_get; + prop->del = prp_delete; + prop->copy = prp_copy; /* Use custom comparison routine if available, otherwise default to memcmp() */ - if(prp_cmp!=NULL) - prop->cmp=prp_cmp; + if(prp_cmp != NULL) + prop->cmp = prp_cmp; else - prop->cmp=&memcmp; - prop->close=prp_close; + prop->cmp = &memcmp; + prop->close = prp_close; /* Set return value */ - ret_value=prop; + ret_value = prop; done: /* Free any resources allocated */ - if(ret_value==NULL) { - if(prop!=NULL) { - if(prop->name!=NULL) + if(ret_value == NULL) { + if(prop != NULL) { + if(prop->name != NULL) H5MM_xfree(prop->name); - if(prop->value!=NULL) + if(prop->value != NULL) H5MM_xfree(prop->value); prop = H5FL_FREE(H5P_genprop_t, prop); } /* end if */ @@ -2338,8 +2356,9 @@ H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, /* Check if the property has been deleted */ if(NULL != H5SL_search(plist->del, name)) { char *temp_name = NULL; + /* Remove the property name from the deleted property skip list */ - if(NULL == (temp_name = H5SL_remove(plist->del, name))) + if(NULL == (temp_name = (char *)H5SL_remove(plist->del, name))) HGOTO_ERROR(H5E_PLIST,H5E_CANTDELETE,FAIL,"can't remove property from deleted skip list") /* free the name of the removed property */ @@ -3319,14 +3338,113 @@ done: /*-------------------------------------------------------------------------- NAME + H5P__iterate_plist_cb + PURPOSE + Internal callback routine when iterating over properties in property list + USAGE + int H5P__iterate_plist_cb(item, key, udata) + void *item; IN: Pointer to the property + void *key; IN: Pointer to the property's name + void *udata; IN/OUT: Pointer to iteration data from user + RETURNS + Success: Returns the return value of the last call to ITER_FUNC + DESCRIPTION + This routine calls the actual callback routine for the property in the +property list. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static int +H5P__iterate_plist_cb(void *_item, void *_key, void *_udata) +{ + H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ + char *key = (char *)_key; /* Pointer to the property's name */ + H5P_iter_plist_ud_t *udata = (H5P_iter_plist_ud_t *)_udata; /* Pointer to user data */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(item); + HDassert(key); + + /* Check if we've found the correctly indexed property */ + if(*udata->curr_idx_ptr >= udata->prev_idx) { + /* Call the callback function */ + ret_value = (*udata->cb_func)(item, udata->udata); + if(ret_value != 0) + HGOTO_DONE(ret_value); + } /* end if */ + + /* Increment the current index */ + (*udata->curr_idx_ptr)++; + + /* Add property name to "seen" list */ + if(H5SL_insert(udata->seen, key, key) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into seen skip list") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__iterate_plist_cb() */ + + +/*-------------------------------------------------------------------------- + NAME + H5P__iterate_plist_pclass_cb + PURPOSE + Internal callback routine when iterating over properties in property class + USAGE + int H5P__iterate_plist_pclass_cb(item, key, udata) + void *item; IN: Pointer to the property + void *key; IN: Pointer to the property's name + void *udata; IN/OUT: Pointer to iteration data from user + RETURNS + Success: Returns the return value of the last call to ITER_FUNC + DESCRIPTION + This routine verifies that the property hasn't already been seen or was +deleted, and then chains to the property list callback. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static int +H5P__iterate_plist_pclass_cb(void *_item, void *_key, void *_udata) +{ + H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ + char *key = (char *)_key; /* Pointer to the property's name */ + H5P_iter_plist_ud_t *udata = (H5P_iter_plist_ud_t *)_udata; /* Pointer to user data */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(item); + HDassert(key); + + /* Only call iterator callback for properties we haven't seen + * before and that haven't been deleted. + */ + if(NULL == H5SL_search(udata->seen, key) && + NULL == H5SL_search(udata->plist->del, key)) + ret_value = H5P__iterate_plist_cb(item, key, udata); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__iterate_plist_pclass_cb() */ + + +/*-------------------------------------------------------------------------- + NAME H5P_iterate_plist PURPOSE Internal routine to iterate over the properties in a property list USAGE - herr_t H5P_iterate_plist(plist_id, idx, iter_func, iter_data) + int H5P_iterate_plist(plist_id, idx, cb_func, iter_data) hid_t plist_id; IN: ID of property list to iterate over int *idx; IN/OUT: Index of the property to begin with - H5P_iterate_t iter_func; IN: Function pointer to function to be + H5P_iterate_t cb_func; IN: Function pointer to function to be called with each property iterated over. void *iter_data; IN/OUT: Pointer to iteration data from user RETURNS @@ -3369,106 +3487,60 @@ iteration, the function's behavior is undefined. REVISION LOG --------------------------------------------------------------------------*/ int -H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_t iter_func, void *iter_data) +H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_int_t cb_func, void *udata) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genplist_t *plist; /* Property list pointer */ - H5P_genprop_t *tmp; /* Temporary pointer to properties */ + H5P_iter_plist_ud_t udata_int; /* User data for skip list iterator */ H5SL_t *seen = NULL; /* Skip list to hold names of properties already seen */ - H5SL_node_t *curr_node; /* Current node in skip list */ int curr_idx = 0; /* Current iteration index */ - int ret_value = FAIL; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(idx); - HDassert(iter_func); + HDassert(cb_func); /* Get the property list object */ if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Create the skip list to hold names of properties already seen */ - if((seen = H5SL_create(H5SL_TYPE_STR, NULL)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCREATE,FAIL,"can't create skip list for seen properties") - - /* Walk through the changed properties in the list */ - if(H5SL_count(plist->props) > 0) { - curr_node = H5SL_first(plist->props); - while(curr_node != NULL) { - /* Get pointer to property from node */ - tmp = (H5P_genprop_t *)H5SL_item(curr_node); - - /* Check if we've found the correctly indexed property */ - if(curr_idx>=*idx) { - /* Call the callback function */ - ret_value=(*iter_func)(plist_id,tmp->name,iter_data); - - if(ret_value!=0) - HGOTO_DONE(ret_value); - } /* end if */ - - /* Increment the current index */ - curr_idx++; - - /* Add property name to "seen" list */ - if(H5SL_insert(seen,tmp->name,tmp->name) < 0) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list") - - /* Get the next property node in the skip list */ - curr_node=H5SL_next(curr_node); - } /* end while */ - } /* end if */ + if(NULL == (seen = H5SL_create(H5SL_TYPE_STR, NULL))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "can't create skip list for seen properties") + + /* Set up iterator callback info */ + udata_int.plist = plist; + udata_int.cb_func = cb_func; + udata_int.udata = udata; + udata_int.seen = seen; + udata_int.curr_idx_ptr = &curr_idx; + udata_int.prev_idx = *idx; + + /* Iterate over properties in property list proper */ + /* (Will be only the non-default (i.e. changed) properties) */ + ret_value = H5SL_iterate(plist->props, H5P__iterate_plist_cb, &udata_int); + if(ret_value != 0) + HGOTO_DONE(ret_value); /* Walk up the class hiearchy */ - tclass=plist->pclass; - while(tclass!=NULL) { - if(tclass->nprops>0) { - /* Walk through the properties in the class */ - curr_node=H5SL_first(tclass->props); - while(curr_node!=NULL) { - /* Get pointer to property from node */ - tmp = (H5P_genprop_t *)H5SL_item(curr_node); - - /* Only call iterator callback for properties we haven't seen - * before and that haven't been deleted - */ - if(H5SL_search(seen,tmp->name) == NULL && - H5SL_search(plist->del,tmp->name) == NULL) { - - - /* Check if we've found the correctly indexed property */ - if(curr_idx>=*idx) { - /* Call the callback function */ - ret_value=(*iter_func)(plist_id,tmp->name,iter_data); - - if(ret_value!=0) - HGOTO_DONE(ret_value); - } /* end if */ - - /* Increment the current index */ - curr_idx++; - - /* Add property name to "seen" list */ - if(H5SL_insert(seen,tmp->name,tmp->name) < 0) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into seen skip list") - } /* end if */ - - /* Get the next property node in the skip list */ - curr_node=H5SL_next(curr_node); - } /* end while */ - } /* end if */ + tclass = plist->pclass; + while(tclass != NULL) { + /* Iterate over properties in property list class */ + ret_value = H5SL_iterate(tclass->props, H5P__iterate_plist_pclass_cb, &udata_int); + if(ret_value != 0) + HGOTO_DONE(ret_value); /* Go up to parent class */ - tclass=tclass->parent; + tclass = tclass->parent; } /* end while */ done: /* Set the index we stopped at */ - *idx=curr_idx; + *idx = curr_idx; /* Release the skip list of 'seen' properties */ - if(seen!=NULL) + if(seen != NULL) H5SL_close(seen); FUNC_LEAVE_NOAPI(ret_value) @@ -3477,14 +3549,65 @@ done: /*-------------------------------------------------------------------------- NAME + H5P__iterate_pclass_cb + PURPOSE + Internal callback routine when iterating over properties in property list + class + USAGE + int H5P__iterate_pclass_cb(item, key, udata) + void *item; IN: Pointer to the property + void *key; IN: Pointer to the property's name + void *udata; IN/OUT: Pointer to iteration data from user + RETURNS + Success: Returns the return value of the last call to ITER_FUNC + DESCRIPTION + This routine calls the actual callback routine for the property in the +property list class. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static int +H5P__iterate_pclass_cb(void *_item, void *_key, void *_udata) +{ + H5P_genprop_t *item = (H5P_genprop_t *)_item; /* Pointer to the property */ + char *key = (char *)_key; /* Pointer to the property's name */ + H5P_iter_pclass_ud_t *udata = (H5P_iter_pclass_ud_t *)_udata; /* Pointer to user data */ + int ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(item); + HDassert(key); + + /* Check if we've found the correctly indexed property */ + if(*udata->curr_idx_ptr >= udata->prev_idx) { + /* Call the callback function */ + ret_value = (*udata->cb_func)(item, udata->udata); + if(ret_value != 0) + HGOTO_DONE(ret_value); + } /* end if */ + + /* Increment the current index */ + (*udata->curr_idx_ptr)++; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__iterate_pclass_cb() */ + + +/*-------------------------------------------------------------------------- + NAME H5P_iterate_pclass PURPOSE Internal routine to iterate over the properties in a property class USAGE - herr_t H5P_iterate_pclass(pclass_id, idx, iter_func, iter_data) + herr_t H5P_iterate_pclass(pclass_id, idx, cb_func, iter_data) hid_t pclass_id; IN: ID of property class to iterate over int *idx; IN/OUT: Index of the property to begin with - H5P_iterate_t iter_func; IN: Function pointer to function to be + H5P_iterate_t cb_func; IN: Function pointer to function to be called with each property iterated over. void *iter_data; IN/OUT: Pointer to iteration data from user RETURNS @@ -3527,49 +3650,36 @@ iteration, the function's behavior is undefined. REVISION LOG --------------------------------------------------------------------------*/ int -H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_t iter_func, void *iter_data) +H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_int_t cb_func, void *udata) { H5P_genclass_t *pclass; /* Property list pointer */ - H5SL_node_t *curr_node; /* Current node in skip list */ - H5P_genprop_t *prop; /* Temporary property pointer */ - int curr_idx=0; /* Current iteration index */ - int ret_value=FAIL; /* Return value */ + H5P_iter_pclass_ud_t udata_int; /* User data for skip list iterator */ + int curr_idx = 0; /* Current iteration index */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(idx); - HDassert(iter_func); + HDassert(cb_func); /* Get the property list object */ if(NULL == (pclass = (H5P_genclass_t *)H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class") - /* Cycle through the properties and call the callback */ - curr_idx=0; - curr_node=H5SL_first(pclass->props); - while(curr_node!=NULL) { - if(curr_idx>=*idx) { - /* Get the property for the node */ - prop = (H5P_genprop_t *)H5SL_item(curr_node); - - /* Call the callback function */ - ret_value=(*iter_func)(pclass_id,prop->name,iter_data); + /* Set up iterator callback info */ + udata_int.cb_func = cb_func; + udata_int.udata = udata; + udata_int.curr_idx_ptr = &curr_idx; + udata_int.prev_idx = *idx; - /* Check if iteration function succeeded */ - if(ret_value!=0) - HGOTO_DONE(ret_value); - } /* end if */ - - /* Increment the iteration index */ - curr_idx++; - - /* Get the next property node in the skip list */ - curr_node=H5SL_next(curr_node); - } /* end while */ + /* Iterate over properties in property list class proper */ + ret_value = H5SL_iterate(pclass->props, H5P__iterate_pclass_cb, &udata_int); + if(ret_value != 0) + HGOTO_DONE(ret_value); done: /* Set the index we stopped at */ - *idx=curr_idx; + *idx = curr_idx; FUNC_LEAVE_NOAPI(ret_value) } /* H5P_iterate_pclass() */ @@ -4111,25 +4221,26 @@ H5P_copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) /* If not, get the information required to do an H5Pinsert2 with the property into the destination list */ else { /* Get the pointer to the source property */ - prop=H5P_find_prop_plist(src_plist,name); + prop = H5P_find_prop_plist(src_plist, name); /* Create property object from parameters */ - if((new_prop=H5P_create_prop(prop->name,prop->size,H5P_PROP_WITHIN_LIST,prop->value,prop->create,prop->set,prop->get,prop->del,prop->copy,prop->cmp,prop->close)) == NULL) + if(NULL == (new_prop = H5P_create_prop(prop->name, prop->size, H5P_PROP_WITHIN_LIST, prop->value, + prop->create, prop->set, prop->get, + prop->del, prop->copy, prop->cmp, prop->close))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL,"Can't create property") /* Call property creation callback, if it exists */ if(new_prop->create) { - if((new_prop->create)(new_prop->name,new_prop->size,new_prop->value) < 0) + if((new_prop->create)(new_prop->name, new_prop->size, new_prop->value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL,"Can't initialize property") } /* end if */ /* Insert property into property list class */ - if(H5P_add_prop(dst_plist->props,new_prop) < 0) + if(H5P_add_prop(dst_plist->props, new_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into class") /* Increment property count for class */ dst_plist->nprops++; - } /* end else */ done: @@ -4205,7 +4316,8 @@ H5P_copy_prop_pclass(hid_t dst_id, hid_t src_id, const char *name) /* Register the property into the destination */ orig_dst_pclass = dst_pclass; - if(H5P_register(&dst_pclass, name, prop->size, prop->value, prop->create, prop->set, prop->get, prop->del, prop->copy, prop->cmp, prop->close) < 0) + if(H5P_register(&dst_pclass, name, prop->size, prop->value, prop->create, prop->set, prop->get, + prop->del, prop->copy, prop->cmp, prop->close) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property") /* Check if the property class changed and needs to be substituted in the ID */ diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index 217d0ba..7a52f11 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -379,8 +379,8 @@ H5Pset_attr_creation_order(hid_t plist_id, unsigned crt_order_flags) ohdr_flags &= (uint8_t)~(H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED); /* Update with new attribute creation order flags */ - ohdr_flags |= (uint8_t)((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? H5O_HDR_ATTR_CRT_ORDER_TRACKED : 0); - ohdr_flags |= (uint8_t)((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? H5O_HDR_ATTR_CRT_ORDER_INDEXED : 0); + ohdr_flags = (uint8_t)(ohdr_flags | ((crt_order_flags & H5P_CRT_ORDER_TRACKED) ? H5O_HDR_ATTR_CRT_ORDER_TRACKED : 0)); + ohdr_flags = (uint8_t)(ohdr_flags | ((crt_order_flags & H5P_CRT_ORDER_INDEXED) ? H5O_HDR_ATTR_CRT_ORDER_INDEXED : 0)); /* Set object header flags */ if(H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) @@ -486,7 +486,7 @@ H5Pset_obj_track_times(hid_t plist_id, hbool_t track_times) ohdr_flags &= (uint8_t)~H5O_HDR_STORE_TIMES; /* Update with new time tracking flag */ - ohdr_flags |= (uint8_t)(track_times ? H5O_HDR_STORE_TIMES : 0); + ohdr_flags = (uint8_t)(ohdr_flags | (track_times ? H5O_HDR_STORE_TIMES : 0)); /* Set object header flags */ if(H5P_set(plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) @@ -1343,7 +1343,7 @@ H5P_get_filter(const H5Z_filter_info_t *filter, unsigned int *flags/*out*/, * *------------------------------------------------------------------------- */ -int +static int H5P_ocrt_pipeline_cmp(const void *_pline1, const void *_pline2, size_t UNUSED size) { const H5O_pline_t *pline1 = (const H5O_pline_t *)_pline1, /* Create local aliases for values */ diff --git a/src/H5Ppkg.h b/src/H5Ppkg.h index 1e71049..65d314e 100644 --- a/src/H5Ppkg.h +++ b/src/H5Ppkg.h @@ -138,6 +138,8 @@ typedef struct H5P_libclass_t { void *close_data; /* Pointer to user data to pass along to close callback */ } H5P_libclass_t; +/* Property list/class iterator callback function pointer */ +typedef int (*H5P_iterate_int_t)(H5P_genprop_t *prop, void *udata); /*****************************/ /* Package Private Variables */ @@ -176,9 +178,9 @@ H5_DLL H5P_genclass_t *H5P_get_class(const H5P_genplist_t *plist); H5_DLL herr_t H5P_get_nprops_plist(const H5P_genplist_t *plist, size_t *nprops); H5_DLL int H5P_cmp_class(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2); H5_DLL int H5P_cmp_plist(const H5P_genplist_t *plist1, const H5P_genplist_t *plist2); -H5_DLL int H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_t iter_func, +H5_DLL int H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_int_t iter_func, void *iter_data); -H5_DLL int H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_t iter_func, +H5_DLL int H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_int_t iter_func, void *iter_data); H5_DLL herr_t H5P_copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name); H5_DLL herr_t H5P_copy_prop_pclass(hid_t dst_id, hid_t src_id, const char *name); diff --git a/src/H5Pstrcpl.c b/src/H5Pstrcpl.c index 91cf70b..188fdd2 100644 --- a/src/H5Pstrcpl.c +++ b/src/H5Pstrcpl.c @@ -108,7 +108,7 @@ const H5P_libclass_t H5P_CLS_STRCRT[1] = {{ * October 31, 2006 *------------------------------------------------------------------------- */ -herr_t +static herr_t H5P_strcrt_reg_prop(H5P_genclass_t *pclass) { H5T_cset_t char_encoding = H5P_STRCRT_CHAR_ENCODING_DEF; /* Default character set encoding */ @@ -213,7 +213,7 @@ H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5 HDassert(_ref); HDassert(loc); HDassert(name); - HDassert(ref_type > H5R_BADTYPE || ref_type < H5R_MAXTYPE); + HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE); /* Set up object location to fill in */ obj_loc.oloc = &oloc; @@ -268,7 +268,7 @@ H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5 HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "Invalid amount of space for serializing selection") /* Increase buffer size to allow for the dataset OID */ - buf_size += sizeof(haddr_t); + buf_size += (hssize_t)sizeof(haddr_t); /* Allocate the space to store the serialized information */ H5_CHECK_OVERFLOW(buf_size, hssize_t, size_t); @@ -422,7 +422,7 @@ H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, FUNC_ENTER_NOAPI_NOINIT HDassert(_ref); - HDassert(ref_type > H5R_BADTYPE || ref_type < H5R_MAXTYPE); + HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE); HDassert(file); /* Initialize the object location */ @@ -529,6 +529,8 @@ H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, } /* end case */ break; + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: default: HGOTO_ERROR(H5E_REFERENCE, H5E_BADTYPE, FAIL, "can't identify type of object referenced") } /* end switch */ @@ -745,7 +745,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5SL_release_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) { H5SL_node_t *node, *next_node; /* Pointers to skip list nodes */ @@ -817,7 +817,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5SL_close_common(H5SL_t *slist, H5SL_operator_t op, void *op_data) { herr_t ret_value = SUCCEED; @@ -873,7 +873,7 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) FUNC_ENTER_NOAPI(NULL) /* Check args */ - HDassert(type>=H5SL_TYPE_INT && type<=H5SL_TYPE_GENERIC); + HDassert(type >= H5SL_TYPE_INT && type <= H5SL_TYPE_GENERIC); /* Allocate skip list structure */ if(NULL == (new_slist = H5FL_MALLOC(H5SL_t))) @@ -889,7 +889,7 @@ H5SL_create(H5SL_type_t type, H5SL_cmp_t cmp) new_slist->nobjs = 0; /* Allocate the header node */ - if(NULL == (header = H5SL_new_node(NULL, NULL, ULONG_MAX))) + if(NULL == (header = H5SL_new_node(NULL, NULL, (uint32_t)ULONG_MAX))) HGOTO_ERROR(H5E_SLIST ,H5E_NOSPACE, NULL, "can't create new skip list node") /* Initialize header node's forward pointer */ diff --git a/src/H5Sall.c b/src/H5Sall.c index c99d699..8d56c80 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -112,7 +112,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{ * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5S_all_iter_init (H5S_sel_iter_t *iter, const H5S_t *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -445,7 +445,7 @@ H5S_all_copy(H5S_t *dst, const H5S_t UNUSED *src, hbool_t UNUSED share_selection EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_all_is_valid (const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -475,7 +475,7 @@ H5S_all_is_valid (const H5S_t UNUSED *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -hssize_t +static hssize_t H5S_all_serial_size (const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -509,7 +509,7 @@ H5S_all_serial_size (const H5S_t UNUSED *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_all_serialize (const H5S_t *space, uint8_t *buf) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -545,7 +545,7 @@ H5S_all_serialize (const H5S_t *space, uint8_t *buf) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_all_deserialize(H5S_t *space, const uint8_t UNUSED *buf) { herr_t ret_value; /* return value */ @@ -588,7 +588,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { unsigned rank; /* Dataspace rank */ @@ -633,7 +633,7 @@ H5S_all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_all_offset(const H5S_t UNUSED *space, hsize_t *offset) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -666,7 +666,7 @@ H5S_all_offset(const H5S_t UNUSED *space, hsize_t *offset) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_all_is_contiguous(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -695,7 +695,7 @@ H5S_all_is_contiguous(const H5S_t UNUSED *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_all_is_single(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -725,7 +725,7 @@ H5S_all_is_single(const H5S_t UNUSED *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_all_is_regular(const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -755,7 +755,7 @@ H5S_all_is_regular(const H5S_t UNUSED *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_all_adjust_u(H5S_t UNUSED *space, const hsize_t UNUSED *offset) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -945,7 +945,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_all_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_iter_t *iter, size_t UNUSED maxseq, size_t maxelem, size_t *nseq, size_t *nelem, hsize_t *off, size_t *len) diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 1eeb098..d9b306d 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -234,7 +234,7 @@ H5S_hyper_print_diminfo(FILE *f, const H5S_t *space) * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) { const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */ @@ -1614,7 +1614,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) { H5S_hyper_sel_t *dst_hslab; /* Pointer to destination hyperslab info */ @@ -1749,7 +1749,7 @@ H5S_hyper_is_valid_helper (const H5S_hyper_span_info_t *spans, const hssize_t *o EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_hyper_is_valid (const H5S_t *space) { unsigned u; /* Counter */ @@ -2068,7 +2068,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) { const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ @@ -2229,7 +2229,7 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_deserialize (H5S_t *space, const uint8_t *buf) { uint32_t rank; /* rank of points */ @@ -2705,7 +2705,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { unsigned rank; /* Dataspace rank */ @@ -2772,7 +2772,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_offset(const H5S_t *space, hsize_t *offset) { const hssize_t *sel_offset; /* Pointer to the selection's offset */ @@ -2878,7 +2878,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_hyper_is_contiguous(const H5S_t *space) { unsigned small_contiguous, /* Flag for small contiguous block */ @@ -3063,7 +3063,7 @@ H5S_hyper_is_contiguous(const H5S_t *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_hyper_is_single(const H5S_t *space) { H5S_hyper_span_info_t *spans; /* Hyperslab span info node */ @@ -3133,7 +3133,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t +static htri_t H5S_hyper_is_regular(const H5S_t *space) { htri_t ret_value; /* return value */ @@ -3175,7 +3175,7 @@ H5S_hyper_is_regular(const H5S_t *space) * changing the hyperslab selection of one data space causes a core dump * when closing some other data space. --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_release(H5S_t *space) { herr_t ret_value = SUCCEED; @@ -4008,7 +4008,7 @@ H5S_hyper_adjust_helper_u (H5S_hyper_span_info_t *spans, const hsize_t *offset) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_hyper_adjust_u(H5S_t *space, const hsize_t *offset) { unsigned u; /* Local index variable */ diff --git a/src/H5Snone.c b/src/H5Snone.c index e9a3bf9..021dd61 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -113,7 +113,7 @@ static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{ * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5S_none_iter_init(H5S_sel_iter_t *iter, const H5S_t UNUSED *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -589,7 +589,7 @@ H5S_none_bounds(const H5S_t UNUSED *space, hsize_t UNUSED *start, hsize_t UNUSED EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_none_offset(const H5S_t UNUSED *space, hsize_t UNUSED *offset) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -708,7 +708,7 @@ H5S_none_is_regular(const H5S_t UNUSED *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_none_adjust_u(H5S_t UNUSED *space, const hsize_t UNUSED *offset) { FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 7e82295..817b2f2 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -120,7 +120,7 @@ H5FL_DEFINE_STATIC(H5S_pnt_list_t); * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1136,7 +1136,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_point_offset(const H5S_t *space, hsize_t *offset) { const hsize_t *pnt; /* Pointer to a selected point's coordinates */ @@ -1316,7 +1316,7 @@ H5S_point_is_regular(const H5S_t *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +static herr_t H5S_point_adjust_u(H5S_t *space, const hsize_t *offset) { H5S_pnt_node_t *node; /* Point node */ @@ -734,7 +734,7 @@ DESCRIPTION Initializes any interface-specific data or routines. --------------------------------------------------------------------------*/ -herr_t +static herr_t H5T_init_interface(void) { H5T_t *native_schar=NULL; /* Datatype structure for native signed char */ @@ -3157,7 +3157,7 @@ done: *------------------------------------------------------------------------- */ H5T_t * -H5T_copy(const H5T_t *old_dt, H5T_copy_t method) +H5T_copy(H5T_t *old_dt, H5T_copy_t method) { H5T_t *new_dt = NULL, *tmp = NULL; H5T_shared_t *reopened_fo = NULL; @@ -3843,8 +3843,10 @@ H5T_set_size(H5T_t *dt, size_t size) case H5T_ENUM: case H5T_VLEN: case H5T_ARRAY: - assert("can't happen" && 0); case H5T_REFERENCE: + assert("can't happen" && 0); + case H5T_NO_CLASS: + case H5T_NCLASSES: assert("invalid type" && 0); default: assert("not implemented yet" && 0); @@ -4299,6 +4301,9 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) /*void */ break; + case H5R_BADTYPE: + case H5R_MAXTYPE: + assert("invalid type" && 0); default: assert("not implemented yet" && 0); } @@ -5150,7 +5155,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) } /* end for */ /* Apply the accumulated size change to the datatype */ - dt->shared->size += accum_change; + dt->shared->size = (size_t)(dt->shared->size + accum_change); break; case H5T_VLEN: /* Recurse on the VL information if it's VL, compound or array, then free VL sequence */ diff --git a/src/H5Tarray.c b/src/H5Tarray.c index e9c8fe7..9986631 100644 --- a/src/H5Tarray.c +++ b/src/H5Tarray.c @@ -279,7 +279,7 @@ H5T__get_array_ndims(const H5T_t *dt) HDassert(dt->shared->type == H5T_ARRAY); /* Retrieve the number of dimensions */ - FUNC_LEAVE_NOAPI(dt->shared->u.array.ndims) + FUNC_LEAVE_NOAPI((int)dt->shared->u.array.ndims) } /* end H5T__get_array_ndims */ @@ -337,9 +337,8 @@ int H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]) { unsigned u; /* Local index variable */ - int ret_value; /* return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE_NOERR HDassert(dt); HDassert(dt->shared->type == H5T_ARRAY); @@ -350,10 +349,7 @@ H5T__get_array_dims(const H5T_t *dt, hsize_t dims[]) dims[u] = dt->shared->u.array.dim[u]; /* Pass along the array rank as the return value */ - ret_value = dt->shared->u.array.ndims; - -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI((int)dt->shared->u.array.ndims) } /* end H5T__get_array_dims */ #ifndef H5_NO_DEPRECATED_SYMBOLS diff --git a/src/H5Tfields.c b/src/H5Tfields.c index aa1efe8..163bab3 100644 --- a/src/H5Tfields.c +++ b/src/H5Tfields.c @@ -83,7 +83,7 @@ H5Tget_nmembers(hid_t type_id) H5TRACE1("Is", "i", type_id); /* Check args */ - if(NULL == (dt = H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if((ret_value = H5T_get_nmembers(dt)) < 0) @@ -165,7 +165,7 @@ H5Tget_member_name(hid_t type_id, unsigned membno) FUNC_ENTER_API(NULL) /* Check args */ - if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) + if (NULL == (dt = (H5T_t *)H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") if(NULL == (ret_value = H5T__get_member_name(dt, membno))) @@ -217,6 +217,17 @@ H5T__get_member_name(H5T_t const *dt, unsigned membno) ret_value = H5MM_xstrdup(dt->shared->u.enumer.name[membno]); break; + case H5T_NO_CLASS: + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_TIME: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_REFERENCE: + case H5T_VLEN: + case H5T_ARRAY: + case H5T_NCLASSES: default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "operation not supported for type class") } /*lint !e788 All appropriate cases are covered */ @@ -255,31 +266,41 @@ H5Tget_member_index(hid_t type_id, const char *name) H5TRACE2("Is", "i*s", type_id, name); /* Check arguments */ - assert(name); - if(NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) + HDassert(name); + if(NULL == (dt = (H5T_t*)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Locate member by name */ - switch (dt->shared->type) { + switch(dt->shared->type) { case H5T_COMPOUND: - for(i=0; i< dt->shared->u.compnd.nmembs; i++) { + for(i = 0; i < dt->shared->u.compnd.nmembs; i++) if(!HDstrcmp(dt->shared->u.compnd.memb[i].name, name)) HGOTO_DONE((int)i) - } break; case H5T_ENUM: - for(i=0; i< dt->shared->u.enumer.nmembs; i++) { + for(i = 0; i < dt->shared->u.enumer.nmembs; i++) if(!HDstrcmp(dt->shared->u.enumer.name[i], name)) HGOTO_DONE((int)i) - } break; + + case H5T_NO_CLASS: + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_TIME: + case H5T_STRING: + case H5T_BITFIELD: + case H5T_OPAQUE: + case H5T_REFERENCE: + case H5T_VLEN: + case H5T_ARRAY: + case H5T_NCLASSES: default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for this type") } /*lint !e788 All appropriate cases are covered */ done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Tget_member_index() */ /*------------------------------------------------------------------------- @@ -308,7 +329,7 @@ H5T__sort_value(const H5T_t *dt, int *map) unsigned i, j; /* Local index variables */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE_NOERR /* Check args */ HDassert(dt); @@ -381,7 +402,6 @@ H5T__sort_value(const H5T_t *dt, int *map) } /* end if */ } /* end else */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__sort_value() */ @@ -411,9 +431,8 @@ H5T__sort_name(const H5T_t *dt, int *map) size_t size; hbool_t swapped; uint8_t tbuf[32]; - herr_t ret_value=SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE_NOERR /* Check args */ assert(dt); @@ -488,7 +507,6 @@ H5T__sort_name(const H5T_t *dt, int *map) } } -done: - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI(SUCCEED) } diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 9c74a76..ca4d346 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -107,7 +107,7 @@ H5_DLLVAR H5T_order_t H5T_native_order_g; /* Private functions */ H5_DLL herr_t H5TN_init_interface(void); H5_DLL herr_t H5T_init(void); -H5_DLL H5T_t *H5T_copy(const H5T_t *old_dt, H5T_copy_t method); +H5_DLL H5T_t *H5T_copy(H5T_t *old_dt, H5T_copy_t method); H5_DLL herr_t H5T_lock(H5T_t *dt, hbool_t immutable); H5_DLL herr_t H5T_close(H5T_t *dt); H5_DLL H5T_t *H5T_get_super(const H5T_t *dt); diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 48948a7..9fa3863 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -537,7 +537,7 @@ done: * *------------------------------------------------------------------------- */ -void +static void H5Z_xform_destroy_parse_tree(H5Z_node *tree) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -567,7 +567,7 @@ H5Z_xform_destroy_parse_tree(H5Z_node *tree) * *------------------------------------------------------------------------- */ -void * +static void * H5Z_xform_parse(const char *expression, H5Z_datval_ptrs* dat_val_pointers) { H5Z_token tok; @@ -1251,7 +1251,7 @@ done: * *------------------------------------------------------------------------- */ -void * +static void * H5Z_xform_copy_tree(H5Z_node* tree, H5Z_datval_ptrs* dat_val_pointers, H5Z_datval_ptrs* new_dat_val_pointers) { H5Z_node* ret_value=NULL; @@ -1386,7 +1386,7 @@ H5Z_op_is_numbs2(H5Z_node* _tree) * *------------------------------------------------------------------------- */ -void +static void H5Z_xform_reduce_tree(H5Z_node* tree) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1516,7 +1516,7 @@ H5Z_xform_create(const char *expr) * we don't need to allocate any space since no array will have to be * stored */ if(count > 0) - if(NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val = (void *)H5MM_calloc(count * sizeof(void *)))) + if(NULL == (data_xform_prop->dat_val_pointers->ptr_dat_val = (void **)H5MM_calloc(count * sizeof(void *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate memory for pointers in transform array") /* Initialize the num_ptrs field, which will be used to keep track of the number of copies @@ -1651,7 +1651,7 @@ H5Z_xform_copy(H5Z_data_xform_t **data_xform_prop) count++; if(count > 0) - if(NULL == (new_data_xform_prop->dat_val_pointers->ptr_dat_val = (void *)H5MM_calloc(count * sizeof(void *)))) + if(NULL == (new_data_xform_prop->dat_val_pointers->ptr_dat_val = (void **)H5MM_calloc(count * sizeof(void *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory for pointers in transform array") /* Zero out num_pointers prior to H5Z_xform_cop_tree call; that call will increment it to the right amount */ diff --git a/src/H5private.h b/src/H5private.h index b99845a..5fc721a 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -2292,7 +2292,8 @@ func_init_failed: \ /* Close Function */ \ } -/* Macro to begin/end tagging (when FUNC_ENTER_*TAG macros are insufficient) */ +/* Macro to begin/end tagging (when FUNC_ENTER_*TAG macros are insufficient). + * Make sure to use HGOTO_ERROR_TAG and HGOTO_DONE_TAG between these macros! */ #define H5_BEGIN_TAG(dxpl, tag, err) { \ haddr_t prv_tag = HADDR_UNDEF; \ hid_t my_dxpl_id = dxpl; \ diff --git a/test/objcopy.c b/test/objcopy.c index ce0f3d3..6b56b66 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -11452,6 +11452,104 @@ error: /*------------------------------------------------------------------------- + * Function: test_copy_iterate + * + * Purpose: Tests iterating over objects in the root group, copying + * all of them. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Neil Fortner + * Thursday, July 12, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_copy_iterate_cb(hid_t loc_id, const char *name, + const H5L_info_t UNUSED *link_info, void *op_data) +{ + hid_t dst_loc_id = *((hid_t *)op_data); + + if(H5Ocopy(loc_id, name, dst_loc_id, name, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + + return(H5_ITER_CONT); + +error: + return(H5_ITER_ERROR); +} /* end test_copy_iterate_cb */ + +static int +test_copy_iterate(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) +{ + hid_t fid1 = -1, fid2 = -1; /* File IDs */ + hid_t gid = -1; /* Group ID */ + int i; + char grp_name[8]; + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; + + TESTING("H5Ocopy(): inside H5Literate() callback"); + + /* Initialize the filenames */ + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], src_fapl, dst_filename, sizeof dst_filename); + + /* Reset file address checking info */ + addr_reset(); + + /* Create source file */ + if((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) + TEST_ERROR + + /* Create groups */ + for(i=0; i<9; i++) { + HDsnprintf(grp_name, sizeof(grp_name), "grp%d", i); + if((gid = H5Gcreate2(fid1, grp_name, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Gclose(gid) < 0) + TEST_ERROR + } /* end for */ + + /* Create destination file */ + if((fid2 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) + TEST_ERROR + + /* Close files */ + if(H5Fclose(fid1) < 0) TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR + + /* Reopen files */ + if((fid1 = H5Fopen(src_filename, H5F_ACC_RDWR, src_fapl)) < 0) TEST_ERROR + if((fid2 = H5Fopen(dst_filename, H5F_ACC_RDWR, dst_fapl)) < 0) TEST_ERROR + + /* Iterate over links in the root group, copying each object */ + if((gid = H5Gopen2(fid1, "/", H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Literate(gid, H5_INDEX_NAME, H5_ITER_INC, NULL, test_copy_iterate_cb, + &fid2) < 0) + TEST_ERROR + + /* Close */ + if(H5Gclose(gid) < 0) TEST_ERROR + if(H5Fclose(fid1) < 0) TEST_ERROR + if(H5Fclose(fid2) < 0) TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Gclose(gid); + H5Fclose(fid1); + H5Fclose(fid2); + } H5E_END_TRY; + return 1; +} /* end test_copy_iterate */ + + +/*------------------------------------------------------------------------- * Function: test_copy_option * * Purpose: Create a group in SRC file and copy it to DST file @@ -12289,6 +12387,7 @@ main(void) nerrors += test_copy_same_file_named_datatype(fcpl_src, src_fapl); nerrors += test_copy_old_layout(fcpl_dst, dst_fapl); nerrors += test_copy_null_ref(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_iterate(fcpl_src, fcpl_dst, src_fapl, dst_fapl); } /* TODO: not implemented diff --git a/tools/h5copy/testh5copy.sh b/tools/h5copy/testh5copy.sh index 0529d53..4415535 100644 --- a/tools/h5copy/testh5copy.sh +++ b/tools/h5copy/testh5copy.sh @@ -76,6 +76,9 @@ H5LS_BIN=`pwd`/../h5ls/$H5LS # The path of the h5ls tool binary CMP='cmp -s' DIFF='diff -c' CP='cp' +DIRNAME='dirname' +LS='ls' +AWK='awk' nerrors=0 verbose=yes @@ -105,17 +108,26 @@ COPY_TESTFILES_TO_TESTDIR() echo $tstfile | tr -d ' ' | grep '^#' > /dev/null RET=$? if [ $RET -eq 1 ]; then - if [ -a $tstfile ]; then - $CP -f $tstfile $TESTDIR - else - echo "Error: FAILED to copy $tstfile." - echo " $tstfile doesn't exist!" - exit $EXIT_FAILURE + # skip cp if srcdir is same as destdir + # this occurs when build/test performed in source dir and + # make cp fail + SDIR=`$DIRNAME $tstfile` + INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` + INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` + if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then + $CP -f $tstfile $TESTDIR + if [ $? -ne 0 ]; then + echo "Error: FAILED to copy $tstfile ." + + # Comment out this to CREATE expected file + exit $EXIT_FAILURE + fi fi fi done } + # Print a "SKIP" message SKIP() { TESTING $H5COPY $@ diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index a208acf..7e95e80 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -41,6 +41,9 @@ H5DIFF_BIN=`pwd`/$H5DIFF # The path of the tool binary CMP='cmp -s' DIFF='diff -c' CP='cp' +DIRNAME='dirname' +LS='ls' +AWK='awk' nerrors=0 verbose=yes @@ -318,12 +321,20 @@ COPY_TESTFILES_TO_TESTDIR() echo $tstfile | tr -d ' ' | grep '^#' > /dev/null RET=$? if [ $RET -eq 1 ]; then - $CP -f $tstfile $TESTDIR - if [ $? -ne 0 ]; then - echo "Error: FAILED to copy $tstfile ." + # skip cp if srcdir is same as destdir + # this occurs when build/test performed in source dir and + # make cp fail + SDIR=`$DIRNAME $tstfile` + INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` + INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` + if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then + $CP -f $tstfile $TESTDIR + if [ $? -ne 0 ]; then + echo "Error: FAILED to copy $tstfile ." - # Comment out this to CREATE expected file - exit $EXIT_FAILURE + # Comment out this to CREATE expected file + exit $EXIT_FAILURE + fi fi fi done @@ -825,14 +836,7 @@ TOOLTEST h5diff_221.txt -c non_comparables1.h5 non_comparables2.h5 /g2 # entire file # All the comparables should display differences. -if test -n "$pmode"; then - # parallel mode: - # skip due to ph5diff hangs on koala (linux64-LE) and ember intermittently. - # (HDFFV-8003 - TBD) - SKIP -c non_comparables1.h5 non_comparables2.h5 -else - TOOLTEST h5diff_222.txt -c non_comparables1.h5 non_comparables2.h5 -fi +TOOLTEST h5diff_222.txt -c non_comparables1.h5 non_comparables2.h5 # non-comparable test for common objects (same name) with different object types # (HDFFV-7644) diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index fa71558..0ca6aa9 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -40,6 +40,9 @@ H5IMPORT_BIN=`pwd`/$H5IMPORT # The path of the h5import tool binary CMP='cmp -s' DIFF='diff -c' CP='cp' +DIRNAME='dirname' +LS='ls' +AWK='awk' nerrors=0 verbose=yes @@ -351,18 +354,25 @@ COPY_TESTFILES_TO_TESTDIR() echo $tstfile | tr -d ' ' | grep '^#' > /dev/null RET=$? if [ $RET -eq 1 ]; then - if [ -a $tstfile ]; then - $CP -f $tstfile $TESTDIR - else - echo "Error: FAILED to copy $tstfile" - echo " $tstfile doesn't exist!" - exit $EXIT_FAILURE + # skip cp if srcdir is same as destdir + # this occurs when build/test performed in source dir and + # make cp fail + SDIR=`$DIRNAME $tstfile` + INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` + INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` + if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then + $CP -f $tstfile $TESTDIR + if [ $? -ne 0 ]; then + echo "Error: FAILED to copy $tstfile ." + + # Comment out this to CREATE expected file + exit $EXIT_FAILURE + fi fi fi done } - # Print a line-line message left justified in a field of 70 characters # beginning with the word "Testing". # diff --git a/tools/h5dump/testh5dumppbits.sh.in b/tools/h5dump/testh5dumppbits.sh.in index 991fe7a..3d9685c 100644 --- a/tools/h5dump/testh5dumppbits.sh.in +++ b/tools/h5dump/testh5dumppbits.sh.in @@ -40,6 +40,9 @@ H5IMPORT_BIN=`pwd`/$H5IMPORT # The path of the h5import tool binary CMP='cmp -s' DIFF='diff -c' CP='cp' +DIRNAME='dirname' +LS='ls' +AWK='awk' nerrors=0 verbose=yes @@ -165,18 +168,25 @@ COPY_TESTFILES_TO_TESTDIR() echo $tstfile | tr -d ' ' | grep '^#' > /dev/null RET=$? if [ $RET -eq 1 ]; then - if [ -a $tstfile ]; then - $CP -f $tstfile $TESTDIR - else - echo "Error: FAILED to copy $tstfile" - echo " $tstfile doesn't exist!" - exit $EXIT_FAILURE + # skip cp if srcdir is same as destdir + # this occurs when build/test performed in source dir and + # make cp fail + SDIR=`$DIRNAME $tstfile` + INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` + INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` + if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then + $CP -f $tstfile $TESTDIR + if [ $? -ne 0 ]; then + echo "Error: FAILED to copy $tstfile ." + + # Comment out this to CREATE expected file + exit $EXIT_FAILURE + fi fi fi done } - # Print a line-line message left justified in a field of 70 characters # beginning with the word "Testing". # diff --git a/tools/h5dump/testh5dumpxml.sh.in b/tools/h5dump/testh5dumpxml.sh.in index 4e6081b..1a6b2b1 100644 --- a/tools/h5dump/testh5dumpxml.sh.in +++ b/tools/h5dump/testh5dumpxml.sh.in @@ -27,6 +27,9 @@ DUMPER_BIN=`pwd`/$DUMPER # The path of the tool binary CMP='cmp -s' DIFF='diff -c' CP='cp' +DIRNAME='dirname' +LS='ls' +AWK='awk' nerrors=0 verbose=yes @@ -195,12 +198,20 @@ COPY_TESTFILES_TO_TESTDIR() echo $tstfile | tr -d ' ' | grep '^#' > /dev/null RET=$? if [ $RET -eq 1 ]; then - if [ -a $tstfile ]; then - $CP -f $tstfile $TESTDIR - else - echo "Error: FAILED to copy $tstfile" - echo " $tstfile doesn't exist!" - exit $EXIT_FAILURE + # skip cp if srcdir is same as destdir + # this occurs when build/test performed in source dir and + # make cp fail + SDIR=`$DIRNAME $tstfile` + INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` + INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` + if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then + $CP -f $tstfile $TESTDIR + if [ $? -ne 0 ]; then + echo "Error: FAILED to copy $tstfile ." + + # Comment out this to CREATE expected file + exit $EXIT_FAILURE + fi fi fi done diff --git a/tools/h5import/CMakeLists.txt b/tools/h5import/CMakeLists.txt index 352ba14..a655bf2 100644 --- a/tools/h5import/CMakeLists.txt +++ b/tools/h5import/CMakeLists.txt @@ -249,6 +249,7 @@ IF (BUILD_TESTING) -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=d${testfile}.dff" -D "TEST_EXPECT=0" + -D "TEST_FILTER=(^(Warning)[^\n]*)" -D "TEST_REFERENCE=testfiles/d${testfile}.txt" -P "${HDF5_RESOURCES_DIR}/runTest.cmake" ) @@ -262,6 +263,18 @@ IF (BUILD_TESTING) ENDIF (NOT HDF5_ENABLE_USING_MEMCHECKER) ENDMACRO (ADD_H5_DUMPTEST testname datasetname testfile) + MACRO (ADD_H5_SKIP_DUMPTEST testname datasetname testfile) + ADD_TEST ( + NAME H5IMPORT-DUMP-${testname}-SKIPPED + COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${testname} ${datasetname} ${testfile} --- DEFLATE filter not available" + ) + ENDMACRO (ADD_H5_SKIP_DUMPTEST testname datasetname testfile) + + # -------------------------------------------------------------------- + # Determine if filter is available for h5diff + # -------------------------------------------------------------------- + SET (USE_FILTER_DEFLATE H5_HAVE_FILTER_DEFLATE) + ############################################################################## ############################################################################## ### T H E T E S T S ### @@ -313,11 +326,19 @@ IF (BUILD_TESTING) # ----- TESTING "BINARY F64 - rank 3 - Output LE+CHUNKED+Extended+Compressed " ADD_H5_TEST (BINARY_F64 binfp64.bin testfiles/binfp64.conf binfp64.h5) - ADD_H5_DUMPTEST (BINARY_F64 "/fp/bin/64-bit" binfp64.h5 BINARY) + IF (NOT USE_FILTER_DEFLATE) + ADD_H5_SKIP_DUMPTEST (BINARY_F64 "/fp/bin/64-bit" binfp64.h5 BINARY) + ELSE (NOT USE_FILTER_DEFLATE) + ADD_H5_DUMPTEST (BINARY_F64 "/fp/bin/64-bit" binfp64.h5 BINARY) + ENDIF (NOT USE_FILTER_DEFLATE) # ----- TESTING "BINARY I8 - rank 3 - Output I16LE + Chunked+Extended+Compressed " ADD_H5_TEST (BINARY_I8 binin8.bin testfiles/binin8.conf binin8.h5) - ADD_H5_DUMPTEST (BINARY_I8 "/int/bin/8-bit" binin8.h5 BINARY) + IF (NOT USE_FILTER_DEFLATE) + ADD_H5_SKIP_DUMPTEST (BINARY_I8 "/int/bin/8-bit" binin8.h5 BINARY) + ELSE (NOT USE_FILTER_DEFLATE) + ADD_H5_DUMPTEST (BINARY_I8 "/int/bin/8-bit" binin8.h5 BINARY) + ENDIF (NOT USE_FILTER_DEFLATE) # ----- TESTING "BINARY I16 - rank 3 - Output order LE + CHUNKED + extended " ADD_H5_TEST (BINARY_I16 binin16.bin testfiles/binin16.conf binin16.h5) diff --git a/tools/h5import/h5importtestutil.sh b/tools/h5import/h5importtestutil.sh index 86db229..4831f71 100755 --- a/tools/h5import/h5importtestutil.sh +++ b/tools/h5import/h5importtestutil.sh @@ -16,11 +16,17 @@ # HDF Utilities Test script # Usage: h5importtestutil.sh [machine-type] +# Determine which filters are available +USE_FILTER_DEFLATE="@USE_FILTER_DEFLATE@" + TESTNAME=h5import EXIT_SUCCESS=0 EXIT_FAILURE=1 CP='cp' +DIRNAME='dirname' +LS='ls' +AWK='awk' # initialize errors variable nerrors=0 @@ -125,12 +131,20 @@ COPY_TESTFILES_TO_TESTDIR() echo $tstfile | tr -d ' ' | grep '^#' > /dev/null RET=$? if [ $RET -eq 1 ]; then - if [ -a $tstfile ]; then - $CP -f $tstfile $TESTDIR - else - echo "Error: FAILED to copy $tstfile" - echo " $tstfile doesn't exist!" - exit $EXIT_FAILURE + # skip cp if srcdir is same as destdir + # this occurs when build/test performed in source dir and + # make cp fail + SDIR=`$DIRNAME $tstfile` + INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` + INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` + if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then + $CP -f $tstfile $TESTDIR + if [ $? -ne 0 ]; then + echo "Error: FAILED to copy $tstfile ." + + # Comment out this to CREATE expected file + exit $EXIT_FAILURE + fi fi fi done @@ -141,6 +155,12 @@ TESTING() { echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' } +# Print a "SKIP" message +SKIP() { + TESTING $TESTNAME $@ + echo " -SKIP-" +} + TOOLTEST() { err=0 @@ -202,6 +222,28 @@ else fi } +# Same as TOOLTEST3 except for h5diff uses report mode without warnings +# Use h5dump output as input to h5import for strings +# Use h5diff to verify results +TOOLTEST4() +{ +err=0 +$RUNSERIAL ../h5dump/h5dump -p -d $1 -o d$2.bin -y --width=1 tmp_testfiles/$2 > d$2.dmp +$RUNSERIAL ./h5import d$2.bin -c d$2.dmp -o d$2 > d$2.imp +$RUNSERIAL ../h5diff/h5diff -r d$2 tmp_testfiles/$2 $1 $1 > log2 +$CP -f $SRC_H5IMPORT_TESTFILES/d$2.txt log1 + + +cmp -s log1 log2 || err=1 +rm -f log1 log2 +if [ $err -eq 1 ]; then +nerrors="` expr $nerrors + 1 `"; + echo "*FAILED*" +else + echo " PASSED" +fi +} + echo "" echo "==============================" echo "H5IMPORT tests started" @@ -251,13 +293,21 @@ TOOLTEST $TESTDIR/txtfp64.txt -c $TESTDIR/txtfp64.conf -o txtfp64.h5 TESTING "BINARY F64 - rank 3 - Output LE+CHUNKED+Extended+Compressed " TOOLTEST binfp64.bin -c $TESTDIR/binfp64.conf -o binfp64.h5 TESTING "H5DUMP-BINARY F64 - rank 3 - Output LE+CHUNKED+Extended+Compressed " -TOOLTEST2 "/fp/bin/64-bit" binfp64.h5 +if test $USE_FILTER_DEFLATE != "yes"; then + SKIP "/fp/bin/64-bit" binfp64.h5 +else + TOOLTEST2 "/fp/bin/64-bit" binfp64.h5 +fi TESTING "BINARY I8 - rank 3 - Output I16LE + Chunked+Extended+Compressed " TOOLTEST binin8.bin -c $TESTDIR/binin8.conf -o binin8.h5 TESTING "H5DUMP-BINARY I8 - rank 3 - Output I16LE + Chunked+Extended+Compressed " -TOOLTEST2 "/int/bin/8-bit" binin8.h5 +if test $USE_FILTER_DEFLATE != "yes"; then + SKIP "/int/bin/8-bit" binin8.h5 +else + TOOLTEST2 "/int/bin/8-bit" binin8.h5 +fi TESTING "BINARY I16 - rank 3 - Output order LE + CHUNKED + extended " TOOLTEST binin16.bin -c $TESTDIR/binin16.conf -o binin16.h5 @@ -284,7 +334,7 @@ TOOLTEST2 "/int/buin/32-bit" binuin32.h5 TESTING "STR" TOOLTEST $TESTDIR/txtstr.txt -c $TESTDIR/txtstr.conf -o txtstr.h5 TESTING "H5DUMP-STR" -TOOLTEST3 "/mytext/data" txtstr.h5 +TOOLTEST43 "/mytext/data" txtstr.h5 TESTING "BINARY I8 CR LF EOF" diff --git a/tools/h5jam/testh5jam.sh.in b/tools/h5jam/testh5jam.sh.in index f359926..29e02bd 100644 --- a/tools/h5jam/testh5jam.sh.in +++ b/tools/h5jam/testh5jam.sh.in @@ -36,6 +36,9 @@ CMP='cmp -s' DIFF='diff -c' AWK='awk' CP='cp' +DIRNAME='dirname' +LS='ls' +AWK='awk' nerrors=0 verbose=yes @@ -103,12 +106,20 @@ COPY_TESTFILES_TO_TESTDIR() echo $tstfile | tr -d ' ' | grep '^#' > /dev/null RET=$? if [ $RET -eq 1 ]; then - if [ -a $tstfile ]; then - $CP -f $tstfile $TESTDIR - else - echo "Error: FAILED to copy $tstfile" - echo " $tstfile doesn't exist!" - exit $EXIT_FAILURE + # skip cp if srcdir is same as destdir + # this occurs when build/test performed in source dir and + # make cp fail + SDIR=`$DIRNAME $tstfile` + INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` + INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` + if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then + $CP -f $tstfile $TESTDIR + if [ $? -ne 0 ]; then + echo "Error: FAILED to copy $tstfile ." + + # Comment out this to CREATE expected file + exit $EXIT_FAILURE + fi fi fi done diff --git a/tools/h5ls/testh5ls.sh.in b/tools/h5ls/testh5ls.sh.in index 110c651..02819e2 100644 --- a/tools/h5ls/testh5ls.sh.in +++ b/tools/h5ls/testh5ls.sh.in @@ -26,6 +26,9 @@ CMP='cmp -s' DIFF='diff -c' CP='cp' NLINES=20 # Max. lines of output to display if test fails +DIRNAME='dirname' +LS='ls' +AWK='awk' WORDS_BIGENDIAN="@WORDS_BIGENDIAN@" @@ -167,12 +170,20 @@ COPY_TESTFILES_TO_TESTDIR() echo $tstfile | tr -d ' ' | grep '^#' > /dev/null RET=$? if [ $RET -eq 1 ]; then - if [ -a $tstfile ]; then - $CP -f $tstfile $TESTDIR - else - echo "Error: FAILED to copy $tstfile" - echo " $tstfile doesn't exist!" - exit $EXIT_FAILURE + # skip cp if srcdir is same as destdir + # this occurs when build/test performed in source dir and + # make cp fail + SDIR=`$DIRNAME $tstfile` + INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` + INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` + if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then + $CP -f $tstfile $TESTDIR + if [ $? -ne 0 ]; then + echo "Error: FAILED to copy $tstfile ." + + # Comment out this to CREATE expected file + exit $EXIT_FAILURE + fi fi fi done diff --git a/tools/h5repack/h5repack.sh.in b/tools/h5repack/h5repack.sh.in index e05b03f..b702152 100644 --- a/tools/h5repack/h5repack.sh.in +++ b/tools/h5repack/h5repack.sh.in @@ -42,6 +42,9 @@ H5DUMP_BIN=`pwd`/$H5DUMP # The path of the h5dump tool binary GREP='grep' CP='cp' +DIRNAME='dirname' +LS='ls' +AWK='awk' H5DETECTSZIP=testh5repack_detect_szip H5DETECTSZIP_BIN=`pwd`/$H5DETECTSZIP @@ -137,12 +140,20 @@ COPY_TESTFILES_TO_TESTDIR() echo $tstfile | tr -d ' ' | grep '^#' > /dev/null RET=$? if [ $RET -eq 1 ]; then - if [ -a $tstfile ]; then - $CP -f $tstfile $TESTDIR - else - echo "Error: FAILED to copy $tstfile" - echo " $tstfile doesn't exist!" - exit $EXIT_FAILURE + # skip cp if srcdir is same as destdir + # this occurs when build/test performed in source dir and + # make cp fail + SDIR=`$DIRNAME $tstfile` + INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` + INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` + if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then + $CP -f $tstfile $TESTDIR + if [ $? -ne 0 ]; then + echo "Error: FAILED to copy $tstfile ." + + # Comment out this to CREATE expected file + exit $EXIT_FAILURE + fi fi fi done diff --git a/tools/h5stat/testh5stat.sh.in b/tools/h5stat/testh5stat.sh.in index c594a97..0b00951 100644 --- a/tools/h5stat/testh5stat.sh.in +++ b/tools/h5stat/testh5stat.sh.in @@ -33,6 +33,9 @@ STAT_BIN=`pwd`/$STAT # The path of the tool binary CMP='cmp -s' DIFF='diff -c' CP='cp' +DIRNAME='dirname' +LS='ls' +AWK='awk' nerrors=0 verbose=yes @@ -106,12 +109,20 @@ COPY_TESTFILES_TO_TESTDIR() echo $tstfile | tr -d ' ' | grep '^#' > /dev/null RET=$? if [ $RET -eq 1 ]; then - if [ -a $tstfile ]; then - $CP -f $tstfile $TESTDIR - else - echo "Error: FAILED to copy $tstfile" - echo " $tstfile doesn't exist!" - exit $EXIT_FAILURE + # skip cp if srcdir is same as destdir + # this occurs when build/test performed in source dir and + # make cp fail + SDIR=`$DIRNAME $tstfile` + INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` + INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` + if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then + $CP -f $tstfile $TESTDIR + if [ $? -ne 0 ]; then + echo "Error: FAILED to copy $tstfile ." + + # Comment out this to CREATE expected file + exit $EXIT_FAILURE + fi fi fi done diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index bcd63f1..0c1f3d3 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -1411,14 +1411,6 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; busyTasks--; } /* end if */ - else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) - { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - havePrintToken = 1; - } /* end else-if */ else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 24aa81a..495aca1 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -1064,37 +1064,6 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) } /*------------------------------------------------------------------------- - * Function: do_bin_output - * - * Purpose: Dump memory buffer to a binary file stream - * - * Return: Success: SUCCEED - * Failure: FAIL - *------------------------------------------------------------------------- - */ -int -do_bin_output(FILE *stream, FILE *err_stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem) -{ - HERR_INIT(int, SUCCEED) - unsigned char *mem = (unsigned char*)_mem; - size_t size; /* datum size */ - hsize_t i; /* element counter */ - - if((size = H5Tget_size(tid)) == 0) - H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); - - for (i = 0; i < nelmts; i++) { - if (render_bin_output(stream, container, tid, mem + i * size) < 0) { - HDfprintf(err_stream,"\nError in writing binary stream\n"); - return FAIL; - } - } - -CATCH - return ret_value; -} - -/*------------------------------------------------------------------------- * Function: render_bin_output * * Purpose: Write one element of memory buffer to a binary file stream @@ -1103,6 +1072,8 @@ CATCH * Failure: FAIL *------------------------------------------------------------------------- */ + +#ifdef DEBUG_H5DUMP_BIN int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) { @@ -1124,44 +1095,27 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) #if H5_SIZEOF_LONG_DOUBLE !=0 long double templdouble; #endif -#ifdef DEBUG_H5DUMP_BIN static char fmt_llong[8], fmt_ullong[8]; if (!fmt_llong[0]) { HDsprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); HDsprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); } -#endif if((size = H5Tget_size(tid)) == 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); if (H5Tequal(tid, H5T_NATIVE_FLOAT)) { HDmemcpy(&tempfloat, mem, sizeof(float)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%g ", tempfloat); -#else - if (1 != HDfwrite(&tempfloat, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) { HDmemcpy(&tempdouble, mem, sizeof(double)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%g ", tempdouble); -#else - if (1 != HDfwrite(&tempdouble, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } #if H5_SIZEOF_LONG_DOUBLE !=0 else if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) { HDmemcpy(&templdouble, mem, sizeof(long double)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%Lf ", templdouble); -#else - if (1 != HDfwrite(&templdouble, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } #endif else if (H5T_STRING == H5Tget_class(tid)) { @@ -1183,160 +1137,75 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) } for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%d", tempuchar); -#else - if (1 != HDfwrite(&tempuchar, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } /* i */ } else if (H5Tequal(tid, H5T_NATIVE_INT)) { HDmemcpy(&tempint, mem, sizeof(int)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%d ", tempint); -#else - if (1 != HDfwrite(&tempint, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_UINT)) { HDmemcpy(&tempuint, mem, sizeof(unsigned int)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%u ", tempuint); -#else - if (1 != HDfwrite(&tempuint, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_SCHAR)) { HDmemcpy(&tempschar, mem, sizeof(char)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%d ", tempschar); -#else - if (1 != HDfwrite(&tempschar, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_UCHAR)) { HDmemcpy(&tempuchar, mem, sizeof(unsigned char)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%u ", tempuchar); -#else - if (1 != HDfwrite(&tempuchar, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_SHORT)) { HDmemcpy(&tempshort, mem, sizeof(short)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%d ", tempshort); -#else - if (1 != HDfwrite(&tempshort, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_USHORT)) { HDmemcpy(&tempushort, mem, sizeof(unsigned short)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%u ", tempushort); -#else - if (1 != HDfwrite(&tempushort, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_LONG)) { HDmemcpy(&templong, mem, sizeof(long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%ld ", templong); -#else - if (1 != HDfwrite(&templong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_ULONG)) { HDmemcpy(&tempulong, mem, sizeof(unsigned long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%lu ", tempulong); -#else - if (1 != HDfwrite(&tempulong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_LLONG)) { HDmemcpy(&templlong, mem, sizeof(long long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, fmt_llong, templlong); -#else - if (1 != HDfwrite(&templlong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_ULLONG)) { HDmemcpy(&tempullong, mem, sizeof(unsigned long long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, fmt_ullong, tempullong); -#else - if (1 != HDfwrite(&tempullong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (H5Tequal(tid, H5T_NATIVE_HSSIZE)) { if (sizeof(hssize_t) == sizeof(int)) { HDmemcpy(&tempint, mem, sizeof(int)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%d ", tempint); -#else - if (1 != HDfwrite(&tempint, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (sizeof(hssize_t) == sizeof(long)) { HDmemcpy(&templong, mem, sizeof(long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%ld ", templong); -#else - if (1 != HDfwrite(&templong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else { HDmemcpy(&templlong, mem, sizeof(long long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, fmt_llong, templlong); -#else - if (1 != HDfwrite(&templlong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } } else if (H5Tequal(tid, H5T_NATIVE_HSIZE)) { if (sizeof(hsize_t) == sizeof(int)) { HDmemcpy(&tempuint, mem, sizeof(unsigned int)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%u ", tempuint); -#else - if (1 != HDfwrite(&tempuint, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else if (sizeof(hsize_t) == sizeof(long)) { HDmemcpy(&tempulong, mem, sizeof(unsigned long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%lu ", tempulong); -#else - if (1 != HDfwrite(&tempulong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else { HDmemcpy(&tempullong, mem, sizeof(unsigned long long)); -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, fmt_ullong, tempullong); -#else - if (1 != HDfwrite(&tempullong, size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } } else if (H5Tget_class(tid) == H5T_COMPOUND) { @@ -1360,21 +1229,11 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) else if (H5Tget_class(tid) == H5T_ENUM) { unsigned int i; if (1 == size) { -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "0x%02x", mem[0]); -#else - if (1 != HDfwrite(&mem[0], size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else { for (i = 0; i < size; i++) { -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%s%02x", i?":":"", mem[i]); -#else - if (1 != HDfwrite(&mem[i], sizeof(char), 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } /*i*/ }/*else 1 */ } @@ -1450,21 +1309,11 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) else { size_t i; if (1 == size) { -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "0x%02x", mem[0]); -#else - if (1 != HDfwrite(&mem[0], size, 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } else { for (i = 0; i < size; i++) { -#ifdef DEBUG_H5DUMP_BIN HDfprintf(stream, "%s%02x", i?":":"", mem[i]); -#else - if (1 != HDfwrite(&mem[i], sizeof(char), 1, stream)) - H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); -#endif } /*i*/ }/*else 1 */ } @@ -1472,6 +1321,190 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem) CATCH return ret_value; } +#else +int +render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts) +{ + HERR_INIT(int, SUCCEED) + unsigned char *mem = (unsigned char*)_mem; + size_t size; /* datum size */ + hsize_t block_index; + H5T_class_t type_class; + + if((size = H5Tget_size(tid)) == 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + + if((type_class = H5Tget_class(tid)) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed"); + + switch (type_class) { + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_ENUM: + block_index = block_nelmts * size; + while(block_index > 0) { + size_t bytes_in = 0; /* # of bytes to write */ + size_t bytes_wrote = 0; /* # of bytes written */ + size_t item_size = size; /* size of items in bytes */ + + if(block_index > sizeof(size_t)) + bytes_in = sizeof(size_t); + else + bytes_in = (size_t)block_index; + + bytes_wrote = HDfwrite(mem, 1, bytes_in, stream); + + if(bytes_wrote != bytes_in || (0 == bytes_wrote && HDferror(stream))) + H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); + + block_index -= (hsize_t)bytes_wrote; + mem = mem + bytes_wrote; + } + break; + case H5T_STRING: + { + unsigned int i; + H5T_str_t pad; + char *s; + unsigned char tempuchar; + + pad = H5Tget_strpad(tid); + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + + if (H5Tis_variable_str(tid)) { + s = *(char**) mem; + if (s != NULL) + size = HDstrlen(s); + } + else { + s = (char *) mem; + } + for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { + HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); + if (1 != HDfwrite(&tempuchar, size, 1, stream)) + H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); + } /* i */ + } /* for (block_index = 0; block_index < block_nelmts; block_index++) */ + } + break; + case H5T_COMPOUND: + { + unsigned j; + hid_t memb; + unsigned nmembs; + size_t offset; + + nmembs = H5Tget_nmembers(tid); + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + for (j = 0; j < nmembs; j++) { + offset = H5Tget_member_offset(tid, j); + memb = H5Tget_member_type(tid, j); + + if (render_bin_output(stream, container, memb, mem + offset, 1) < 0) + return FAIL; + + H5Tclose(memb); + } + } + } + break; + case H5T_ARRAY: + { + int k, ndims; + hsize_t i, dims[H5S_MAX_RANK], temp_nelmts, nelmts; + hid_t memb; + + /* get the array's base datatype for each element */ + memb = H5Tget_super(tid); + ndims = H5Tget_array_ndims(tid); + H5Tget_array_dims2(tid, dims); + HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK); + + /* calculate the number of array elements */ + for (k = 0, nelmts = 1; k < ndims; k++) { + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + nelmts = (size_t) temp_nelmts; + } + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + /* dump the array element */ + if (render_bin_output(stream, container, memb, mem, nelmts) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed"); + } + H5Tclose(memb); + } + break; + case H5T_VLEN: + { + unsigned int i; + hsize_t nelmts; + hid_t memb; + + /* get the VL sequences's base datatype for each element */ + memb = H5Tget_super(tid); + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + /* Get the number of sequence elements */ + nelmts = ((hvl_t *) mem)->len; + + /* dump the array element */ + if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)), nelmts) < 0) + H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed"); + } + H5Tclose(memb); + } + break; + case H5T_REFERENCE: + { + if (H5Tequal(tid, H5T_STD_REF_DSETREG)) { + if (region_output) { + /* region data */ + hid_t region_id, region_space; + H5S_sel_type region_type; + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, mem); + if (region_id >= 0) { + region_space = H5Rget_region(container, H5R_DATASET_REGION, mem); + if (region_space >= 0) { + region_type = H5Sget_select_type(region_space); + if(region_type == H5S_SEL_POINTS) + render_bin_output_region_points(region_space, region_id, stream, container); + else + render_bin_output_region_blocks(region_space, region_id, stream, container); + H5Sclose(region_space); + } /* end if (region_space >= 0) */ + H5Dclose(region_id); + } /* end if (region_id >= 0) */ + } + } /* end if (region_output... */ + } + else if (H5Tequal(tid, H5T_STD_REF_OBJ)) { + ; + } + } + break; + default: + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + if (size != HDfwrite(mem, sizeof(char), size, stream)) + H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); + } + break; + } + +CATCH + return ret_value; +} +#endif /*------------------------------------------------------------------------- * Audience: Public @@ -1552,12 +1585,8 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); - for (numindex = 0; numindex < numelem; numindex++) { - - render_bin_output(stream, container, type_id, - ((char*)region_buf + numindex * type_size)); - /* Render the region data element end */ - } /* end for (jndx = 0; jndx < numelem; jndx++) */ + render_bin_output(stream, container, type_id, (char*)region_buf, numelem); + /* Render the region data element end */ } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ done: @@ -1684,12 +1713,10 @@ render_bin_output_region_data_points(hid_t region_space, hid_t region_id, if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); - for (jndx = 0; jndx < npoints; jndx++) { - if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); - render_bin_output(stream, container, type_id, ((char*)region_buf + jndx * type_size)); - } /* end for (jndx = 0; jndx < npoints; jndx++) */ + render_bin_output(stream, container, type_id, (char*)region_buf, npoints); done: HDfree(region_buf); diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 0f4b271..3e3a4cf 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -560,8 +560,7 @@ H5TOOLS_DLL void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *i H5TOOLS_DLL void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum); -H5TOOLS_DLL int do_bin_output(FILE *stream, FILE *err_stream, hid_t container, hsize_t nelmts, hid_t tid, void *_mem); -H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem); +H5TOOLS_DLL int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t nelmts); H5TOOLS_DLL int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata); H5TOOLS_DLL hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id, diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 0c0a49f..c2add9a 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -282,7 +282,9 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai /* binary dump */ if (bin_output) { - do_bin_output(rawdatastream, rawoutstream, container, nelmts, type, _mem); + if (render_bin_output(rawdatastream, container, type, _mem, nelmts) < 0) { + HDfprintf(rawoutstream,"\nError in writing binary stream\n"); + } } /* end if */ else { /* setup */ diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 0de126d..1646351 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -693,6 +693,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai unsigned nmembs; static char fmt_llong[8], fmt_ullong[8]; H5T_str_t pad; + H5T_class_t type_class; /* * some tempvars to store the value before we append it to the string to @@ -729,480 +730,494 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } } } - else if (H5Tequal(type, H5T_NATIVE_FLOAT)) { - float tempfloat; + else { + if((type_class = H5Tget_class(type)) < 0) + return NULL; + switch (type_class) { + case H5T_FLOAT: + if (H5Tequal(type, H5T_NATIVE_FLOAT)) { + float tempfloat; - HDmemcpy(&tempfloat, vp, sizeof(float)); - h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat); - } - else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { - double tempdouble; + HDmemcpy(&tempfloat, vp, sizeof(float)); + h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat); + } + else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { + double tempdouble; - HDmemcpy(&tempdouble, vp, sizeof(double)); - h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); + HDmemcpy(&tempdouble, vp, sizeof(double)); + h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); #if H5_SIZEOF_LONG_DOUBLE !=0 - } - else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) { - long double templdouble; + } + else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) { + long double templdouble; - HDmemcpy(&templdouble, vp, sizeof(long double)); - h5tools_str_append(str, "%Lf", templdouble); + HDmemcpy(&templdouble, vp, sizeof(long double)); + h5tools_str_append(str, "%Lf", templdouble); #endif - } - else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || - H5Tequal(type, H5T_NATIVE_UCHAR))) { - h5tools_print_char(str, info, (char) (*ucp_vp)); - } - else if (H5T_STRING == H5Tget_class(type)) { - unsigned int i; - char quote = '\0'; - char *s; - - quote = '\0'; - if (H5Tis_variable_str(type)) { - /* cp_vp is the pointer into the struct where a `char*' is stored. So we have - * to dereference the pointer to get the `char*' to pass to HDstrlen(). */ - s = *(char**) cp_vp; - if (s != NULL) - size = HDstrlen(s); - } - else { - s = cp_vp; - size = H5Tget_size(type); - } - pad = H5Tget_strpad(type); - - /* Check for NULL pointer for string */ - if (s == NULL) { - h5tools_str_append(str, "NULL"); - } - else { - for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { - int j = 1; - - /* - * Count how many times the next character repeats. If the - * threshold is zero then that means it can repeat any number - * of times. - */ - if (info->str_repeat > 0) - while (i + j < size && s[i] == s[i + j]) - j++; - - /* - * Print the opening quote. If the repeat count is high enough to - * warrant printing the number of repeats instead of enumerating - * the characters, then make sure the character to be repeated is - * in it's own quote. - */ - if (info->str_repeat > 0 && j > info->str_repeat) { - if (quote) - h5tools_str_append(str, "%c", quote); - - quote = '\''; - h5tools_str_append(str, "%s%c", i ? " " : "", quote); } - else if (!quote) { - quote = '"'; - h5tools_str_append(str, "%s%c", i ? " " : "", quote); - } - - /* Print the character */ - h5tools_print_char(str, info, s[i]); + break; + case H5T_STRING: + { + unsigned int i; + char quote = '\0'; + char *s; - /* Print the repeat count */ - if (info->str_repeat && j > info->str_repeat) { + quote = '\0'; + if (H5Tis_variable_str(type)) { + /* cp_vp is the pointer into the struct where a `char*' is stored. So we have + * to dereference the pointer to get the `char*' to pass to HDstrlen(). */ + s = *(char**) cp_vp; + if (s != NULL) size = HDstrlen(s); + } + else { + s = cp_vp; + size = H5Tget_size(type); + } + pad = H5Tget_strpad(type); + + /* Check for NULL pointer for string */ + if (s == NULL) { + h5tools_str_append(str, "NULL"); + } + else { + for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { + int j = 1; + + /* + * Count how many times the next character repeats. If the + * threshold is zero then that means it can repeat any number + * of times. + */ + if (info->str_repeat > 0) while (i + j < size && s[i] == s[i + j]) + j++; + + /* + * Print the opening quote. If the repeat count is high enough to + * warrant printing the number of repeats instead of enumerating + * the characters, then make sure the character to be repeated is + * in it's own quote. + */ + if (info->str_repeat > 0 && j > info->str_repeat) { + if (quote) h5tools_str_append(str, "%c", quote); + + quote = '\''; + h5tools_str_append(str, "%s%c", i ? " " : "", quote); + } + else if (!quote) { + quote = '"'; + h5tools_str_append(str, "%s%c", i ? " " : "", quote); + } + + /* Print the character */ + h5tools_print_char(str, info, s[i]); + + /* Print the repeat count */ + if (info->str_repeat && j > info->str_repeat) { #ifdef REPEAT_VERBOSE - h5tools_str_append(str, "%c repeats %d times", quote, j - 1); + h5tools_str_append(str, "%c repeats %d times", quote, j - 1); #else - h5tools_str_append(str, "%c*%d", quote, j - 1); + h5tools_str_append(str, "%c*%d", quote, j - 1); #endif /* REPEAT_VERBOSE */ - quote = '\0'; - i += j - 1; - } + quote = '\0'; + i += j - 1; + } - } + } - if (quote) - h5tools_str_append(str, "%c", quote); + if (quote) h5tools_str_append(str, "%c", quote); - if (i == 0) - /*empty string*/ - h5tools_str_append(str, "\"\""); - } /* end else */ - } - else if (H5Tequal(type, H5T_NATIVE_INT)) { - HDmemcpy(&tempint, vp, sizeof(int)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(int)) - tempint = 0; - else - tempint = (tempint >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); - } - else if (H5Tequal(type, H5T_NATIVE_UINT)) { - HDmemcpy(&tempuint, vp, sizeof(unsigned int)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(unsigned int)) - tempuint = 0; - else - tempuint = (tempuint >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); - } - else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { - signed char tempchar; - HDmemcpy(&tempchar, cp_vp, sizeof(char)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(char)) - tempchar = 0; - else - tempchar = (tempchar >> packed_data_offset) & packed_data_mask; - } + if (i == 0) + /*empty string*/ + h5tools_str_append(str, "\"\""); + } /* end else */ + } + break; + case H5T_INTEGER: + if (H5Tequal(type, H5T_NATIVE_INT)) { + HDmemcpy(&tempint, vp, sizeof(int)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(int)) + tempint = 0; + else + tempint = (tempint >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); + } + else if (H5Tequal(type, H5T_NATIVE_UINT)) { + HDmemcpy(&tempuint, vp, sizeof(unsigned int)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned int)) + tempuint = 0; + else + tempuint = (tempuint >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); + } + else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) { + h5tools_print_char(str, info, (char) (*ucp_vp)); + } + else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { + signed char tempchar; + HDmemcpy(&tempchar, cp_vp, sizeof(char)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(char)) + tempchar = 0; + else + tempchar = (tempchar >> packed_data_offset) & packed_data_mask; + } #ifdef H5_VMS - h5tools_str_append(str, OPT(info->fmt_schar, "%hd"), tempchar); + h5tools_str_append(str, OPT(info->fmt_schar, "%hd"), tempchar); #else - h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), tempchar); + h5tools_str_append(str, OPT(info->fmt_schar, "%hhd"), tempchar); #endif - } - else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { - unsigned char tempuchar; - HDmemcpy(&tempuchar, ucp_vp, sizeof(unsigned char)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(unsigned char)) - tempuchar = 0; - else - tempuchar = (tempuchar >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), tempuchar); - } - else if (H5Tequal(type, H5T_NATIVE_SHORT)) { - short tempshort; - - HDmemcpy(&tempshort, vp, sizeof(short)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(short)) - tempshort = 0; - else - tempshort = (tempshort >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort); - } - else if (H5Tequal(type, H5T_NATIVE_USHORT)) { - unsigned short tempushort; - - HDmemcpy(&tempushort, vp, sizeof(unsigned short)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(unsigned short)) - tempushort = 0; - else - tempushort = (tempushort >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort); - } - else if (H5Tequal(type, H5T_NATIVE_LONG)) { - HDmemcpy(&templong, vp, sizeof(long)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(long)) - templong = 0; - else - templong = (templong >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); - } - else if (H5Tequal(type, H5T_NATIVE_ULONG)) { - HDmemcpy(&tempulong, vp, sizeof(unsigned long)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(unsigned long)) - tempulong = 0; - else - tempulong = (tempulong >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); - } - else if (H5Tequal(type, H5T_NATIVE_LLONG)) { - HDmemcpy(&templlong, vp, sizeof(long long)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(long long)) - templlong = 0; - else - templlong = (templlong >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); - } - else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { - HDmemcpy(&tempullong, vp, sizeof(unsigned long long)); - if(packed_bits_num) { - if(packed_data_offset >= 8*sizeof(unsigned long long)) - tempullong = 0; - else - tempullong = (tempullong >> packed_data_offset) & packed_data_mask; - } - h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); - } - else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) { - if (sizeof(hssize_t) == sizeof(int)) { - HDmemcpy(&tempint, vp, sizeof(int)); - h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); - } - else if (sizeof(hssize_t) == sizeof(long)) { - HDmemcpy(&templong, vp, sizeof(long)); - h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); - } - else { - HDmemcpy(&templlong, vp, sizeof(long long)); - h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); - } - } - else if (H5Tequal(type, H5T_NATIVE_HSIZE)) { - if (sizeof(hsize_t) == sizeof(int)) { - HDmemcpy(&tempuint, vp, sizeof(unsigned int)); - h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); - } - else if (sizeof(hsize_t) == sizeof(long)) { - HDmemcpy(&tempulong, vp, sizeof(long)); - h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); - } - else { - HDmemcpy(&tempullong, vp, sizeof(unsigned long long)); - h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); - } - } - else if (H5Tget_class(type) == H5T_COMPOUND) { - unsigned j; - - nmembs = H5Tget_nmembers(type); - h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); + } + else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { + unsigned char tempuchar; + HDmemcpy(&tempuchar, ucp_vp, sizeof(unsigned char)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned char)) + tempuchar = 0; + else + tempuchar = (tempuchar >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), tempuchar); + } + else if (H5Tequal(type, H5T_NATIVE_SHORT)) { + short tempshort; + + HDmemcpy(&tempshort, vp, sizeof(short)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(short)) + tempshort = 0; + else + tempshort = (tempshort >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort); + } + else if (H5Tequal(type, H5T_NATIVE_USHORT)) { + unsigned short tempushort; + + HDmemcpy(&tempushort, vp, sizeof(unsigned short)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned short)) + tempushort = 0; + else + tempushort = (tempushort >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort); + } + else if (H5Tequal(type, H5T_NATIVE_LONG)) { + HDmemcpy(&templong, vp, sizeof(long)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(long)) + templong = 0; + else + templong = (templong >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); + } + else if (H5Tequal(type, H5T_NATIVE_ULONG)) { + HDmemcpy(&tempulong, vp, sizeof(unsigned long)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned long)) + tempulong = 0; + else + tempulong = (tempulong >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); + } + else if (H5Tequal(type, H5T_NATIVE_LLONG)) { + HDmemcpy(&templlong, vp, sizeof(long long)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(long long)) + templlong = 0; + else + templlong = (templlong >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); + } + else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { + HDmemcpy(&tempullong, vp, sizeof(unsigned long long)); + if (packed_bits_num) { + if (packed_data_offset >= 8 * sizeof(unsigned long long)) + tempullong = 0; + else + tempullong = (tempullong >> packed_data_offset) & packed_data_mask; + } + h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); + } + else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) { + if (sizeof(hssize_t) == sizeof(int)) { + HDmemcpy(&tempint, vp, sizeof(int)); + h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); + } + else if (sizeof(hssize_t) == sizeof(long)) { + HDmemcpy(&templong, vp, sizeof(long)); + h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); + } + else { + HDmemcpy(&templlong, vp, sizeof(long long)); + h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); + } + } + else if (H5Tequal(type, H5T_NATIVE_HSIZE)) { + if (sizeof(hsize_t) == sizeof(int)) { + HDmemcpy(&tempuint, vp, sizeof(unsigned int)); + h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); + } + else if (sizeof(hsize_t) == sizeof(long)) { + HDmemcpy(&tempulong, vp, sizeof(long)); + h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); + } + else { + HDmemcpy(&tempullong, vp, sizeof(unsigned long long)); + h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); + } + } + break; + case H5T_COMPOUND: + { + unsigned j; - ctx->indent_level++; + nmembs = H5Tget_nmembers(type); + h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{")); - for (j = 0; j < nmembs; j++) { - if (j) - h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", "OPTIONAL_LINE_BREAK)); - else - h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); + ctx->indent_level++; - if(info->arr_linebreak) - h5tools_str_indent(str, info, ctx); - - /* The name */ - name = H5Tget_member_name(type, j); - h5tools_str_append(str, OPT(info->cmpd_name, ""), name); - HDfree(name); + for (j = 0; j < nmembs; j++) { + if (j) + h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", "OPTIONAL_LINE_BREAK)); + else + h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); - /* The value */ - offset = H5Tget_member_offset(type, j); - memb = H5Tget_member_type(type, j); + if (info->arr_linebreak) h5tools_str_indent(str, info, ctx); - h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx); + /* The name */ + name = H5Tget_member_name(type, j); + h5tools_str_append(str, OPT(info->cmpd_name, ""), name); + HDfree(name); - H5Tclose(memb); - } - ctx->indent_level--; + /* The value */ + offset = H5Tget_member_offset(type, j); + memb = H5Tget_member_type(type, j); + h5tools_str_sprint(str, info, container, memb, cp_vp + offset, ctx); - if(info->arr_linebreak) { - h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); - h5tools_str_indent(str, info, ctx); - } - h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); + H5Tclose(memb); + } + ctx->indent_level--; - } - else if (H5Tget_class(type) == H5T_ENUM) { - char enum_name[1024]; + if (info->arr_linebreak) { + h5tools_str_append(str, "%s", OPT(info->cmpd_end, "")); + h5tools_str_indent(str, info, ctx); + } + h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}")); - if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0) { - h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name))); - } - else { - size_t i; - n = H5Tget_size(type); - if (1 == n) { - h5tools_str_append(str, "0x%02x", ucp_vp[0]); - } - else { - for (i = 0; i < n; i++) - h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); - } - } - } - else if (H5Tequal(type, H5T_STD_REF_DSETREG)) { - if (h5tools_str_is_zero(vp, H5Tget_size(type))) { - h5tools_str_append(str, "NULL"); - } - else { - h5tools_str_sprint_region(str, info, container, vp); - } - } - else if (H5Tequal(type, H5T_STD_REF_OBJ)) { - /* - * Object references -- show the type and OID of the referenced - * object. - */ - if (h5tools_str_is_zero(vp, H5Tget_size(type))) { - h5tools_str_append(str, "NULL"); - } - else { - H5O_info_t oi; - const char *path; - - obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp); - H5Oget_info(obj, &oi); - - /* Print object type and close object */ - switch (oi.type) { - case H5O_TYPE_GROUP: - h5tools_str_append(str, H5_TOOLS_GROUP); - break; - - case H5O_TYPE_DATASET: - h5tools_str_append(str, H5_TOOLS_DATASET); + } break; - - case H5O_TYPE_NAMED_DATATYPE: - h5tools_str_append(str, H5_TOOLS_DATATYPE); + case H5T_ENUM: + { + char enum_name[1024]; + + if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0) { + h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name))); + } + else { + size_t i; + n = H5Tget_size(type); + if (1 == n) { + h5tools_str_append(str, "0x%02x", ucp_vp[0]); + } + else { + for (i = 0; i < n; i++) + h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); + } + } + } break; - - default: - h5tools_str_append(str, "%u-", (unsigned) oi.type); + case H5T_REFERENCE: + if (H5Tequal(type, H5T_STD_REF_DSETREG)) { + if (h5tools_str_is_zero(vp, H5Tget_size(type))) { + h5tools_str_append(str, "NULL"); + } + else { + h5tools_str_sprint_region(str, info, container, vp); + } + } + else if (H5Tequal(type, H5T_STD_REF_OBJ)) { + /* + * Object references -- show the type and OID of the referenced + * object. + */ + if (h5tools_str_is_zero(vp, H5Tget_size(type))) { + h5tools_str_append(str, "NULL"); + } + else { + H5O_info_t oi; + const char *path; + + obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp); + H5Oget_info(obj, &oi); + + /* Print object type and close object */ + switch (oi.type) { + case H5O_TYPE_GROUP: + h5tools_str_append(str, H5_TOOLS_GROUP); + break; + + case H5O_TYPE_DATASET: + h5tools_str_append(str, H5_TOOLS_DATASET); + break; + + case H5O_TYPE_NAMED_DATATYPE: + h5tools_str_append(str, H5_TOOLS_DATATYPE); + break; + + default: + h5tools_str_append(str, "%u-", (unsigned) oi.type); + break; + } /* end switch */ + H5Oclose(obj); + + /* Print OID */ + if (info->obj_hidefileno) + h5tools_str_append(str, info->obj_format, oi.addr); + else + h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr); + + /* Print name */ + path = lookup_ref_path(*(haddr_t *) vp); + if (path) { + h5tools_str_append(str, " "); + h5tools_str_append(str, path); + h5tools_str_append(str, " "); + } /* end if */ + } /* end else */ + } break; - } /* end switch */ - H5Oclose(obj); - - /* Print OID */ - if (info->obj_hidefileno) - h5tools_str_append(str, info->obj_format, oi.addr); - else - h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr); - - /* Print name */ - path = lookup_ref_path(*(haddr_t *) vp); - if (path) { - h5tools_str_append(str, " "); - h5tools_str_append(str, path); - h5tools_str_append(str, " "); - } /* end if */ - } /* end else */ - } - else if (H5Tget_class(type) == H5T_ARRAY) { - int k, ndims; - hsize_t i, dims[H5S_MAX_RANK], temp_nelmts; - static int is_next_arry_elmt = 0; - - /* Get the array's base datatype for each element */ - memb = H5Tget_super(type); - size = H5Tget_size(memb); - ndims = H5Tget_array_ndims(type); - H5Tget_array_dims2(type, dims); - HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK); - - /* Calculate the number of array elements */ - for (k = 0, nelmts = 1; k < ndims; k++) { - temp_nelmts = nelmts; - temp_nelmts *= dims[k]; - HDassert(temp_nelmts == (hsize_t) ((size_t) temp_nelmts)); - nelmts = (size_t) temp_nelmts; - } - /* Print the opening bracket */ - h5tools_str_append(str, "%s", OPT(info->arr_pre, "[")); - - ctx->indent_level++; - - for (i = 0; i < nelmts; i++) { - if (i) - h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); - - if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) { - h5tools_str_append(str, "%s", "\n"); - h5tools_str_indent(str, info, ctx); - - } /* end if */ - else if (i && info->arr_sep) { - /* if next element begin, add next line with indent */ - if (is_next_arry_elmt) { - is_next_arry_elmt = 0; - - h5tools_str_append(str, "%s", "\n "); - h5tools_str_indent(str, info, ctx); - + case H5T_ARRAY: + { + int k, ndims; + hsize_t i, dims[H5S_MAX_RANK], temp_nelmts; + static int is_next_arry_elmt = 0; + + /* Get the array's base datatype for each element */ + memb = H5Tget_super(type); + size = H5Tget_size(memb); + ndims = H5Tget_array_ndims(type); + H5Tget_array_dims2(type, dims); + HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK); + + /* Calculate the number of array elements */ + for (k = 0, nelmts = 1; k < ndims; k++) { + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + HDassert(temp_nelmts == (hsize_t) ((size_t) temp_nelmts)); + nelmts = (size_t) temp_nelmts; + } + /* Print the opening bracket */ + h5tools_str_append(str, "%s", OPT(info->arr_pre, "[")); + + ctx->indent_level++; + + for (i = 0; i < nelmts; i++) { + if (i) h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); + + if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) { + h5tools_str_append(str, "%s", "\n"); + h5tools_str_indent(str, info, ctx); + + } /* end if */ + else if (i && info->arr_sep) { + /* if next element begin, add next line with indent */ + if (is_next_arry_elmt) { + is_next_arry_elmt = 0; + + h5tools_str_append(str, "%s", "\n "); + h5tools_str_indent(str, info, ctx); + + } + /* otherwise just add space */ + else + h5tools_str_append(str, " "); + + } /* end else if */ + + /* Dump values in an array element */ + is_next_arry_elmt = 0; /* dump all values in the array element, so turn it off */ + h5tools_str_sprint(str, info, container, memb, cp_vp + i * size, ctx); + } /* end for */ + + ctx->indent_level--; + + /* Print the closing bracket */ + h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); + is_next_arry_elmt = 1; /* set for begining of next array element */ + H5Tclose(memb); } - /* otherwise just add space */ - else - h5tools_str_append(str, " "); - - } /* end else if */ - - /* Dump values in an array element */ - is_next_arry_elmt = 0; /* dump all values in the array element, so turn it off */ - h5tools_str_sprint(str, info, container, memb, cp_vp + i * size, ctx); - } /* end for */ - - ctx->indent_level--; - - /* Print the closing bracket */ - h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); - is_next_arry_elmt = 1; /* set for begining of next array element */ - H5Tclose(memb); - } - else if (H5Tget_class(type) == H5T_VLEN) { - unsigned int i; + break; + case H5T_VLEN: + { + unsigned int i; - /* Get the VL sequences's base datatype for each element */ - memb = H5Tget_super(type); - size = H5Tget_size(memb); + /* Get the VL sequences's base datatype for each element */ + memb = H5Tget_super(type); + size = H5Tget_size(memb); - /* Print the opening bracket */ - h5tools_str_append(str, "%s", OPT(info->vlen_pre, "(")); + /* Print the opening bracket */ + h5tools_str_append(str, "%s", OPT(info->vlen_pre, "(")); - /* Get the number of sequence elements */ - nelmts = ((hvl_t *) cp_vp)->len; + /* Get the number of sequence elements */ + nelmts = ((hvl_t *) cp_vp)->len; - for (i = 0; i < nelmts; i++) { - if (i) - h5tools_str_append(str, "%s", OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK)); + for (i = 0; i < nelmts; i++) { + if (i) h5tools_str_append(str, "%s", OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK)); #ifdef LATER - /* Need to fix so VL data breaks at correct location on end of line -QAK */ - if (info->arr_linebreak && h5tools_str_len(str)>=info->line_ncols) { - int x; + /* Need to fix so VL data breaks at correct location on end of line -QAK */ + if (info->arr_linebreak && h5tools_str_len(str)>=info->line_ncols) { + int x; - h5tools_str_append(str, "%s", "\n"); + h5tools_str_append(str, "%s", "\n"); - /* need to indent some more here */ - if (ctx->indent_level >= 0) - h5tools_str_append(str, "%s", OPT(info->line_pre, "")); + /* need to indent some more here */ + if (ctx->indent_level >= 0) + h5tools_str_append(str, "%s", OPT(info->line_pre, "")); - for (x = 0; x < ctx->indent_level + 1; x++) - h5tools_str_append(str,"%s",OPT(info->line_indent,"")); - } /* end if */ + for (x = 0; x < ctx->indent_level + 1; x++) + h5tools_str_append(str,"%s",OPT(info->line_indent,"")); + } /* end if */ #endif /* LATER */ - ctx->indent_level++; + ctx->indent_level++; - /* Dump the array element */ - h5tools_str_sprint(str, info, container, memb, - ((char *) (((hvl_t *) cp_vp)->p)) + i * size, ctx); + /* Dump the array element */ + h5tools_str_sprint(str, info, container, memb, ((char *) (((hvl_t *) cp_vp)->p)) + i * size, ctx); - ctx->indent_level--; - } /* end for */ + ctx->indent_level--; + } /* end for */ - h5tools_str_append(str, "%s", OPT(info->vlen_suf, ")")); - H5Tclose(memb); - } - else { - /* All other types get printed as hexadecimal */ - size_t i; - n = H5Tget_size(type); - if (1 == n) { - h5tools_str_append(str, "0x%02x", ucp_vp[0]); - } - else { - for (i = 0; i < n; i++) - h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); - } - } + h5tools_str_append(str, "%s", OPT(info->vlen_suf, ")")); + H5Tclose(memb); + } + break; + default: + { + /* All other types get printed as hexadecimal */ + size_t i; + n = H5Tget_size(type); + if (1 == n) { + h5tools_str_append(str, "0x%02x", ucp_vp[0]); + } + else { + for (i = 0; i < n; i++) + h5tools_str_append(str, "%s%02x", i ? ":" : "", ucp_vp[i]); + } + } + break; + } /* end switch */ + } return h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s")); } |