From d16dbbf455d081e2addf4f1d15c4b343c6758c5f Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Jan 2022 09:36:10 +0100 Subject: [PATCH 1/8] add error::kDefault and property::kDefault constants --- doc/design/source/design/property_lists.rst | 35 +++++++-------- examples/rgbpixel.hpp | 2 +- examples/useage/app.cpp | 2 +- examples/useage/core.cpp | 2 +- examples/useage/core.hpp | 2 +- src/h5cpp/attribute/attribute.cpp | 9 ++-- src/h5cpp/attribute/attribute_manager.cpp | 8 ++-- src/h5cpp/core/fixed_length_string.hpp | 2 +- src/h5cpp/core/object_handle.cpp | 12 +++++ src/h5cpp/core/object_handle.hpp | 2 +- src/h5cpp/core/object_id.cpp | 7 +-- src/h5cpp/core/path.cpp | 3 +- src/h5cpp/core/utilities.hpp | 5 ++- src/h5cpp/dataspace/selection.hpp | 7 +++ src/h5cpp/dataspace/selection_manager.cpp | 3 +- src/h5cpp/dataspace/simple.cpp | 15 +++++-- src/h5cpp/dataspace/view.cpp | 3 +- src/h5cpp/datatype/array.cpp | 5 ++- src/h5cpp/datatype/compound.cpp | 12 ++--- src/h5cpp/datatype/compound.hpp | 7 +++ src/h5cpp/datatype/float.cpp | 5 ++- src/h5cpp/datatype/integer.cpp | 3 +- src/h5cpp/datatype/string.cpp | 4 +- src/h5cpp/datatype/types.cpp | 18 ++++---- src/h5cpp/error/descriptor.cpp | 13 +++--- src/h5cpp/error/error.cpp | 18 ++++---- src/h5cpp/error/error.hpp | 11 ++++- src/h5cpp/file/file.cpp | 11 ++--- src/h5cpp/file/functions.hpp | 3 +- src/h5cpp/file/types.cpp | 12 ++--- src/h5cpp/filter/external_filter.cpp | 11 +++-- src/h5cpp/filter/external_filter.hpp | 9 +++- src/h5cpp/filter/szip.cpp | 1 + src/h5cpp/node/dataset.cpp | 11 ++--- src/h5cpp/node/dataset.hpp | 25 ++++++----- src/h5cpp/node/link.cpp | 2 +- src/h5cpp/node/link_iterator.cpp | 7 +-- src/h5cpp/node/link_view.cpp | 5 ++- src/h5cpp/node/node_iterator.cpp | 7 +-- src/h5cpp/property/creation_order.hpp | 2 +- src/h5cpp/property/dataset_creation.cpp | 5 ++- src/h5cpp/property/link_access.cpp | 2 - src/h5cpp/property/link_access.hpp | 13 +++--- src/h5cpp/property/object_copy.cpp | 2 +- src/h5cpp/property/property_list.hpp | 9 ++++ test/core/ObjectHandleDefault.cpp | 2 +- test/core/attribute_object_handle_test.cpp | 6 +-- test/core/dataset_object_handle_test.cpp | 4 +- test/core/file_object_handle_test.cpp | 2 +- test/core/group_object_handle_test.cpp | 4 +- test/core/iteration_index_test.cpp | 2 +- test/core/object_handle_test.hpp | 7 +-- test/core/object_id_test.cpp | 49 +++++++++++---------- test/core/test_environment.cpp | 2 +- test/dataspace/selection_manager_test.cpp | 2 +- test/dataspace/selection_operator_set.cpp | 2 +- test/dataspace/type_test.cpp | 2 +- test/datatype/test_traits.hpp | 2 +- test/error/error_test.cpp | 4 +- test/error/h5c_error_test.cpp | 2 +- test/file/file_image_test.cpp | 11 ++--- test/filter/external_filter_test.cpp | 2 +- test/filter/fletcher32_test.cpp | 2 +- test/filter/nbit_test.cpp | 2 +- test/h5cpp_test_helpers.hpp | 2 +- test/node/dataset_direct_chunk_test.cpp | 8 ++-- test/node/dataset_partial_io_test.cpp | 2 +- test/node/functions_test.cpp | 2 +- test/node/type_test.cpp | 2 +- test/property/creation_order_test.cpp | 2 +- test/property/dataset_creation_test.cpp | 2 +- test/property/property_class_test.cpp | 2 +- test/property/type_creation_test.cpp | 2 +- 73 files changed, 281 insertions(+), 204 deletions(-) diff --git a/doc/design/source/design/property_lists.rst b/doc/design/source/design/property_lists.rst index 3c5799f67e..56fc4dce1a 100644 --- a/doc/design/source/design/property_lists.rst +++ b/doc/design/source/design/property_lists.rst @@ -2,10 +2,10 @@ Property lists ============== -Property lists are the basic mechanism to pass arguments to the functions +Property lists are the basic mechanism to pass arguments to the functions of the C-API. One major obstacle of the C interface is that though there is a whole bunch -of different property lists, all of them are represented as the same instance +of different property lists, all of them are represented as the same instance of :cpp:type:`hid_t` instance. Hence, the compiler cannot check if the correct property list is passed to as an argument. The C++ wrapper provides an extensive set of property list types which make type checking at compile time possible. @@ -13,13 +13,13 @@ set of property list types which make type checking at compile time possible. .. figure:: ../images/property_lists_inheritance.png :align: center :width: 75% - + The base class :cpp:class:`property_list_t` owns the :cpp:type:`id_t` instance -associated with a particular property list. The child classes should -provide convenience methods to set the parameters of a particular property -list. +associated with a particular property list. The child classes should +provide convenience methods to set the parameters of a particular property +list. -To demonstrate the motivation for these property list types consider +To demonstrate the motivation for these property list types consider the following C function to create a dataset .. code-block:: c @@ -31,10 +31,10 @@ the following C function to create a dataset hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) - -The last three arguments are the id's to the *link creation property list*, -the *dataset creation property list* and the *dataset access property list*. -A possible wrapper for this function in C++ could look like this + +The last three arguments are the id's to the *link creation property list*, +the *dataset creation property list* and the *dataset access property list*. +A possible wrapper for this function in C++ could look like this .. code-block:: c++ @@ -45,18 +45,15 @@ A possible wrapper for this function in C++ could look like this const property_list::link_create_t &lcpl, const property_list::dataset_create_t &dcpl, const property_list::dataset_access_t &dapl) - + With this signature it would be possible for the compiler to check the types -of the property lists passed to the function at compile-time instead of -waiting for a runtime error when testing the program. +of the property lists passed to the function at compile-time instead of +waiting for a runtime error when testing the program. General requirements ==================== * the base class :cpp:class:`property_list_t` should not be constructible! * property lists of every type should be *default constructible* -* in case of a default construction the appropriate :cpp:any:`H5P_DEFAULT` - default property list should be constructed. - - - +* in case of a default construction the appropriate :cpp:var:`property::kDefault` + default property list should be constructed. diff --git a/examples/rgbpixel.hpp b/examples/rgbpixel.hpp index 9bbf812d24..4a998ccfa1 100644 --- a/examples/rgbpixel.hpp +++ b/examples/rgbpixel.hpp @@ -46,4 +46,4 @@ class RGBPixel std::uint8_t green() const; void green(std::uint8_t value); -}; \ No newline at end of file +}; diff --git a/examples/useage/app.cpp b/examples/useage/app.cpp index b4f9bddd02..80e6d9e790 100644 --- a/examples/useage/app.cpp +++ b/examples/useage/app.cpp @@ -4,4 +4,4 @@ int main() { auto file = create_file("test.h5"); return 0; -} \ No newline at end of file +} diff --git a/examples/useage/core.cpp b/examples/useage/core.cpp index 4ee292a3cd..bb88737904 100644 --- a/examples/useage/core.cpp +++ b/examples/useage/core.cpp @@ -2,4 +2,4 @@ hdf5::file::File create_file(const std::string &name) { return hdf5::file::create(name); -} \ No newline at end of file +} diff --git a/examples/useage/core.hpp b/examples/useage/core.hpp index 9a6ae11dda..8d4fca9a54 100644 --- a/examples/useage/core.hpp +++ b/examples/useage/core.hpp @@ -3,4 +3,4 @@ #include -hdf5::file::File create_file(const std::string &filename); \ No newline at end of file +hdf5::file::File create_file(const std::string &filename); diff --git a/src/h5cpp/attribute/attribute.cpp b/src/h5cpp/attribute/attribute.cpp index 78cc393bbd..3ae00d21fe 100644 --- a/src/h5cpp/attribute/attribute.cpp +++ b/src/h5cpp/attribute/attribute.cpp @@ -26,6 +26,7 @@ // Created on: Oct 4, 2017 // #include +#include #include namespace hdf5 { @@ -69,15 +70,15 @@ dataspace::Dataspace Attribute::dataspace() const std::string Attribute::name() const { - ssize_t size = H5Aget_name(static_cast(handle_),0,NULL); - if(size<0) + ssize_t ssize = H5Aget_name(static_cast(handle_),0,nullptr); + if(ssize<0) { error::Singleton::instance().throw_with_stack("Could not determine the size of the attributes name!"); } - std::string buffer(size,' '); + std::string buffer(signed2unsigned(ssize),' '); char *ptr = const_cast(buffer.data()); - if(H5Aget_name(static_cast(handle_),size+1,ptr)<0) + if(H5Aget_name(static_cast(handle_),signed2unsigned(ssize+1),ptr)<0) { error::Singleton::instance().throw_with_stack("Failure retrieving the attributes name!"); } diff --git a/src/h5cpp/attribute/attribute_manager.cpp b/src/h5cpp/attribute/attribute_manager.cpp index 5936151458..91a2d56349 100644 --- a/src/h5cpp/attribute/attribute_manager.cpp +++ b/src/h5cpp/attribute/attribute_manager.cpp @@ -43,7 +43,7 @@ Attribute AttributeManager::operator[](size_t index) const static_cast(iter_config_.index()), static_cast(iter_config_.order()), index, - H5P_DEFAULT, + property::kDefault, static_cast(iter_config_.link_access_list()) ); if(id<0) @@ -62,7 +62,7 @@ Attribute AttributeManager::operator[](const std::string &name) const { hid_t id = H5Aopen_by_name(static_cast(node_),".", name.c_str(), - H5P_DEFAULT, + property::kDefault, static_cast(iter_config_.link_access_list()) ); if(id<0) @@ -147,7 +147,7 @@ Attribute AttributeManager::create(const std::string &name, static_cast(datatype), static_cast(dataspace), static_cast(acpl), - H5P_DEFAULT); + property::kDefault); if(id<0) { std::stringstream ss; @@ -192,7 +192,7 @@ AttributeIterator AttributeManager::begin() const AttributeIterator AttributeManager::end() const { - return AttributeIterator(*this,size()); + return AttributeIterator(*this,unsigned2signed(size())); } } // namespace attribute diff --git a/src/h5cpp/core/fixed_length_string.hpp b/src/h5cpp/core/fixed_length_string.hpp index 78fa234dda..de2346c149 100644 --- a/src/h5cpp/core/fixed_length_string.hpp +++ b/src/h5cpp/core/fixed_length_string.hpp @@ -140,7 +140,7 @@ struct FixedLengthStringTrait> for(const auto &str: data) { std::copy(str.begin(),str.end(),iter); - std::advance(iter,memory_type.size()); //move iterator to the next position + std::advance(iter,unsigned2signed(memory_type.size())); //move iterator to the next position } return buffer; diff --git a/src/h5cpp/core/object_handle.cpp b/src/h5cpp/core/object_handle.cpp index acb37d72ce..dec3321ceb 100644 --- a/src/h5cpp/core/object_handle.cpp +++ b/src/h5cpp/core/object_handle.cpp @@ -227,6 +227,18 @@ void ObjectHandle::close() case ObjectHandle::Type::ErrorClass: error_code = H5Eunregister_class(handle_); break; + case ObjectHandle::Type::Dataset: + error_code = H5Dclose(handle_); + break; + case ObjectHandle::Type::Uninitialized: + error_code = H5Oclose(handle_); + break; + case ObjectHandle::Type::BadObject: + error_code = H5Oclose(handle_); + break; + case ObjectHandle::Type::VirtualFileLayer: + error_code = H5Oclose(handle_); + break; default: error_code = H5Oclose(handle_); } diff --git a/src/h5cpp/core/object_handle.hpp b/src/h5cpp/core/object_handle.hpp index 64e3142587..609825e193 100644 --- a/src/h5cpp/core/object_handle.hpp +++ b/src/h5cpp/core/object_handle.hpp @@ -131,7 +131,7 @@ class DLL_EXPORT ObjectHandle /*! \code ..... - hdf5::ObjectHandle handle(H5Gopen(fid,"data",H5P_DEFAULT)); + hdf5::ObjectHandle handle(H5Gopen(fid,"data",hdf5::property::kDefault)); ... \endcode */ diff --git a/src/h5cpp/core/object_id.cpp b/src/h5cpp/core/object_id.cpp index c18fefab72..7a586a6d54 100644 --- a/src/h5cpp/core/object_id.cpp +++ b/src/h5cpp/core/object_id.cpp @@ -22,6 +22,7 @@ // Author: Martin Shetty // #include +#include #include #include @@ -30,7 +31,7 @@ namespace hdf5 std::string ObjectId::get_file_name(const ObjectHandle &handle) { - ssize_t size = H5Fget_name(static_cast(handle), NULL, 0); + ssize_t size = H5Fget_name(static_cast(handle), nullptr, 0); if(size<0) { error::Singleton::instance().throw_with_stack("Failure retrieving the size of the filename string!"); @@ -38,10 +39,10 @@ std::string ObjectId::get_file_name(const ObjectHandle &handle) //we have to add the space for the space for the \0 which will terminate the //string - std::vector buffer(size+1,'\0'); + std::vector buffer(signed2unsigned(size+1),'\0'); //read the characters to the buffer - if(H5Fget_name(static_cast(handle), buffer.data(), size+1)<0) + if(H5Fget_name(static_cast(handle), buffer.data(), signed2unsigned(size+1))<0) { error::Singleton::instance().throw_with_stack("Failure to retrieve the name of the HDF5 file."); } diff --git a/src/h5cpp/core/path.cpp b/src/h5cpp/core/path.cpp index 85c5d86dfa..f6de2b2781 100644 --- a/src/h5cpp/core/path.cpp +++ b/src/h5cpp/core/path.cpp @@ -26,6 +26,7 @@ // #include +#include #include #include @@ -233,7 +234,7 @@ Path Path::relative_to(const Path &base) const throw std::runtime_error("invalid base for relative path!"); } auto it = link_names_.begin(); - std::advance(it, base.size()); + std::advance(it, unsigned2signed(base.size())); Path ret; for (; it != link_names_.end(); ++it) ret.link_names_.push_back(*it); diff --git a/src/h5cpp/core/utilities.hpp b/src/h5cpp/core/utilities.hpp index a619919b3c..01b6e9947a 100644 --- a/src/h5cpp/core/utilities.hpp +++ b/src/h5cpp/core/utilities.hpp @@ -28,6 +28,7 @@ #include #include #include +#include /** * @brief convert unsigned to signed integers @@ -52,10 +53,10 @@ TType unsigned2signed(SType &&source_value) { // provide compile time errors if types are not appropriate static_assert(std::is_integral::value && std::is_signed::value, - "source type must be an unsigned integral type"); + "target type must be a signed integral type"); static_assert(std::is_integral::value && std::is_unsigned::value, - "target type must be a signed integral type"); + "source type must be an unsigned integral type"); using target_limits = std::numeric_limits; // if the source value is smaller than the maximum positive value of the diff --git a/src/h5cpp/dataspace/selection.hpp b/src/h5cpp/dataspace/selection.hpp index 2a644533fc..5dcd74f300 100644 --- a/src/h5cpp/dataspace/selection.hpp +++ b/src/h5cpp/dataspace/selection.hpp @@ -114,10 +114,17 @@ class DLL_EXPORT Selection { virtual SelectionType type() const = 0; }; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif struct OperationWithSelection { SelectionOperation operation; Selection::SharedPointer selection; }; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif using SelectionPair = std::pair; using SelectionList = std::list; diff --git a/src/h5cpp/dataspace/selection_manager.cpp b/src/h5cpp/dataspace/selection_manager.cpp index bfa7d66d0b..9848fcc62f 100644 --- a/src/h5cpp/dataspace/selection_manager.cpp +++ b/src/h5cpp/dataspace/selection_manager.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include namespace hdf5 { @@ -45,7 +46,7 @@ size_t SelectionManager::size() const { if (s < 0) { error::Singleton::instance().throw_with_stack("Failure retrieving selection size!"); } - return s; + return signed2unsigned(s); } SelectionType SelectionManager::type() const { diff --git a/src/h5cpp/dataspace/simple.cpp b/src/h5cpp/dataspace/simple.cpp index 0b09beb7e0..331e7d9122 100644 --- a/src/h5cpp/dataspace/simple.cpp +++ b/src/h5cpp/dataspace/simple.cpp @@ -29,9 +29,18 @@ namespace hdf5 { namespace dataspace { - + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wold-style-cast" +#endif + const hsize_t Simple::unlimited = H5S_UNLIMITED; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + Simple::Simple() : Dataspace(Type::Simple) {} @@ -78,7 +87,7 @@ Dimensions Simple::current_dimensions() const { } Dimensions dims(my_rank); - if (H5Sget_simple_extent_dims(static_cast(*this), dims.data(), NULL) < 0) { + if (H5Sget_simple_extent_dims(static_cast(*this), dims.data(), nullptr) < 0) { error::Singleton::instance().throw_with_stack("Could not retrieve current dimensions for Simple dataspace"); } return dims; @@ -94,7 +103,7 @@ Dimensions Simple::maximum_dimensions() const { } Dimensions dims(my_rank); - if (H5Sget_simple_extent_dims(static_cast(*this), NULL, dims.data()) < 0) { + if (H5Sget_simple_extent_dims(static_cast(*this), nullptr, dims.data()) < 0) { error::Singleton::instance().throw_with_stack("Could not retrieve maximum dimensions for Simple dataspace"); } return dims; diff --git a/src/h5cpp/dataspace/view.cpp b/src/h5cpp/dataspace/view.cpp index 5c880395e0..c52d680930 100644 --- a/src/h5cpp/dataspace/view.cpp +++ b/src/h5cpp/dataspace/view.cpp @@ -27,6 +27,7 @@ #include #include +#include namespace hdf5 { namespace dataspace { @@ -76,7 +77,7 @@ size_t View::size() const { if (s < 0) { error::Singleton::instance().throw_with_stack("Failure retrieving selection size!"); } - return s; + return signed2unsigned(s); } } // namespace dataspace diff --git a/src/h5cpp/datatype/array.cpp b/src/h5cpp/datatype/array.cpp index 2da451e966..cc788d9b80 100644 --- a/src/h5cpp/datatype/array.cpp +++ b/src/h5cpp/datatype/array.cpp @@ -27,6 +27,7 @@ #include #include +#include #include namespace hdf5 { @@ -45,7 +46,7 @@ Array::Array(const Datatype &type) : } Array Array::create(const Datatype &base_type, const Dimensions &dims) { - hid_t ret = H5Tarray_create(static_cast(base_type), static_cast(dims.size()), dims.data()); + hid_t ret = H5Tarray_create(static_cast(base_type), static_cast(dims.size()), dims.data()); if (ret < 0) { std::stringstream ss; ss << "Could not create Array of base=" << base_type.get_class(); @@ -76,7 +77,7 @@ size_t Array::rank() const { if (ndims < 0) { error::Singleton::instance().throw_with_stack("Could not obtain rank for Array datatype!"); } - return ndims; + return signed2unsigned(ndims); } VLengthArray::VLengthArray(ObjectHandle &&handle) : diff --git a/src/h5cpp/datatype/compound.cpp b/src/h5cpp/datatype/compound.cpp index bdee58b214..bb92cca614 100644 --- a/src/h5cpp/datatype/compound.cpp +++ b/src/h5cpp/datatype/compound.cpp @@ -57,7 +57,7 @@ Compound Compound::create(size_t size) { Datatype Compound::operator[](size_t index) const { - hid_t id = H5Tget_member_type(static_cast(*this), unsigned2signed(index)); + hid_t id = H5Tget_member_type(static_cast(*this), static_cast(index)); if (id < 0) { std::stringstream ss; @@ -78,13 +78,13 @@ size_t Compound::field_index(const std::string &name) const { ss << "Failure to obtain the index for field [" << name << "] in compound data type!"; error::Singleton::instance().throw_with_stack(ss.str()); } - return index; + return signed2unsigned(index); } // implementation same as for Enum std::string Compound::field_name(size_t index) const { - char *buffer = H5Tget_member_name(static_cast(*this), unsigned2signed(index)); - if (buffer == NULL) { + char *buffer = H5Tget_member_name(static_cast(*this), static_cast(index)); + if (buffer == nullptr) { std::stringstream ss; ss << "Failure to obtain name of field [" << index << "] in compound data type!"; error::Singleton::instance().throw_with_stack(ss.str()); @@ -105,7 +105,7 @@ size_t Compound::field_offset(const std::string &name) const { } size_t Compound::field_offset(size_t index) const { - size_t offset = H5Tget_member_offset(static_cast(*this), unsigned2signed(index)); + size_t offset = H5Tget_member_offset(static_cast(*this), static_cast(index)); if (offset == 0) { // if offset == 0, there could be a field at 0, or there could be nothing try { @@ -126,7 +126,7 @@ Class Compound::field_class(const std::string &name) const { } Class Compound::field_class(size_t index) const { - H5T_class_t value = H5Tget_member_class(static_cast(*this), unsigned2signed(index)); + H5T_class_t value = H5Tget_member_class(static_cast(*this), static_cast(index)); if (value < 0) { std::stringstream ss; ss << "Failure to obtain type class for field [" << index << "] in compound type!"; diff --git a/src/h5cpp/datatype/compound.hpp b/src/h5cpp/datatype/compound.hpp index fd12aed714..226ac83cf7 100644 --- a/src/h5cpp/datatype/compound.hpp +++ b/src/h5cpp/datatype/compound.hpp @@ -37,6 +37,10 @@ namespace datatype { //! A compound data type which can be used for data elements of heterogeneous //! type like C-structures or a C++ class. //! +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#endif class DLL_EXPORT Compound : public Datatype { public: //! @@ -92,6 +96,9 @@ class DLL_EXPORT Compound : public Datatype { void pack() const; }; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif } // namespace datatype } // namespace hdf5 diff --git a/src/h5cpp/datatype/float.cpp b/src/h5cpp/datatype/float.cpp index 9d5ecf2c1c..8a40634611 100644 --- a/src/h5cpp/datatype/float.cpp +++ b/src/h5cpp/datatype/float.cpp @@ -28,6 +28,7 @@ #include #include +#include #include namespace hdf5 { @@ -67,7 +68,7 @@ size_t Float::offset() const { if (p < 0) { error::Singleton::instance().throw_with_stack("Could not retrieve datatype offset"); } - return p; + return signed2unsigned(p); } void Float::offset(size_t offset) const { @@ -135,7 +136,7 @@ void Float::fields(size_t spos, size_t epos, size_t esize, size_t mpos, size_t m } size_t Float::ebias() const { - ssize_t p = H5Tget_ebias(static_cast(*this)); + size_t p = H5Tget_ebias(static_cast(*this)); if (p == 0) { error::Singleton::instance().throw_with_stack("Could not retrieve datatype ebias"); } diff --git a/src/h5cpp/datatype/integer.cpp b/src/h5cpp/datatype/integer.cpp index 5ff1319d17..cd7acf4293 100644 --- a/src/h5cpp/datatype/integer.cpp +++ b/src/h5cpp/datatype/integer.cpp @@ -28,6 +28,7 @@ #include #include +#include #include namespace hdf5 { @@ -83,7 +84,7 @@ size_t Integer::offset() const { if (p < 0) { error::Singleton::instance().throw_with_stack("Could not retrieve datatype offset"); } - return p; + return signed2unsigned(p); } void Integer::offset(size_t offset) const { diff --git a/src/h5cpp/datatype/string.cpp b/src/h5cpp/datatype/string.cpp index 190766130b..c1c30954d8 100644 --- a/src/h5cpp/datatype/string.cpp +++ b/src/h5cpp/datatype/string.cpp @@ -49,7 +49,7 @@ String String::variable() { // We assume no H5 errors are possible here String ret = ObjectHandle(H5Tcopy(H5T_C_S1)); - H5Tset_size(static_cast(ret), H5T_VARIABLE); + H5Tset_size(static_cast(ret), kVariable); return ret; } @@ -129,7 +129,7 @@ void String::padding(StringPad strpad) size_t String::size() const { if (is_variable_length()) - return H5T_VARIABLE; + return kVariable; return Datatype::size(); } diff --git a/src/h5cpp/datatype/types.cpp b/src/h5cpp/datatype/types.cpp index e41a7b8199..af89f1f15b 100644 --- a/src/h5cpp/datatype/types.cpp +++ b/src/h5cpp/datatype/types.cpp @@ -44,24 +44,26 @@ std::ostream &operator<<(std::ostream &stream, const Class &c) { case Class::Enum: return stream << "ENUM"; case Class::VarLength: return stream << "VARLENGTH"; case Class::Array: return stream << "ARRAY"; - default:return stream; } + return stream; } std::ostream &operator<<(std::ostream &stream, const Order &o) { switch (o) { case Order::BE: return stream << "BE"; case Order::LE: return stream << "LE"; - default:return stream; + case Order::Vax: return stream << "VAX"; + case Order::None: return stream << "NONE"; } + return stream; } std::ostream &operator<<(std::ostream &stream, const Sign &s) { switch (s) { case Sign::TwosComplement: return stream << "TWOS COMPLEMENT"; case Sign::Unsigned: return stream << "UNSIGNED"; - default:return stream; } + return stream; } std::ostream &operator<<(std::ostream &stream, const Norm &n) { @@ -69,8 +71,8 @@ std::ostream &operator<<(std::ostream &stream, const Norm &n) { case Norm::Implied: return stream << "IMPLIED"; case Norm::MSBSet: return stream << "MSBSET"; case Norm::None: return stream << "NONE"; - default:return stream; } + return stream; } std::ostream &operator<<(std::ostream &stream, const Pad &p) { @@ -78,8 +80,8 @@ std::ostream &operator<<(std::ostream &stream, const Pad &p) { case Pad::Background: return stream << "BACKGROUND"; case Pad::One: return stream << "ONE"; case Pad::Zero: return stream << "ZERO"; - default:return stream; } + return stream; } std::ostream &operator<<(std::ostream &stream, const StringPad &pad) { @@ -87,24 +89,24 @@ std::ostream &operator<<(std::ostream &stream, const StringPad &pad) { case StringPad::NullPad: return stream << "NULLPAD"; case StringPad::NullTerm: return stream << "NULLTERM"; case StringPad::SpacePad: return stream << "SPACEPAD"; - default:return stream; } + return stream; } std::ostream &operator<<(std::ostream &stream, const Direction &d) { switch (d) { case Direction::Ascend: return stream << "ASCEND"; case Direction::Descend: return stream << "DESCEND"; - default:return stream; } + return stream; } std::ostream &operator<<(std::ostream &stream, const CharacterEncoding &enc) { switch (enc) { case CharacterEncoding::ASCII: return stream << "ASCII"; case CharacterEncoding::UTF8: return stream << "UTF8"; - default:return stream; } + return stream; } } // namespace datatype diff --git a/src/h5cpp/error/descriptor.cpp b/src/h5cpp/error/descriptor.cpp index 1f3430a89d..2aac33cb07 100644 --- a/src/h5cpp/error/descriptor.cpp +++ b/src/h5cpp/error/descriptor.cpp @@ -24,6 +24,7 @@ // #include +#include #include #include @@ -63,20 +64,20 @@ void Descriptor::extract_strings() ssize_t message_size = 0; // retrieve the major error message - message_size = H5Eget_msg(maj_num,&message_type,NULL,0); + message_size = H5Eget_msg(maj_num,&message_type,nullptr,0); if(message_size > 0 && message_type == H5E_MAJOR) { - std::vector message_buffer(message_size+1); - H5Eget_msg(maj_num,&message_type,message_buffer.data(),message_size+1); + std::vector message_buffer(signed2unsigned(message_size+1)); + H5Eget_msg(maj_num,&message_type,message_buffer.data(),signed2unsigned(message_size+1)); major = std::string(message_buffer.begin(),--message_buffer.end()); } // retrieve the minor error message - message_size = H5Eget_msg(min_num,&message_type,NULL,0); + message_size = H5Eget_msg(min_num,&message_type,nullptr,0); if(message_size > 0 && message_type == H5E_MINOR) { - std::vector message_buffer(message_size+1); - H5Eget_msg(min_num,&message_type,message_buffer.data(),message_size+1); + std::vector message_buffer(signed2unsigned(message_size+1)); + H5Eget_msg(min_num,&message_type,message_buffer.data(),signed2unsigned(message_size+1)); minor = std::string(message_buffer.begin(),--message_buffer.end()); } } diff --git a/src/h5cpp/error/error.cpp b/src/h5cpp/error/error.cpp index b4227de6f9..dd79895c38 100644 --- a/src/h5cpp/error/error.cpp +++ b/src/h5cpp/error/error.cpp @@ -39,9 +39,9 @@ namespace error { void Singleton::auto_print(bool enable) { - herr_t ret = H5Eset_auto2(H5E_DEFAULT, - enable ? reinterpret_cast(H5Eprint2) : NULL, - enable ? stderr : NULL); + herr_t ret = H5Eset_auto2(error::kDefault, + enable ? reinterpret_cast(H5Eprint2) : nullptr, + enable ? stderr : nullptr); if (0 > ret) { @@ -59,7 +59,7 @@ bool Singleton::auto_print() const H5CError Singleton::extract_stack() { std::list ret; - herr_t err = H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, + herr_t err = H5Ewalk2(error::kDefault, H5E_WALK_DOWNWARD, reinterpret_cast(to_list), &ret); if (0 > err) @@ -87,7 +87,7 @@ void Singleton::throw_with_stack(const std::string& message) throw std::runtime_error(message); } -std::string print_nested(const std::exception& exception, int level) +std::string print_nested(const std::exception& exception, size_t level) { std::stringstream ss; ss << std::string(level, ' ') << exception.what() << '\n'; @@ -121,7 +121,7 @@ void Singleton::throw_stack() void Singleton::clear_stack() { - herr_t ret = H5Eclear2(H5E_DEFAULT); + herr_t ret = H5Eclear2(error::kDefault); if (0 > ret) { throw std::runtime_error("Could not clear HDF5 error stack"); @@ -130,15 +130,15 @@ void Singleton::clear_stack() bool Singleton::auto_print_enabled() const { - H5E_auto2_t func = NULL; - herr_t ret = H5Eget_auto2(H5E_DEFAULT, &func, NULL); + H5E_auto2_t func = nullptr; + herr_t ret = H5Eget_auto2(error::kDefault, &func, nullptr); if (0 > ret) { throw std::runtime_error("Could not determine automatic error printing settings"); } - return (func != NULL); + return (func != nullptr); } herr_t Singleton::to_list(unsigned n, diff --git a/src/h5cpp/error/error.hpp b/src/h5cpp/error/error.hpp index 86fd9e969b..9ef2d38c68 100644 --- a/src/h5cpp/error/error.hpp +++ b/src/h5cpp/error/error.hpp @@ -30,6 +30,15 @@ namespace hdf5 { namespace error { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wold-style-cast" +#endif +const decltype(H5E_DEFAULT) kDefault = H5E_DEFAULT; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + //! //! \brief singleton class for HDF5 error handling //! @@ -134,7 +143,7 @@ class DLL_EXPORT Singleton //! //! \param level indentation level //! -std::string DLL_EXPORT print_nested(const std::exception& exception, int level = 0); +std::string DLL_EXPORT print_nested(const std::exception& exception, size_t level = 0); } // namespace file diff --git a/src/h5cpp/file/file.cpp b/src/h5cpp/file/file.cpp index 02a7c69f7a..b526fe7ba7 100644 --- a/src/h5cpp/file/file.cpp +++ b/src/h5cpp/file/file.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace hdf5 { @@ -64,7 +65,7 @@ size_t File::size() const ssize_t File::buffer_size() const { - ssize_t s = H5Fget_file_image(static_cast(*this), NULL, 0); + ssize_t s = H5Fget_file_image(static_cast(*this), nullptr, 0); if (s < 0) { error::Singleton::instance().throw_with_stack("Failure retrieving the buffer size"); @@ -103,15 +104,15 @@ void File::close() fs::path File::path() const { - ssize_t size = H5Fget_name(static_cast(*this), NULL, 0); + ssize_t size = H5Fget_name(static_cast(*this), nullptr, 0); if (size < 0) { error::Singleton::instance().throw_with_stack("Failure to determine file name length!"); } - std::vector buffer(size + 1); - if (H5Fget_name(static_cast(*this), buffer.data(), size + 1) < 0) + std::vector buffer(signed2unsigned(size + 1)); + if (H5Fget_name(static_cast(*this), buffer.data(), signed2unsigned(size + 1)) < 0) { std::stringstream ss; ss << "Error retrieving file name of size " << size << " for HDF5 file!"; @@ -130,7 +131,7 @@ size_t File::count_open_objects(SearchFlagsBase flags) const error::Singleton::instance().throw_with_stack("Failure retrieving the open object count for this file!"); } - return nobjects; + return signed2unsigned(nobjects); } size_t File::count_open_objects(SearchFlags flag) const diff --git a/src/h5cpp/file/functions.hpp b/src/h5cpp/file/functions.hpp index 4f5e46be78..818f4fe00d 100644 --- a/src/h5cpp/file/functions.hpp +++ b/src/h5cpp/file/functions.hpp @@ -36,6 +36,7 @@ #include #include #include +#include namespace hdf5 { @@ -157,7 +158,7 @@ File from_buffer(T &data, { if ((flags & ImageFlags::DontCopy) && !(flags & ImageFlags::DontRelease)) throw std::runtime_error("Invalid ImageFlags in from_buffer: the DONT_COPY flag without the DONT_RELEASE flag"); - size_t databytesize = mem_space.size() * mem_type.size(); + size_t databytesize = signed2unsigned(mem_space.size()) * mem_type.size(); hid_t fid = 0; if(mem_type.get_class() == datatype::Class::Integer) { diff --git a/src/h5cpp/file/types.cpp b/src/h5cpp/file/types.cpp index 2ade80c391..6bad11f989 100644 --- a/src/h5cpp/file/types.cpp +++ b/src/h5cpp/file/types.cpp @@ -42,9 +42,8 @@ std::ostream &operator<<(std::ostream &stream,const AccessFlags &flags) case AccessFlags::SWMRRead: return stream<<"SWMR READ"; case AccessFlags::SWMRWrite: return stream<<"SWMR WRITE"; #endif - default: - return stream; } + return stream; } AccessFlagsBase operator|(const AccessFlags &lhs,const AccessFlags &rhs) @@ -87,9 +86,8 @@ std::ostream &operator<<(std::ostream &stream,const ImageFlags &flags) case ImageFlags::DontCopy: return stream<<"DONT COPY"; case ImageFlags::DontRelease: return stream<<"DONT RELEASE"; case ImageFlags::All: return stream<<"ALL"; - default: - return stream; } + return stream; } ImageFlagsBase operator|(const ImageFlags &lhs,const ImageFlags &rhs) @@ -134,9 +132,8 @@ std::ostream &operator<<(std::ostream &stream,const SearchFlags &flags) case SearchFlags::File: return stream<<"FILE"; case SearchFlags::Group: return stream<<"GROUP"; case SearchFlags::Local: return stream<<"LOCAL"; - default: - return stream; } + return stream; } SearchFlagsBase operator|(const SearchFlags &lhs,const SearchFlags &rhs) @@ -175,9 +172,8 @@ std::ostream &operator<<(std::ostream &stream,const Scope &scope) { case Scope::Global: return stream<<"GLOBAL"; case Scope::Local: return stream<<"LOCAL"; - default: - return stream; } + return stream; } diff --git a/src/h5cpp/filter/external_filter.cpp b/src/h5cpp/filter/external_filter.cpp index 943b4b81cd..10495d1ae4 100644 --- a/src/h5cpp/filter/external_filter.cpp +++ b/src/h5cpp/filter/external_filter.cpp @@ -24,6 +24,7 @@ // #include +#include #include #include #include @@ -56,14 +57,12 @@ ExternalFilter::ExternalFilter(): { } -ExternalFilter::~ExternalFilter() -{} - void ExternalFilter::operator()(const property::DatasetCreationList &dcpl, Availability flag) const { - if(H5Pset_filter(static_cast(dcpl), id(), static_cast(flag), + if(H5Pset_filter(static_cast(dcpl), id(), + signed2unsigned(static_cast(flag)), cd_values_.size(), cd_values_.data()) < 0) { error::Singleton::instance().throw_with_stack("Could not apply external filter!"); @@ -100,7 +99,7 @@ const std::vector ExternalFilters::fill(const property::DatasetCre cd_values.data(), fname.size(), fname.data(), - NULL); + nullptr); if(filter_id < 0) { std::stringstream ss; @@ -115,7 +114,7 @@ const std::vector ExternalFilters::fill(const property::DatasetCre error::Singleton::instance().throw_with_stack(ss.str()); } cd_values.resize(cd_number); - if(static_cast(static_cast(flag)) != flag) + if(static_cast(static_cast(flag)) != unsigned2signed(flag)) { std::stringstream ss; ss<<"Wrong filter flag value in " << dcpl.get_class(); diff --git a/src/h5cpp/filter/external_filter.hpp b/src/h5cpp/filter/external_filter.hpp index 27cd0ae735..e926b52da0 100644 --- a/src/h5cpp/filter/external_filter.hpp +++ b/src/h5cpp/filter/external_filter.hpp @@ -41,6 +41,10 @@ namespace filter { //! DLL_EXPORT bool is_filter_available(FilterID id); +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif class DLL_EXPORT ExternalFilter : public Filter { @@ -58,7 +62,6 @@ class DLL_EXPORT ExternalFilter : public Filter const std::vector cd_values, const std::string &name=std::string()); ExternalFilter(); - ~ExternalFilter() override; //! //! \brief apply filter @@ -102,6 +105,10 @@ class DLL_EXPORT ExternalFilter : public Filter #endif }; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4251) diff --git a/src/h5cpp/filter/szip.cpp b/src/h5cpp/filter/szip.cpp index 6b3c2f0ed8..05163dcc93 100644 --- a/src/h5cpp/filter/szip.cpp +++ b/src/h5cpp/filter/szip.cpp @@ -92,6 +92,7 @@ std::ostream &operator<<(std::ostream &stream,const SZip::OptionMask &flags) { switch(flags) { + case SZip::OptionMask::None : return stream<<"WITHOUT_CODING"; case SZip::OptionMask::AllowK13 : return stream<<"ALLOW_K13_CODING"; case SZip::OptionMask::Chip : return stream<<"CHIP_CODING"; case SZip::OptionMask::EntropyCoding : return stream<<"ENTROPY_CODING"; diff --git a/src/h5cpp/node/dataset.cpp b/src/h5cpp/node/dataset.cpp index c54e016105..568bdc4f57 100644 --- a/src/h5cpp/node/dataset.cpp +++ b/src/h5cpp/node/dataset.cpp @@ -33,6 +33,7 @@ #include #include #include +#include namespace hdf5 { namespace node { @@ -84,8 +85,8 @@ Dataset::Dataset(const Node &node): ss<<"Node ["<(delta); dataset.resize(current_dims); } diff --git a/src/h5cpp/node/dataset.hpp b/src/h5cpp/node/dataset.hpp index ffcf050aaa..3085bd7b24 100644 --- a/src/h5cpp/node/dataset.hpp +++ b/src/h5cpp/node/dataset.hpp @@ -52,6 +52,7 @@ class Selection; #ifdef __clang__ #pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wweak-vtables" #endif class DLL_EXPORT Dataset : public Node @@ -566,7 +567,7 @@ class DLL_EXPORT Dataset : public Node filter::ExternalFilters filters() const; private: - datatype::Datatype file_type; + datatype::Datatype file_type_; datatype::Class file_type_class; dataspace::DataspacePool space_pool; //! @@ -833,23 +834,23 @@ void Dataset::write(const T &data,const datatype::Datatype &mem_type, { if(file_type_class == datatype::Class::VarLength) { - write_variable_length_data(data,mem_type,mem_space,file_type,file_space,dtpl); + write_variable_length_data(data,mem_type,mem_space,file_type_,file_space,dtpl); } else if(file_type_class == datatype::Class::String) { - datatype::String string_type(file_type); + datatype::String string_type(file_type_); if(string_type.is_variable_length()) { - write_variable_length_string_data(data,mem_type,mem_space,file_type,file_space,dtpl); + write_variable_length_string_data(data,mem_type,mem_space,file_type_,file_space,dtpl); } else { - write_fixed_length_string_data(data,mem_type,mem_space,file_type,file_space,dtpl); + write_fixed_length_string_data(data,mem_type,mem_space,file_type_,file_space,dtpl); } } else { - write_contiguous_data(data,mem_type,mem_space,file_type,file_space,dtpl); + write_contiguous_data(data,mem_type,mem_space,file_type_,file_space,dtpl); } } @@ -1036,23 +1037,23 @@ void Dataset::read(T &data,const datatype::Datatype &mem_type, { if(file_type_class == datatype::Class::VarLength) { - read_variable_length_data(data,mem_type,mem_space,file_type,file_space,dtpl); + read_variable_length_data(data,mem_type,mem_space,file_type_,file_space,dtpl); } else if(file_type_class == datatype::Class::String) { - datatype::String string_type(file_type); + datatype::String string_type(file_type_); if(string_type.is_variable_length()) { - read_variable_length_string_data(data,mem_type,mem_space,file_type,file_space,dtpl); + read_variable_length_string_data(data,mem_type,mem_space,file_type_,file_space,dtpl); } else { - read_fixed_length_string_data(data,mem_type,mem_space,file_type,file_space,dtpl); + read_fixed_length_string_data(data,mem_type,mem_space,file_type_,file_space,dtpl); } } else { - read_contiguous_data(data,mem_type,mem_space,file_type,file_space,dtpl); + read_contiguous_data(data,mem_type,mem_space,file_type_,file_space,dtpl); } } @@ -1177,7 +1178,7 @@ void Dataset::read(T &data,const property::DatasetTransferList &dtpl) hdf5::dataspace::DataspaceHolder mem_space_holder(space_pool); if(file_type_class == datatype::Class::String){ // in hdf5 1.12.1 UFT8 data cannot be read to an ASCII buffer - read_reshape(data, file_type, mem_space_holder.get(data), dtpl); + read_reshape(data, file_type_, mem_space_holder.get(data), dtpl); } else { hdf5::datatype::DatatypeHolder mem_type_holder; diff --git a/src/h5cpp/node/link.cpp b/src/h5cpp/node/link.cpp index c528da097c..61fae65090 100644 --- a/src/h5cpp/node/link.cpp +++ b/src/h5cpp/node/link.cpp @@ -125,7 +125,7 @@ LinkTarget Link::get_external_link_target(const property::LinkAccessList &lapl) const char *filename_buffer, *objectpath_buffer; - if(H5Lunpack_elink_val(value.c_str(),value.size()+1,0, + if(H5Lunpack_elink_val(value.c_str(),value.size()+1,nullptr, &filename_buffer,&objectpath_buffer)<0) { std::stringstream ss; diff --git a/src/h5cpp/node/link_iterator.cpp b/src/h5cpp/node/link_iterator.cpp index bca4b3e6f4..dd47a609ef 100644 --- a/src/h5cpp/node/link_iterator.cpp +++ b/src/h5cpp/node/link_iterator.cpp @@ -25,6 +25,7 @@ #include #include +#include namespace hdf5 { namespace node { @@ -43,18 +44,18 @@ LinkIterator LinkIterator::begin(const Group &group) LinkIterator LinkIterator::end(const Group &group) { - return LinkIterator(group,group.links.size()); + return LinkIterator(group,unsigned2signed(group.links.size())); } Link LinkIterator::operator*() const { - current_link_ = group_.links[index()]; + current_link_ = group_.links[signed2unsigned(index())]; return current_link_; } Link *LinkIterator::operator->() { - current_link_ = group_.links[index()]; + current_link_ = group_.links[signed2unsigned(index())]; return ¤t_link_; } diff --git a/src/h5cpp/node/link_view.cpp b/src/h5cpp/node/link_view.cpp index 0f7d9a041d..fa21850a85 100644 --- a/src/h5cpp/node/link_view.cpp +++ b/src/h5cpp/node/link_view.cpp @@ -27,6 +27,7 @@ #include #include #include +#include namespace hdf5 { namespace node { @@ -60,7 +61,7 @@ Link LinkView::operator[](size_t index) const } //setting up the string where to store the name - std::string name(size,' '); + std::string name(signed2unsigned(size),' '); //------------------------------------------------------------------------ // load the link name @@ -71,7 +72,7 @@ Link LinkView::operator[](size_t index) const static_cast(config.order()), index, const_cast(name.data()), - size+1, + signed2unsigned(size+1), static_cast(config.link_access_list())); if(size<0) { diff --git a/src/h5cpp/node/node_iterator.cpp b/src/h5cpp/node/node_iterator.cpp index de9b761edf..459ef8b4d7 100644 --- a/src/h5cpp/node/node_iterator.cpp +++ b/src/h5cpp/node/node_iterator.cpp @@ -25,6 +25,7 @@ #include #include +#include namespace hdf5 { namespace node { @@ -43,18 +44,18 @@ NodeIterator NodeIterator::begin(const Group &group) NodeIterator NodeIterator::end(const Group &group) { - return NodeIterator(group,group.nodes.size()); + return NodeIterator(group,unsigned2signed(group.nodes.size())); } Node NodeIterator::operator*() const { - current_node_ = group_.nodes[index()]; + current_node_ = group_.nodes[signed2unsigned(index())]; return current_node_; } Node *NodeIterator::operator->() { - current_node_ = group_.nodes[index()]; + current_node_ = group_.nodes[signed2unsigned(index())]; return ¤t_node_; } diff --git a/src/h5cpp/property/creation_order.hpp b/src/h5cpp/property/creation_order.hpp index b0db7874cf..6189323e47 100644 --- a/src/h5cpp/property/creation_order.hpp +++ b/src/h5cpp/property/creation_order.hpp @@ -119,7 +119,7 @@ class DLL_EXPORT CreationOrder { unsigned tracked_:1; unsigned indexed_:1; #ifdef __clang__ - __attribute__((unused)) unsigned reserved_:sizeof(unsigned) - 2; + unsigned reserved_:sizeof(unsigned) - 2 __attribute__((unused)); #else unsigned reserved_:sizeof(unsigned) - 2; #endif diff --git a/src/h5cpp/property/dataset_creation.cpp b/src/h5cpp/property/dataset_creation.cpp index 5593ff9c12..205ba107fc 100644 --- a/src/h5cpp/property/dataset_creation.cpp +++ b/src/h5cpp/property/dataset_creation.cpp @@ -27,6 +27,7 @@ // #include #include +#include namespace hdf5 { namespace property { @@ -113,12 +114,12 @@ void DatasetCreationList::chunk(const Dimensions &chunk_dims) const { } Dimensions DatasetCreationList::chunk() const { - int s = H5Pget_chunk(static_cast(*this), 0, NULL); + int s = H5Pget_chunk(static_cast(*this), 0, nullptr); if (s < 0) { error::Singleton::instance().throw_with_stack("Failure retrieving the chunk rank!"); } - Dimensions buffer(s); + Dimensions buffer(signed2unsigned(s)); if (H5Pget_chunk(static_cast(*this), s, buffer.data()) < 0) { error::Singleton::instance().throw_with_stack("Failure retrieving the chunk dimension!"); } diff --git a/src/h5cpp/property/link_access.cpp b/src/h5cpp/property/link_access.cpp index 2ab4185fa5..471df0fe03 100644 --- a/src/h5cpp/property/link_access.cpp +++ b/src/h5cpp/property/link_access.cpp @@ -53,8 +53,6 @@ LinkAccessList::LinkAccessList(ObjectHandle &&handle) : } } -LinkAccessList::~LinkAccessList() {} - size_t LinkAccessList::maximum_link_traversals() const { size_t buffer = 0; if (H5Pget_nlinks(static_cast(*this), &buffer) < 0) { diff --git a/src/h5cpp/property/link_access.hpp b/src/h5cpp/property/link_access.hpp index 19e059a240..dd5c8ed511 100644 --- a/src/h5cpp/property/link_access.hpp +++ b/src/h5cpp/property/link_access.hpp @@ -33,6 +33,10 @@ namespace hdf5 { namespace property { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#endif //! //! \brief link access property list //! @@ -43,11 +47,6 @@ class DLL_EXPORT LinkAccessList : public List { //! LinkAccessList(); - //! - //! \brief destructor - //! - virtual ~LinkAccessList() override; - explicit LinkAccessList(ObjectHandle &&handle); //! @@ -105,5 +104,9 @@ class DLL_EXPORT LinkAccessList : public List { #endif }; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + } // namespace property } // namespace hdf5 diff --git a/src/h5cpp/property/object_copy.cpp b/src/h5cpp/property/object_copy.cpp index 3e439d9215..ca4b2c091d 100644 --- a/src/h5cpp/property/object_copy.cpp +++ b/src/h5cpp/property/object_copy.cpp @@ -41,8 +41,8 @@ std::ostream &operator<<(std::ostream &stream, const CopyFlag &flag) { case CopyFlag::ExpandReferences:return stream << "EXPAND_REFERENCES"; case CopyFlag::WithoutAttributes:return stream << "WITHOUT_ATTRIBUTES"; case CopyFlag::MergeCommittedTypes:return stream << "MERGE_COMMITTED_TYPES"; - default:return stream << "NONE"; //should never happen } + return stream << "NONE"; //should never happen } CopyFlags operator|(const CopyFlag &lhs, const CopyFlag &rhs) { diff --git a/src/h5cpp/property/property_list.hpp b/src/h5cpp/property/property_list.hpp index bef938fef4..95f2ed687d 100644 --- a/src/h5cpp/property/property_list.hpp +++ b/src/h5cpp/property/property_list.hpp @@ -37,6 +37,15 @@ namespace hdf5 { namespace property { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wold-style-cast" +#endif +const decltype(H5P_DEFAULT) kDefault = H5P_DEFAULT; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + class Class; //! diff --git a/test/core/ObjectHandleDefault.cpp b/test/core/ObjectHandleDefault.cpp index d6fa350ee2..c1d65fc5be 100644 --- a/test/core/ObjectHandleDefault.cpp +++ b/test/core/ObjectHandleDefault.cpp @@ -99,4 +99,4 @@ TEST_CASE("testing handle behavior for different object types") { test->test_close_pathology(); test->test_equality(); } -} \ No newline at end of file +} diff --git a/test/core/attribute_object_handle_test.cpp b/test/core/attribute_object_handle_test.cpp index f6e0386f6c..fb819765e8 100644 --- a/test/core/attribute_object_handle_test.cpp +++ b/test/core/attribute_object_handle_test.cpp @@ -30,7 +30,7 @@ AttributeObjectHandleTest::AttributeObjectHandleTest(const std::string &fname): ObjectHandleTest(hdf5::ObjectHandle::Type::Attribute), filename_(fname), environment_(filename_), - group_(H5Gcreate(static_cast(environment_.file_handle()),"test",H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT)) + group_(H5Gcreate(static_cast(environment_.file_handle()),"test",hdf5::property::kDefault,hdf5::property::kDefault,hdf5::property::kDefault)) { hdf5::ObjectHandle dtype(H5Tcopy(H5T_NATIVE_DOUBLE)); hdf5::ObjectHandle dspace(H5Screate(H5S_SCALAR)); @@ -38,7 +38,7 @@ AttributeObjectHandleTest::AttributeObjectHandleTest(const std::string &fname): H5Acreate(static_cast(group_),"test", static_cast(dtype), static_cast(dspace), - H5P_DEFAULT,H5P_DEFAULT); + hdf5::property::kDefault,hdf5::property::kDefault); } AttributeObjectHandleTest::~AttributeObjectHandleTest() @@ -48,5 +48,5 @@ AttributeObjectHandleTest::~AttributeObjectHandleTest() hid_t AttributeObjectHandleTest::create_object() { - return H5Aopen(static_cast(group_),"test",H5P_DEFAULT); + return H5Aopen(static_cast(group_),"test",hdf5::property::kDefault); } diff --git a/test/core/dataset_object_handle_test.cpp b/test/core/dataset_object_handle_test.cpp index 99f06838b9..46ab86268f 100644 --- a/test/core/dataset_object_handle_test.cpp +++ b/test/core/dataset_object_handle_test.cpp @@ -35,7 +35,7 @@ DatasetObjectHandleTest::DatasetObjectHandleTest(const std::string &filename): H5Dcreate(static_cast(environment_.file_handle()),"test", static_cast(dtype_), static_cast(dspace_), - H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); + hdf5::property::kDefault,hdf5::property::kDefault,hdf5::property::kDefault); } DatasetObjectHandleTest::~DatasetObjectHandleTest() @@ -45,7 +45,7 @@ DatasetObjectHandleTest::~DatasetObjectHandleTest() hid_t DatasetObjectHandleTest::create_object() { - return H5Dopen(static_cast(environment_.file_handle()),"test",H5P_DEFAULT); + return H5Dopen(static_cast(environment_.file_handle()),"test",hdf5::property::kDefault); } diff --git a/test/core/file_object_handle_test.cpp b/test/core/file_object_handle_test.cpp index 2fe91e921e..cf0f7ce383 100644 --- a/test/core/file_object_handle_test.cpp +++ b/test/core/file_object_handle_test.cpp @@ -38,7 +38,7 @@ FileObjectHandleTest::~FileObjectHandleTest() hid_t FileObjectHandleTest::create_object() { - return H5Fcreate(filename_.c_str(),H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT); + return H5Fcreate(filename_.c_str(),H5F_ACC_TRUNC,hdf5::property::kDefault,hdf5::property::kDefault); } diff --git a/test/core/group_object_handle_test.cpp b/test/core/group_object_handle_test.cpp index dc6ae56b94..9dd1d98c30 100644 --- a/test/core/group_object_handle_test.cpp +++ b/test/core/group_object_handle_test.cpp @@ -31,12 +31,12 @@ GroupObjectHandleTest::GroupObjectHandleTest(const std::string &filename): environment_(filename) { H5Gcreate(static_cast(environment_.file_handle()),"test", - H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); + hdf5::property::kDefault,hdf5::property::kDefault,hdf5::property::kDefault); } hid_t GroupObjectHandleTest::create_object() { - return H5Gopen(static_cast(environment_.file_handle()),"test",H5P_DEFAULT); + return H5Gopen(static_cast(environment_.file_handle()),"test",hdf5::property::kDefault); } diff --git a/test/core/iteration_index_test.cpp b/test/core/iteration_index_test.cpp index bfc36375f6..3a3cb177c0 100644 --- a/test/core/iteration_index_test.cpp +++ b/test/core/iteration_index_test.cpp @@ -53,4 +53,4 @@ SCENARIO("testing the iteration index") { } } -} \ No newline at end of file +} diff --git a/test/core/object_handle_test.hpp b/test/core/object_handle_test.hpp index c38458815e..f85626fcf6 100644 --- a/test/core/object_handle_test.hpp +++ b/test/core/object_handle_test.hpp @@ -29,6 +29,7 @@ #include #include +#include class TestEnvironment { @@ -75,7 +76,7 @@ class FileObjectHandleTest : public ObjectHandleTest std::string filename_{}; public: FileObjectHandleTest(const std::string &filename); - ~FileObjectHandleTest(); + ~FileObjectHandleTest() override; virtual hid_t create_object() override; }; @@ -115,7 +116,7 @@ class DatasetObjectHandleTest : public ObjectHandleTest hdf5::ObjectHandle dspace_; public: DatasetObjectHandleTest(const std::string &filename); - ~DatasetObjectHandleTest(); + ~DatasetObjectHandleTest() override; virtual hid_t create_object() override; }; @@ -128,7 +129,7 @@ class AttributeObjectHandleTest : public ObjectHandleTest hdf5::ObjectHandle group_; public: AttributeObjectHandleTest(const std::string &filename); - ~AttributeObjectHandleTest(); + ~AttributeObjectHandleTest() override; virtual hid_t create_object() override; }; diff --git a/test/core/object_id_test.cpp b/test/core/object_id_test.cpp index 01d397b1e8..3bf43bf8b9 100644 --- a/test/core/object_id_test.cpp +++ b/test/core/object_id_test.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include #include @@ -66,35 +67,35 @@ hid_t to_hid(const ObjectHandle& handle) { return static_cast(handle); } ObjectHandle h5f_create(const fs::path& path) { - hid_t id = H5Fcreate(path.string().data(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + hid_t id = H5Fcreate(path.string().data(), H5F_ACC_TRUNC, hdf5::property::kDefault, hdf5::property::kDefault); return ObjectHandle(id); } ObjectHandle h5g_create(const ObjectHandle& parent, const std::string& name) { - return ObjectHandle(H5Gcreate(to_hid(parent), name.data(), H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT)); + return ObjectHandle(H5Gcreate(to_hid(parent), name.data(), hdf5::property::kDefault, + hdf5::property::kDefault, hdf5::property::kDefault)); } auto open = [](const fs::path& p) { - return H5Fopen(p.string().data(), H5F_ACC_RDONLY, H5P_DEFAULT); + return H5Fopen(p.string().data(), H5F_ACC_RDONLY, hdf5::property::kDefault); }; auto openrw = [](const fs::path& p) { - return H5Fopen(p.string().data(), H5F_ACC_RDWR, H5P_DEFAULT); + return H5Fopen(p.string().data(), H5F_ACC_RDWR, hdf5::property::kDefault); }; void hard_link(const ObjectHandle& parent, const std::string& orig_path, const std::string& link_path) { REQUIRE(H5Lcreate_hard(to_hid(parent), orig_path.data(), to_hid(parent), - link_path.data(), H5P_DEFAULT, H5P_DEFAULT) >= 0); + link_path.data(), hdf5::property::kDefault, hdf5::property::kDefault) >= 0); } void soft_link(const ObjectHandle& parent, const std::string& orig_path, const std::string& link_path) { REQUIRE(H5Lcreate_soft(orig_path.data(), to_hid(parent), link_path.data(), - H5P_DEFAULT, H5P_DEFAULT) >= 0); + hdf5::property::kDefault, hdf5::property::kDefault) >= 0); } struct File { fs::path file_path; @@ -114,7 +115,7 @@ struct File { H5Screate_simple(static_cast(dims.size()), dims.data(), nullptr)); dataset = ObjectHandle(H5Dcreate( to_hid(group1), "dset1", H5T_NATIVE_DOUBLE, - to_hid(space), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)); + to_hid(space), hdf5::property::kDefault, hdf5::property::kDefault, hdf5::property::kDefault)); } }; } @@ -182,7 +183,7 @@ SCENARIO("working with links") { GIVEN("a hard link to group1 with name group3") { hard_link(file1.file, "/group1", "/group3"); AND_GIVEN("an id to group3") { - ObjectHandle g(H5Gopen(to_hid(file1.file), "/group3", H5P_DEFAULT)); + ObjectHandle g(H5Gopen(to_hid(file1.file), "/group3", hdf5::property::kDefault)); THEN("the handles must not be equal") { REQUIRE(to_hid(g) != to_hid(file1.group1)); } @@ -198,7 +199,7 @@ SCENARIO("working with links") { GIVEN("a soft link to group1 with name group4") { soft_link(file1.file, "/group1", "/group4"); AND_GIVEN("a handle to group4") { - ObjectHandle g(H5Gopen(to_hid(file1.file), "/group4", H5P_DEFAULT)); + ObjectHandle g(H5Gopen(to_hid(file1.file), "/group4", hdf5::property::kDefault)); THEN("the handles to group4 and group1 must be different") { REQUIRE(to_hid(g) != to_hid(file1.group1)); } @@ -214,7 +215,7 @@ SCENARIO("working with links") { GIVEN("a hard link to dset1 of name dset2") { hard_link(file1.file, "/group1/dset1", "/group2/dset2"); AND_GIVEN("a handle to /group2/dset2") { - ObjectHandle d(H5Dopen(to_hid(file1.group2), "dset2", H5P_DEFAULT)); + ObjectHandle d(H5Dopen(to_hid(file1.group2), "dset2", hdf5::property::kDefault)); THEN("handles must not be equal") { REQUIRE(to_hid(d) != to_hid(file1.dataset)); } @@ -230,7 +231,7 @@ SCENARIO("working with links") { GIVEN("a soft link to dset1 of name /group2/dset3") { soft_link(file1.file, "/group1/dset1", "/group2/dset3"); AND_GIVEN("a handle to /group2/dset3") { - ObjectHandle d(H5Dopen(to_hid(file1.group2), "dset3", H5P_DEFAULT)); + ObjectHandle d(H5Dopen(to_hid(file1.group2), "dset3", hdf5::property::kDefault)); THEN("handles must not be equal") { REQUIRE(to_hid(d) != to_hid(file1.dataset)); } @@ -274,10 +275,10 @@ SCENARIO("checking copies and files of identical structure") { files_t{path1, path3}})); GIVEN("a handle to group 1 in the first file") { ObjectHandle file1{open(std::get<0>(files))}; - ObjectHandle g_file1(H5Gopen(to_hid(file1), "/group1", H5P_DEFAULT)); + ObjectHandle g_file1(H5Gopen(to_hid(file1), "/group1", hdf5::property::kDefault)); AND_GIVEN("a handle to group 1 in the second file") { ObjectHandle file2{open(std::get<1>(files))}; - ObjectHandle g_file2(H5Gopen(to_hid(file2), "/group1", H5P_DEFAULT)); + ObjectHandle g_file2(H5Gopen(to_hid(file2), "/group1", hdf5::property::kDefault)); THEN("we expect the two handles to be different") { REQUIRE(to_hid(g_file1) != to_hid(g_file2)); } @@ -317,9 +318,9 @@ SCENARIO("testing symbolic links") { GIVEN("a handler to the first group in the original file") { ObjectHandle orig(open(path1)); ObjectHandle link(open(path2)); - ObjectHandle g_orig(H5Gopen(to_hid(orig), "/group1", H5P_DEFAULT)); + ObjectHandle g_orig(H5Gopen(to_hid(orig), "/group1", hdf5::property::kDefault)); AND_GIVEN("a handle to the group in the symbolic link") { - ObjectHandle g_link(H5Gopen(to_hid(link), "/group1", H5P_DEFAULT)); + ObjectHandle g_link(H5Gopen(to_hid(link), "/group1", hdf5::property::kDefault)); THEN("the two handle must be different") { REQUIRE(to_hid(g_orig) != to_hid(g_link)); } @@ -343,8 +344,8 @@ void external_link(const fs::path& target_file, const ObjectHandle& link_file, const std::string& link_path) { REQUIRE(H5Lcreate_external(target_file.string().data(), target_path.c_str(), - to_hid(link_file), link_path.c_str(), H5P_DEFAULT, - H5P_DEFAULT) >= 0); + to_hid(link_file), link_path.c_str(), hdf5::property::kDefault, + hdf5::property::kDefault) >= 0); } SCENARIO("testing with external links") { @@ -360,10 +361,10 @@ SCENARIO("testing with external links") { ObjectHandle file2(openrw(path2)); external_link(path1, "/group1", file2, "/group3"); AND_GIVEN("a handle to this external link group in file") { - ObjectHandle linked(H5Gopen(to_hid(file2), "/group3", H5P_DEFAULT)); + ObjectHandle linked(H5Gopen(to_hid(file2), "/group3", hdf5::property::kDefault)); AND_GIVEN("a handle to the original group in the first file") { ObjectHandle file1(open(path1)); - ObjectHandle original(H5Gopen(to_hid(file1), "/group1", H5P_DEFAULT)); + ObjectHandle original(H5Gopen(to_hid(file1), "/group1", hdf5::property::kDefault)); THEN("the two handles must be different") { REQUIRE(linked != original); } @@ -404,15 +405,15 @@ SCENARIO("testing wiht external synmbolic link") { // Extlink file2/group3 -> file3/group1 ObjectHandle file2(openrw(path2)); external_link(path3, "/group1", file2, "/group3"); - ObjectHandle group23(H5Gopen(to_hid(file2), "/group3", H5P_DEFAULT)); + ObjectHandle group23(H5Gopen(to_hid(file2), "/group3", hdf5::property::kDefault)); // Original node ObjectHandle file1(open(path1)); - ObjectHandle group11(H5Gopen(to_hid(file1), "/group1", H5P_DEFAULT)); + ObjectHandle group11(H5Gopen(to_hid(file1), "/group1", hdf5::property::kDefault)); // Node in symlinked file ObjectHandle file3(open(path3)); - ObjectHandle group31(H5Gopen(to_hid(file3), "/group1", H5P_DEFAULT)); + ObjectHandle group31(H5Gopen(to_hid(file3), "/group1", hdf5::property::kDefault)); ObjectId info11(group11); ObjectId info31(group31); @@ -504,4 +505,4 @@ SCENARIO("comparing ids") { // remove the two HDF5 file as the yare no longer required fs::remove(path1); fs::remove(path2); -} \ No newline at end of file +} diff --git a/test/core/test_environment.cpp b/test/core/test_environment.cpp index 750bc0bf55..b294887e9a 100644 --- a/test/core/test_environment.cpp +++ b/test/core/test_environment.cpp @@ -30,7 +30,7 @@ TestEnvironment::TestEnvironment(const std::string &filename): filename_{filename}, file_handle_{} { - file_handle_= hdf5::ObjectHandle{H5Fcreate(filename.c_str(),H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)}; + file_handle_= hdf5::ObjectHandle{H5Fcreate(filename.c_str(),H5F_ACC_TRUNC,hdf5::property::kDefault,hdf5::property::kDefault)}; } void TestEnvironment::close() diff --git a/test/dataspace/selection_manager_test.cpp b/test/dataspace/selection_manager_test.cpp index 133a6c73be..1b04501e34 100644 --- a/test/dataspace/selection_manager_test.cpp +++ b/test/dataspace/selection_manager_test.cpp @@ -78,4 +78,4 @@ SCENARIO("test selection handling on dataspaces") { } } } -} \ No newline at end of file +} diff --git a/test/dataspace/selection_operator_set.cpp b/test/dataspace/selection_operator_set.cpp index e1f0e9a444..455c56dafe 100644 --- a/test/dataspace/selection_operator_set.cpp +++ b/test/dataspace/selection_operator_set.cpp @@ -61,4 +61,4 @@ SCENARIO("testing the operators for selection operations") { } } } -} \ No newline at end of file +} diff --git a/test/dataspace/type_test.cpp b/test/dataspace/type_test.cpp index f14cc0f734..83c72e2d00 100644 --- a/test/dataspace/type_test.cpp +++ b/test/dataspace/type_test.cpp @@ -114,4 +114,4 @@ SCENARIO("Writing the selection operation to a stream") { stream << SelectionOperation::Prepend; THEN("the stream mus contain") { REQUIRE(stream.str() == "PREPEND");} } -} \ No newline at end of file +} diff --git a/test/datatype/test_traits.hpp b/test/datatype/test_traits.hpp index bb7f3d43b6..46cb3d1c72 100644 --- a/test/datatype/test_traits.hpp +++ b/test/datatype/test_traits.hpp @@ -50,4 +50,4 @@ TYPE_TRAIT(long long, 16); TYPE_TRAIT(unsigned long long, 16); TYPE_TRAIT(float, 4); TYPE_TRAIT(double, 8); -TYPE_TRAIT(long double, 16); \ No newline at end of file +TYPE_TRAIT(long double, 16); diff --git a/test/error/error_test.cpp b/test/error/error_test.cpp index 42408765c8..dbcb01bbc3 100644 --- a/test/error/error_test.cpp +++ b/test/error/error_test.cpp @@ -45,7 +45,7 @@ class ErrorTestCase { ~ErrorTestCase() { // return stderr to normal function - setvbuf(stderr, NULL, _IONBF, bufsize); + setvbuf(stderr, nullptr, _IONBF, bufsize); } std::string extract_string() { @@ -149,4 +149,4 @@ TEST_CASE_METHOD(ErrorTestCase, "testing exception generation printing off", "[h TEST_COUT << "\n" << message; #endif } -} \ No newline at end of file +} diff --git a/test/error/h5c_error_test.cpp b/test/error/h5c_error_test.cpp index 0fd3a3b3cc..1ae3c611b1 100644 --- a/test/error/h5c_error_test.cpp +++ b/test/error/h5c_error_test.cpp @@ -61,4 +61,4 @@ SCENARIO("testing h5cerror") { } } } -} \ No newline at end of file +} diff --git a/test/file/file_image_test.cpp b/test/file/file_image_test.cpp index 641968038e..7da069def6 100644 --- a/test/file/file_image_test.cpp +++ b/test/file/file_image_test.cpp @@ -31,6 +31,7 @@ #include #include #include +#include using namespace hdf5; @@ -45,7 +46,7 @@ using Bytes = std::vector; * @param filename path to the file to read * @return Bytes buffer with uninterpreted bytes */ -Bytes file_to_bytes(const std::string &filename) +static Bytes file_to_bytes(const std::string &filename) { std::ifstream fin(filename, std::ios::binary); return Bytes(std::istreambuf_iterator(fin), {}); @@ -59,10 +60,10 @@ Bytes file_to_bytes(const std::string &filename) * @param filename path to the file to write * @param bytes the payload which should be written to a file */ -void bytes_to_file(const std::string &filename, const Bytes &bytes) +static void bytes_to_file(const std::string &filename, const Bytes &bytes) { std::ofstream fout(filename, std::ios::out | std::ios::binary); - fout.write(reinterpret_cast(bytes.data()), bytes.size()); + fout.write(reinterpret_cast(bytes.data()), unsigned2signed(bytes.size())); fout.close(); } @@ -86,7 +87,7 @@ SCENARIO("reading a file from a memory buffer") auto f = file::open(filename); THEN("we can store this to buffer") { - Bytes buffer(f.buffer_size()); + Bytes buffer(signed2unsigned(f.buffer_size())); REQUIRE(f.to_buffer(buffer) == static_cast(f.buffer_size())); AND_THEN("write this to a file") { @@ -127,7 +128,7 @@ SCENARIO("reading a file from a memory buffer") auto f = file::open(filename); THEN("we can write this file to a buffer") { - Bytes buffer(f.buffer_size()); + Bytes buffer(signed2unsigned(f.buffer_size())); f.to_buffer(buffer); AND_THEN("open it again with from_buffer") { diff --git a/test/filter/external_filter_test.cpp b/test/filter/external_filter_test.cpp index 356e613030..e60b3de3bf 100644 --- a/test/filter/external_filter_test.cpp +++ b/test/filter/external_filter_test.cpp @@ -146,4 +146,4 @@ SCENARIO("deflate and shuffle filters as external filter") { } } } -} \ No newline at end of file +} diff --git a/test/filter/fletcher32_test.cpp b/test/filter/fletcher32_test.cpp index 28258e531e..3866eeed55 100644 --- a/test/filter/fletcher32_test.cpp +++ b/test/filter/fletcher32_test.cpp @@ -43,4 +43,4 @@ SCENARIO("using the Fletcher32 filter") { } } } -} \ No newline at end of file +} diff --git a/test/filter/nbit_test.cpp b/test/filter/nbit_test.cpp index 1987c4bee1..70e70be923 100644 --- a/test/filter/nbit_test.cpp +++ b/test/filter/nbit_test.cpp @@ -65,4 +65,4 @@ SCENARIO("testing the NBit filter") { } } } -} \ No newline at end of file +} diff --git a/test/h5cpp_test_helpers.hpp b/test/h5cpp_test_helpers.hpp index c4da1b2a35..9a54c96715 100644 --- a/test/h5cpp_test_helpers.hpp +++ b/test/h5cpp_test_helpers.hpp @@ -40,4 +40,4 @@ inline void provoke_h5cpp_exception() { hdf5::ObjectHandle invalid_handle; invalid_handle.get_reference_count(); -} \ No newline at end of file +} diff --git a/test/node/dataset_direct_chunk_test.cpp b/test/node/dataset_direct_chunk_test.cpp index 78ddc11fba..64dec46dc3 100644 --- a/test/node/dataset_direct_chunk_test.cpp +++ b/test/node/dataset_direct_chunk_test.cpp @@ -86,11 +86,11 @@ SCENARIO("testing dataset access via chunks") { UShorts sframe(sxdim); for (size_t i = 0; i != sxdim; i++) - sframe[i] = static_cast(i / 2); + sframe[i] = static_cast(i / 2); UShorts tframe(sxdim); for (size_t i = 0; i != sxdim; i++) - tframe[i] = static_cast(i / 4); + tframe[i] = static_cast(i / 4); GIVEN("an integer dataset") { node::Dataset dataset(root, "data1", datatype::create(), @@ -137,7 +137,7 @@ TEST_F(DatasetDirectChunkTest, read_chunk) { for (long long unsigned int i = 0; i != nframe; i++) { filter_mask = data2.read_chunk(read_value, {i, 0, 0}); EXPECT_EQ(frame, read_value); - EXPECT_EQ(filter_mask, H5P_DEFAULT); + EXPECT_EQ(filter_mask, property::kDefault); } } @@ -185,7 +185,7 @@ TEST_F(DatasetDirectChunkTest, read_chunk_deflate) { EXPECT_EQ(tcpvalue, tread_value); } - EXPECT_EQ(filter_mask, H5P_DEFAULT); + EXPECT_EQ(filter_mask, property::kDefault); } } */ diff --git a/test/node/dataset_partial_io_test.cpp b/test/node/dataset_partial_io_test.cpp index 7d519340e8..ea0801f9f7 100644 --- a/test/node/dataset_partial_io_test.cpp +++ b/test/node/dataset_partial_io_test.cpp @@ -50,7 +50,7 @@ SCENARIO("writing and reading with selections") { AND_GIVEN("a hyperslab selection") { dataspace::Hyperslab slab{{0}, {1}, {1}, {1}}; THEN("we cann append new values to the dataset") { - int write, read; + int write=0, read=0; for (size_t index = 0; index < 100; ++index, write = static_cast(index), read = 0) { node::resize_by(dset, 0, 1); slab.offset(0, index); diff --git a/test/node/functions_test.cpp b/test/node/functions_test.cpp index d74bb2ab1e..77984cdb45 100644 --- a/test/node/functions_test.cpp +++ b/test/node/functions_test.cpp @@ -292,4 +292,4 @@ TEST_F(NodeFunctions, test_link) EXPECT_NO_THROW(nd::link(target_, root_, Path("internal"))); EXPECT_NO_THROW(nd::link(file2_target_, root_, Path("external"))); } -*/ \ No newline at end of file +*/ diff --git a/test/node/type_test.cpp b/test/node/type_test.cpp index 230800bd48..1d1929d1c1 100644 --- a/test/node/type_test.cpp +++ b/test/node/type_test.cpp @@ -64,4 +64,4 @@ SCENARIO("testing node::NodeType stream output") { WHEN("converting the value to an integer") { REQUIRE(static_cast(std::get<0>(d)) == std::get<2>(d)); } -} \ No newline at end of file +} diff --git a/test/property/creation_order_test.cpp b/test/property/creation_order_test.cpp index 224bbf07a4..098bd589ba 100644 --- a/test/property/creation_order_test.cpp +++ b/test/property/creation_order_test.cpp @@ -73,4 +73,4 @@ SCENARIO("setting LinkCreationOrder configuration by member methods") { } } } -} \ No newline at end of file +} diff --git a/test/property/dataset_creation_test.cpp b/test/property/dataset_creation_test.cpp index 536dfd86c7..2d761f93d2 100644 --- a/test/property/dataset_creation_test.cpp +++ b/test/property/dataset_creation_test.cpp @@ -229,4 +229,4 @@ SCENARIO("setting the fill value on a DatasetCreation property list") { } } } -} \ No newline at end of file +} diff --git a/test/property/property_class_test.cpp b/test/property/property_class_test.cpp index f0b0e22d1b..91d62c62c4 100644 --- a/test/property/property_class_test.cpp +++ b/test/property/property_class_test.cpp @@ -173,4 +173,4 @@ SCENARIO("testing comparison operators for the property list class") { } } } -} \ No newline at end of file +} diff --git a/test/property/type_creation_test.cpp b/test/property/type_creation_test.cpp index 5f7e4db3c7..485d64a62f 100644 --- a/test/property/type_creation_test.cpp +++ b/test/property/type_creation_test.cpp @@ -52,4 +52,4 @@ SCENARIO("create a TypeCreationList property list") { std::runtime_error); } } -} \ No newline at end of file +} From 544586479e48bad0648427a2e337f93faabc8808 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Jan 2022 10:33:58 +0100 Subject: [PATCH 2/8] ignore padded warnings --- src/h5cpp/core/iterator_config.cpp | 8 ++------ src/h5cpp/core/object_handle.cpp | 17 +++++++++++++---- src/h5cpp/filter/nbit.hpp | 7 +++++++ src/h5cpp/filter/scaleoffset.cpp | 2 +- src/h5cpp/filter/shuffle.hpp | 7 +++++++ src/h5cpp/property/creation_order.hpp | 6 +++--- src/h5cpp/property/dataset_access.cpp | 2 +- src/h5cpp/property/property_class.cpp | 2 +- test/core/ObjectHandleDefault.cpp | 7 +++++-- test/core/object_handle_test.hpp | 7 +++++++ test/examples/h5cpp/hklpoint.hpp | 3 ++- 11 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/h5cpp/core/iterator_config.cpp b/src/h5cpp/core/iterator_config.cpp index d360b4b5fa..dd923a12f7 100644 --- a/src/h5cpp/core/iterator_config.cpp +++ b/src/h5cpp/core/iterator_config.cpp @@ -34,10 +34,8 @@ std::ostream &operator<<(std::ostream &stream,const IterationOrder &order) case IterationOrder::Decreasing: return stream<<"DECREASING"; case IterationOrder::Increasing: return stream<<"INCREASING"; case IterationOrder::Native: return stream<<"NATIVE"; - default: - return stream; } - + return stream; } std::ostream &operator<<(std::ostream &stream,const IterationIndex &index) @@ -46,10 +44,8 @@ std::ostream &operator<<(std::ostream &stream,const IterationIndex &index) { case IterationIndex::CreationOrder: return stream<<"CREATION_ORDER"; case IterationIndex::Name: return stream<<"NAME"; - default: - return stream; } - + return stream; } IteratorConfig::IteratorConfig(): diff --git a/src/h5cpp/core/object_handle.cpp b/src/h5cpp/core/object_handle.cpp index dec3321ceb..af5e038f86 100644 --- a/src/h5cpp/core/object_handle.cpp +++ b/src/h5cpp/core/object_handle.cpp @@ -239,8 +239,15 @@ void ObjectHandle::close() case ObjectHandle::Type::VirtualFileLayer: error_code = H5Oclose(handle_); break; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" +#endif default: error_code = H5Oclose(handle_); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif } if (error_code < 0) @@ -289,11 +296,13 @@ ObjectHandle::Type ObjectHandle::get_type() const return ObjectHandle::Type::ErrorMessage; case H5I_ERROR_STACK: return ObjectHandle::Type::ErrorStack; - default: - std::stringstream ss; - ss << "ObjectHandle: unknown object type=" << type; - error::Singleton::instance().throw_with_stack(ss.str()); + case H5I_REFERENCE: + case H5I_NTYPES: + break; }; + std::stringstream ss; + ss << "ObjectHandle: unknown object type=" << type; + error::Singleton::instance().throw_with_stack(ss.str()); return {}; } diff --git a/src/h5cpp/filter/nbit.hpp b/src/h5cpp/filter/nbit.hpp index 7c7b5af214..f579dc8a7f 100644 --- a/src/h5cpp/filter/nbit.hpp +++ b/src/h5cpp/filter/nbit.hpp @@ -37,6 +37,10 @@ namespace filter { //! If applied to a dataset creation property list this filter will setup //! the nbit checksum filter. //! +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif class DLL_EXPORT NBit : public Filter { public: @@ -59,6 +63,9 @@ class DLL_EXPORT NBit : public Filter virtual void operator()(const property::DatasetCreationList &dcpl, Availability flag = Availability::Mandatory) const override; }; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif } // namespace filter } // namespace hdf5 diff --git a/src/h5cpp/filter/scaleoffset.cpp b/src/h5cpp/filter/scaleoffset.cpp index cb5ee853d7..a28df0c371 100644 --- a/src/h5cpp/filter/scaleoffset.cpp +++ b/src/h5cpp/filter/scaleoffset.cpp @@ -82,8 +82,8 @@ std::ostream &operator<<(std::ostream &stream, const ScaleOffset::ScaleType &sca case ScaleOffset::ScaleType::FloatDScale: return stream << "FLOAT_DSCALE"; case ScaleOffset::ScaleType::FloatEScale: return stream << "FLOAT_ESCALE"; case ScaleOffset::ScaleType::Int: return stream << "INT"; - default:return stream; } + return stream; } } // namespace filter diff --git a/src/h5cpp/filter/shuffle.hpp b/src/h5cpp/filter/shuffle.hpp index 16d632a5db..3948b5f4c8 100644 --- a/src/h5cpp/filter/shuffle.hpp +++ b/src/h5cpp/filter/shuffle.hpp @@ -29,6 +29,10 @@ namespace hdf5 { namespace filter { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif class DLL_EXPORT Shuffle : public Filter { public: @@ -43,6 +47,9 @@ class DLL_EXPORT Shuffle : public Filter Availability flag = Availability::Mandatory) const override; }; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif } // namespace filter } // namespace hdf5 diff --git a/src/h5cpp/property/creation_order.hpp b/src/h5cpp/property/creation_order.hpp index 6189323e47..1251baeb76 100644 --- a/src/h5cpp/property/creation_order.hpp +++ b/src/h5cpp/property/creation_order.hpp @@ -119,10 +119,10 @@ class DLL_EXPORT CreationOrder { unsigned tracked_:1; unsigned indexed_:1; #ifdef __clang__ - unsigned reserved_:sizeof(unsigned) - 2 __attribute__((unused)); -#else - unsigned reserved_:sizeof(unsigned) - 2; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-but-set-variable" #endif + unsigned reserved_:sizeof(unsigned) - 2; }; #ifdef __clang__ #pragma clang diagnostic pop diff --git a/src/h5cpp/property/dataset_access.cpp b/src/h5cpp/property/dataset_access.cpp index c839affdfc..4a6ae01e64 100644 --- a/src/h5cpp/property/dataset_access.cpp +++ b/src/h5cpp/property/dataset_access.cpp @@ -71,8 +71,8 @@ std::ostream &operator<<(std::ostream &stream, const VirtualDataView &view) { switch (view) { case VirtualDataView::FirstMissing:return stream << "FIRST_MISSING"; case VirtualDataView::LastAvailable:return stream << "LAST_AVAILABLE"; - default:return stream; } + return stream; } #endif diff --git a/src/h5cpp/property/property_class.cpp b/src/h5cpp/property/property_class.cpp index 11ec4e4a6f..9497f8ccd3 100644 --- a/src/h5cpp/property/property_class.cpp +++ b/src/h5cpp/property/property_class.cpp @@ -53,7 +53,7 @@ std::string Class::name() const { } std::string buffer(cptr, std::strlen(cptr)); - free((void *) cptr); + free(static_cast(cptr)); return buffer; } diff --git a/test/core/ObjectHandleDefault.cpp b/test/core/ObjectHandleDefault.cpp index c1d65fc5be..23f226f68e 100644 --- a/test/core/ObjectHandleDefault.cpp +++ b/test/core/ObjectHandleDefault.cpp @@ -60,9 +60,12 @@ std::shared_ptr create_test(hdf5::ObjectHandle::Type type) { return std::make_shared(); case hdf5::ObjectHandle::Type::ErrorStack: return std::make_shared(); - default: - return ptr_type(nullptr); + case hdf5::ObjectHandle::Type::Uninitialized: + case hdf5::ObjectHandle::Type::BadObject: + case hdf5::ObjectHandle::Type::VirtualFileLayer: + break; } + return ptr_type(nullptr); } SCENARIO("testing object handle construction") { GIVEN("a default constructed handle") { diff --git a/test/core/object_handle_test.hpp b/test/core/object_handle_test.hpp index f85626fcf6..a4f7d15c5a 100644 --- a/test/core/object_handle_test.hpp +++ b/test/core/object_handle_test.hpp @@ -31,6 +31,10 @@ #include #include +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif class TestEnvironment { std::string filename_{}; @@ -170,6 +174,9 @@ class ErrorClassObjectHandleTest : public ObjectHandleTest ErrorClassObjectHandleTest(); virtual hid_t create_object() override; }; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/test/examples/h5cpp/hklpoint.hpp b/test/examples/h5cpp/hklpoint.hpp index 94e53ab188..10f4d5d54f 100644 --- a/test/examples/h5cpp/hklpoint.hpp +++ b/test/examples/h5cpp/hklpoint.hpp @@ -91,7 +91,8 @@ struct VarLengthBufferTrait { std::transform(points.begin(),points.end(),std::back_inserter(buffer), [](const HKLPointList &list) - { return hvl_t{list.size(),(void*)list.data()}; }); + { return hvl_t{list.size(), + const_cast(static_cast(list.data()))}; }); } static void from_buffer(const VarLengthDataBuffer &buffer,HKLPoints &points) From b81415b59826c376c94f7ee4a1b6a3db4ef80516 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Jan 2022 10:55:49 +0100 Subject: [PATCH 3/8] remove default switch --- src/h5cpp/core/object_handle.cpp | 13 +++++++++++++ src/h5cpp/node/link.cpp | 6 ++++-- src/h5cpp/node/types.cpp | 6 ++---- src/h5cpp/property/creation_order.hpp | 8 ++++---- src/h5cpp/property/dataset_creation.cpp | 5 ++++- src/h5cpp/property/file_access.cpp | 4 ++-- 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/h5cpp/core/object_handle.cpp b/src/h5cpp/core/object_handle.cpp index af5e038f86..1c675a1040 100644 --- a/src/h5cpp/core/object_handle.cpp +++ b/src/h5cpp/core/object_handle.cpp @@ -296,7 +296,13 @@ ObjectHandle::Type ObjectHandle::get_type() const return ObjectHandle::Type::ErrorMessage; case H5I_ERROR_STACK: return ObjectHandle::Type::ErrorStack; +#if H5_VERSION_GE(1,12,0) + case H5I_MAP: + case H5I_VOL: + case H5I_SPACE_SEL_ITER: +#else case H5I_REFERENCE: +#endif case H5I_NTYPES: break; }; @@ -408,8 +414,15 @@ std::ostream &operator<<(std::ostream &stream, const ObjectHandle::Type &type) case ObjectHandle::Type::ErrorStack: stream << "ERROR_STACK"; break; +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" +#endif default: stream << "unknown"; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif }; return stream; diff --git a/src/h5cpp/node/link.cpp b/src/h5cpp/node/link.cpp index 61fae65090..4c09a9cb8a 100644 --- a/src/h5cpp/node/link.cpp +++ b/src/h5cpp/node/link.cpp @@ -167,9 +167,11 @@ LinkType Link::type(const property::LinkAccessList &lapl) const case H5L_TYPE_HARD: return LinkType::Hard; case H5L_TYPE_SOFT: return LinkType::Soft; case H5L_TYPE_EXTERNAL: return LinkType::External; - default: - return LinkType::Error; + case H5L_TYPE_ERROR: + case H5L_TYPE_MAX: + break; } + return LinkType::Error; } Group Link::parent() const diff --git a/src/h5cpp/node/types.cpp b/src/h5cpp/node/types.cpp index 8d6fdd32bf..f4054c1885 100644 --- a/src/h5cpp/node/types.cpp +++ b/src/h5cpp/node/types.cpp @@ -37,9 +37,8 @@ std::ostream &operator<<(std::ostream &stream,const NodeType &type) case NodeType::Group: return stream<<"GROUP"; case NodeType::Dataset: return stream<<"DATASET"; case NodeType::Datatype: return stream<<"DATATYPE"; - default: - return stream; } + return stream; } std::ostream &operator<<(std::ostream &stream,const LinkType &type) @@ -50,9 +49,8 @@ std::ostream &operator<<(std::ostream &stream,const LinkType &type) case LinkType::External: return stream<<"EXTERNAL"; case LinkType::Hard: return stream<<"HARD"; case LinkType::Soft: return stream<<"SOFT"; - default: - return stream; } + return stream; } } // namespace node diff --git a/src/h5cpp/property/creation_order.hpp b/src/h5cpp/property/creation_order.hpp index 1251baeb76..2391aaf68e 100644 --- a/src/h5cpp/property/creation_order.hpp +++ b/src/h5cpp/property/creation_order.hpp @@ -118,10 +118,10 @@ class DLL_EXPORT CreationOrder { private: unsigned tracked_:1; unsigned indexed_:1; -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-but-set-variable" -#endif + //#ifdef __clang__ + //#pragma clang diagnostic push + //#pragma clang diagnostic ignored "-Wunused-but-set-variable" + //#endif unsigned reserved_:sizeof(unsigned) - 2; }; #ifdef __clang__ diff --git a/src/h5cpp/property/dataset_creation.cpp b/src/h5cpp/property/dataset_creation.cpp index 205ba107fc..37f14a27b4 100644 --- a/src/h5cpp/property/dataset_creation.cpp +++ b/src/h5cpp/property/dataset_creation.cpp @@ -100,8 +100,11 @@ DatasetLayout DatasetCreationList::layout() const { #if H5_VERSION_GE(1, 10, 0) case H5D_VIRTUAL:return DatasetLayout::Virtual; #endif - default:error::Singleton::instance().throw_with_stack("Failure retrieving the dataset layout!"); + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: + break; } + error::Singleton::instance().throw_with_stack("Failure retrieving the dataset layout!"); return {}; } diff --git a/src/h5cpp/property/file_access.cpp b/src/h5cpp/property/file_access.cpp index 7315cca205..ec0c24073c 100644 --- a/src/h5cpp/property/file_access.cpp +++ b/src/h5cpp/property/file_access.cpp @@ -37,8 +37,8 @@ std::ostream &operator<<(std::ostream &stream, const LibVersion &version) { switch (version) { case LibVersion::Earliest: return stream << "EARLIEST"; case LibVersion::Latest: return stream << "LATEST"; - default:return stream; } + return stream; } std::ostream &operator<<(std::ostream &stream, const CloseDegree &version) { @@ -47,8 +47,8 @@ std::ostream &operator<<(std::ostream &stream, const CloseDegree &version) { case CloseDegree::Semi: return stream << "SEMI"; case CloseDegree::Strong: return stream << "STRONG"; case CloseDegree::Default: return stream << "DEFAULT"; - default:return stream; } + return stream; } FileAccessList::FileAccessList() : From a1b2a317f473dadf7c277c89766b6e27810d7ffa Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Jan 2022 12:14:20 +0100 Subject: [PATCH 4/8] fix warning with static statement --- src/h5cpp/dataspace/hyperslab.hpp | 6 +++++- src/h5cpp/dataspace/scalar.cpp | 2 -- src/h5cpp/dataspace/scalar.hpp | 2 -- src/h5cpp/datatype/factory.hpp | 2 +- src/h5cpp/filter/szip.cpp | 3 +-- src/h5cpp/node/link.cpp | 6 +++--- test/core/ObjectHandleDefault.cpp | 2 +- test/core/object_id_test.cpp | 2 +- test/file/accessflags_test.cpp | 2 +- test/file/searchflags_test.cpp | 2 +- test/node/dataset_const_data.cpp | 2 +- test/node/dataset_dynamic_type_io.cpp | 4 ++-- 12 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/h5cpp/dataspace/hyperslab.hpp b/src/h5cpp/dataspace/hyperslab.hpp index e247edf30a..630e5272f9 100644 --- a/src/h5cpp/dataspace/hyperslab.hpp +++ b/src/h5cpp/dataspace/hyperslab.hpp @@ -254,7 +254,7 @@ class DLL_EXPORT Hyperslab : public Selection { //! \brief get current dimensions //! //! Get a number of elements along each dimension a selection spans - //! this is particularly useful in the case of a Hyperslab + //! this is particularly useful in the case of a Hyperslab //! //! \throws std::runtime_error in case of a failure //! @@ -317,5 +317,9 @@ class DLL_EXPORT Hyperslab : public Selection { DLL_EXPORT Dataspace operator||(const Dataspace &space, const Hyperslab &selection); +DLL_EXPORT SelectionList operator|(const Hyperslab &a, const Hyperslab &b); + +DLL_EXPORT SelectionList &operator|(SelectionList &selections, const Hyperslab &b); + } // namespace dataspace } // namespace hdf5 diff --git a/src/h5cpp/dataspace/scalar.cpp b/src/h5cpp/dataspace/scalar.cpp index e8d321157b..a78b9c4532 100644 --- a/src/h5cpp/dataspace/scalar.cpp +++ b/src/h5cpp/dataspace/scalar.cpp @@ -35,8 +35,6 @@ namespace dataspace { Scalar::Scalar() : Dataspace(Type::Scalar) {} -Scalar::~Scalar() {} - Scalar::Scalar(const Dataspace &space) : Dataspace(space) { if (space.type() != Type::Scalar) { diff --git a/src/h5cpp/dataspace/scalar.hpp b/src/h5cpp/dataspace/scalar.hpp index b2521b7752..0d4bf768da 100644 --- a/src/h5cpp/dataspace/scalar.hpp +++ b/src/h5cpp/dataspace/scalar.hpp @@ -57,8 +57,6 @@ class DLL_EXPORT Scalar : public Dataspace { //! Scalar(const Dataspace &space); - ~Scalar() override; - }; } // namespace dataspace diff --git a/src/h5cpp/datatype/factory.hpp b/src/h5cpp/datatype/factory.hpp index 125bf93f94..dc786ed58a 100644 --- a/src/h5cpp/datatype/factory.hpp +++ b/src/h5cpp/datatype/factory.hpp @@ -43,7 +43,7 @@ typename TypeTrait::type>::TypeClass create(const //! \brief factory function for getting reference of data types //! template -static const Datatype & get(const T &v = T()) { +const Datatype & get(const T &v = T()) { return TypeTrait::type>::get(v); } diff --git a/src/h5cpp/filter/szip.cpp b/src/h5cpp/filter/szip.cpp index 05163dcc93..67e5f3c4a4 100644 --- a/src/h5cpp/filter/szip.cpp +++ b/src/h5cpp/filter/szip.cpp @@ -97,9 +97,8 @@ std::ostream &operator<<(std::ostream &stream,const SZip::OptionMask &flags) case SZip::OptionMask::Chip : return stream<<"CHIP_CODING"; case SZip::OptionMask::EntropyCoding : return stream<<"ENTROPY_CODING"; case SZip::OptionMask::NearestNeighbor : return stream<<"NEAREST_NEIGHBOR_CODING"; - default: - return stream; } + return stream; } SZip::OptionMaskBase operator|(const SZip::OptionMask &lhs,const SZip::OptionMask &rhs) diff --git a/src/h5cpp/node/link.cpp b/src/h5cpp/node/link.cpp index 4c09a9cb8a..fb2501b174 100644 --- a/src/h5cpp/node/link.cpp +++ b/src/h5cpp/node/link.cpp @@ -149,10 +149,10 @@ LinkTarget Link::target(const property::LinkAccessList &lapl) const return get_soft_link_target(lapl); case LinkType::External: return get_external_link_target(lapl); - default: - throw std::runtime_error("Unkown link type - cannot determine target!"); + case LinkType::Error: + break; } - + throw std::runtime_error("Unkown link type - cannot determine target!"); } LinkType Link::type(const property::LinkAccessList &lapl) const diff --git a/test/core/ObjectHandleDefault.cpp b/test/core/ObjectHandleDefault.cpp index 23f226f68e..d382e9d0ba 100644 --- a/test/core/ObjectHandleDefault.cpp +++ b/test/core/ObjectHandleDefault.cpp @@ -34,7 +34,7 @@ #include "object_handle_test.hpp" -std::shared_ptr create_test(hdf5::ObjectHandle::Type type) { +static std::shared_ptr create_test(hdf5::ObjectHandle::Type type) { using ptr_type = std::shared_ptr; switch (type) { case hdf5::ObjectHandle::Type::File: diff --git a/test/core/object_id_test.cpp b/test/core/object_id_test.cpp index 3bf43bf8b9..8c329a0294 100644 --- a/test/core/object_id_test.cpp +++ b/test/core/object_id_test.cpp @@ -339,7 +339,7 @@ SCENARIO("testing symbolic links") { } #endif -void external_link(const fs::path& target_file, +static void external_link(const fs::path& target_file, const std::string& target_path, const ObjectHandle& link_file, const std::string& link_path) { diff --git a/test/file/accessflags_test.cpp b/test/file/accessflags_test.cpp index d520f8b497..d52615f972 100644 --- a/test/file/accessflags_test.cpp +++ b/test/file/accessflags_test.cpp @@ -30,7 +30,7 @@ using namespace hdf5; -file::AccessFlagsBase to_int(file::AccessFlags flag) +static file::AccessFlagsBase to_int(file::AccessFlags flag) { return static_cast(flag); } diff --git a/test/file/searchflags_test.cpp b/test/file/searchflags_test.cpp index 01fa96f534..c80f2cb651 100644 --- a/test/file/searchflags_test.cpp +++ b/test/file/searchflags_test.cpp @@ -31,7 +31,7 @@ using namespace hdf5; -file::SearchFlagsBase cast(file::SearchFlags flags) { +static file::SearchFlagsBase cast(file::SearchFlags flags) { return static_cast(flags); } diff --git a/test/node/dataset_const_data.cpp b/test/node/dataset_const_data.cpp index db3ce01948..9972b3f834 100644 --- a/test/node/dataset_const_data.cpp +++ b/test/node/dataset_const_data.cpp @@ -37,7 +37,7 @@ void constData() { dset.write(SomeData); } -void DoNotRun() { +static void DoNotRun() { constData(); constData(); constData(); diff --git a/test/node/dataset_dynamic_type_io.cpp b/test/node/dataset_dynamic_type_io.cpp index 127c3d6bef..a0f7733313 100644 --- a/test/node/dataset_dynamic_type_io.cpp +++ b/test/node/dataset_dynamic_type_io.cpp @@ -50,11 +50,11 @@ struct Flip { std::int32_t data_[1]; }; -bool operator==(const Flip& lhs, const Flip& rhs) { +static bool operator==(const Flip& lhs, const Flip& rhs) { return std::equal(lhs.begin(), lhs.end(), rhs.begin()); } -bool operator!=(const Flip& lhs, const Flip& rhs) { +static bool operator!=(const Flip& lhs, const Flip& rhs) { return !(lhs == rhs); } From 75df86545529af67a66aacbe9d9d6a03e141c4cb Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Jan 2022 14:29:51 +0100 Subject: [PATCH 5/8] improve comparing floats --- src/h5cpp/attribute/attribute_manager.cpp | 2 ++ src/h5cpp/core/object_handle.cpp | 6 ++++-- src/h5cpp/dataspace/scalar.hpp | 7 +++++++ src/h5cpp/datatype/integer.cpp | 2 +- src/h5cpp/error/error.hpp | 3 +++ src/h5cpp/node/dataset.hpp | 1 - src/h5cpp/node/link_view.cpp | 2 ++ src/h5cpp/node/node_view.cpp | 2 ++ src/h5cpp/property/creation_order.hpp | 8 ++++---- src/h5cpp/property/dataset_creation.cpp | 2 +- test/core/object_handle_test.hpp | 2 +- test/datatype/compound_test.cpp | 4 ++-- test/datatype/datatype_test.cpp | 1 - test/datatype/string_test.cpp | 5 +++-- test/node/dataset_const_data.cpp | 2 +- test/property/dataset_creation_test.cpp | 2 +- 16 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/h5cpp/attribute/attribute_manager.cpp b/src/h5cpp/attribute/attribute_manager.cpp index 91a2d56349..712543f719 100644 --- a/src/h5cpp/attribute/attribute_manager.cpp +++ b/src/h5cpp/attribute/attribute_manager.cpp @@ -134,7 +134,9 @@ bool AttributeManager::exists(const std::string &name) const <(*this)); if (s < 0) { error::Singleton::instance().throw_with_stack("Could not retrieve datatype sign"); - return false; + // return false; } return bool(s); } diff --git a/src/h5cpp/error/error.hpp b/src/h5cpp/error/error.hpp index 9ef2d38c68..5783b9f49d 100644 --- a/src/h5cpp/error/error.hpp +++ b/src/h5cpp/error/error.hpp @@ -98,6 +98,9 @@ class DLL_EXPORT Singleton //! //! \param message a user-supplied message for the exception //! +#ifdef __clang__ + [[ noreturn ]] +#endif void throw_with_stack(const std::string& message); //! diff --git a/src/h5cpp/node/dataset.hpp b/src/h5cpp/node/dataset.hpp index 3085bd7b24..dd3b83799e 100644 --- a/src/h5cpp/node/dataset.hpp +++ b/src/h5cpp/node/dataset.hpp @@ -821,7 +821,6 @@ class DLL_EXPORT Dataset : public Node } } }; - #ifdef __clang__ #pragma clang diagnostic pop #endif diff --git a/src/h5cpp/node/link_view.cpp b/src/h5cpp/node/link_view.cpp index fa21850a85..27b0a74b92 100644 --- a/src/h5cpp/node/link_view.cpp +++ b/src/h5cpp/node/link_view.cpp @@ -125,7 +125,9 @@ bool LinkView::exists(const std::string &name, const property::LinkAccessList &l <; auto p = GENERATE(table( {ptype{h5t.native_uint8, Class::Integer, 1}, diff --git a/test/datatype/string_test.cpp b/test/datatype/string_test.cpp index 43b16e7871..b52a52ddcc 100644 --- a/test/datatype/string_test.cpp +++ b/test/datatype/string_test.cpp @@ -27,6 +27,7 @@ #include #include +#include using namespace hdf5; @@ -36,8 +37,8 @@ SCENARIO("testing variable length strings") { THEN("the instance if of type STRING") { REQUIRE(t.get_class() == datatype::Class::String); } - THEN("the size of the type is H5T_VARIABLE") { - REQUIRE(t.size() == size_t(H5T_VARIABLE)); + THEN("the size of the type is datatype::kVariable") { + REQUIRE(t.size() == size_t(datatype::kVariable)); } THEN("the variable length flag is set") { REQUIRE(t.is_variable_length()); } diff --git a/test/node/dataset_const_data.cpp b/test/node/dataset_const_data.cpp index 9972b3f834..db3ce01948 100644 --- a/test/node/dataset_const_data.cpp +++ b/test/node/dataset_const_data.cpp @@ -37,7 +37,7 @@ void constData() { dset.write(SomeData); } -static void DoNotRun() { +void DoNotRun() { constData(); constData(); constData(); diff --git a/test/property/dataset_creation_test.cpp b/test/property/dataset_creation_test.cpp index 2d761f93d2..2b24dfb717 100644 --- a/test/property/dataset_creation_test.cpp +++ b/test/property/dataset_creation_test.cpp @@ -222,7 +222,7 @@ SCENARIO("setting the fill value on a DatasetCreation property list") { float buffer{0.0}; THEN("we can read the fill vlaue back as a float") { buffer = pl.fill_value(get_type); - REQUIRE(buffer == float(fill_value)); + REQUIRE(buffer == Approx(float(fill_value)).epsilon(1e-12)); } } } From 10cb131609fcf3ba7384b5a5923d6f35cb327b45 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Jan 2022 14:42:39 +0100 Subject: [PATCH 6/8] ignore -Wmissing-prototypes for DoNotRun() --- src/h5cpp/property/dataset_creation.cpp | 4 +++- src/h5cpp/property/property_class.cpp | 4 ++++ test/node/dataset_const_data.cpp | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/h5cpp/property/dataset_creation.cpp b/src/h5cpp/property/dataset_creation.cpp index d677827669..7de2685f6e 100644 --- a/src/h5cpp/property/dataset_creation.cpp +++ b/src/h5cpp/property/dataset_creation.cpp @@ -105,7 +105,9 @@ DatasetLayout DatasetCreationList::layout() const { break; } error::Singleton::instance().throw_with_stack("Failure retrieving the dataset layout!"); - // return {}; +#ifndef __clang__ + return {}; +#endif } void DatasetCreationList::chunk(const Dimensions &chunk_dims) const { diff --git a/src/h5cpp/property/property_class.cpp b/src/h5cpp/property/property_class.cpp index 9497f8ccd3..cb6c72a0b9 100644 --- a/src/h5cpp/property/property_class.cpp +++ b/src/h5cpp/property/property_class.cpp @@ -66,7 +66,9 @@ bool operator==(const Class &lhs, const Class &rhs) { return false; else error::Singleton::instance().throw_with_stack("Could check equality of property list classes"); +#ifndef __clang__ return {}; +#endif } bool operator!=(const Class &lhs, const Class &rhs) { @@ -77,7 +79,9 @@ bool operator!=(const Class &lhs, const Class &rhs) { return true; else error::Singleton::instance().throw_with_stack("Could check inequality of property list classes"); +#ifndef __clang__ return {}; +#endif } const Class kAttributeCreate = Class(ObjectHandle(H5P_ATTRIBUTE_CREATE, diff --git a/test/node/dataset_const_data.cpp b/test/node/dataset_const_data.cpp index db3ce01948..4da95f759d 100644 --- a/test/node/dataset_const_data.cpp +++ b/test/node/dataset_const_data.cpp @@ -37,6 +37,10 @@ void constData() { dset.write(SomeData); } +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-prototypes" +#endif void DoNotRun() { constData(); constData(); @@ -50,3 +54,6 @@ void DoNotRun() { constData(); constData(); } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif From 2a57a70dad7e7a88602802b3693fa54dcf7154ec Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Jan 2022 15:40:52 +0100 Subject: [PATCH 7/8] apply changes for -Wglobal-constructors and -Wexit-time-destructors --- src/h5cpp/property/property_class.cpp | 8 ++++++++ test/core/object_id_test.cpp | 24 ++++++++++++------------ test/datatype/datatype_test.cpp | 7 +++++++ test/file/file_open_test.cpp | 2 +- test/node/dataset_direct_chunk_test.cpp | 8 ++++---- test/node/virtual_dataset_test.cpp | 8 ++++---- 6 files changed, 36 insertions(+), 21 deletions(-) diff --git a/src/h5cpp/property/property_class.cpp b/src/h5cpp/property/property_class.cpp index cb6c72a0b9..5ab2c2fa8c 100644 --- a/src/h5cpp/property/property_class.cpp +++ b/src/h5cpp/property/property_class.cpp @@ -84,6 +84,11 @@ bool operator!=(const Class &lhs, const Class &rhs) { #endif } +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wglobal-constructors" +#pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif const Class kAttributeCreate = Class(ObjectHandle(H5P_ATTRIBUTE_CREATE, ObjectHandle::Policy::WithoutWard)); const Class kDatasetAccess = Class(ObjectHandle(H5P_DATASET_ACCESS, @@ -116,6 +121,9 @@ const Class kObjectCreate = Class(ObjectHandle(H5P_OBJECT_CREATE, ObjectHandle::Policy::WithoutWard)); const Class kStringCreate = Class(ObjectHandle(H5P_STRING_CREATE, ObjectHandle::Policy::WithoutWard)); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif std::ostream &operator<<(std::ostream &stream, const Class &c) { return stream << "AttributeClass(" << c.name() << ")"; diff --git a/test/core/object_id_test.cpp b/test/core/object_id_test.cpp index 8c329a0294..3d25460e35 100644 --- a/test/core/object_id_test.cpp +++ b/test/core/object_id_test.cpp @@ -161,7 +161,7 @@ SCENARIO("testing Id construction") { } SCENARIO("testing info retrievel from a file") { - static const fs::path path1 = fs::absolute("info_from_file.h5"); + const fs::path path1 = fs::absolute("info_from_file.h5"); GIVEN("an HDF5 file with some content") { File file1(path1); THEN("we can obtain the filename") { @@ -174,7 +174,7 @@ SCENARIO("testing info retrievel from a file") { fs::remove(path1); } SCENARIO("working with links") { - static const fs::path path1 = fs::absolute("working_with_links_1.h5"); + const fs::path path1 = fs::absolute("working_with_links_1.h5"); GIVEN("a file object with a group and a dataset") { File file1(path1); ObjectId id_group1(file1.group1); @@ -307,8 +307,8 @@ SCENARIO("checking copies and files of identical structure") { // only file_number and object_address are equal // file_name is not equal SCENARIO("testing symbolic links") { - static const fs::path path1 = fs::absolute("symbolic_links_1.h5"); - static const fs::path path2 = fs::absolute("symbolic_links_2.h5"); + const fs::path path1 = fs::absolute("symbolic_links_1.h5"); + const fs::path path2 = fs::absolute("symbolic_links_2.h5"); { File{path1}; } // Symlink FILE2 -> FILE1 @@ -349,8 +349,8 @@ static void external_link(const fs::path& target_file, } SCENARIO("testing with external links") { - static const fs::path path1 = fs::absolute("external_links_1.h5"); - static const fs::path path2 = fs::absolute("external_links_2.h5"); + const fs::path path1 = fs::absolute("external_links_1.h5"); + const fs::path path2 = fs::absolute("external_links_2.h5"); { File{path1}; File{path2}; @@ -391,9 +391,9 @@ SCENARIO("testing with external links") { // only file_number and object_address are equal // file_name is not equal SCENARIO("testing wiht external synmbolic link") { - static const fs::path path1 = fs::absolute("ext_symlink_1.h5"); - static const fs::path path2 = fs::absolute("ext_symlink_2.h5"); - static const fs::path path3 = fs::absolute("ext_symlink_3.h5"); + const fs::path path1 = fs::absolute("ext_symlink_1.h5"); + const fs::path path2 = fs::absolute("ext_symlink_2.h5"); + const fs::path path3 = fs::absolute("ext_symlink_3.h5"); { File{path1}; File{path2}; @@ -442,7 +442,7 @@ SCENARIO("testing wiht external synmbolic link") { #endif SCENARIO("opening an instance serveral time") { - static const fs::path path1 = fs::absolute("open_several_times_1.h5"); + const fs::path path1 = fs::absolute("open_several_times_1.h5"); // This works because the ObjectId does not store any HDF5 object. // It only stores some metadata about an object. GIVEN("an id to the first file object") { @@ -472,8 +472,8 @@ SCENARIO("opening an instance serveral time") { } SCENARIO("comparing ids") { - static const fs::path path1 = fs::absolute("cmp_ids_1.h5"); - static const fs::path path2 = fs::absolute("cmp_ids_2.h5"); + const fs::path path1 = fs::absolute("cmp_ids_1.h5"); + const fs::path path2 = fs::absolute("cmp_ids_2.h5"); ObjectId file1_id, file2_id, group1_id, group2_id; { diff --git a/test/datatype/datatype_test.cpp b/test/datatype/datatype_test.cpp index 3a6a78ac43..447327104f 100644 --- a/test/datatype/datatype_test.cpp +++ b/test/datatype/datatype_test.cpp @@ -125,6 +125,10 @@ SCENARIO("comparing datatypes") { } } +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wglobal-constructors" +#endif struct { const hid_t& native_uint8 = H5T_NATIVE_UINT8; const hid_t& native_int8 = H5T_NATIVE_INT8; @@ -137,6 +141,9 @@ struct { const hid_t& native_float32 = H5T_NATIVE_FLOAT; const hid_t& native_float64 = H5T_NATIVE_DOUBLE; } h5t; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif SCENARIO("Properties of numeric types") { auto create = [](const hid_t& tc) { diff --git a/test/file/file_open_test.cpp b/test/file/file_open_test.cpp index 18eb5582c7..a08e2b13ff 100644 --- a/test/file/file_open_test.cpp +++ b/test/file/file_open_test.cpp @@ -28,9 +28,9 @@ using namespace hdf5; -static const std::string filename = "file_optn_test.h5"; SCENARIO("opening a file") { + const std::string filename = "file_optn_test.h5"; #if H5_VERSION_GE(1, 10, 0) property::FileCreationList fcpl; property::FileAccessList fapl; diff --git a/test/node/dataset_direct_chunk_test.cpp b/test/node/dataset_direct_chunk_test.cpp index 64dec46dc3..9dfd2f6003 100644 --- a/test/node/dataset_direct_chunk_test.cpp +++ b/test/node/dataset_direct_chunk_test.cpp @@ -30,10 +30,10 @@ using namespace hdf5; namespace { -static const long long unsigned int xdim = 867; -static const long long unsigned int ydim = 700; -static const long long unsigned int sxdim = 17; -static const long long unsigned int nframe = 33; +const long long unsigned int xdim = 867; +const long long unsigned int ydim = 700; +const long long unsigned int sxdim = 17; +const long long unsigned int nframe = 33; using UShorts = std::vector; diff --git a/test/node/virtual_dataset_test.cpp b/test/node/virtual_dataset_test.cpp index 5d27cb84da..0b9327df8e 100644 --- a/test/node/virtual_dataset_test.cpp +++ b/test/node/virtual_dataset_test.cpp @@ -57,8 +57,8 @@ namespace { #endif static void create_module_file(const fs::path& filename, const DataVector& data) { - const static property::FileCreationList gfcpl; - const static property::FileAccessList gfapl; + const property::FileCreationList gfcpl; + const property::FileAccessList gfapl; file::File f = file::create(filename, file::AccessFlags::Truncate, gfcpl, gfapl); node::Dataset dataset(f.root(), Path("module_data"), module_type, @@ -77,8 +77,8 @@ namespace { SCENARIO("testing virtual datasets") { - const static property::FileCreationList gfcpl; - const static property::FileAccessList gfapl; + const property::FileCreationList gfcpl; + const property::FileAccessList gfapl; auto data_module_1 = create_data(kModuleSize, 1); auto data_module_2 = create_data(kModuleSize, 2); auto data_module_3 = create_data(kModuleSize, 3); From e6d3ba37c824be29107ad27757cbd4c976419089 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Jan 2022 16:00:40 +0100 Subject: [PATCH 8/8] fix a type of print_nested in sphinx --- doc/source/api_reference/namespace_error.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/api_reference/namespace_error.rst b/doc/source/api_reference/namespace_error.rst index 25839a15ce..8f8713eeb0 100644 --- a/doc/source/api_reference/namespace_error.rst +++ b/doc/source/api_reference/namespace_error.rst @@ -31,4 +31,4 @@ Functions :cpp:func:`print_nested` ------------------------ -.. doxygenfunction:: hdf5::error::print_nested(const std::exception&, int) +.. doxygenfunction:: hdf5::error::print_nested(const std::exception&, size_t)