From 14c1b707688c8e9f804b758eb2f1e41028ba7323 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 8 Oct 2025 14:18:17 +0200 Subject: [PATCH] Address some compiler warnings --- src/ifcparse/IfcEntityInstanceData.cpp | 25 +++++++++++++++++-------- src/ifcparse/IfcEntityInstanceData.h | 3 +-- src/ifcparse/set_to_map_transformer.h | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/ifcparse/IfcEntityInstanceData.cpp b/src/ifcparse/IfcEntityInstanceData.cpp index ca2f73b4ef..e87c429545 100644 --- a/src/ifcparse/IfcEntityInstanceData.cpp +++ b/src/ifcparse/IfcEntityInstanceData.cpp @@ -38,7 +38,7 @@ namespace { } #ifdef IFOPSH_WITH_ROCKSDB else { - T val; + T val = T{}; const bool is_header = entity_or_type->schema() == &Header_section_schema::get_schema(); if constexpr ( // the following types cannot be directly deserialized from rocksdb, but need to be constructed @@ -51,6 +51,12 @@ namespace { (is_header ? entity_or_type->name() : std::to_string(instance_name_)) + "|" + std::to_string(index_), &str); impl::deserialize(array_.db_ptr, str, val); + } else { + static_assert( + std::is_same_v || + std::is_same_v>, IfcUtil::IfcBaseClass>, + "RocksDB deserialization must be specialized for this EnumerationReference and IfcBaseClass*" + ); } return val; } @@ -194,13 +200,15 @@ AttributeValue::operator IfcUtil::IfcBaseClass* () const std::to_string(index_), &str); size_t v; memcpy(&v, str.data() + 2, sizeof(size_t)); - if (str[1] == 'i') { + if (str.size() > 1 && str[1] == 'i') { // entity reference, by #Name return array_.db_ptr->assert_existance(v, IfcParse::impl::rocks_db_file_storage::entityinstance_ref); - } else if (str[1] == 't') { + } else if (str.size() > 1 && str[1] == 't') { // type reference by Identity return array_.db_ptr->assert_existance(v, IfcParse::impl::rocks_db_file_storage::typedecl_ref); - } + } else { + throw std::runtime_error("Invalid data encountered"); + } } #endif } @@ -339,28 +347,28 @@ bool impl::serialize(std::string& val, const aggregate_of_aggregate_of_instance: return true; } -bool impl::serialize(std::string& val, const Blank& t) +bool impl::serialize(std::string& val, const Blank&) { val.resize(1); val[0] = TypeEncoder::encode_type(); return true; } -bool impl::serialize(std::string& val, const Derived& t) +bool impl::serialize(std::string& val, const Derived&) { val.resize(1); val[0] = TypeEncoder::encode_type(); return true; } -bool impl::serialize(std::string& val, const empty_aggregate_t& t) +bool impl::serialize(std::string& val, const empty_aggregate_t&) { val.resize(1); val[0] = TypeEncoder::encode_type(); return true; } -bool impl::serialize(std::string& val, const empty_aggregate_of_aggregate_t& t) +bool impl::serialize(std::string& val, const empty_aggregate_of_aggregate_t&) { val.resize(1); val[0] = TypeEncoder::encode_type(); @@ -397,6 +405,7 @@ bool impl::deserialize(IfcParse::impl::rocks_db_file_storage*, const std::string } else { return false; } + return true; } bool impl::deserialize(IfcParse::impl::rocks_db_file_storage*, const std::string& val, boost::dynamic_bitset<>& t) { diff --git a/src/ifcparse/IfcEntityInstanceData.h b/src/ifcparse/IfcEntityInstanceData.h index df2edddb94..bf1f4789f6 100644 --- a/src/ifcparse/IfcEntityInstanceData.h +++ b/src/ifcparse/IfcEntityInstanceData.h @@ -266,7 +266,6 @@ namespace impl { if (val[0] != TypeEncoder::encode_type()) { return false; } - auto s = (val.size() - 1) / sizeof(T); memcpy(&t, val.data() + 1, sizeof(T)); return true; } @@ -404,7 +403,7 @@ public: template auto apply_visitor(void* storage, const IfcParse::declaration* decl, std::size_t identity, std::size_t index, Visitor&& visitor) const { // @todo do we need visitation on all data/storage/attribute levels? - AttributeValue((IfcParse::impl::rocks_db_file_storage*)storage, identity, decl, index).apply_visitor(std::forward(visitor)); + AttributeValue((IfcParse::impl::rocks_db_file_storage*)storage, identity, decl, (uint8_t) index).apply_visitor(std::forward(visitor)); } #endif }; diff --git a/src/ifcparse/set_to_map_transformer.h b/src/ifcparse/set_to_map_transformer.h index 21bf597f4f..eccbdfa766 100644 --- a/src/ifcparse/set_to_map_transformer.h +++ b/src/ifcparse/set_to_map_transformer.h @@ -106,7 +106,7 @@ public: return iterator(base_map_->find(k), &transform_); } - size_t erase(const key_type& k) { + size_t erase(const key_type&) { // @todo return 0; }