Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ warning and build fixes #707

Merged
merged 44 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ba9deae
Committing clang-format changes
github-actions[bot] Mar 19, 2021
00f9750
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 21, 2021
e997283
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 22, 2021
3eac585
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 23, 2021
71643b7
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 24, 2021
d242911
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 24, 2021
bc70f95
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 26, 2021
3d7ad8e
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 26, 2021
aeb16b7
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins Mar 26, 2021
765cb5b
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 27, 2021
18401fc
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 29, 2021
222242c
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins Mar 29, 2021
8d0cafa
Merge remote-tracking branch 'canonical/develop' into develop
derobins Mar 30, 2021
d3694d1
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 2, 2021
1c7bcc2
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 15, 2021
70551e3
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 16, 2021
2dfc7db
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 20, 2021
71d2fbf
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 21, 2021
c8925f8
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 22, 2021
dd3e970
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins Apr 22, 2021
bb61990
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 23, 2021
2c2b368
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 25, 2021
be2ada6
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 27, 2021
439f3a8
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 28, 2021
649aa9b
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 29, 2021
3fa627f
Merge remote-tracking branch 'canonical/develop' into develop
derobins Apr 29, 2021
0df36ec
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 3, 2021
d65c841
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 6, 2021
fc7eb21
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins May 6, 2021
130d491
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 8, 2021
544b320
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 15, 2021
bb66bb1
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 18, 2021
0c87055
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 20, 2021
33ca480
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 21, 2021
8f9fffa
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 22, 2021
a0fe592
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 24, 2021
92d5fcf
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 25, 2021
8e71a0e
Merge branch 'develop' of https://github.com/derobins/hdf5 into develop
derobins May 25, 2021
f740f2e
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 27, 2021
802519c
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 27, 2021
527af61
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 28, 2021
6c0e1db
Merge remote-tracking branch 'canonical/develop' into develop
derobins May 28, 2021
1b5c01d
C++ build and warning updates
derobins May 29, 2021
4c3fee0
Undo warning clobber
derobins May 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,6 @@ if (EXISTS "${HDF5_SOURCE_DIR}/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/c++")
endif ()
endif ()

include (${HDF_RESOURCES_EXT_DIR}/HDFUseCXX.cmake)
include (${HDF_RESOURCES_DIR}/HDFCXXCompilerFlags.cmake)

add_subdirectory (c++)
Expand Down
5 changes: 1 addition & 4 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
./.github/workflows/main.yml _DO_NOT_DISTRIBUTE_
./.github/workflows/pr-check.yml _DO_NOT_DISTRIBUTE_

./m4/aclocal_cxx.m4
./m4/aclocal_fc.m4
./m4/aclocal_fc.f90
./m4/ax_check_class.m4
Expand Down Expand Up @@ -172,6 +171,7 @@
./config/gnu-warnings/cxx-4.8
./config/gnu-warnings/cxx-4.9
./config/gnu-warnings/cxx-5
./config/gnu-warnings/cxx-9
./config/gnu-warnings/cxx-error-5
./config/gnu-warnings/cxx-error-general
./config/gnu-warnings/cxx-noerror-5
Expand Down Expand Up @@ -3545,7 +3545,6 @@
./config/cmake/CTestCustom.cmake
./config/cmake/fileCompareTest.cmake
./config/cmake/FindHDFS.cmake
./config/cmake/H5cxx_config.h.in
./config/cmake/H5pubconf.h.in
./config/cmake/hdf5-config.cmake.in
./config/cmake/hdf5-config-version.cmake.in
Expand Down Expand Up @@ -3580,11 +3579,9 @@
./config/cmake_ext_mod/hdf.bmp
./config/cmake_ext_mod/hdf.icns
./config/cmake_ext_mod/hdf.ico
./config/cmake_ext_mod/HDFCXXTests.cpp
./config/cmake_ext_mod/HDFLibMacros.cmake
./config/cmake_ext_mod/HDFMacros.cmake
./config/cmake_ext_mod/HDFTests.c
./config/cmake_ext_mod/HDFUseCXX.cmake
./config/cmake_ext_mod/HDFUseFortran.cmake
./config/cmake_ext_mod/NSIS.InstallOptions.ini.in
./config/cmake_ext_mod/NSIS.template.in
Expand Down
7 changes: 0 additions & 7 deletions c++/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
cmake_minimum_required (VERSION 3.12)
project (HDF5_CPP_SRC CXX)

#-----------------------------------------------------------------------------
# Generate configure file
#-----------------------------------------------------------------------------
configure_file (${HDF_RESOURCES_DIR}/H5cxx_config.h.in
${HDF5_SRC_BINARY_DIR}/H5cxx_pubconf.h
)

#-----------------------------------------------------------------------------
# Define cpp Library
#-----------------------------------------------------------------------------
Expand Down
10 changes: 0 additions & 10 deletions c++/src/H5Cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,4 @@
#include "H5File.h"
#include "H5Library.h"

/* Some C++ compilers do not have offsetof macro; define to bypass the problem
- BMR- -EIP- 2007/08/01
*/
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer true. C++11 adds additional functionality on top of offset(), so it will always be present.

#ifndef H5_CXX_HAVE_OFFSETOF
#ifdef HOFFSET
#undef HOFFSET
#endif
#define HOFFSET(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER)
#endif

#endif // H5Cpp_H
7 changes: 3 additions & 4 deletions c++/src/H5DataSpace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ const DataSpace &DataSpace::ALL = *getConstant();
///\exception H5::DataSpaceIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
DataSpace::DataSpace(H5S_class_t type) : IdComponent()
DataSpace::DataSpace(H5S_class_t type) : IdComponent(), id{H5Screate(type)}
{
id = H5Screate(type);
if (id < 0) {
throw DataSpaceIException("DataSpace constructor", "H5Screate failed");
}
Expand All @@ -105,9 +104,9 @@ DataSpace::DataSpace(H5S_class_t type) : IdComponent()
///\exception H5::DataSpaceIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
DataSpace::DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims) : IdComponent()
DataSpace::DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims)
: IdComponent(), id{H5Screate_simple(rank, dims, maxdims)}
{
id = H5Screate_simple(rank, dims, maxdims);
if (id < 0) {
throw DataSpaceIException("DataSpace constructor", "H5Screate_simple failed");
}
Expand Down
24 changes: 11 additions & 13 deletions c++/src/H5DataType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ DataType::DataType(const hid_t existing_id) : H5Object(), id(existing_id), encod
///\exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), encoded_buf(NULL), buf_size(0)
DataType::DataType(const H5T_class_t type_class, size_t size)
: H5Object(), id{H5Tcreate(type_class, size)}, encoded_buf(NULL), buf_size(0)
{
// Call C routine to create the new datatype
id = H5Tcreate(type_class, size);
if (id < 0) {
throw DataTypeIException("DataType constructor", "H5Tcreate failed");
}
Expand All @@ -97,9 +96,10 @@ DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), enco
// Programmer Binh-Minh Ribler - Oct, 2006
//--------------------------------------------------------------------------
DataType::DataType(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist)
: H5Object(), encoded_buf(NULL), buf_size(0)
: H5Object(), id{H5Location::p_dereference(loc.getId(), ref, ref_type, plist,
"constructor - by dereference")},
encoded_buf(NULL), buf_size(0)
{
id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference");
}

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -146,10 +146,9 @@ DataType::DataType(const DataType &original) : H5Object(), id(original.id), enco
// unnecessarily and will produce undefined behavior.
// -BMR, Apr 2015
//--------------------------------------------------------------------------
DataType::DataType(const PredType &pred_type) : H5Object(), encoded_buf(NULL), buf_size(0)
DataType::DataType(const PredType &pred_type)
: H5Object(), id{H5Tcopy(pred_type.getId())}, encoded_buf(NULL), buf_size(0)
{
// Call C routine to copy the datatype
id = H5Tcopy(pred_type.getId());
if (id < 0)
throw DataTypeIException("DataType constructor", "H5Tcopy failed");
}
Expand All @@ -168,9 +167,9 @@ DataType::DataType(const PredType &pred_type) : H5Object(), encoded_buf(NULL), b
// improve usability.
// -BMR, Dec 2016
//--------------------------------------------------------------------------
DataType::DataType(const H5Location &loc, const char *dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0)
DataType::DataType(const H5Location &loc, const char *dtype_name)
: H5Object(), id{p_opentype(loc, dtype_name)}, encoded_buf(NULL), buf_size(0)
{
id = p_opentype(loc, dtype_name);
}

//--------------------------------------------------------------------------
Expand All @@ -188,9 +187,8 @@ DataType::DataType(const H5Location &loc, const char *dtype_name) : H5Object(),
// -BMR, Dec 2016
//--------------------------------------------------------------------------
DataType::DataType(const H5Location &loc, const H5std_string &dtype_name)
: H5Object(), encoded_buf(NULL), buf_size(0)
: H5Object(), id{p_opentype(loc, dtype_name.c_str())}, encoded_buf(NULL), buf_size(0)
{
id = p_opentype(loc, dtype_name.c_str());
}

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -318,7 +316,7 @@ DataType::encode()

// Allocate buffer and call C function again to encode
if (buf_size > 0) {
encoded_buf = (unsigned char *)HDcalloc((size_t)1, buf_size);
encoded_buf = static_cast<unsigned char *>(HDcalloc(1, buf_size));
ret_value = H5Tencode(id, encoded_buf, &buf_size);
if (ret_value < 0) {
throw DataTypeIException("DataType::encode", "H5Tencode failed");
Expand Down
4 changes: 2 additions & 2 deletions c++/src/H5DxferProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ DSetMemXferPropList::getBuffer(void **tconv, void **bkg) const
void
DSetMemXferPropList::setPreserve(bool status) const
{
herr_t ret_value = H5Pset_preserve(id, (hbool_t)status);
herr_t ret_value = H5Pset_preserve(id, static_cast<hbool_t>(status));
if (ret_value < 0) {
throw PropListIException("DSetMemXferPropList::setPreserve", "H5Pset_preserve failed");
}
Expand Down Expand Up @@ -314,7 +314,7 @@ DSetMemXferPropList::getDataTransform() const
H5std_string expression;

// Preliminary call to get the expression's length
ssize_t exp_len = H5Pget_data_transform(id, NULL, (size_t)0);
ssize_t exp_len = H5Pget_data_transform(id, NULL, 0);

// If H5Pget_data_transform returns a negative value, raise an exception
if (exp_len < 0) {
Expand Down
2 changes: 1 addition & 1 deletion c++/src/H5Exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const char Exception::DEFAULT_MSG[] = "No detailed information provided";
///\brief Default constructor.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
Exception::Exception()
Exception::Exception() : detail_message{""}, func_name{""}
{
}

Expand Down
6 changes: 2 additions & 4 deletions c++/src/H5File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,8 @@ H5File::p_get_file(const char *name, unsigned int flags, const FileCreatPropList
// constructor is needed by the library in order to return
// an object, H5File doesn't need it. -BMR (HDFFV-8766 partially)
//--------------------------------------------------------------------------
H5File::H5File(hid_t existing_id) : Group()
H5File::H5File(hid_t existing_id) : Group(), id{existing_id}
{
id = existing_id;
incRefCount(); // increment number of references to this id
}

Expand All @@ -180,9 +179,8 @@ H5File::H5File(hid_t existing_id) : Group()
///\param original - IN: H5File instance to copy
// December 2000
//--------------------------------------------------------------------------
H5File::H5File(const H5File &original) : Group(original)
H5File::H5File(const H5File &original) : Group(original), id{original.getId()}
{
id = original.getId();
incRefCount(); // increment number of references to this id
}

Expand Down
4 changes: 2 additions & 2 deletions c++/src/H5LcreatProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id)
void
LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const
{
herr_t ret_value = H5Pset_create_intermediate_group(id, (unsigned)crt_intmd_group);
herr_t ret_value = H5Pset_create_intermediate_group(id, static_cast<unsigned>(crt_intmd_group));
// Throw exception if H5Pset_create_intermediate_group returns failure
if (ret_value < 0) {
throw PropListIException("setCreateIntermediateGroup", "H5Pset_create_intermediate_group failed");
Expand All @@ -146,7 +146,7 @@ LinkCreatPropList::getCreateIntermediateGroup() const
throw PropListIException("getCreateIntermediateGroup", "H5Pget_create_intermediate_group failed");
}

return ((bool)crt_intmd_group);
return static_cast<bool>(crt_intmd_group);
}

//--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion c++/src/H5Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ H5Location::getComment(const char *name, size_t buf_size) const
H5std_string comment;

// Preliminary call to get the comment's length
ssize_t comment_len = H5Oget_comment_by_name(getId(), name, NULL, (size_t)0, H5P_DEFAULT);
ssize_t comment_len = H5Oget_comment_by_name(getId(), name, NULL, 0, H5P_DEFAULT);

// If H5Oget_comment_by_name returns a negative value, raise an exception
if (comment_len < 0) {
Expand Down
8 changes: 3 additions & 5 deletions c++/src/H5PropList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,8 @@ PropList::PropList(const PropList &original) : IdComponent(), id(original.id)
// property's id to H5P_DEFAULT.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
PropList::PropList(const hid_t plist_id) : IdComponent()
PropList::PropList(const hid_t plist_id) : IdComponent(), id{H5P_DEFAULT}
{
if (plist_id <= 0)
id = H5P_DEFAULT;

H5I_type_t id_type = H5Iget_type(plist_id);
switch (id_type) {
case H5I_GENPROP_CLS:
Expand Down Expand Up @@ -633,11 +630,12 @@ PropList::setProperty(const char *name, void *value) const
void
PropList::setProperty(const char *name, const char *charptr) const
{
herr_t ret_value = H5Pset(id, name, (const void *)charptr);
herr_t ret_value = H5Pset(id, name, static_cast<const void *>(charptr));
if (ret_value < 0) {
throw PropListIException(inMemFunc("setProperty"), "H5Pset failed");
}
}

//--------------------------------------------------------------------------
// Function: PropList::setProperty
///\brief This is an overloaded member function, provided for convenience.
Expand Down
Loading