summaryrefslogtreecommitdiffstats
path: root/tools/h5repack
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2018-11-09 14:13:07 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2018-11-09 14:13:07 (GMT)
commit4da93e9d6f9ee0fc7462ee66645c5ad0fa9a9e35 (patch)
treead6d5f412a8f1af0a2121bb0fb7fa3073462c713 /tools/h5repack
parentf97de01d36cde2b66042ffac3debcfab72de0c1d (diff)
downloadhdf5-4da93e9d6f9ee0fc7462ee66645c5ad0fa9a9e35.zip
hdf5-4da93e9d6f9ee0fc7462ee66645c5ad0fa9a9e35.tar.gz
hdf5-4da93e9d6f9ee0fc7462ee66645c5ad0fa9a9e35.tar.bz2
TRILABS-81 coverity tools fixes
Diffstat (limited to 'tools/h5repack')
-rw-r--r--tools/h5repack/CMakeLists.txt82
-rw-r--r--tools/h5repack/h5repack_copy.c6
-rw-r--r--tools/h5repack/h5repack_main.c2
-rw-r--r--tools/h5repack/h5repack_parse.c2
-rw-r--r--tools/h5repack/h5repacktst.c33
5 files changed, 67 insertions, 58 deletions
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);
}
/*-------------------------------------------------------------------------