diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2018-11-09 14:13:07 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2018-11-09 14:13:07 (GMT) |
commit | 4da93e9d6f9ee0fc7462ee66645c5ad0fa9a9e35 (patch) | |
tree | ad6d5f412a8f1af0a2121bb0fb7fa3073462c713 | |
parent | f97de01d36cde2b66042ffac3debcfab72de0c1d (diff) | |
download | hdf5-4da93e9d6f9ee0fc7462ee66645c5ad0fa9a9e35.zip hdf5-4da93e9d6f9ee0fc7462ee66645c5ad0fa9a9e35.tar.gz hdf5-4da93e9d6f9ee0fc7462ee66645c5ad0fa9a9e35.tar.bz2 |
TRILABS-81 coverity tools fixes
30 files changed, 660 insertions, 666 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 117f24e..85ccc7a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -59,6 +59,7 @@ endif () ################################################################################# # If filter plugin tests can be tested ################################################################################# +if (BUILD_SHARED_LIBS) # make plugins dir file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testdir1") file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testdir2") @@ -124,6 +125,7 @@ endif () "${CMAKE_BINARY_DIR}/testdir2/$<TARGET_FILE_NAME:${HDF5_TEST_PLUGIN_TARGET}>" ) endforeach () +endif () ################################################################################# # Test program sources diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 5fb8c93..a19d0ca 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -798,19 +798,21 @@ endif () ############################################################################## ### F I L T E R P L U G I N T E S T S ############################################################################## -if (WIN32) - set (CMAKE_SEP "\;") - set (BIN_REL_PATH "../../") -else () - set (CMAKE_SEP ":") - set (BIN_REL_PATH "../") -endif () +if (BUILD_SHARED_LIBS AND TEST_SHARED_PROGRAMS) + if (WIN32) + set (CMAKE_SEP "\;") + set (BIN_REL_PATH "../../") + else () + set (CMAKE_SEP ":") + set (BIN_REL_PATH "../") + endif () -add_test (NAME H5PLUGIN-plugin COMMAND $<TARGET_FILE:filter_plugin>) -set_tests_properties (H5PLUGIN-plugin PROPERTIES - ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/testdir1${CMAKE_SEP}${CMAKE_BINARY_DIR}/testdir2;srcdir=${HDF5_TEST_BINARY_DIR}" - WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} -) + add_test (NAME H5PLUGIN-plugin COMMAND $<TARGET_FILE:filter_plugin>) + set_tests_properties (H5PLUGIN-plugin PROPERTIES + ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/testdir1${CMAKE_SEP}${CMAKE_BINARY_DIR}/testdir2;srcdir=${HDF5_TEST_BINARY_DIR}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} + ) +endif () ############################################################################## ############################################################################## diff --git a/tools/h5copy/CMakeLists.txt b/tools/h5copy/CMakeLists.txt index 42bde0c..be50e9d 100644 --- a/tools/h5copy/CMakeLists.txt +++ b/tools/h5copy/CMakeLists.txt @@ -35,6 +35,35 @@ if (BUILD_TESTING) #add_test (NAME h5copygentest COMMAND $<TARGET_FILE:h5copygentest>) endif () + #----------------------------------------------------------------------------- + # If plugin library tests can be tested + #----------------------------------------------------------------------------- + if (BUILD_SHARED_LIBS) + set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibcopy") + set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") + set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) + + add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_copy.c) + target_include_directories(${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED) + target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") + + # make plugins dir + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") + #----------------------------------------------------------------------------- + # Copy plugin library to a plugins folder + #----------------------------------------------------------------------------- + add_custom_command ( + TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" + "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" + ) + endif () + include (CMakeTests.cmake) endif () diff --git a/tools/h5copy/h5copygentest.c b/tools/h5copy/h5copygentest.c index 0af4dc1..5edc5b6 100644 --- a/tools/h5copy/h5copygentest.c +++ b/tools/h5copy/h5copygentest.c @@ -224,7 +224,7 @@ static void gent_compressed(hid_t loc_id) /*------------------------------------------------------------------------- * Function: gent_named_vl * - * Purpose: Generate a variable lenght named datatype for a dataset in + * Purpose: Generate a variable length named datatype for a dataset in LOC_ID * *------------------------------------------------------------------------- diff --git a/tools/h5diff/h5diff_common.c b/tools/h5diff/h5diff_common.c index 6221843..de6a51d 100644 --- a/tools/h5diff/h5diff_common.c +++ b/tools/h5diff/h5diff_common.c @@ -350,7 +350,7 @@ check_n_input( const char *str ) unsigned i; char c; - for (i = 0; i < strlen(str); i++) { + for (i = 0; i < HDstrlen(str); i++) { c = str[i]; if (i == 0) { if (c < 49 || c > 57) /* ascii values between 1 and 9 */ @@ -387,7 +387,7 @@ check_p_input( const char *str ) the atof return value on a hexadecimal input is different on some systems; we do a character check for this */ - if (strlen(str) > 2 && str[0] == '0' && str[1] == 'x') + if (HDstrlen(str) > 2 && str[0] == '0' && str[1] == 'x') return -1; x = atof(str); @@ -421,7 +421,7 @@ check_d_input( const char *str ) the atof return value on a hexadecimal input is different on some systems; we do a character check for this */ - if (strlen(str) > 2 && str[0] == '0' && str[1] == 'x') + if (HDstrlen(str) > 2 && str[0] == '0' && str[1] == 'x') return -1; x = atof(str); diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index 2955d2c..233baa9 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -114,6 +114,7 @@ static hid_t UD_traverse(H5_ATTR_UNUSED const char * link_name, H5_ATTR_UNUSED size_t udata_size, H5_ATTR_UNUSED hid_t lapl_id) { return -1; } + const H5L_class_t UD_link_class[1] = { { H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ (H5L_type_t) MY_LINKCLASS, /* Link type id number */ @@ -4810,10 +4811,8 @@ static void test_objs_nocomparables(const char *fname1, const char *fname2) hid_t topgid1 = -1; hid_t topgid2 = -1; hid_t gid1 = -1; - hid_t did1 = -1; hid_t tid1 = -1; hid_t gid2 = -1; - hid_t did2 = -1; hid_t tid2 = -1; hsize_t dims[1] = { DIM_ARRY }; int data1[DIM_ARRY] = { 1, 1, 1 }; @@ -4918,10 +4917,6 @@ out: H5Gclose(topgid1); if (topgid2) H5Gclose(topgid2); - if (did1) - H5Dclose(did1); - if (did2) - H5Dclose(did2); if (gid1) H5Gclose(gid1); if (gid2) diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index 569f453..a0ca17a 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -33,33 +33,34 @@ if (BUILD_SHARED_LIBS) endif () if (BUILD_TESTING) - - #----------------------------------------------------------------------------- - # If plugin library tests can be tested - #----------------------------------------------------------------------------- - set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibdump") - set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") - set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) - - add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_dump.c) - target_include_directories(${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") - TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED) - target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIB_TARGET}) - H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") - - # make plugins dir - file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") - #----------------------------------------------------------------------------- - # Copy plugin library to a plugins folder - #----------------------------------------------------------------------------- - add_custom_command ( - TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" - "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" - ) + if (BUILD_SHARED_LIBS) + #----------------------------------------------------------------------------- + # If plugin library tests can be tested + #----------------------------------------------------------------------------- + set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibdump") + set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") + set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) + + add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_dump.c) + target_include_directories(${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED) + target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") + + # make plugins dir + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") + #----------------------------------------------------------------------------- + # Copy plugin library to a plugins folder + #----------------------------------------------------------------------------- + add_custom_command ( + TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" + "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" + ) + endif () # -------------------------------------------------------------------- # Add the h5dump test executable diff --git a/tools/h5dump/CMakeTests.cmake b/tools/h5dump/CMakeTests.cmake index a9ff122..8a30962 100644 --- a/tools/h5dump/CMakeTests.cmake +++ b/tools/h5dump/CMakeTests.cmake @@ -1532,4 +1532,6 @@ ############################################################################## ### P L U G I N T E S T S ############################################################################## -ADD_H5_UD_TEST (h5dump_plugin_test 0 tudfilter --enable-error-stack tudfilter.h5) +if (BUILD_SHARED_LIBS) + ADD_H5_UD_TEST (h5dump_plugin_test 0 tudfilter --enable-error-stack tudfilter.h5) +endif () diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index fa67548..9b81b8d 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -65,7 +65,7 @@ struct handler_t { * parameters. The long-named ones can be partially spelled. When * adding more, make sure that they don't clash with each other. */ -/* The following initialization makes use of C language cancatenating */ +/* The following initialization makes use of C language concatenating */ /* "xxx" "yyy" into "xxxyyy". */ static const char *s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o*b*F:s:S:A*q:z:m:RE*CM:O*N:"; static struct long_options l_opts[] = { @@ -189,7 +189,7 @@ static struct long_options l_opts[] = { { NULL, 0, '\0' } }; - + /*------------------------------------------------------------------------- * Function: leave * @@ -212,7 +212,7 @@ leave(int ret) HDexit(ret); } - + /*------------------------------------------------------------------------- * Function: usage * @@ -362,7 +362,7 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, "\n"); } - + /*------------------------------------------------------------------------- * Function: table_list_add * @@ -415,7 +415,7 @@ table_list_add(hid_t oid, unsigned long file_no) return((ssize_t) idx); } /* end table_list_add() */ - + /*------------------------------------------------------------------------- * Function: table_list_visited * @@ -445,7 +445,7 @@ table_list_visited(unsigned long file_no) return(-1); } /* end table_list_visited() */ - + /*------------------------------------------------------------------------- * Function: table_list_free * @@ -813,7 +813,7 @@ parse_mask_list(const char *h_list) } } - + /*------------------------------------------------------------------------- * Function: free_handler * @@ -861,7 +861,7 @@ free_handler(struct handler_t *hand, int len) } } - + /*------------------------------------------------------------------------- * Function: parse_command_line * @@ -1295,7 +1295,7 @@ error: return hand; } - + /*------------------------------------------------------------------------- * Function: main * @@ -1753,7 +1753,7 @@ h5_fileaccess(void) return fapl; } - + /*------------------------------------------------------------------------- * Function: init_prefix * @@ -1774,7 +1774,7 @@ init_prefix(char **prfx, size_t prfx_len) error_msg("unable to allocate prefix buffer\n"); } - + /*------------------------------------------------------------------------- * Function: add_prefix * diff --git a/tools/h5dump/h5dump_xml.c b/tools/h5dump/h5dump_xml.c index 6e72b56..15a059b 100644 --- a/tools/h5dump/h5dump_xml.c +++ b/tools/h5dump/h5dump_xml.c @@ -3438,8 +3438,7 @@ xml_dump_fill_value(hid_t dcpl, hid_t type) h5tools_str_reset(&buffer); h5tools_str_append(&buffer, "\""); for (i = 0; i < sz; i++) { - h5tools_str_append(&buffer, "%x ", *(unsigned int *) buf); - buf = (char *) buf + sizeof(unsigned int); + h5tools_str_append(&buffer, "%x ", *(unsigned int *) buf + (i * sizeof(unsigned int))); } h5tools_str_append(&buffer, "\""); h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0); diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index a2f4036..be6361e 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -9574,7 +9574,7 @@ static void gent_bitnopaquefields(void) uint32_t c; uint64_t d; } s_t; - + hid_t file, grp=-1, type=-1, space=-1, dset=-1; size_t i; hsize_t nelmts = F80_DIM32; diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c index 76e78af..16c0d8c 100644 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c @@ -88,6 +88,7 @@ int main(int argc, char *argv[]) const char *err7 = "Invalid type of data - %s.\n"; const char *err8 = "Invalid size of data - %s.\n"; const char *err9 = "Cannot specify more than 30 input files in one call to h5import.\n"; + const char *err10 = "Length of output file name limited to 255 chars.\n"; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -98,6 +99,9 @@ int main(int argc, char *argv[]) (void) HDsetvbuf(stderr, (char *) NULL, _IOLBF, 0); (void) HDsetvbuf(stdout, (char *) NULL, _IOLBF, 0); + /* Initialize the file structure to 0 */ + HDmemset(&opt, 0, sizeof(struct Options)); + if (argv[1] && (HDstrcmp("-V", argv[1]) == 0)) { print_version(PROGRAMNAME); HDexit(EXIT_SUCCESS); @@ -112,9 +116,6 @@ int main(int argc, char *argv[]) goto err; } - /* Initialize the file structure to 0 */ - HDmemset(&opt, 0, sizeof(struct Options)); - /* * parse the command line */ @@ -155,6 +156,10 @@ int main(int argc, char *argv[]) break; case 5: /* get outfile found */ + if (HDstrlen(argv[i]) > MAX_PATH_NAME_LENGTH) { + (void) HDfprintf(stderr, err10, argv[i]); + goto err; + } (void) HDstrcpy(opt.outfile, argv[i]); outfile_named = TRUE; break; @@ -494,7 +499,7 @@ static int readIntegerData(FILE *strm, struct Input *in) return (-1); } #ifdef H5DEBUGIMPORT - printf("readIntegerData %d (0x%.8X)\n", *in08, *in08); + HDprintf("readIntegerData %d (0x%.8X)\n", *in08, *in08); #endif } break; @@ -531,7 +536,7 @@ static int readIntegerData(FILE *strm, struct Input *in) */ *in16 = temp16; #ifdef H5DEBUGIMPORT - printf("readIntegerData %d (0x%.8X)\n", *in16, temp16); + HDprintf("readIntegerData %d (0x%.8X)\n", *in16, temp16); #endif } break; @@ -567,7 +572,7 @@ static int readIntegerData(FILE *strm, struct Input *in) */ *in32 = temp32; #ifdef H5DEBUGIMPORT - printf("readIntegerData %d (0x%.8X = 0x%.8X)\n", *in32, *in32, temp32); + HDprintf("readIntegerData %d (0x%.8X = 0x%.8X)\n", *in32, *in32, temp32); #endif } break; @@ -605,7 +610,7 @@ static int readIntegerData(FILE *strm, struct Input *in) */ *in64 = temp64; #ifdef H5DEBUGIMPORT - printf("readIntegerData %d (0x%.8X)\n", *in64, temp64); + HDprintf("readIntegerData %d (0x%.8X)\n", *in64, temp64); #endif } break; @@ -701,7 +706,7 @@ static int readUIntegerData(FILE *strm, struct Input *in) */ *in16 = temp16; #ifdef H5DEBUGIMPORT - printf("readUIntegerData %d (0x%.4X = 0x%.4X)\n", *in16, *in16, temp16); + HDprintf("readUIntegerData %d (0x%.4X = 0x%.4X)\n", *in16, *in16, temp16); #endif } break; @@ -737,7 +742,7 @@ static int readUIntegerData(FILE *strm, struct Input *in) */ *in32 = temp32; #ifdef H5DEBUGIMPORT - printf("readUIntegerData %d (0x%.8X = 0x%.8X)\n", *in32, *in32, temp32); + HDprintf("readUIntegerData %d (0x%.8X = 0x%.8X)\n", *in32, *in32, temp32); #endif } break; @@ -775,7 +780,7 @@ static int readUIntegerData(FILE *strm, struct Input *in) */ *in64 = temp64; #ifdef H5DEBUGIMPORT - printf("readUIntegerData %ld (0x%.8X = 0x%.8X)\n", *in64, *in64, temp64); + HDprintf("readUIntegerData %ld (0x%.8X = 0x%.8X)\n", *in64, *in64, temp64); #endif } break; @@ -855,7 +860,7 @@ static int readFloatData(FILE *strm, struct Input *in) */ *bfp32 = temp32; #ifdef H5DEBUGIMPORT - printf("readFloatData %ld (0x%.8X = 0x%.8X)\n", *bfp32, *bfp32, temp32); + HDprintf("readFloatData %ld (0x%.8X = 0x%.8X)\n", *bfp32, *bfp32, temp32); #endif } break; @@ -907,7 +912,7 @@ static int readFloatData(FILE *strm, struct Input *in) */ *bfp64 = temp64; #ifdef H5DEBUGIMPORT - printf("readFloatData %ld (0x%.16lX)\n", *bfp64, temp64); + HDprintf("readFloatData %ld (0x%.16lX)\n", *bfp64, temp64); #endif } break; @@ -1099,7 +1104,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) *------------------------------------------------------------------------- */ #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING\n"); + HDprintf("processStrHDFData DATATYPE STRING\n"); #endif if ((type_id = H5Tcopy(H5T_C_S1)) < 0) @@ -1136,7 +1141,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) } H5E_END_TRY; #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING groups created\n"); + HDprintf("processStrHDFData DATATYPE STRING groups created\n"); #endif if ((space_id = H5Screate_simple(in->rank, in->sizeOfDimension, NULL)) < 0) @@ -1149,7 +1154,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) goto out; #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING ready to process strings\n"); + HDprintf("processStrHDFData DATATYPE STRING ready to process strings\n"); #endif line = 0; j = 0; @@ -1159,36 +1164,36 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) str2 = NULL; str3 = NULL; #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING[%llu]={%s}\n", (unsigned long long)line, str1); + HDprintf("processStrHDFData DATATYPE STRING[%llu]={%s}\n", (unsigned long long)line, str1); #endif /* process string to remove the first and last quote char */ str2 = strchr(str1, '"'); if (str2 != NULL) { #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", strlen(str2), str2); + HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2); #endif str2++; #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", strlen(str2), str2); + HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2); #endif str3 = strrchr(str2, '"'); if (str3 != NULL) { #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", strlen(str3), str3); + HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str3), str3); #endif *str3 = '\0'; #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", strlen(str2), str2); + HDprintf("processStrHDFData DATATYPE STRING len:%d for {%s}\n", HDstrlen(str2), str2); #endif - if(strlen(str2) > 0) { + if(HDstrlen(str2) > 0) { hid_t fspace_id; hsize_t start[1]; hsize_t count[1] = { 1 }; #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING[%llu] store %s\n", (unsigned long long)line, str2); + HDprintf("processStrHDFData DATATYPE STRING[%llu] store %s\n", (unsigned long long)line, str2); #endif if ((fspace_id = H5Dget_space(dset_id)) < 0) goto out; @@ -1210,7 +1215,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) j++; } #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING eof reached\n"); + HDprintf("processStrHDFData DATATYPE STRING eof reached\n"); #endif /* close */ @@ -1223,7 +1228,7 @@ static int processStrHDFData(FILE *strm, struct Input *in, hid_t file_id) out: #ifdef H5DEBUGIMPORT - printf("processStrHDFData DATATYPE STRING error exit\n"); + HDprintf("processStrHDFData DATATYPE STRING error exit\n"); #endif /* disable error reporting */ H5E_BEGIN_TRY @@ -1366,9 +1371,9 @@ static int allocateFloatStorage(struct Input *in) static int processConfigurationFile(char *infile, struct Input *in) { FILE *strm = NULL; - char key[255]; + char key[MAX_PATH_NAME_LENGTH]; int kindex; - char temp[255]; + char temp[MAX_PATH_NAME_LENGTH]; int ival; int scanret; int retval = -1; @@ -1437,7 +1442,7 @@ static int processConfigurationFile(char *infile, struct Input *in) } in->inputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif in->inputArchitecture = 0; /* default to NATIVE */ @@ -1446,64 +1451,64 @@ static int processConfigurationFile(char *infile, struct Input *in) goto error; } - scanret = fscanf(strm, "%s", key); + scanret = fscanf(strm, "%254s", key); if((scanret == 1) && !HDstrcmp("HDF5", key)) { #ifdef H5DEBUGIMPORT int pndx; - printf("\nh5dump file\n"); + HDprintf("\nh5dump file\n"); #endif in->h5dumpInput = 1; - scanret = fscanf(strm, "%s", temp); /* filename */ - scanret = fscanf(strm, "%s", temp); /* start bracket */ - scanret = fscanf(strm, "%s", key); /* DATASET */ + scanret = fscanf(strm, "%254s", temp); /* filename */ + scanret = fscanf(strm, "%254s", temp); /* start bracket */ + scanret = fscanf(strm, "%254s", key); /* DATASET */ while (scanret == 1) { if(!HDstrcmp("DATASET", key)) { /* PATH */ #ifdef H5DEBUGIMPORT - printf("h5dump DATASET key\n"); + HDprintf("h5dump DATASET key\n"); #endif if (in->configOptionVector[PATH] == 1) { (void) HDfprintf(stderr, err3a, infile); goto error; } - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATASET %s found\n", temp); + HDprintf("h5dump DATASET %s found\n", temp); #endif if (parsePathInfo(&in->path, temp) == -1) { (void) HDfprintf(stderr, err3b, infile); goto error; } in->configOptionVector[PATH] = 1; - scanret = fscanf(strm, "%s", temp); /* start bracket */ + scanret = fscanf(strm, "%254s", temp); /* start bracket */ #ifdef H5DEBUGIMPORT - printf("h5dump DATASET %s found\n", temp); + HDprintf("h5dump DATASET %s found\n", temp); #endif } /* if(!HDstrcmp("DATASET", key)) PATH */ else if(!HDstrcmp("DATATYPE", key)) { /* INPUT-CLASS */ #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE key\n"); + HDprintf("h5dump DATATYPE key\n"); #endif if (in->configOptionVector[INPUT_CLASS] == 1) { (void) HDfprintf(stderr, err4a, infile); goto error; } - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE %s found\n", temp); + HDprintf("h5dump DATATYPE %s found\n", temp); #endif if ((kindex = getInputClassType(in, temp)) == -1) { (void) HDfprintf(stderr, err4b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE type %d inputClass\n", in->inputClass); + HDprintf("h5dump DATATYPE type %d inputClass\n", in->inputClass); #endif in->configOptionVector[INPUT_CLASS] = 1; @@ -1519,34 +1524,34 @@ static int processConfigurationFile(char *infile, struct Input *in) in->outputClass = 2; } #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE type %d outputClass\n", in->outputClass); + HDprintf("h5dump DATATYPE type %d outputClass\n", in->outputClass); #endif if(in->inputClass == 5) { /* STRING */ int get_next_prop = 1; in->outputClass = -1; #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE STRING found\n"); + HDprintf("h5dump DATATYPE STRING found\n"); #endif - if (fscanf(strm, "%s", temp) != 1) { /* start bracket */ + if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */ (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE STRING %s found\n", temp); + HDprintf("h5dump DATATYPE STRING %s found\n", temp); #endif - if (fscanf(strm, "%s", temp) != 1) { /* string properties */ + if (fscanf(strm, "%254s", temp) != 1) { /* string properties */ (void) HDfprintf(stderr, "%s", err18); goto error; } while (get_next_prop) { if(!HDstrcmp("STRSIZE", temp)) { /* STRSIZE */ - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err19); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE STRING STRSIZE %s found\n", temp); + HDprintf("h5dump DATATYPE STRING STRSIZE %s found\n", temp); #endif if (HDstrcmp("H5T_VARIABLE;", temp)) { char *more = temp; @@ -1556,44 +1561,44 @@ static int processConfigurationFile(char *infile, struct Input *in) goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE STRING %d InputSize\n", in->inputSize); + HDprintf("h5dump DATATYPE STRING %d InputSize\n", in->inputSize); #endif } } else if(!HDstrcmp("STRPAD", temp)) { /* STRPAD */ - if (fscanf(strm, "%s", temp) != 1) { /* STRPAD type */ + if (fscanf(strm, "%254s", temp) != 1) { /* STRPAD type */ (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE STRING STRPAD %s found\n", temp); + HDprintf("h5dump DATATYPE STRING STRPAD %s found\n", temp); #endif } else if(!HDstrcmp("CSET", key)) { /* CSET */ - if (fscanf(strm, "%s", temp) != 1) { /* CSET type */ + if (fscanf(strm, "%254s", temp) != 1) { /* CSET type */ (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE STRING CSET %s found\n", temp); + HDprintf("h5dump DATATYPE STRING CSET %s found\n", temp); #endif } else if(!HDstrcmp("CTYPE", temp)) { /* CTYPE */ - if (fscanf(strm, "%s", temp) != 1) { /* CTYPE type */ + if (fscanf(strm, "%254s", temp) != 1) { /* CTYPE type */ (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE STRING CTYPE %s found\n", temp); + HDprintf("h5dump DATATYPE STRING CTYPE %s found\n", temp); #endif } /* if(!HDstrcmp("CSET", key)) */ - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE STRING %s found\n", temp); + HDprintf("h5dump DATATYPE STRING %s found\n", temp); #endif if(!HDstrcmp("}", temp)) { /* end bracket */ get_next_prop = 0; @@ -1605,9 +1610,9 @@ static int processConfigurationFile(char *infile, struct Input *in) hsize_t temp_dims[MAX_NUM_DIMENSION]; #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE key\n"); + HDprintf("h5dump DATASPACE key\n"); #endif - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err18); goto error; } @@ -1621,42 +1626,42 @@ static int processConfigurationFile(char *infile, struct Input *in) else if(!HDstrcmp("SIMPLE", temp)) { /* SIMPLE */ int icount = 0; #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE found\n"); + HDprintf("h5dump DATASPACE SIMPLE found\n"); #endif - if (fscanf(strm, "%s", temp) != 1) { /* start bracket */ + if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE %s found\n", temp); + HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif - if (fscanf(strm, "%s", temp) != 1) { /* start paren */ + if (fscanf(strm, "%254s", temp) != 1) { /* start paren */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE %s found\n", temp); + HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif if(!HDstrcmp("(", temp)) { /* start paren */ int get_next_dim = 1; int i = 0; - if (fscanf(strm, "%s", temp) != 1) { /* Dimension with optional comma */ + if (fscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */ (void) HDfprintf(stderr, err16c, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE %s found\n", temp); + HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif while (get_next_dim) { char *more = temp; temp_dims[icount] = HDstrtoull(more, &more, 10); - if (fscanf(strm, "%s", temp) != 1) { /* Dimension or end paren */ + if (fscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE %s found\n", temp); + HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif if(!HDstrcmp(")", temp)) { /* end paren */ in->rank = ++icount; @@ -1676,17 +1681,17 @@ static int processConfigurationFile(char *infile, struct Input *in) goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE %ld rank\n", in->rank); + HDprintf("h5dump DATASPACE SIMPLE %ld rank\n", in->rank); #endif for (i = 0; i < in->rank; i++) { in->sizeOfDimension[i] = temp_dims[i]; } #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE dims[%ld]:", in->rank); + HDprintf("h5dump DATASPACE SIMPLE dims[%ld]:", in->rank); for (pndx = 0; pndx < in->rank; pndx++) { - printf(" %ld", in->sizeOfDimension[pndx]); + HDprintf(" %ld", in->sizeOfDimension[pndx]); } - printf("\n"); + HDprintf("\n"); #endif in->configOptionVector[DIM] = 1; } /* if(!HDstrcmp("(", key)) start paren */ @@ -1694,41 +1699,41 @@ static int processConfigurationFile(char *infile, struct Input *in) (void) HDfprintf(stderr, err5b, infile); goto error; } - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE %s found\n", temp); + HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif if(!HDstrcmp("/", temp)) { /* / max dims */ if ((in->maxsizeOfDimension = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { goto error; } - if (fscanf(strm, "%s", temp) != 1) { /* start paren */ + if (fscanf(strm, "%254s", temp) != 1) { /* start paren */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE %s found\n", temp); + HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif if(!HDstrcmp("(", temp)) { /* start paren */ int get_next_dim = 1; int i = 0; #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE process max dim values\n"); + HDprintf("h5dump DATASPACE SIMPLE process max dim values\n"); #endif - if (fscanf(strm, "%s", temp) != 1) { /* max dim with optional comma */ + if (fscanf(strm, "%254s", temp) != 1) { /* max dim with optional comma */ (void) HDfprintf(stderr, err16c, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE %s found\n", temp); + HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif while (get_next_dim) { #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE get max dim value\n"); + HDprintf("h5dump DATASPACE SIMPLE get max dim value\n"); #endif if(!HDstrcmp("H5S_UNLIMITED", temp) || !HDstrcmp("H5S_UNLIMITED,", temp)) { /* unlimited */ in->maxsizeOfDimension[i] = H5S_UNLIMITED; @@ -1738,40 +1743,40 @@ static int processConfigurationFile(char *infile, struct Input *in) char *more = temp; in->maxsizeOfDimension[i] = HDstrtoull(more, &more, 10); } - if (fscanf(strm, "%s", temp) != 1) { /* max dim or end paren */ + if (fscanf(strm, "%254s", temp) != 1) { /* max dim or end paren */ (void) HDfprintf(stderr, err16c, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE %s found\n", temp); + HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif if(!HDstrcmp(")", temp)) { /* end paren */ get_next_dim = 0; } else { /* comma */ i++; - if (i > MAX_NUM_DIMENSION) { + if (i >= MAX_NUM_DIMENSION) { (void) HDfprintf(stderr, "Invalid value for rank.\n"); goto error; } } } /* while (get_next_dim) */ #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE maxdims[%ld]:", in->rank); + HDprintf("h5dump DATASPACE SIMPLE maxdims[%ld]:", in->rank); for (pndx = 0; pndx < in->rank; pndx++) { - printf(" %ld", in->maxsizeOfDimension[pndx]); + HDprintf(" %ld", in->maxsizeOfDimension[pndx]); } - printf("\n"); - printf("h5dump DATASPACE SIMPLE get max dim finished\n"); + HDprintf("\n"); + HDprintf("h5dump DATASPACE SIMPLE get max dim finished\n"); #endif } /* if(!HDstrcmp("(", key)) start paren */ else { (void) HDfprintf(stderr, err16c, infile); goto error; } - scanret = fscanf(strm, "%s", temp); /* end bracket */ + scanret = fscanf(strm, "%254s", temp); /* end bracket */ #ifdef H5DEBUGIMPORT - printf("h5dump DATASPACE SIMPLE %s found\n", temp); + HDprintf("h5dump DATASPACE SIMPLE %s found\n", temp); #endif } /* if(!HDstrcmp("/", key)) max dims separator */ } /* else if(!HDstrcmp("SIMPLE", key)) */ @@ -1782,54 +1787,54 @@ static int processConfigurationFile(char *infile, struct Input *in) } /* else if(!HDstrcmp("DATASPACE", key)) RANK and DIMENSIONS */ else if(!HDstrcmp("STORAGE_LAYOUT", key)) { /* CHUNKED-DIMENSION-SIZES */ #ifdef H5DEBUGIMPORT - printf("h5dump STORAGE_LAYOUT key\n"); + HDprintf("h5dump STORAGE_LAYOUT key\n"); #endif - if (fscanf(strm, "%s", temp) != 1) { /* start bracket */ + if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump STORAGE_LAYOUT %s found\n", temp); + HDprintf("h5dump STORAGE_LAYOUT %s found\n", temp); #endif - if (fscanf(strm, "%s", temp) != 1) { /* CHUNKED */ + if (fscanf(strm, "%254s", temp) != 1) { /* CHUNKED */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump STORAGE_LAYOUT %s found\n", temp); + HDprintf("h5dump STORAGE_LAYOUT %s found\n", temp); #endif if(!HDstrcmp("CHUNKED", temp)) { /* CHUNKED */ if ((in->sizeOfChunk = (hsize_t *) HDmalloc ((size_t) in->rank * sizeof(hsize_t))) == NULL) { (void) HDfprintf(stderr, "Unable to allocate dynamic memory.\n"); goto error; } - if (fscanf(strm, "%s", temp) != 1) { /* start paren */ + if (fscanf(strm, "%254s", temp) != 1) { /* start paren */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); + HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); #endif if(!HDstrcmp("(", temp)) { /* start paren */ int get_next_dim = 1; int icount = 0; - if (fscanf(strm, "%s", temp) != 1) { /* Dimension with optional comma */ + if (fscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */ (void) HDfprintf(stderr, err16c, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); + HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); #endif while (get_next_dim) { char *more = temp; in->sizeOfChunk[icount] = HDstrtoull(more, &more, 10); - if (fscanf(strm, "%s", temp) != 1) { /* Dimension or end paren */ + if (fscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); + HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); #endif if(!HDstrcmp(")", temp)) { /* end paren */ in->configOptionVector[RANK] = 1; @@ -1844,11 +1849,11 @@ static int processConfigurationFile(char *infile, struct Input *in) } } /* while (get_next_dim) */ #ifdef H5DEBUGIMPORT - printf("h5dump STORAGE_LAYOUT CHUNKED dims [%ld]:", in->rank); + HDprintf("h5dump STORAGE_LAYOUT CHUNKED dims [%ld]:", in->rank); for (pndx = 0; pndx < in->rank; pndx++) { - printf(" %ld", in->sizeOfChunk[pndx]); + HDprintf(" %ld", in->sizeOfChunk[pndx]); } - printf("\n"); + HDprintf("\n"); #endif in->configOptionVector[DIM] = 1; } /* if(!HDstrcmp("(", key)) start paren */ @@ -1856,12 +1861,12 @@ static int processConfigurationFile(char *infile, struct Input *in) (void) HDfprintf(stderr, err5b, infile); goto error; } - if (fscanf(strm, "%s", temp) != 1) { /* SIZE */ + if (fscanf(strm, "%254s", temp) != 1) { /* SIZE */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); + HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); #endif if(!HDstrcmp("SIZE", temp)) { /* SIZE */ if (fscanf(strm, "%d", (&ival)) != 1) { @@ -1869,16 +1874,16 @@ static int processConfigurationFile(char *infile, struct Input *in) goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump STORAGE_LAYOUT CHUNKED SIZE %d found\n", ival); + HDprintf("h5dump STORAGE_LAYOUT CHUNKED SIZE %d found\n", ival); #endif } while (HDstrcmp("}", temp)) { - if (fscanf(strm, "%s", temp) != 1) { /* end bracket */ + if (fscanf(strm, "%254s", temp) != 1) { /* end bracket */ (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); + HDprintf("h5dump STORAGE_LAYOUT CHUNKED %s found\n", temp); #endif } in->configOptionVector[CHUNK] = 1; @@ -1886,135 +1891,135 @@ static int processConfigurationFile(char *infile, struct Input *in) } /* else if(!HDstrcmp("STORAGE_LAYOUT", key)) CHUNKED-DIMENSION-SIZES */ else if(!HDstrcmp("FILTERS", key)) { /* FILTERS */ #ifdef H5DEBUGIMPORT - printf("h5dump FILTERS key\n"); + HDprintf("h5dump FILTERS key\n"); #endif - if (fscanf(strm, "%s", temp) != 1) { /* start bracket */ + if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump FILTERS %s found\n", temp); + HDprintf("h5dump FILTERS %s found\n", temp); #endif - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump FILTERS %s found\n", temp); + HDprintf("h5dump FILTERS %s found\n", temp); #endif if(!HDstrcmp("COMPRESSION", temp)) { /* COMPRESSION */ #ifdef H5DEBUGIMPORT - printf("h5dump FILTERS COMPRESSION found\n"); + HDprintf("h5dump FILTERS COMPRESSION found\n"); #endif - if (fscanf(strm, "%s", temp) != 1) { /* DEFLATE */ + if (fscanf(strm, "%254s", temp) != 1) { /* DEFLATE */ (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump FILTERS COMPRESSION %s found\n", temp); + HDprintf("h5dump FILTERS COMPRESSION %s found\n", temp); #endif - if (fscanf(strm, "%s", temp) != 1) { /* bgin bracket */ + if (fscanf(strm, "%254s", temp) != 1) { /* bgin bracket */ (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump FILTERS COMPRESSION %s found\n", temp); + HDprintf("h5dump FILTERS COMPRESSION %s found\n", temp); #endif - if (fscanf(strm, "%s", temp) != 1) { /* LEVEL */ + if (fscanf(strm, "%254s", temp) != 1) { /* LEVEL */ (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump FILTERS COMPRESSION %s found\n", temp); + HDprintf("h5dump FILTERS COMPRESSION %s found\n", temp); #endif if (fscanf(strm, "%d", (&ival)) != 1) { (void) HDfprintf(stderr, "%s", err19); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump FILTERS COMPRESSION LEVEL %d found\n", ival); + HDprintf("h5dump FILTERS COMPRESSION LEVEL %d found\n", ival); #endif in->compressionParam = ival; - if (fscanf(strm, "%s", temp) != 1) { /* end bracket */ + if (fscanf(strm, "%254s", temp) != 1) { /* end bracket */ (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump FILTERS COMPRESSION %s found\n", temp); + HDprintf("h5dump FILTERS COMPRESSION %s found\n", temp); #endif in->compressionType = 0; /* ONLY GZIP supported */ in->configOptionVector[COMPRESS] = 1; } else if(!HDstrcmp("CONTIGUOUS", temp)) { /* CONTIGUOUS */ #ifdef H5DEBUGIMPORT - printf("h5dump FILTERS CONTIGUOUS found\n"); + HDprintf("h5dump FILTERS CONTIGUOUS found\n"); #endif in->configOptionVector[COMPRESS] = 0; } else if(!HDstrcmp("NONE", temp)) { /* NONE */ #ifdef H5DEBUGIMPORT - printf("h5dump FILTERS NONE found\n"); + HDprintf("h5dump FILTERS NONE found\n"); #endif in->configOptionVector[COMPRESS] = 0; } - if (fscanf(strm, "%s", temp) != 1) { /* end bracket */ + if (fscanf(strm, "%254s", temp) != 1) { /* end bracket */ (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump FILTERS %s found\n", temp); + HDprintf("h5dump FILTERS %s found\n", temp); #endif } else if(!HDstrcmp("SUBSET", key)) { /* reduce dimensions */ hsize_t temp_dims[MAX_NUM_DIMENSION]; int get_next_prop = 1; #ifdef H5DEBUGIMPORT - printf("h5dump SUBSET key\n"); + HDprintf("h5dump SUBSET key\n"); #endif - if (fscanf(strm, "%s", temp) != 1) { /* start bracket */ + if (fscanf(strm, "%254s", temp) != 1) { /* start bracket */ (void) HDfprintf(stderr, err20, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump SUBSET %s found\n", temp); + HDprintf("h5dump SUBSET %s found\n", temp); #endif - if (fscanf(strm, "%s", temp) != 1) { /* SUBSET keyword */ + if (fscanf(strm, "%254s", temp) != 1) { /* SUBSET keyword */ (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump SUBSET %s found\n", temp); + HDprintf("h5dump SUBSET %s found\n", temp); #endif while (get_next_prop) { if(!HDstrcmp("COUNT", temp)) { /* COUNT */ int icount = 0; - if (fscanf(strm, "%s", temp) != 1) { /* start paren */ + if (fscanf(strm, "%254s", temp) != 1) { /* start paren */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump SUBSET %s found\n", temp); + HDprintf("h5dump SUBSET %s found\n", temp); #endif if(!HDstrcmp("(", temp)) { /* start paren */ int get_next_dim = 1; int i = 0; - if (fscanf(strm, "%s", temp) != 1) { /* Dimension with optional comma */ + if (fscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */ (void) HDfprintf(stderr, err16c, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump SUBSET COUNT [%s] found\n", temp); + HDprintf("h5dump SUBSET COUNT [%s] found\n", temp); #endif while (get_next_dim) { char *more = temp; temp_dims[icount] = HDstrtoull(more, &more, 10); - if (fscanf(strm, "%s", temp) != 1) { /* Dimension or end paren */ + if (fscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump SUBSET COUNT %s found\n", temp); + HDprintf("h5dump SUBSET COUNT %s found\n", temp); #endif if(!HDstrcmp(");", temp)) { /* end paren */ in->rank = ++icount; @@ -2023,7 +2028,7 @@ static int processConfigurationFile(char *infile, struct Input *in) } else { /* Dimension */ icount++; - if (icount > MAX_NUM_DIMENSION) { + if (icount >= MAX_NUM_DIMENSION) { (void) HDfprintf(stderr, "Invalid value for rank.\n"); goto error; } @@ -2033,44 +2038,44 @@ static int processConfigurationFile(char *infile, struct Input *in) in->sizeOfDimension[i] = temp_dims[i]; } #ifdef H5DEBUGIMPORT - printf("h5dump SUBSET COUNT dims: [%d]", in->rank); + HDprintf("h5dump SUBSET COUNT dims: [%d]", in->rank); for (pndx = 0; pndx < in->rank; pndx++) { - printf(" %ld", in->sizeOfDimension[pndx]); + HDprintf(" %ld", in->sizeOfDimension[pndx]); } - printf("\n"); + HDprintf("\n"); #endif in->configOptionVector[DIM] = 1; } /* if(!HDstrcmp("(", key)) start paren */ } /* if(!HDstrcmp("COUNT", temp)) COUNT */ if(!HDstrcmp("BLOCK", temp)) { /* BLOCK */ int icount = 0; - if (fscanf(strm, "%s", temp) != 1) { /* start paren */ + if (fscanf(strm, "%254s", temp) != 1) { /* start paren */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump SUBSET %s found\n", temp); + HDprintf("h5dump SUBSET %s found\n", temp); #endif if(!HDstrcmp("(", temp)) { /* start paren */ int get_next_dim = 1; int i = 0; - if (fscanf(strm, "%s", temp) != 1) { /* Dimension with optional comma */ + if (fscanf(strm, "%254s", temp) != 1) { /* Dimension with optional comma */ (void) HDfprintf(stderr, err16c, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump SUBSET BLOCK [%s] found\n", temp); + HDprintf("h5dump SUBSET BLOCK [%s] found\n", temp); #endif while (get_next_dim) { char *more = temp; temp_dims[icount] = HDstrtoull(more, &more, 10); - if (fscanf(strm, "%s", temp) != 1) { /* Dimension or end paren */ + if (fscanf(strm, "%254s", temp) != 1) { /* Dimension or end paren */ (void) HDfprintf(stderr, err6b, infile); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump SUBSET BLOCK %s found\n", temp); + HDprintf("h5dump SUBSET BLOCK %s found\n", temp); #endif if(!HDstrcmp(");", temp)) { /* end paren */ in->rank = ++icount; @@ -2089,21 +2094,21 @@ static int processConfigurationFile(char *infile, struct Input *in) in->sizeOfDimension[i] = in->sizeOfDimension[i] * temp_dims[i]; } #ifdef H5DEBUGIMPORT - printf("h5dump SUBSET BLOCK dims: [%d]", in->rank); + HDprintf("h5dump SUBSET BLOCK dims: [%d]", in->rank); for (pndx = 0; pndx < in->rank; pndx++) { - printf(" %ld", in->sizeOfDimension[pndx]); + HDprintf(" %ld", in->sizeOfDimension[pndx]); } - printf("\n"); + HDprintf("\n"); #endif in->configOptionVector[DIM] = 1; } /* if(!HDstrcmp("(", key)) start paren */ } /* if(!HDstrcmp("BLOCK", temp)) BLOCK */ - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err18); goto error; } #ifdef H5DEBUGIMPORT - printf("h5dump SUBSET %s found\n", temp); + HDprintf("h5dump SUBSET %s found\n", temp); #endif if(!HDstrcmp("}", temp)) { /* end bracket */ get_next_prop = 0; @@ -2112,40 +2117,40 @@ static int processConfigurationFile(char *infile, struct Input *in) } /* else if(!HDstrcmp("SUBSET", key)) */ else if(!HDstrcmp("DATA", key)) { /* FINSHED */ #ifdef H5DEBUGIMPORT - printf("h5dump DATA key\n"); + HDprintf("h5dump DATA key\n"); #endif scanret = 0; break; } - scanret = fscanf(strm, "%s", key); + scanret = fscanf(strm, "%254s", key); } #ifdef H5DEBUGIMPORT - printf("h5dump path"); + HDprintf("h5dump path"); for (pndx = 0; pndx < in->path.count; pndx++) { - printf(" : %s", in->path.group[pndx]); - } - printf("\n"); - printf("h5dump inputClass=%d\n", in->inputClass); - printf("h5dump inputSize=%d\n", in->inputSize); - printf("h5dump inputArchitecture=%d\n", in->inputArchitecture); - printf("h5dump inputByteOrder=%d\n", in->inputByteOrder); - printf("h5dump rank=%d\n", in->rank); - printf("h5dump outputClass=%d\n", in->outputClass); - printf("h5dump outputSize=%d\n", in->outputSize); - printf("h5dump outputArchitecture=%d\n", in->outputArchitecture); - printf("h5dump outputByteOrder=%d\n", in->outputByteOrder); - printf("h5dump compressionType=%d\n", in->compressionType); - printf("h5dump compressionParam=%d\n", in->compressionParam); - printf("h5dump externFilename=%s\n", in->externFilename); - printf("h5dump sizeOfDimensions:\n"); + HDprintf(" : %s", in->path.group[pndx]); + } + HDprintf("\n"); + HDprintf("h5dump inputClass=%d\n", in->inputClass); + HDprintf("h5dump inputSize=%d\n", in->inputSize); + HDprintf("h5dump inputArchitecture=%d\n", in->inputArchitecture); + HDprintf("h5dump inputByteOrder=%d\n", in->inputByteOrder); + HDprintf("h5dump rank=%d\n", in->rank); + HDprintf("h5dump outputClass=%d\n", in->outputClass); + HDprintf("h5dump outputSize=%d\n", in->outputSize); + HDprintf("h5dump outputArchitecture=%d\n", in->outputArchitecture); + HDprintf("h5dump outputByteOrder=%d\n", in->outputByteOrder); + HDprintf("h5dump compressionType=%d\n", in->compressionType); + HDprintf("h5dump compressionParam=%d\n", in->compressionParam); + HDprintf("h5dump externFilename=%s\n", in->externFilename); + HDprintf("h5dump sizeOfDimensions:\n"); for (pndx = 0; pndx < in->rank; pndx++) { - printf(" %ld\n", in->sizeOfDimension[pndx]); + HDprintf(" %ld\n", in->sizeOfDimension[pndx]); } #endif } else { #ifdef H5DEBUGIMPORT - printf("original option keyword parsing\n"); + HDprintf("original option keyword parsing\n"); #endif while (scanret == 1) { if ((kindex = mapKeywordToIndex(key)) == -1) { @@ -2158,7 +2163,7 @@ static int processConfigurationFile(char *infile, struct Input *in) (void) HDfprintf(stderr, err3a, infile); goto error; } - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err18); goto error; } @@ -2175,7 +2180,7 @@ static int processConfigurationFile(char *infile, struct Input *in) goto error; } - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err18); goto error; } @@ -2203,7 +2208,7 @@ static int processConfigurationFile(char *infile, struct Input *in) (void) HDfprintf(stderr, err5a, infile); goto error; } - if (fscanf(strm, "%d", (&ival)) != 1) { + if (fscanf(strm, "%254d", (&ival)) != 1) { (void) HDfprintf(stderr, "%s", err19); goto error; } @@ -2400,7 +2405,7 @@ static int processConfigurationFile(char *infile, struct Input *in) default: break; } - scanret = fscanf(strm, "%s", key); + scanret = fscanf(strm, "%254s", key); } /* @@ -2571,7 +2576,7 @@ static int getOutputClass(struct Input *in, FILE *strm) const char *err1 = "Unable to get 'string' value.\n"; const char *err2 = "Invalid value for output class.\n"; - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err1); return (-1); } @@ -2655,7 +2660,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 4; @@ -2676,7 +2681,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 4; @@ -2697,7 +2702,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 4; @@ -2718,7 +2723,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 4; @@ -2739,7 +2744,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 4; @@ -2760,7 +2765,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 4; @@ -2781,7 +2786,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 4; @@ -2802,7 +2807,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 4; @@ -2823,7 +2828,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 7; @@ -2844,7 +2849,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 7; @@ -2865,7 +2870,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 7; @@ -2886,7 +2891,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 7; @@ -2907,7 +2912,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 7; @@ -2928,7 +2933,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 7; @@ -2949,7 +2954,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 7; @@ -2970,7 +2975,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 7; @@ -3111,7 +3116,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 3; @@ -3132,7 +3137,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 3; @@ -3153,7 +3158,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 3; @@ -3174,7 +3179,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = 3; @@ -3250,7 +3255,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = -1; @@ -3269,7 +3274,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = -1; @@ -3288,7 +3293,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = -1; @@ -3307,7 +3312,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = -1; @@ -3326,7 +3331,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = -1; @@ -3345,7 +3350,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = -1; @@ -3364,7 +3369,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = -1; @@ -3383,7 +3388,7 @@ static int getInputClassType(struct Input *in, char * buffer) } in->outputByteOrder = kindex; #ifdef H5DEBUGIMPORT - printf("h5dump inputByteOrder %d\n", in->inputByteOrder); + HDprintf("h5dump inputByteOrder %d\n", in->inputByteOrder); #endif kindex = -1; @@ -3422,9 +3427,9 @@ static int getInputClassType(struct Input *in, char * buffer) if (in->configOptionVector[OUTPUT_SIZE] == 0) in->outputSize = in->inputSize; #ifdef H5DEBUGIMPORT - printf("h5dump DATATYPE InClass %d inputSize\n", in->inputSize); - printf("h5dump DATATYPE InClass %d outputSize\n", in->outputSize); - printf("h5dump DATATYPE InClass %d outputArchitecture\n", in->outputArchitecture); + HDprintf("h5dump DATATYPE InClass %d inputSize\n", in->inputSize); + HDprintf("h5dump DATATYPE InClass %d outputSize\n", in->outputSize); + HDprintf("h5dump DATATYPE InClass %d outputArchitecture\n", in->outputArchitecture); #endif in->inputClass = kindex; @@ -3464,7 +3469,7 @@ static int getInputByteOrder(struct Input *in, FILE *strm) const char *err1 = "Unable to get 'string' value.\n"; const char *err2 = "Invalid value for input byte-order.\n"; - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err1); return (-1); } @@ -3595,7 +3600,7 @@ static int getOutputArchitecture(struct Input *in, FILE *strm) const char *err1 = "Unable to get 'string' value.\n"; const char *err2 = "Invalid value for output architecture.\n"; - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err1); return (-1); } @@ -3627,7 +3632,7 @@ static int getOutputByteOrder(struct Input *in, FILE *strm) const char *err1 = "Unable to get 'string' value.\n"; const char *err2 = "Invalid value for output byte-order.\n"; - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err1); return (-1); } @@ -3658,7 +3663,7 @@ static int getCompressionType(struct Input *in, FILE *strm) const char *err1 = "Unable to get 'string' value.\n"; const char *err2 = "Invalid value for compression.\n"; - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err1); return (-1); } @@ -3722,7 +3727,7 @@ static int getExternalFilename(struct Input *in, FILE *strm) char temp[255]; const char *err1 = "Unable to get 'string' value.\n"; - if (fscanf(strm, "%s", temp) != 1) { + if (fscanf(strm, "%254s", temp) != 1) { (void) HDfprintf(stderr, "%s", err1); return (-1); } @@ -4631,7 +4636,7 @@ static int process(struct Options *opt) intype = createInputDataType(in); outtype = createOutputDataType(in); #ifdef H5DEBUGIMPORT - printf("process intype %ld outtype %ld\n", intype, outtype); + HDprintf("process intype %ld outtype %ld\n", intype, outtype); #endif /* create property list */ diff --git a/tools/h5import/h5import.h b/tools/h5import/h5import.h index c55717d..00c41f6 100644 --- a/tools/h5import/h5import.h +++ b/tools/h5import/h5import.h @@ -102,8 +102,8 @@ struct Input struct infilesformat { - char datafile[255]; - char configfile[255]; + char datafile[MAX_PATH_NAME_LENGTH]; + char configfile[MAX_PATH_NAME_LENGTH]; struct Input in; int config; /* Configfile present? No - 0. Yes - 1 */ }; diff --git a/tools/h5import/h5importtest.c b/tools/h5import/h5importtest.c index 489bc01..bbb67b6 100644 --- a/tools/h5import/h5importtest.c +++ b/tools/h5import/h5importtest.c @@ -71,9 +71,9 @@ main(void) volatile uint32_t ibyte=0x01234567; /* 0 for big endian, 1 for little endian. */ if ((*((uint8_t*)(&ibyte))) == 0x67) - strncpy(machine_order, "LE", 2); + HDstrncpy(machine_order, "LE", 2); else - strncpy(machine_order, "BE", 2); + HDstrncpy(machine_order, "BE", 2); /* diff --git a/tools/h5jam/getub.c b/tools/h5jam/getub.c index 7cfde36..26a427d 100644 --- a/tools/h5jam/getub.c +++ b/tools/h5jam/getub.c @@ -148,7 +148,7 @@ main(int argc, const char *argv[]) error: if(buf) HDfree(buf); - if(fd > -1) + if(fd >= 0) HDclose(fd); return EXIT_FAILURE; } /* end main() */ diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c index a7c1cc7..28a62fd 100644 --- a/tools/h5jam/h5jam.c +++ b/tools/h5jam/h5jam.c @@ -59,11 +59,6 @@ static struct long_options l_opts[] = { * Purpose: Print the usage message * * Return: void - * - * Programmer: - * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -123,7 +118,6 @@ usage (const char *prog) * Purpose: Shutdown and call exit() * * Return: Does not return - * *------------------------------------------------------------------------- */ static void @@ -147,13 +141,7 @@ leave(int ret) * Purpose: Parse the command line for the h5dumper. * * Return: Success: - * * Failure: Exits program with EXIT_FAILURE value. - * - * Programmer: - * - * Modifications: - * *------------------------------------------------------------------------- */ @@ -202,7 +190,6 @@ parse_command_line (int argc, const char *argv[]) * * Return: Success: 0 * Failure: 1 - * *------------------------------------------------------------------------- */ int @@ -237,7 +224,7 @@ main (int argc, const char *argv[]) /* Initialize h5tools lib */ h5tools_init(); - parse_command_line (argc, argv); + parse_command_line(argc, argv); if (ub_file == NULL) { /* no user block */ @@ -268,21 +255,21 @@ main (int argc, const char *argv[]) leave (EXIT_FAILURE); } - ifile = H5Fopen (input_file, H5F_ACC_RDONLY, H5P_DEFAULT); + ifile = H5Fopen(input_file, H5F_ACC_RDONLY, H5P_DEFAULT); if (ifile < 0) { error_msg("Can't open input HDF5 file \"%s\"\n", input_file); leave (EXIT_FAILURE); } - plist = H5Fget_create_plist (ifile); + plist = H5Fget_create_plist(ifile); if (plist < 0) { error_msg("Can't get file creation plist for file \"%s\"\n", input_file); H5Fclose(ifile); leave (EXIT_FAILURE); } - status = H5Pget_userblock (plist, &usize); + status = H5Pget_userblock(plist, &usize); if (status < 0) { error_msg("Can't get user block for file \"%s\"\n", input_file); H5Pclose(plist); @@ -346,7 +333,7 @@ main (int argc, const char *argv[]) } } - newubsize = compute_user_block_size ((hsize_t) fsize); + newubsize = compute_user_block_size((hsize_t) fsize); startub = usize; @@ -361,39 +348,39 @@ main (int argc, const char *argv[]) else { /* add new ub to current ublock, pad to new offset */ newubsize += usize; - newubsize = compute_user_block_size ((hsize_t) newubsize); + newubsize = compute_user_block_size((hsize_t) newubsize); } } /* copy the HDF5 from starting at usize to starting at newubsize: * makes room at 'from' for new ub */ /* if no current ub, usize is 0 */ - copy_some_to_file (h5fid, ofid, usize, newubsize, (ssize_t) (h5fsize - usize)); + copy_some_to_file(h5fid, ofid, usize, newubsize, (ssize_t) (h5fsize - usize)); /* copy the old ub to the beginning of the new file */ if (!do_clobber) { - where = copy_some_to_file (h5fid, ofid, (hsize_t) 0, (hsize_t) 0, (ssize_t) usize); + where = copy_some_to_file(h5fid, ofid, (hsize_t) 0, (hsize_t) 0, (ssize_t) usize); } /* copy the new ub to the end of the ub */ - where = copy_some_to_file (ufid, ofid, (hsize_t) 0, startub, (ssize_t) - 1); + where = copy_some_to_file(ufid, ofid, (hsize_t) 0, startub, (ssize_t) - 1); /* pad the ub */ where = write_pad (ofid, where); if(ub_file) - HDfree (ub_file); + HDfree(ub_file); if(input_file) - HDfree (input_file); + HDfree(input_file); if(output_file) - HDfree (output_file); + HDfree(output_file); if(ufid >= 0) - HDclose (ufid); + HDclose(ufid); if(h5fid >= 0) - HDclose (h5fid); + HDclose(h5fid); if(ofid >= 0) - HDclose (ofid); + HDclose(ofid); return h5tools_getstatus(); } @@ -416,7 +403,6 @@ main (int argc, const char *argv[]) * * Return: Success: last byte written in the output. * Failure: Exits program with EXIT_FAILURE value. - * *------------------------------------------------------------------------- */ hsize_t @@ -448,7 +434,8 @@ copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout, } /* end if */ howmuch = (ssize_t)sbuf.st_size; - } else { + } + else { howmuch = limit; } /* end if */ @@ -461,7 +448,8 @@ copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout, if (howmuch > 512) { to = toend - 512; from = fromend - 512; - } else { + } + else { to = toend - howmuch; from = fromend - howmuch; } /* end if */ @@ -472,7 +460,8 @@ copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout, if (howmuch > 512) { nchars = HDread(infid, buf, (unsigned) 512); - } else { + } + else { nchars = HDread(infid, buf, (unsigned)howmuch); } /* end if */ @@ -491,7 +480,8 @@ copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout, if(howmuch > 512) { to -= nchars; from -= nchars; - } else { + } + else { to -= howmuch; from -= howmuch; } /* end if */ @@ -505,15 +495,11 @@ copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout, * Function: compute_user_block_size * * Purpose: Find the offset of the HDF5 header after the user block: - * align at 0, 512, 1024, etc. - * ublock_size: the size of the user block (bytes). + * align at 0, 512, 1024, etc. + * ublock_size: the size of the user block (bytes). * - * Return: Success: the location of the header == the size of the - * padded user block. + * Return: Success: the location of the header == the size of the padded user block. * Failure: none - * - * Return: Success: last byte written in the output. - * Failure: Exits program with EXIT_FAILURE value. *------------------------------------------------------------------------- */ hsize_t @@ -530,7 +516,7 @@ compute_user_block_size (hsize_t ublock_size) return where; } /* end compute_user_block_size() */ -/* +/*------------------------------------------------------------------------- * Write zeroes to fill the file from 'where' to 512, 1024, etc. bytes. * * Returns the size of the padded file. diff --git a/tools/h5jam/h5unjam.c b/tools/h5jam/h5unjam.c index a269cfe..59e5dae 100644 --- a/tools/h5jam/h5unjam.c +++ b/tools/h5jam/h5unjam.c @@ -58,11 +58,6 @@ static struct long_options l_opts[] = { * Purpose: Print the usage message * * Return: void - * - * Programmer: - * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -126,9 +121,7 @@ usage(const char *prog) * Purpose: Parse the command line for the h5dumper. * * Return: Success: EXIT_SUCCESS; - * * Failure: Exits function with EXIT_FAILURE value. - * *------------------------------------------------------------------------- */ static int @@ -201,11 +194,6 @@ done: * * Return: Success: 0 * Failure: 1 - * - * Programmer: - * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -338,11 +326,12 @@ done: return h5tools_getstatus(); } -/* +/*------------------------------------------------------------------------- * Copy 'how_much' bytes from the input file to the output file, * starting at byte 'where' in the input file. * * Returns 0 on success, -1 on failure. + *------------------------------------------------------------------------- */ herr_t copy_to_file( FILE *infid, FILE *ofid, ssize_t _where, ssize_t how_much ) diff --git a/tools/h5ls/CMakeLists.txt b/tools/h5ls/CMakeLists.txt index 26d77ea..607a7d8 100644 --- a/tools/h5ls/CMakeLists.txt +++ b/tools/h5ls/CMakeLists.txt @@ -25,33 +25,34 @@ if (BUILD_SHARED_LIBS) endif () if (BUILD_TESTING) - #----------------------------------------------------------------------------- # If plugin library tests can be tested #----------------------------------------------------------------------------- - set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibls") - set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") - set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) + if (BUILD_SHARED_LIBS) + set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibls") + set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") + set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) - add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_ls.c) - target_include_directories(${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") - TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED) - target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIB_TARGET}) - H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") + add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_ls.c) + target_include_directories(${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED) + target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") - # make plugins dir - file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") - #----------------------------------------------------------------------------- - # Copy plugin library to a plugins folder - #----------------------------------------------------------------------------- - add_custom_command ( - TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" - "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" - ) + # make plugins dir + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") + #----------------------------------------------------------------------------- + # Copy plugin library to a plugins folder + #----------------------------------------------------------------------------- + add_custom_command ( + TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" + "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" + ) + endif () include (CMakeTests.cmake) diff --git a/tools/h5ls/CMakeTests.cmake b/tools/h5ls/CMakeTests.cmake index 6c9f118..6a9819d 100644 --- a/tools/h5ls/CMakeTests.cmake +++ b/tools/h5ls/CMakeTests.cmake @@ -461,4 +461,6 @@ ############################################################################## ### P L U G I N T E S T S ############################################################################## -ADD_H5_UD_TEST (h5ls_plugin_test 0 tudfilter -w80 -d tudfilter.h5) +if (BUILD_SHARED_LIBS) + ADD_H5_UD_TEST (h5ls_plugin_test 0 tudfilter -w80 -d tudfilter.h5) +endif () diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt index 3439aed..106d383 100644 --- a/tools/h5repack/CMakeLists.txt +++ b/tools/h5repack/CMakeLists.txt @@ -56,46 +56,48 @@ if (BUILD_TESTING) #----------------------------------------------------------------------------- # If plugin library tests can be tested #----------------------------------------------------------------------------- - set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibadd") - set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") - set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) - set (HDF5_TOOL_PLUGIN_LIB_VCORENAME "dynlibvers") - set (HDF5_TOOL_PLUGIN_LIB_VNAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_VCORENAME}") - set (HDF5_TOOL_PLUGIN_LIB_VTARGET ${HDF5_TOOL_PLUGIN_LIB_VCORENAME}) - - add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_rpk.c) - target_include_directories(${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") - TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED) - target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIB_TARGET}) - H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") - - add_library (${HDF5_TOOL_PLUGIN_LIB_VTARGET} SHARED dynlib_vrpk.c) - target_include_directories(${HDF5_TOOL_PLUGIN_LIB_VTARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") - TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_VTARGET} SHARED) - target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_VTARGET} PRIVATE ${HDF5_TEST_LIB_TARGET}) - H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_VTARGET} ${HDF5_TOOL_PLUGIN_LIB_VNAME} SHARED "LIB") - - # make plugins dir - file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") - #----------------------------------------------------------------------------- - # Copy plugin library to a plugins folder - #----------------------------------------------------------------------------- - add_custom_command ( - TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" - "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" - ) - add_custom_command ( - TARGET ${HDF5_TOOL_PLUGIN_LIB_VTARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different - "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_VTARGET}>" - "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_VTARGET}>" - ) + if (BUILD_SHARED_LIBS) + set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibadd") + set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") + set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) + set (HDF5_TOOL_PLUGIN_LIB_VCORENAME "dynlibvers") + set (HDF5_TOOL_PLUGIN_LIB_VNAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_VCORENAME}") + set (HDF5_TOOL_PLUGIN_LIB_VTARGET ${HDF5_TOOL_PLUGIN_LIB_VCORENAME}) + + add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_rpk.c) + target_include_directories(${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED) + target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED "LIB") + + add_library (${HDF5_TOOL_PLUGIN_LIB_VTARGET} SHARED dynlib_vrpk.c) + target_include_directories(${HDF5_TOOL_PLUGIN_LIB_VTARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_VTARGET} SHARED) + target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_VTARGET} PRIVATE ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_VTARGET} ${HDF5_TOOL_PLUGIN_LIB_VNAME} SHARED "LIB") + + # make plugins dir + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") + #----------------------------------------------------------------------------- + # Copy plugin library to a plugins folder + #----------------------------------------------------------------------------- + add_custom_command ( + TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" + "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_TARGET}>" + ) + add_custom_command ( + TARGET ${HDF5_TOOL_PLUGIN_LIB_VTARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$<TARGET_FILE:${HDF5_TOOL_PLUGIN_LIB_VTARGET}>" + "${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${HDF5_TOOL_PLUGIN_LIB_VTARGET}>" + ) + endif () include (CMakeTests.cmake) diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index a4f8f5b..dee5145 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -1368,9 +1368,9 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size) } /* end while */ done: - if (infid > 0) + if (infid >= 0) HDclose(infid); - if (outfid > 0) + if (outfid >= 0) HDclose(outfid); return ret_value; @@ -1443,7 +1443,7 @@ print_user_block(const char *filename, hid_t fid) } done: - if (fh > 0) + if (fh >= 0) HDclose(fh); return; diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index c739960..2bd0fbb 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -598,6 +598,8 @@ int main(int argc, const char **argv) void *edata; void *tools_edata; + HDmemset(&options, 0, sizeof(pack_opt_t)); + h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c index f646ee7..03fcf0e 100644 --- a/tools/h5repack/h5repack_parse.c +++ b/tools/h5repack/h5repack_parse.c @@ -462,7 +462,7 @@ obj_list_t* parse_filter(const char *str, unsigned *n_objs, filter_info_t *filt, return obj_list; } - + /*------------------------------------------------------------------------- * Function: parse_layout * diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index 72f76c3..98f12f0 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -189,13 +189,12 @@ int main (void) PASSED(); /*------------------------------------------------------------------------- - * Format of the tests: - * - * 1) make a copy of the file with h5repack - * 2) use the h5diff function to compare the input and output file - *------------------------------------------------------------------------- - */ - + * Format of the tests: + * + * 1) make a copy of the file with h5repack + * 2) use the h5diff function to compare the input and output file + *------------------------------------------------------------------------- + */ /*------------------------------------------------------------------------- * file with fill values @@ -3339,7 +3338,7 @@ out: H5Pclose(fcpl); H5Fclose(fid); } H5E_END_TRY; - if(fd > 0) + if(fd >= 0) HDclose(fd); return -1; @@ -3408,7 +3407,7 @@ out: H5Pclose(fcpl); H5Fclose(fid); } H5E_END_TRY; - if(fd > 0) + if(fd >= 0) HDclose(fd); return -1; @@ -3449,7 +3448,7 @@ make_userblock_file(void) out: - if(fd > 0) + if(fd >= 0) HDclose(fd); return -1; @@ -3745,13 +3744,19 @@ int write_dset_in(hid_t loc_id, } /* create a type larger than TEST_BUFSIZE */ - if ((tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, tdims)) < 0) + if ((tid = H5Tarray_create2(H5T_NATIVE_DOUBLE, 1, tdims)) < 0) { + HDfree(dbuf); goto out; + } size = H5Tget_size(tid); - if ((sid = H5Screate_simple(1, sdims, NULL)) < 0) + if ((sid = H5Screate_simple(1, sdims, NULL)) < 0) { + HDfree(dbuf); goto out; - if ((did = H5Dcreate2(loc_id, "arrayd", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + } + if ((did = H5Dcreate2(loc_id, "arrayd", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + HDfree(dbuf); goto out; + } #if defined(WRITE_ARRAY) H5Dwrite(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dbuf); #endif @@ -3760,7 +3765,7 @@ int write_dset_in(hid_t loc_id, H5Dclose(did); H5Tclose(tid); H5Sclose(sid); - HDfree( dbuf ); + HDfree(dbuf); } /*------------------------------------------------------------------------- diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c index 1357952..55ae638 100644 --- a/tools/h5stat/h5stat.c +++ b/tools/h5stat/h5stat.c @@ -24,9 +24,9 @@ /* Parameters to control statistics gathered */ /* Default threshold for small groups/datasets/attributes */ -#define DEF_SIZE_SMALL_GROUPS 10 -#define DEF_SIZE_SMALL_DSETS 10 -#define DEF_SIZE_SMALL_ATTRS 10 +#define DEF_SIZE_SMALL_GROUPS 10 +#define DEF_SIZE_SMALL_DSETS 10 +#define DEF_SIZE_SMALL_ATTRS 10 #define H5_NFILTERS_IMPL 8 /* Number of currently implemented filters + one to accommodate for user-define filters + one @@ -72,7 +72,7 @@ typedef struct iter_t { hsize_t max_dset_dims; /* Maximum dimension size of dataset */ unsigned long *small_dset_dims; /* Size of dimensions of small datasets tracked */ unsigned long dset_layouts[H5D_NLAYOUTS]; /* Type of storage for each dataset */ - unsigned long dset_comptype[H5_NFILTERS_IMPL]; /* Number of currently implemented filters */ + unsigned long dset_comptype[H5_NFILTERS_IMPL]; /* Number of currently implemented filters */ unsigned long dset_ntypes; /* Number of diff. dataset datatypes found */ dtype_info_t *dset_type_info; /* Pointer to dataset datatype information found */ unsigned dset_dim_nbins; /* Number of bins for dataset dimensions */ @@ -114,9 +114,9 @@ static int display_dset_metadata = FALSE; /* display file space info f static int display_object = FALSE; /* not implemented yet */ /* Initialize threshold for small groups/datasets/attributes */ -static int sgroups_threshold = DEF_SIZE_SMALL_GROUPS; -static int sdsets_threshold = DEF_SIZE_SMALL_DSETS; -static int sattrs_threshold = DEF_SIZE_SMALL_ATTRS; +static int sgroups_threshold = DEF_SIZE_SMALL_GROUPS; +static int sdsets_threshold = DEF_SIZE_SMALL_DSETS; +static int sattrs_threshold = DEF_SIZE_SMALL_ATTRS; /* a structure for handling the order command-line parameters come in */ struct handler_t { @@ -347,9 +347,8 @@ attribute_stats(iter_t *iter, const H5O_info_t *oi) * * Purpose: Gather statistics about the group * - * Return: Success: 0 - * - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * * Programmer: Quincey Koziol * Tuesday, August 16, 2005 @@ -430,7 +429,6 @@ group_stats(iter_t *iter, const char *name, const H5O_info_t *oi) * Purpose: Gather statistics about the dataset * * Return: Success: 0 - * * Failure: -1 * * Programmer: Quincey Koziol @@ -521,27 +519,27 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi) /* Only gather dim size statistics on 1-D datasets */ if(ndims == 1) { - /* Determine maximum dimension size */ - if(dims[0] > iter->max_dset_dims) - iter->max_dset_dims = dims[0]; - /* Collect statistics for small datasets */ - if(dims[0] < (hsize_t)sdsets_threshold) - (iter->small_dset_dims[(size_t)dims[0]])++; - - /* Add dim count to proper bin */ - bin = ceil_log10((unsigned long)dims[0]); - if((bin + 1) > iter->dset_dim_nbins) { - /* Allocate more storage for info about dataset's datatype */ - iter->dset_dim_bins = (unsigned long *)HDrealloc(iter->dset_dim_bins, (bin + 1) * sizeof(unsigned long)); - HDassert(iter->dset_dim_bins); - - /* Initialize counts for intermediate bins */ - while(iter->dset_dim_nbins < bin) - iter->dset_dim_bins[iter->dset_dim_nbins++] = 0; - iter->dset_dim_nbins++; - - /* Initialize count for this bin */ - iter->dset_dim_bins[bin] = 1; + /* Determine maximum dimension size */ + if(dims[0] > iter->max_dset_dims) + iter->max_dset_dims = dims[0]; + /* Collect statistics for small datasets */ + if(dims[0] < (hsize_t)sdsets_threshold) + (iter->small_dset_dims[(size_t)dims[0]])++; + + /* Add dim count to proper bin */ + bin = ceil_log10((unsigned long)dims[0]); + if((bin + 1) > iter->dset_dim_nbins) { + /* Allocate more storage for info about dataset's datatype */ + iter->dset_dim_bins = (unsigned long *)HDrealloc(iter->dset_dim_bins, (bin + 1) * sizeof(unsigned long)); + HDassert(iter->dset_dim_bins); + + /* Initialize counts for intermediate bins */ + while(iter->dset_dim_nbins < bin) + iter->dset_dim_bins[iter->dset_dim_nbins++] = 0; + iter->dset_dim_nbins++; + + /* Initialize count for this bin */ + iter->dset_dim_bins[bin] = 1; } /* end if */ else (iter->dset_dim_bins[bin])++; @@ -560,6 +558,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi) type_found = TRUE; break; } /* end for */ + if(type_found) (iter->dset_type_info[u].count)++; else { @@ -702,9 +701,8 @@ obj_stats(const char *path, const H5O_info_t *oi, const char *already_visited, * * Purpose: Gather statistics about a link * - * Return: Success: 0 - * - * Failure: -1 + * Return: Success: 0 + * Failure: -1 * * Programmer: Quincey Koziol * Tuesday, November 6, 2007 @@ -822,14 +820,14 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) break; case 'l': - if(opt_arg) { - sgroups_threshold = HDatoi(opt_arg); - if(sgroups_threshold < 1) { - error_msg("Invalid threshold for small groups\n"); - goto error; - } - } else - error_msg("Missing threshold for small groups\n"); + if(opt_arg) { + sgroups_threshold = HDatoi(opt_arg); + if(sgroups_threshold < 1) { + error_msg("Invalid threshold for small groups\n"); + goto error; + } + } else + error_msg("Missing threshold for small groups\n"); break; @@ -844,14 +842,14 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) break; case 'm': - if(opt_arg) { - sdsets_threshold = HDatoi(opt_arg); - if(sdsets_threshold < 1) { - error_msg("Invalid threshold for small datasets\n"); - goto error; - } - } else - error_msg("Missing threshold for small datasets\n"); + if(opt_arg) { + sdsets_threshold = HDatoi(opt_arg); + if(sdsets_threshold < 1) { + error_msg("Invalid threshold for small datasets\n"); + goto error; + } + } else + error_msg("Missing threshold for small datasets\n"); break; @@ -866,13 +864,13 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret) break; case 'a': - if(opt_arg) { - sattrs_threshold = HDatoi(opt_arg); - if(sattrs_threshold < 1) { - error_msg("Invalid threshold for small # of attributes\n"); - goto error; - } - } else + if(opt_arg) { + sattrs_threshold = HDatoi(opt_arg); + if(sattrs_threshold < 1) { + error_msg("Invalid threshold for small # of attributes\n"); + goto error; + } + } else error_msg("Missing threshold for small # of attributes\n"); break; @@ -1143,9 +1141,8 @@ print_group_info(const iter_t *iter) * * Purpose: Prints file space information for groups' metadata * - * Return: Success: 0 - * - * Failure: Never fails + * Return: Success: 0 + * Failure: Never fails * * Programmer: Vailin Choi; October 2009 * @@ -1171,9 +1168,8 @@ print_group_metadata(const iter_t *iter) * * Purpose: Prints information about datasets in the file * - * Return: Success: 0 - * - * Failure: Never fails + * Return: Success: 0 + * Failure: Never fails * * Programmer: Elena Pourmal * Saturday, August 12, 2006 @@ -1234,7 +1230,7 @@ print_dataset_info(const iter_t *iter) printf("Dataset layout information:\n"); for(u = 0; u < H5D_NLAYOUTS; u++) - printf("\tDataset layout counts[%s]: %lu\n", (u == 0 ? "COMPACT" : + printf("\tDataset layout counts[%s]: %lu\n", (u == 0 ? "COMPACT" : (u == 1 ? "CONTIG" : "CHUNKED")), iter->dset_layouts[u]); printf("\tNumber of external files : %lu\n", iter->nexternal); diff --git a/tools/h5stat/h5stat_gentest.c b/tools/h5stat/h5stat_gentest.c index 6031808..fda8ac4 100644 --- a/tools/h5stat/h5stat_gentest.c +++ b/tools/h5stat/h5stat_gentest.c @@ -14,7 +14,7 @@ /* * Generate the binary hdf5 files for the h5stat tests. * Usage: just execute the program without any arguments will - * generate all the binary hdf5 files + * generate all the binary hdf5 files * * If you regenerate the test files (e.g., changing some code, * trying it on a new platform, ...), you need to verify the correctness @@ -23,26 +23,26 @@ #include "hdf5.h" /* For gen_newgrat_file() */ -#define NEWGRAT_FILE "h5stat_newgrat.h5" -#define DATASET_NAME "DATASET_NAME" -#define GROUP_NAME "GROUP" -#define ATTR_NAME "ATTR" -#define NUM_GRPS 35000 -#define NUM_ATTRS 100 +#define NEWGRAT_FILE "h5stat_newgrat.h5" +#define DATASET_NAME "DATASET_NAME" +#define GROUP_NAME "GROUP" +#define ATTR_NAME "ATTR" +#define NUM_GRPS 35000 +#define NUM_ATTRS 100 /* For gen_threshold_file() */ -#define THRESHOLD_FILE "h5stat_threshold.h5" -#define THRES_ATTR_NAME "attr" -#define THRES_ATTR_GRP_NAME "grp_attr" -#define THRES_DSET_NAME "dset" -#define THRES_NUM 10 -#define THRES_NUM_25 25 +#define THRESHOLD_FILE "h5stat_threshold.h5" +#define THRES_ATTR_NAME "attr" +#define THRES_ATTR_GRP_NAME "grp_attr" +#define THRES_DSET_NAME "dset" +#define THRES_NUM 10 +#define THRES_NUM_25 25 /* * Generate HDF5 file with latest format with * NUM_GRPS groups and NUM_ATTRS attributes for the dataset */ -static void +static void gen_newgrat_file(const char *fname) { hid_t fapl = -1; /* File access property */ @@ -52,65 +52,57 @@ gen_newgrat_file(const char *fname) hid_t sid = -1; /* Dataspace id */ hid_t attr_id = -1; /* Attribute id */ hid_t did = -1; /* Dataset id */ - char name[30]; /* Group name */ - char attrname[30]; /* Attribute name */ - int i; /* Local index variable */ + char name[30]; /* Group name */ + char attrname[30]; /* Attribute name */ + int i; /* Local index variable */ /* Get a copy file access property list */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; + goto error; /* Set to use latest library format */ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - goto error; + goto error; /* Create file */ if((fid = H5Fcreate(NEWGRAT_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - goto error; + goto error; /* Create NUM_GRPS groups in the root group */ for(i = 1; i <= NUM_GRPS; i++) { sprintf(name, "%s%d", GROUP_NAME,i); if((gid = H5Gcreate2(fid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; if(H5Gclose(gid) < 0) - goto error; + goto error; } /* end for */ /* Create a datatype to commit and use */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) - goto error; + goto error; /* Create dataspace for dataset */ if((sid = H5Screate(H5S_SCALAR)) < 0) - goto error; + goto error; /* Create dataset */ if((did = H5Dcreate2(fid, DATASET_NAME, tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Create NUM_ATTRS for the dataset */ for(i = 1; i <= NUM_ATTRS; i++) { sprintf(attrname, "%s%d", ATTR_NAME,i); if((attr_id = H5Acreate2(did, attrname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; if(H5Aclose(attr_id) < 0) - goto error; + goto error; } /* end for */ /* Close dataset, dataspace, datatype, file */ - if(H5Dclose(did) < 0) - goto error; - if(H5Sclose(sid) < 0) - goto error; - if(H5Tclose(tid) < 0) - goto error; - if(H5Fclose(fid) < 0) - goto error; - error: H5E_BEGIN_TRY { - H5Aclose(attr_id); + H5Pclose(fapl); + H5Aclose(attr_id); H5Dclose(did); H5Tclose(tid); H5Sclose(sid); @@ -121,192 +113,175 @@ error: /* * Generate an HDF5 file with groups, datasets, attributes for testing the options: - * -l N (--links=N): Set the threshold for # of links when printing information for small groups. - * -m N (--dims=N): Set the threshold for the # of dimension sizes when printing information for small datasets. - * -a N (--numattrs=N): Set the threshold for the # of attributes when printing information for small # of attributes. + * -l N (--links=N): Set the threshold for # of links when printing information for small groups. + * -m N (--dims=N): Set the threshold for the # of dimension sizes when printing information for small datasets. + * -a N (--numattrs=N): Set the threshold for the # of attributes when printing information for small # of attributes. */ static void gen_threshold_file(const char *fname) { - hid_t fid; /* File ID */ - hid_t sid0, sid1, sid2, sid3, sid4; /* Dataspace IDs */ - hid_t did; /* Dataset ID */ - hid_t attr_id; /* Attribute ID */ - hid_t gid; /* Group ID */ - hsize_t two_dims[] = {2, 5}; /* Dimension array */ - hsize_t one_dims[] = {6}; /* Dimension array */ - hsize_t zero_dims[] = {0}; /* Dimension array */ - char name[30]; /* Name */ - unsigned i; /* Local index variable */ + hid_t fid = -1; /* File ID */ + hid_t sid0 = -1; /* Dataspace IDs */ + hid_t sid1 = -1; /* Dataspace IDs */ + hid_t sid2 = -1; /* Dataspace IDs */ + hid_t sid3 = -1; /* Dataspace IDs */ + hid_t sid4 = -1; /* Dataspace IDs */ + hid_t did = -1; /* Dataset ID */ + hid_t attr_id = -1; /* Attribute ID */ + hid_t gid = -1; /* Group ID */ + hsize_t two_dims[] = {2, 5}; /* Dimension array */ + hsize_t one_dims[] = {6}; /* Dimension array */ + hsize_t zero_dims[] = {0}; /* Dimension array */ + char name[30]; /* Name */ + unsigned i; /* Local index variable */ /* Create file */ if((fid = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Create 1-D dataspace with zero dimension size */ if((sid0 = H5Screate_simple(1, zero_dims, NULL)) < 0) - goto error; + goto error; /* Create 1-D dataspace with non-zero dimension size*/ if((sid1 = H5Screate_simple(1, one_dims, NULL)) < 0) - goto error; + goto error; /* Create 2-D dataspace */ if((sid2 = H5Screate_simple(2, two_dims, NULL)) < 0) - goto error; + goto error; /* Create scalar dataspace */ if((sid3 = H5Screate(H5S_SCALAR)) < 0) - goto error; + goto error; /* Create null dataspace */ if((sid4 = H5Screate(H5S_NULL)) < 0) - goto error; + goto error; /* Create an attribute for the root group */ if((attr_id = H5Acreate2(fid, "attr", H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; if(H5Aclose(attr_id) < 0) - goto error; + goto error; /* Create 1-D dataset with zero dimension size for the root group */ if((did = H5Dcreate2(fid, "zero_dset", H5T_NATIVE_UCHAR, sid0, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Create 11 attributes for the dataset */ for(i = 1; i <= (THRES_NUM+1); i++) { sprintf(name, "%s%d", THRES_ATTR_NAME,i); if((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; if(H5Aclose(attr_id) < 0) - goto error; + goto error; } if(H5Dclose(did) < 0) - goto error; + goto error; /* Create dataset with scalar dataspace for the root group */ if((did = H5Dcreate2(fid, "scalar_dset", H5T_NATIVE_UCHAR, sid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; if(H5Dclose(did) < 0) - goto error; + goto error; /* Create dataset with null dataspace for the root group */ if((did = H5Dcreate2(fid, "null_dset", H5T_NATIVE_UCHAR, sid4, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; if(H5Dclose(did) < 0) - goto error; + goto error; /* Create 2-D dataset for the root group */ if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_UCHAR, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Create 10 attributes for the 2-D dataset */ for(i = 1; i <= THRES_NUM; i++) { sprintf(name, "%s%d", THRES_ATTR_NAME,i); if((attr_id = H5Acreate2(did, name, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; if(H5Aclose(attr_id) < 0) - goto error; + goto error; } if(H5Dclose(did) < 0) - goto error; + goto error; /* Create first group */ if((gid = H5Gcreate2(fid, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Create an attribute for the group */ if((attr_id = H5Acreate2(gid, "ATTR", H5T_NATIVE_INT, sid3, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Close attribute */ if(H5Aclose(attr_id) < 0) - goto error; + goto error; /* Create 10 1-D datasets with non-zero dimension size for the group */ for(i = 1; i <= THRES_NUM; i++) { - /* set up dataset name */ + /* set up dataset name */ sprintf(name, "%s%d", THRES_DSET_NAME,i); - /* Create the dataset */ - if((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + /* Create the dataset */ + if((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; - /* Close the dataset */ + /* Close the dataset */ if(H5Dclose(did) < 0) - goto error; + goto error; } /* Close the group */ if(H5Gclose(gid) < 0) - goto error; + goto error; /* Create second group */ if((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Create 25 attributes for the group */ for(i = 1; i <= THRES_NUM_25; i++) { - /* Set up attribute name */ + /* Set up attribute name */ sprintf(name, "%s%d", THRES_ATTR_GRP_NAME,i); - /* Create the attribute */ + /* Create the attribute */ if((attr_id = H5Acreate2(gid, name, H5T_NATIVE_INT, sid2, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; - /* Close the attribute */ + /* Close the attribute */ if(H5Aclose(attr_id) < 0) - goto error; + goto error; } /* Close the group */ if(H5Gclose(gid) < 0) - goto error; + goto error; /* Create third group */ if((gid = H5Gcreate2(fid, "group3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + goto error; /* Create 9 1-D datasets with non-zero dimension size for the group */ for(i = 1; i < THRES_NUM; i++) { - /* set up dataset name */ + /* set up dataset name */ sprintf(name, "%s%d", THRES_DSET_NAME,i); - /* Create the dataset */ - if((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + /* Create the dataset */ + if((did = H5Dcreate2(gid, name, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; - /* Close the dataset */ + /* Close the dataset */ if(H5Dclose(did) < 0) - goto error; + goto error; } - /* Close the group */ - if(H5Gclose(gid) < 0) - goto error; - - - /* Close dataspaces */ - if(H5Sclose(sid0) < 0) - goto error; - if(H5Sclose(sid1) < 0) - goto error; - if(H5Sclose(sid2) < 0) - goto error; - if(H5Sclose(sid3) < 0) - goto error; - if(H5Sclose(sid4) < 0) - goto error; - - /* Close file */ - if(H5Fclose(fid) < 0) - goto error; - error: H5E_BEGIN_TRY { H5Gclose(gid); - H5Aclose(attr_id); + H5Aclose(attr_id); H5Dclose(did); H5Sclose(sid0); H5Sclose(sid1); diff --git a/tools/misc/h5repart.c b/tools/misc/h5repart.c index dee0c1f..f6252b2 100644 --- a/tools/misc/h5repart.c +++ b/tools/misc/h5repart.c @@ -245,9 +245,9 @@ main (int argc, char *argv[]) sprintf (src_name, src_gen_name, src_membno); src_is_family = strcmp (src_name, src_gen_name); - if ((src=HDopen(src_name, O_RDONLY,0))<0) { - perror (src_name); - exit (EXIT_FAILURE); + if ((src = HDopen(src_name, O_RDONLY, 0)) < 0) { + HDperror (src_name); + HDexit (EXIT_FAILURE); } if (HDfstat(src, &sb)<0) { @@ -265,9 +265,9 @@ main (int argc, char *argv[]) sprintf (dst_name, dst_gen_name, dst_membno); dst_is_family = strcmp (dst_name, dst_gen_name); - if ((dst=HDopen (dst_name, O_RDWR|O_CREAT|O_TRUNC, 0666))<0) { - perror (dst_name); - exit (EXIT_FAILURE); + if ((dst = HDopen (dst_name, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) { + HDperror (dst_name); + HDexit (EXIT_FAILURE); } if (verbose) fprintf (stderr, "> %s\n", dst_name); @@ -346,9 +346,9 @@ main (int argc, char *argv[]) break; } sprintf (src_name, src_gen_name, ++src_membno); - if ((src=HDopen (src_name, O_RDONLY,0))<0 && ENOENT==errno) { - dst_offset = dst_offset + (off_t)n; - break; + if ((src = HDopen (src_name, O_RDONLY, 0)) < 0 && ENOENT == errno) { + dst_offset = dst_offset + (off_t)n; + break; } else if (src<0) { perror (src_name); exit (EXIT_FAILURE); @@ -393,9 +393,9 @@ main (int argc, char *argv[]) } HDclose (dst); sprintf (dst_name, dst_gen_name, ++dst_membno); - if ((dst=HDopen (dst_name, O_RDWR|O_CREAT|O_TRUNC, 0666))<0) { - perror (dst_name); - exit (EXIT_FAILURE); + if ((dst = HDopen (dst_name, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) { + HDperror (dst_name); + HDexit (EXIT_FAILURE); } dst_offset = 0; need_seek = FALSE; diff --git a/tools/perform/perf.c b/tools/perform/perf.c index b421328..994615f 100644 --- a/tools/perform/perf.c +++ b/tools/perform/perf.c @@ -63,13 +63,13 @@ #define H5FATAL 1 #define VRFY(val, mesg, fatal) do { \ if (!val) { \ - printf("Proc %d: ", mynod); \ + printf("Proc %d: ", mynod); \ printf("*** Assertion failed (%s) at line %4d in %s\n", \ - mesg, (int)__LINE__, __FILE__); \ - if (fatal){ \ - fflush(stdout); \ - goto die_jar_jar_die; \ - } \ + mesg, (int)__LINE__, __FILE__); \ + if (fatal){ \ + fflush(stdout); \ + goto die_jar_jar_die; \ + } \ } \ } while(0) #define RANK 1 @@ -180,38 +180,38 @@ int main(int argc, char **argv) /* setup file access template with parallel IO access. */ if (opt_split_vfd){ - hid_t mpio_pl; - - mpio_pl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_mpio(mpio_pl, MPI_COMM_WORLD, MPI_INFO_NULL); - VRFY((ret >= 0), "", H5FATAL); - - /* set optional allocation alignment */ - if (opt_alignment*opt_threshold != 1){ - ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment ); - VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); - } - - /* setup file access template */ - acc_tpl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_split(acc_tpl, meta_ext, mpio_pl, raw_ext, mpio_pl); - VRFY((ret >= 0), "H5Pset_fapl_split succeeded", H5FATAL); - ret = H5Pclose(mpio_pl); - VRFY((ret >= 0), "H5Pclose mpio_pl succeeded", H5FATAL); + hid_t mpio_pl; + + mpio_pl = H5Pcreate (H5P_FILE_ACCESS); + VRFY((acc_tpl >= 0), "", H5FATAL); + ret = H5Pset_fapl_mpio(mpio_pl, MPI_COMM_WORLD, MPI_INFO_NULL); + VRFY((ret >= 0), "", H5FATAL); + + /* set optional allocation alignment */ + if (opt_alignment*opt_threshold != 1){ + ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment ); + VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); + } + + /* setup file access template */ + acc_tpl = H5Pcreate (H5P_FILE_ACCESS); + VRFY((acc_tpl >= 0), "", H5FATAL); + ret = H5Pset_fapl_split(acc_tpl, meta_ext, mpio_pl, raw_ext, mpio_pl); + VRFY((ret >= 0), "H5Pset_fapl_split succeeded", H5FATAL); + ret = H5Pclose(mpio_pl); + VRFY((ret >= 0), "H5Pclose mpio_pl succeeded", H5FATAL); }else{ - /* setup file access template */ - acc_tpl = H5Pcreate (H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL); - VRFY((ret >= 0), "", H5FATAL); - - /* set optional allocation alignment */ - if (opt_alignment*opt_threshold != 1){ - ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment ); - VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); - } + /* setup file access template */ + acc_tpl = H5Pcreate (H5P_FILE_ACCESS); + VRFY((acc_tpl >= 0), "", H5FATAL); + ret = H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL); + VRFY((ret >= 0), "", H5FATAL); + + /* set optional allocation alignment */ + if (opt_alignment*opt_threshold != 1){ + ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment ); + VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); + } } h5_fixname_no_suffix(FILENAME[0], acc_tpl, filename, sizeof filename); @@ -225,7 +225,7 @@ int main(int argc, char **argv) sid = H5Screate_simple(RANK, dims, NULL); VRFY((sid >= 0), "H5Screate_simple succeeded", H5FATAL); dataset = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_CHAR, sid, - H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); VRFY((dataset >= 0), "H5Dcreate2 succeeded", H5FATAL); /* create the memory dataspace and the file dataspace */ diff --git a/tools/perform/pio_perf.h b/tools/perform/pio_perf.h index b595c90..7605f20 100644 --- a/tools/perform/pio_perf.h +++ b/tools/perform/pio_perf.h @@ -15,7 +15,6 @@ #include "io_timer.h" #ifndef STANDALONE -#include "H5private.h" #include "h5test.h" #include "h5tools.h" #include "h5tools_utils.h" @@ -36,22 +35,22 @@ typedef enum iotype_ { } iotype; typedef struct parameters_ { - iotype io_type; /* The type of IO test to perform */ - int num_procs; /* Maximum number of processes to use */ - long num_files; /* Number of files to create */ - long num_dsets; /* Number of datasets to create */ - off_t num_bytes; /* Number of bytes in each dset */ + iotype io_type; /* The type of IO test to perform */ + int num_procs; /* Maximum number of processes to use */ + long num_files; /* Number of files to create */ + long num_dsets; /* Number of datasets to create */ + off_t num_bytes; /* Number of bytes in each dset */ int num_iters; /* Number of times to loop doing the IO */ - size_t buf_size; /* Buffer size */ - size_t blk_size; /* Block size */ + size_t buf_size; /* Buffer size */ + size_t blk_size; /* Block size */ unsigned interleaved; /* Interleaved vs. contiguous blocks */ unsigned collective; /* Collective vs. independent I/O */ unsigned dim2d; /* 1D vs. 2D */ - hsize_t h5_align; /* HDF5 object alignment */ - hsize_t h5_thresh; /* HDF5 object alignment threshold */ - int h5_use_chunks; /* Make HDF5 dataset chunked */ - int h5_write_only; /* Perform the write tests only */ - int verify; /* Verify data correctness */ + hsize_t h5_align; /* HDF5 object alignment */ + hsize_t h5_thresh; /* HDF5 object alignment threshold */ + int h5_use_chunks; /* Make HDF5 dataset chunked */ + int h5_write_only; /* Perform the write tests only */ + int verify; /* Verify data correctness */ } parameters; typedef struct results_ { diff --git a/tools/perform/zip_perf.c b/tools/perform/zip_perf.c index 0636d3b..e301bb3 100644 --- a/tools/perform/zip_perf.c +++ b/tools/perform/zip_perf.c @@ -419,7 +419,9 @@ fill_with_random_data(Bytef *src, uLongf src_len) buf += rc; len -= (size_t)rc; } - } else { + HDclose(fd); + } + else { HDfprintf(stdout, "Using random() for random data\n"); for (u = 0; u < src_len; ++u) @@ -557,7 +559,7 @@ main(int argc, char **argv) int opt; prog = argv[0]; - + /* Initialize h5tools lib */ h5tools_init(); |