diff options
-rw-r--r-- | fortran/src/CMakeLists.txt | 72 | ||||
-rw-r--r-- | fortran/test/CMakeLists.txt | 72 | ||||
-rw-r--r-- | hl/fortran/src/CMakeLists.txt | 66 | ||||
-rw-r--r-- | java/src/jni/h5pImp.c | 12 | ||||
-rw-r--r-- | java/src/jni/h5util.c | 18 | ||||
-rw-r--r-- | src/H5Odtype.c | 3 | ||||
-rw-r--r-- | src/H5Znbit.c | 99 | ||||
-rw-r--r-- | tools/h5ls/CMakeTests.cmake | 1 | ||||
-rw-r--r-- | tools/h5ls/CMakeTestsVDS.cmake | 3 |
9 files changed, 228 insertions, 118 deletions
diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 278f814..d4ca791 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -93,6 +93,8 @@ add_custom_command ( WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} DEPENDS H5match_types ) +set_source_files_properties (${HDF5_F90_BINARY_DIR}/H5f90i_gen.h PROPERTIES GENERATED TRUE) +set_source_files_properties (${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 PROPERTIES GENERATED TRUE) #----------------------------------------------------------------------------- # f90CStub lib @@ -115,7 +117,6 @@ set (f90CStub_C_SOURCES ${HDF5_F90_SRC_SOURCE_DIR}/H5Tf.c ${HDF5_F90_SRC_SOURCE_DIR}/H5Zf.c ) - set_source_files_properties (${f90CStub_C_SOURCES} PROPERTIES LANGUAGE C) set (f90CStub_C_HDRS @@ -154,10 +155,40 @@ endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) #----------------------------------------------------------------------------- # Fortran Modules #----------------------------------------------------------------------------- -set (f90_F_BASE_SOURCES - # generated files - ${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 +set (f90_F_GEN_SOURCES + ${HDF5_F90_SRC_SOURCE_DIR}/H5Aff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Dff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Pff.F90 +) +set (CMD $<TARGET_FILE:H5_buildiface>) +add_custom_command ( + OUTPUT ${HDF5_F90_BINARY_DIR}/H5_gen.F90 + COMMAND ${CMD} + WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} + DEPENDS ${f90_F_GEN_SOURCES} + COMMENT "Generating the H5_gen.F90 file" +) +add_custom_target (H5gen ALL + DEPENDS ${HDF5_F90_BINARY_DIR}/H5_gen.F90 +) +set_source_files_properties (${HDF5_F90_BINARY_DIR}/H5_gen.F90 PROPERTIES GENERATED TRUE) + +if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + set (CMDSH $<TARGET_FILE:H5_buildiface>) + add_custom_command ( + OUTPUT ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 + COMMAND ${CMDSH} + WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/shared + DEPENDS ${f90_F_GEN_SOURCES} + COMMENT "Generating the H5_gen.F90 shared file" + ) + add_custom_target (H5genSH ALL + DEPENDS ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 + ) + set_source_files_properties (${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 PROPERTIES GENERATED TRUE) +endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) +set (f90_F_BASE_SOURCES # normal distribution ${HDF5_F90_SRC_SOURCE_DIR}/H5f90global.F90 ${HDF5_F90_SRC_SOURCE_DIR}/H5fortkit.F90 @@ -177,8 +208,10 @@ set (f90_F_BASE_SOURCES ${HDF5_F90_SRC_SOURCE_DIR}/H5Zff.F90 ) -set_source_files_properties (${HDF5_F90_BINARY_DIR}/H5_gen.F90 PROPERTIES GENERATED TRUE) set (f90_F_SOURCES + # generated file + ${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 + ${f90_F_BASE_SOURCES} # generated file @@ -188,11 +221,13 @@ set (f90_F_SOURCES ${HDF5_F90_SRC_SOURCE_DIR}/HDF5.F90 ) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - set_source_files_properties (${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 PROPERTIES GENERATED TRUE) set (f90_F_SOURCES_SHARED + # generated file + ${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 + ${f90_F_BASE_SOURCES} - # generated file + # generated file ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 # normal distribution @@ -200,27 +235,6 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) ) endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - -set (CMD $<TARGET_FILE:H5_buildiface>) -add_custom_target (H5gen ALL - COMMAND ${CMD} -#v3.2 BYPRODUCT ${HDF5_F90_BINARY_DIR}/H5_gen.F90 - WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} - DEPENDS ${f90_F_BASE_SOURCES} -) -set_source_files_properties (${f90_F_SOURCES} PROPERTIES LANGUAGE Fortran) - -if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - add_custom_target (H5genSH ALL - COMMAND ${CMD} - #v3.2 BYPRODUCT ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 - WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/shared - DEPENDS ${f90_F_BASE_SOURCES} - ) - set_source_files_properties (${f90_F_SOURCES_SHARED} PROPERTIES LANGUAGE Fortran) -endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - - #----------------------------------------------------------------------------- # Add Main fortran library #----------------------------------------------------------------------------- @@ -245,6 +259,7 @@ if (WIN32) ) endif (WIN32) set (install_targets ${install_targets} ${HDF5_F90_LIB_TARGET}) +add_dependencies(${HDF5_F90_LIB_TARGET} H5gen) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) add_library (${HDF5_F90_LIBSH_TARGET} SHARED ${f90_F_SOURCES_SHARED}) @@ -273,6 +288,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) ) endif (WIN32) set (install_targets ${install_targets} ${HDF5_F90_LIBSH_TARGET}) + add_dependencies(${HDF5_F90_LIBSH_TARGET} H5genSH) endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) #----------------------------------------------------------------------------- diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index d1ca6e8..219f937 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -32,13 +32,19 @@ set_target_properties (H5_test_buildiface PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} ) -if (NOT SKIP_HDF5_FORTRAN_SHARED) +if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + file (MAKE_DIRECTORY "${HDF5_F90_BINARY_DIR}/shared") if (WIN32) - set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static/\${BUILD_TYPE}) + set (MODSH_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared/\${BUILD_TYPE}) else (WIN32) - set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static) + set (MODSH_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) endif (WIN32) -endif (NOT SKIP_HDF5_FORTRAN_SHARED) +endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) +if (WIN32) + set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static/\${BUILD_TYPE}) +else (WIN32) + set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static) +endif (WIN32) INCLUDE_DIRECTORIES (${CMAKE_Fortran_MODULE_DIRECTORY} ${MOD_BUILD_DIR}) @@ -75,29 +81,54 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) ) endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) -set (HDF5_F90_TF_SOURCES - # generated files - ${HDF5_F90_BINARY_DIR}/tf_gen.F90 -) -set_source_files_properties ( - ${HDF5_F90_BINARY_DIR}/tf_gen.F90 - PROPERTIES GENERATED TRUE -) -set_source_files_properties (tf.F90 ${HDF5_F90_BINARY_DIR}/${HDF5_F90_TF_SOURCES} PROPERTIES LANGUAGE Fortran) - set (CMD $<TARGET_FILE:H5_test_buildiface>) -add_custom_target (H5testgen ALL +add_custom_command ( + OUTPUT ${HDF5_F90_BINARY_DIR}/tf_gen.F90 COMMAND ${CMD} -#v3.2 BYPRODUCT ${HDF5_F90_BINARY_DIR}/tf_gen.F90 WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} DEPENDS H5_test_buildiface + COMMENT "Generating the tf_gen.F90 file" ) +add_custom_target (H5testgen ALL + DEPENDS ${HDF5_F90_BINARY_DIR}/tf_gen.F90 +) +set_source_files_properties (${HDF5_F90_BINARY_DIR}/tf_gen.F90 PROPERTIES GENERATED TRUE) -add_library (${HDF5_F90_TEST_LIB_TARGET} STATIC tf.F90 ${HDF5_F90_TF_SOURCES}) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - add_library (${HDF5_F90_TEST_LIBSH_TARGET} SHARED tf.F90 ${HDF5_F90_TF_SOURCES}) + set (CMDSH $<TARGET_FILE:H5_test_buildiface>) + add_custom_command ( + OUTPUT ${HDF5_F90_BINARY_DIR}/shared/tf_gen.F90 + COMMAND ${CMDSH} + WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/shared + DEPENDS H5_test_buildiface + COMMENT "Generating the tf_gen.F90 shared file" + ) + add_custom_target (H5testgenSH ALL + DEPENDS ${HDF5_F90_BINARY_DIR}/shared/tf_gen.F90 + ) + set_source_files_properties (${HDF5_F90_BINARY_DIR}/shared/tf_gen.F90 PROPERTIES GENERATED TRUE) +endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + +set (HDF5_F90_TF_SOURCES + # generated files + ${HDF5_F90_BINARY_DIR}/tf_gen.F90 + + # normal distribution + tf.F90 +) +set_source_files_properties (${HDF5_F90_TF_SOURCES} PROPERTIES LANGUAGE Fortran) +if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + set (HDF5_F90_TF_SOURCES_SHARED + # generated file + ${HDF5_F90_BINARY_DIR}/shared/tf_gen.F90 + + # normal distribution + tf.F90 + ) + set_source_files_properties (${HDF5_F90_TF_SOURCES_SHARED} PROPERTIES LANGUAGE Fortran) endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) +add_library (${HDF5_F90_TEST_LIB_TARGET} STATIC ${HDF5_F90_TF_SOURCES}) TARGET_FORTRAN_PROPERTIES (${HDF5_F90_TEST_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_C_TEST_LIB_TARGET} @@ -117,7 +148,10 @@ if (WIN32) COMPILE_DEFINITIONS "HDF5F90_WINDOWS" ) endif (WIN32) +add_dependencies(${HDF5_F90_TEST_LIB_TARGET} H5testgen) + if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + add_library (${HDF5_F90_TEST_LIBSH_TARGET} SHARED ${HDF5_F90_TF_SOURCES_SHARED}) set (SHARED_LINK_FLAGS " ") if (WIN32 AND MSVC) set (SHARED_LINK_FLAGS "/DLL") @@ -143,6 +177,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) COMPILE_DEFINITIONS "BUILD_HDF5_TEST_DLL;HDF5F90_WINDOWS" ) endif (WIN32) + add_dependencies(${HDF5_F90_TEST_LIBSH_TARGET} H5testgenSH) endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) #----------------------------------------------------------------------------- @@ -327,6 +362,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) if (WIN32 AND MSVC) target_link_libraries (fortranlib_test_F03-shared "ws2_32.lib") endif (WIN32 AND MSVC) + target_include_directories (fortranlib_test_F03-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) set_target_properties (fortranlib_test_F03-shared PROPERTIES LINKER_LANGUAGE Fortran diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index 6419ab8..774aa7c 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -37,6 +37,7 @@ set_target_properties (H5HL_buildiface PROPERTIES ) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + file (MAKE_DIRECTORY "${HDF5_HL_F90_SRC_BINARY_DIR}/shared") if (WIN32) set (MODSH_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared/\${BUILD_TYPE}) else (WIN32) @@ -111,30 +112,61 @@ set (HDF5_HL_F90_F_BASE_SOURCES ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5LTff.F90 ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5IMff.F90 ) -set (HDF5_HL_F90_F_SOURCES - ${HDF5_HL_F90_F_BASE_SOURCES} - # generated files - ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 - ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 +set (CMD $<TARGET_FILE:H5HL_buildiface>) +add_custom_command ( + OUTPUT ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 + COMMAND ${CMD} + WORKING_DIRECTORY ${HDF5_HL_F90_SRC_BINARY_DIR} + DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} + COMMENT "Generating the H5LTff_gen.F90, H5TBff_gen.F90 files" +) +add_custom_target (H5HLgen ALL + DEPENDS ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 ) - -set_source_files_properties (${HDF5_HL_F90_F_SOURCES} PROPERTIES LANGUAGE Fortran) - set_source_files_properties ( ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 PROPERTIES GENERATED TRUE ) +if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + set (CMDSH $<TARGET_FILE:H5HL_buildiface>) + add_custom_command ( + OUTPUT ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90 + COMMAND ${CMD} + WORKING_DIRECTORY ${HDF5_HL_F90_SRC_BINARY_DIR}/shared + DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} + COMMENT "Generating the H5LTff_gen.F90, H5TBff_gen.F90 shared files" + ) + add_custom_target (H5HLgenSH ALL + DEPENDS ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90 + ) + set_source_files_properties ( + ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90 + ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90 + PROPERTIES GENERATED TRUE + ) +endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) -set (CMD $<TARGET_FILE:H5HL_buildiface>) -add_custom_target (H5HLgen ALL - COMMAND ${CMD} -#v3.2 BYPRODUCT ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 -#v3.2 ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 - WORKING_DIRECTORY ${HDF5_HL_F90_SRC_BINARY_DIR} - DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} +set (HDF5_HL_F90_F_SOURCES + ${HDF5_HL_F90_F_BASE_SOURCES} + + # generated files + ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 + ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 ) +set_source_files_properties (${HDF5_HL_F90_F_SOURCES} PROPERTIES LANGUAGE Fortran) + +if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + set (HDF5_HL_F90_F_SOURCES_SHARED + ${HDF5_HL_F90_F_BASE_SOURCES} + + # generated files + ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90 + ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90 + ) + set_source_files_properties (${HDF5_HL_F90_F_SOURCES_SHARED} PROPERTIES LANGUAGE Fortran) +endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) add_library (${HDF5_HL_F90_LIB_TARGET} STATIC ${HDF5_HL_F90_F_SOURCES}) TARGET_FORTRAN_PROPERTIES (${HDF5_HL_F90_LIB_TARGET} STATIC " " " ") @@ -153,9 +185,10 @@ if (WIN32) ) endif (WIN32) set (install_targets ${install_targets} ${HDF5_HL_F90_LIB_TARGET}) +add_dependencies(${HDF5_HL_F90_LIB_TARGET} H5HLgen) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - add_library (${HDF5_HL_F90_LIBSH_TARGET} SHARED ${HDF5_HL_F90_F_SOURCES}) + add_library (${HDF5_HL_F90_LIBSH_TARGET} SHARED ${HDF5_HL_F90_F_SOURCES_SHARED}) set (SHARED_LINK_FLAGS " ") if (WIN32 AND MSVC) set (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_HL_F90_SRC_BINARY_DIR}/hdf5_hl_fortrandll.def") @@ -177,6 +210,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) ) endif (WIN32) set (install_targets ${install_targets} ${HDF5_HL_F90_LIBSH_TARGET}) + add_dependencies(${HDF5_HL_F90_LIBSH_TARGET} H5HLgenSH) endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) #----------------------------------------------------------------------------- diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c index ad79733..7c71da1 100644 --- a/java/src/jni/h5pImp.c +++ b/java/src/jni/h5pImp.c @@ -4947,7 +4947,6 @@ H5P_cls_create_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { cls = CBENVPTR->GetObjectClass(CBENVPAR create_callback); @@ -4972,7 +4971,6 @@ H5P_cls_copy_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { cls = CBENVPTR->GetObjectClass(CBENVPAR copy_callback); @@ -4995,7 +4993,6 @@ H5P_cls_close_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { cls = CBENVPTR->GetObjectClass(CBENVPAR close_callback); @@ -5019,7 +5016,6 @@ H5D_append_cb jclass cls; jmethodID mid; jlongArray cur_dimsArray; - jsize size; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { JVMPTR->DetachCurrentThread(JVMPAR); @@ -5135,7 +5131,6 @@ H5P_prp_create_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5160,7 +5155,6 @@ H5P_prp_copy_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5185,7 +5179,6 @@ H5P_prp_close_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5210,7 +5203,6 @@ H5P_prp_compare_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { cls = CBENVPTR->GetObjectClass(CBENVPAR compare_callback); @@ -5233,7 +5225,6 @@ H5P_prp_get_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5258,7 +5249,6 @@ H5P_prp_set_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5283,7 +5273,6 @@ H5P_prp_delete_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5472,7 +5461,6 @@ H5P_iterate_cb jclass cls; jmethodID mid; jstring str; - jmethodID constructor; /* fprintf(stderr, "\nJNI H5P_iterate_cb entered\n"); fflush(stderr); */ if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index acf57c8..0d2999a 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -181,7 +181,6 @@ h5str_sprintf char *this_str; size_t this_strlen; int n; - int len; hvl_t *vlptr; char *cptr = (char*) ptr; unsigned char *ucptr = (unsigned char*) ptr; @@ -522,7 +521,6 @@ h5str_print_region_data_blocks hsize_t *count = NULL; hsize_t blkndx; hsize_t total_size[H5S_MAX_RANK]; - unsigned int region_flags; /* buffer extent flags */ hsize_t numelem; hsize_t numindex; size_t jndx; @@ -622,7 +620,6 @@ h5str_dump_region_blocks_data hsize_t *ptdata; hid_t dtype = -1; hid_t type_id = -1; - char tmp_str[256]; int ndims = H5Sget_simple_extent_ndims(region); /* @@ -634,8 +631,6 @@ h5str_dump_region_blocks_data /* Print block information */ if (nblocks > 0) { - int i; - alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); @@ -745,13 +740,10 @@ h5str_print_region_data_points hsize_t *dims1 = NULL; hsize_t total_size[H5S_MAX_RANK]; size_t jndx; - unsigned indx; size_t type_size; int ret_value = SUCCEED; - unsigned int region_flags; /* buffer extent flags */ hid_t mem_space = -1; void *region_buf = NULL; - char tmp_str[256]; /* Allocate space for the dimension array */ if((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { @@ -810,7 +802,6 @@ h5str_dump_region_points_data hssize_t npoints; hsize_t alloc_size; hsize_t *ptdata; - char tmp_str[256]; hid_t dtype = -1; hid_t type_id = -1; int ndims = H5Sget_simple_extent_ndims(region); @@ -824,8 +815,6 @@ h5str_dump_region_points_data /* Print point information */ if (npoints > 0) { - int i; - alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); @@ -1297,7 +1286,7 @@ h5str_render_bin_output case H5T_ARRAY: { int k, ndims; - hsize_t i, dims[H5S_MAX_RANK], temp_nelmts, nelmts; + hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts; hid_t memb; /* get the array's base datatype for each element */ @@ -1325,7 +1314,6 @@ h5str_render_bin_output break; case H5T_VLEN: { - unsigned int i; hsize_t nelmts; hid_t memb; @@ -1416,7 +1404,6 @@ render_bin_output_region_data_blocks hsize_t *start = NULL; hsize_t *count = NULL; hsize_t numelem; - hsize_t numindex; hsize_t total_size[H5S_MAX_RANK]; int jndx; size_t type_size; @@ -1587,7 +1574,6 @@ render_bin_output_region_data_points hid_t container, int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) { hsize_t *dims1 = NULL; - int jndx; size_t type_size; hid_t mem_space = -1; void *region_buf = NULL; @@ -1705,7 +1691,6 @@ h5str_dump_simple_dset int ndims; int carry; /* counter carry value */ hsize_t zero[8]; /* vector of zeros */ - unsigned int flags; /* buffer extent flags */ hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ /* Print info */ @@ -1862,7 +1847,6 @@ h5tools_dump_simple_data int line_count; unsigned char *mem = (unsigned char*)_mem; size_t size; /* datum size */ - H5T_class_t type_class; hsize_t i; /*element counter */ h5str_t buffer; /*string into which to render */ diff --git a/src/H5Odtype.c b/src/H5Odtype.c index 3c3f284..799f475 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -523,7 +523,8 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p dt->shared->u.array.ndims = *(*pp)++; /* Double-check the number of dimensions */ - HDassert(dt->shared->u.array.ndims <= H5S_MAX_RANK); + if(dt->shared->u.array.ndims > H5S_MAX_RANK) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "too many dimensions for array datatype") /* Skip reserved bytes, if version has them */ if(version < H5O_DTYPE_VERSION_3) diff --git a/src/H5Znbit.c b/src/H5Znbit.c index 04e8869..7a41d16 100644 --- a/src/H5Znbit.c +++ b/src/H5Znbit.c @@ -65,13 +65,13 @@ static void H5Z_nbit_decompress_one_nooptype(unsigned char *data, size_t data_of unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size); static void H5Z_nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p); -static void H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, +static herr_t H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], unsigned *parms_index); -static void H5Z_nbit_decompress_one_compound(unsigned char *data, size_t data_offset, +static herr_t H5Z__nbit_decompress_one_compound(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], unsigned *parms_index); -static void H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, +static herr_t H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, const unsigned parms[]); static void H5Z_nbit_compress_one_nooptype(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size); @@ -1011,7 +1011,8 @@ H5Z_filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for nbit decompression") /* decompress the buffer */ - H5Z_nbit_decompress(outbuf, d_nelmts, (unsigned char *)*buf, cd_values); + if(H5Z__nbit_decompress(outbuf, d_nelmts, (unsigned char *)*buf, cd_values) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, 0, "can't decompress buffer") } /* end if */ /* output; compress */ else { @@ -1166,13 +1167,16 @@ H5Z_nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, } } -static void -H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, +static herr_t +H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], unsigned *parms_index) { unsigned i, total_size, base_class, base_size, n, begin_index; parms_atomic p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC total_size = parms[(*parms_index)++]; base_class = parms[(*parms_index)++]; @@ -1183,6 +1187,11 @@ H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, p.order = parms[(*parms_index)++]; p.precision = parms[(*parms_index)++]; p.offset = parms[(*parms_index)++]; + + /* Check values of precision and offset */ + if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + n = total_size / p.size; for(i = 0; i < n; i++) H5Z_nbit_decompress_one_atomic(data, data_offset + i * p.size, @@ -1194,8 +1203,9 @@ H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, n = total_size / base_size; /* number of base_type elements inside the array datatype */ begin_index = *parms_index; for(i = 0; i < n; i++) { - H5Z_nbit_decompress_one_array(data, data_offset + i * base_size, - buffer, j, buf_len, parms, parms_index); + if(H5Z__nbit_decompress_one_array(data, data_offset + i * base_size, + buffer, j, buf_len, parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") *parms_index = begin_index; } break; @@ -1205,8 +1215,9 @@ H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, n = total_size / base_size; /* number of base_type elements inside the array datatype */ begin_index = *parms_index; for(i = 0; i < n; i++) { - H5Z_nbit_decompress_one_compound(data, data_offset + i * base_size, - buffer, j, buf_len, parms, parms_index); + if(H5Z__nbit_decompress_one_compound(data, data_offset + i * base_size, + buffer, j, buf_len, parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") *parms_index = begin_index; } break; @@ -1219,56 +1230,81 @@ H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, default: HDassert(0 && "This Should never be executed!"); } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) } -static void -H5Z_nbit_decompress_one_compound(unsigned char *data, size_t data_offset, +static herr_t +H5Z__nbit_decompress_one_compound(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], unsigned *parms_index) { - unsigned i, nmembers, member_offset, member_class, size; + unsigned i, nmembers, member_offset, member_class, member_size, used_size = 0, size; parms_atomic p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC - (*parms_index)++; /* skip total size of compound datatype */ + size = parms[(*parms_index)++]; nmembers = parms[(*parms_index)++]; for(i = 0; i < nmembers; i++) { member_offset = parms[(*parms_index)++]; member_class = parms[(*parms_index)++]; + + /* Check for overflow */ + member_size = parms[*parms_index]; + used_size += member_size; + if(used_size > size) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "compound member offset overflowed compound size") switch(member_class) { case H5Z_NBIT_ATOMIC: - p.size = parms[(*parms_index)++]; + p.size = member_size; + /* Advance past member size */ + (*parms_index)++; p.order = parms[(*parms_index)++]; p.precision = parms[(*parms_index)++]; p.offset = parms[(*parms_index)++]; + + /* Check values of precision and offset */ + if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + H5Z_nbit_decompress_one_atomic(data, data_offset + member_offset, buffer, j, buf_len, &p); break; case H5Z_NBIT_ARRAY: - H5Z_nbit_decompress_one_array(data, data_offset + member_offset, - buffer, j, buf_len, parms, parms_index); + if(H5Z__nbit_decompress_one_array(data, data_offset + member_offset, + buffer, j, buf_len, parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") break; case H5Z_NBIT_COMPOUND: - H5Z_nbit_decompress_one_compound(data, data_offset+member_offset, - buffer, j, buf_len, parms, parms_index); + if(H5Z__nbit_decompress_one_compound(data, data_offset+member_offset, + buffer, j, buf_len, parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") break; case H5Z_NBIT_NOOPTYPE: - size = parms[(*parms_index)++]; + /* Advance past member size */ + (*parms_index)++; H5Z_nbit_decompress_one_nooptype(data, data_offset+member_offset, - buffer, j, buf_len, size); + buffer, j, buf_len, member_size); break; default: HDassert(0 && "This Should never be executed!"); } /* end switch */ } + +done: + FUNC_LEAVE_NOAPI(ret_value) } -static void -H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, +static herr_t +H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, const unsigned parms[]) { /* i: index of data, j: index of buffer, @@ -1278,6 +1314,9 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe size_t buf_len; parms_atomic p; unsigned parms_index; /* index in array parms used by compression/decompression functions */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC /* may not have to initialize to zeros */ HDmemset(data, 0, d_nelmts * parms[4]); @@ -1292,6 +1331,11 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe p.order = parms[5]; p.precision = parms[6]; p.offset = parms[7]; + + /* Check values of precision and offset */ + if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + for(i = 0; i < d_nelmts; i++) H5Z_nbit_decompress_one_atomic(data, i * p.size, buffer, &j, &buf_len, &p); break; @@ -1300,7 +1344,8 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe size = parms[4]; parms_index = 4; /* set the index before goto function call */ for(i = 0; i < d_nelmts; i++) { - H5Z_nbit_decompress_one_array(data, i * size, buffer, &j, &buf_len, parms, &parms_index); + if(H5Z__nbit_decompress_one_array(data, i * size, buffer, &j, &buf_len, parms, &parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") parms_index = 4; } break; @@ -1309,7 +1354,8 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe size = parms[4]; parms_index = 4; /* set the index before goto function call */ for(i = 0; i < d_nelmts; i++) { - H5Z_nbit_decompress_one_compound(data, i * size, buffer, &j, &buf_len, parms, &parms_index); + if(H5Z__nbit_decompress_one_compound(data, i * size, buffer, &j, &buf_len, parms, &parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") parms_index = 4; } break; @@ -1317,6 +1363,9 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe default: HDassert(0 && "This Should never be executed!"); } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) } static void diff --git a/tools/h5ls/CMakeTests.cmake b/tools/h5ls/CMakeTests.cmake index 009ea79..2367df8 100644 --- a/tools/h5ls/CMakeTests.cmake +++ b/tools/h5ls/CMakeTests.cmake @@ -258,6 +258,7 @@ tvldtypes2be.out tvldtypes2be.out.err ) + set_tests_properties (H5LS-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") if (NOT "${last_test}" STREQUAL "") set_tests_properties (H5LS-clearall-objects PROPERTIES DEPENDS ${last_test}) endif (NOT "${last_test}" STREQUAL "") diff --git a/tools/h5ls/CMakeTestsVDS.cmake b/tools/h5ls/CMakeTestsVDS.cmake index 0d08774..e6c216d 100644 --- a/tools/h5ls/CMakeTestsVDS.cmake +++ b/tools/h5ls/CMakeTestsVDS.cmake @@ -73,7 +73,7 @@ add_test ( NAME H5LS-${resultfile}-clear-objects COMMAND ${CMAKE_COMMAND} - -E remove ./testfiles/${resultfile}.out ./testfiles/vds/${resultfile}.out.err + -E remove ./testfiles/vds/${resultfile}.out ./testfiles/vds/${resultfile}.out.err ) add_test ( NAME H5LS-${resultfile} @@ -127,6 +127,7 @@ tvds_layout-5.out tvds_layout-5.out.err ) + set_tests_properties (H5LS_VDS-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") if (NOT "${last_test}" STREQUAL "") set_tests_properties (H5LS_VDS-clearall-objects PROPERTIES DEPENDS ${last_test}) endif (NOT "${last_test}" STREQUAL "") |