From 37a3e8b414466f76135a1ae3d89a40a93bc43b44 Mon Sep 17 00:00:00 2001 From: clockblocker Date: Fri, 27 Nov 2026 08:18:05 +0100 Subject: [PATCH] Fix -Wextra, -Wextra-semi, -Wsign-conversion, and -Wunused-parameter warnings in public headers --- include/rfl/Generic.hpp | 4 ++-- include/rfl/Literal.hpp | 2 +- include/rfl/MetaField.hpp | 4 ++-- include/rfl/NamedTuple.hpp | 2 +- include/rfl/Variant.hpp | 2 +- include/rfl/atomic/is_atomic.hpp | 4 ++-- include/rfl/env/Writer.hpp | 2 +- include/rfl/internal/find_index.hpp | 2 +- include/rfl/internal/move_from_tuple.hpp | 2 +- include/rfl/internal/nth_element.hpp | 2 +- include/rfl/internal/strings/utf8_conversions.hpp | 3 ++- include/rfl/parsing/NamedTupleParser.hpp | 2 +- include/rfl/parsing/ParserDefaultVal.hpp | 6 ++++-- include/rfl/parsing/VectorParser.hpp | 3 ++- 14 files changed, 22 insertions(+), 18 deletions(-) diff --git a/include/rfl/Generic.hpp b/include/rfl/Generic.hpp index 46f79f65f..d266300c2 100644 --- a/include/rfl/Generic.hpp +++ b/include/rfl/Generic.hpp @@ -196,10 +196,10 @@ class RFL_API Generic { Result to_string() const noexcept; /// Returns the underlying variant. - VariantType& variant() noexcept { return value_; }; + VariantType& variant() noexcept { return value_; } /// Returns the underlying variant. - const VariantType& variant() const noexcept { return value_; }; + const VariantType& variant() const noexcept { return value_; } /// Equality comparison. Two Generics are equal if they hold the same /// alternative and the underlying values compare equal. diff --git a/include/rfl/Literal.hpp b/include/rfl/Literal.hpp index 4208d7713..161dc9f79 100644 --- a/include/rfl/Literal.hpp +++ b/include/rfl/Literal.hpp @@ -164,7 +164,7 @@ class Literal { return Literal(_v); }; return find_value(_str).transform(to_literal); - }; + } /// The name defined by the Literal (returns the string representation). /// @return The string value of the current literal diff --git a/include/rfl/MetaField.hpp b/include/rfl/MetaField.hpp index 192c7e6c5..62ac12294 100644 --- a/include/rfl/MetaField.hpp +++ b/include/rfl/MetaField.hpp @@ -21,11 +21,11 @@ class MetaField { /// Returns the name of the field. /// @return The field name as it appears in the struct - const std::string& name() const { return name_; }; + const std::string& name() const { return name_; } /// Returns the type information of the field. /// @return A string describing the field's type - const std::string& type() const { return type_; }; + const std::string& type() const { return type_; } private: /// The name of the field. diff --git a/include/rfl/NamedTuple.hpp b/include/rfl/NamedTuple.hpp index 381fe8811..9123b188d 100644 --- a/include/rfl/NamedTuple.hpp +++ b/include/rfl/NamedTuple.hpp @@ -716,7 +716,7 @@ class NamedTuple<> { using Values = rfl::Tuple<>; /// @brief Default constructor for empty NamedTuple. - NamedTuple(){}; + NamedTuple() {} /// @brief Destructor. ~NamedTuple() = default; diff --git a/include/rfl/Variant.hpp b/include/rfl/Variant.hpp index 018edca72..046b5a030 100644 --- a/include/rfl/Variant.hpp +++ b/include/rfl/Variant.hpp @@ -774,7 +774,7 @@ namespace std { template void swap(rfl::Variant& _lhs, rfl::Variant& _rhs) noexcept { _lhs.swap(_rhs); -}; +} } // namespace std #endif diff --git a/include/rfl/atomic/is_atomic.hpp b/include/rfl/atomic/is_atomic.hpp index 93312de28..303468e3f 100644 --- a/include/rfl/atomic/is_atomic.hpp +++ b/include/rfl/atomic/is_atomic.hpp @@ -19,7 +19,7 @@ template struct is_atomic { static constexpr bool value = false; using RemoveAtomicT = T; - static void set(RemoveAtomicT&& val, T* _t) { *_t = std::forward(val); }; + static void set(RemoveAtomicT&& val, T* _t) { *_t = std::forward(val); } }; template @@ -28,7 +28,7 @@ struct is_atomic> { using RemoveAtomicT = T; static void set(RemoveAtomicT&& val, std::atomic* _t) { _t->store(std::forward(val), std::memory_order_relaxed); - }; + } }; template <> diff --git a/include/rfl/env/Writer.hpp b/include/rfl/env/Writer.hpp index 23512bb72..d0d505fd4 100644 --- a/include/rfl/env/Writer.hpp +++ b/include/rfl/env/Writer.hpp @@ -56,7 +56,7 @@ class RFL_API Writer { } template - OutputVarType value_as_root(const T& _var) const noexcept { + OutputVarType value_as_root(const T&) const noexcept { static_assert( always_false_v, "Writing basic types to ENV as root variables is not supported."); diff --git a/include/rfl/internal/find_index.hpp b/include/rfl/internal/find_index.hpp index 04c524e7d..c962ae5e6 100644 --- a/include/rfl/internal/find_index.hpp +++ b/include/rfl/internal/find_index.hpp @@ -25,7 +25,7 @@ constexpr auto operator|(const FieldWrapper& _f1, template constexpr auto find_matching_field(const Head& _head, const Tail&... _tail) { return (_head | ... | _tail); -}; +} template constexpr auto wrap_fields(std::integer_sequence) { diff --git a/include/rfl/internal/move_from_tuple.hpp b/include/rfl/internal/move_from_tuple.hpp index c5edf9043..3855f7741 100644 --- a/include/rfl/internal/move_from_tuple.hpp +++ b/include/rfl/internal/move_from_tuple.hpp @@ -44,7 +44,7 @@ struct IndptrHelper { static constexpr auto indptr_ = ArrayType{_head, _tail...}; template - consteval auto operator+(const IndptrHelper<_is...>& _other) const { + consteval auto operator+(const IndptrHelper<_is...>&) const { constexpr auto last = std::get(indptr_); return IndptrHelper<_head, _tail..., (last + _is)...>{}; } diff --git a/include/rfl/internal/nth_element.hpp b/include/rfl/internal/nth_element.hpp index 281e5968c..c5c5c9c77 100644 --- a/include/rfl/internal/nth_element.hpp +++ b/include/rfl/internal/nth_element.hpp @@ -23,7 +23,7 @@ constexpr auto operator|(const ElementWrapper& _e1, template constexpr auto find_matching_element(const Head& _head, const Tail&... _tail) { return (_head | ... | _tail); -}; +} template constexpr auto wrap_elements(Ts... _ts, std::integer_sequence) { diff --git a/include/rfl/internal/strings/utf8_conversions.hpp b/include/rfl/internal/strings/utf8_conversions.hpp index dc24923f4..7be5e57e5 100644 --- a/include/rfl/internal/strings/utf8_conversions.hpp +++ b/include/rfl/internal/strings/utf8_conversions.hpp @@ -46,7 +46,8 @@ inline std::optional decode_utf8(const std::string& _str) { return std::nullopt; // truncated multi-byte sequence } for (int k = 1; k <= extra; ++k) { - const auto cc = static_cast(_str[i + k]); + const auto cc = + static_cast(_str[i + static_cast(k)]); if ((cc >> 6) != 0x2) { return std::nullopt; // bad continuation byte } diff --git a/include/rfl/parsing/NamedTupleParser.hpp b/include/rfl/parsing/NamedTupleParser.hpp index 90b062edb..864ae7400 100644 --- a/include/rfl/parsing/NamedTupleParser.hpp +++ b/include/rfl/parsing/NamedTupleParser.hpp @@ -308,7 +308,7 @@ struct NamedTupleParser { _schema->types_[std::string(F::name())] = std::move(s); } } - }; + } template static void build_object(const W& _w, const NamedTuple& _tup, diff --git a/include/rfl/parsing/ParserDefaultVal.hpp b/include/rfl/parsing/ParserDefaultVal.hpp index 9f11fea44..23620dfdb 100644 --- a/include/rfl/parsing/ParserDefaultVal.hpp +++ b/include/rfl/parsing/ParserDefaultVal.hpp @@ -64,8 +64,10 @@ struct ParserDefaultVal { static schema::Type to_schema( std::map* _definitions) { using U = std::remove_cvref_t; - return schema::Type{schema::Type::DefaultVal{Ref::make( - Parser::to_schema(_definitions))}}; + return schema::Type{schema::Type::DefaultVal{ + .type_ = Ref::make( + Parser::to_schema(_definitions)), + .default_value_ = std::nullopt}}; } }; diff --git a/include/rfl/parsing/VectorParser.hpp b/include/rfl/parsing/VectorParser.hpp index 2be9ee2e7..3e30934c2 100644 --- a/include/rfl/parsing/VectorParser.hpp +++ b/include/rfl/parsing/VectorParser.hpp @@ -92,7 +92,8 @@ struct VectorParser { MapParser::write(_w, _vec, _parent); } else { auto arr = ParentType::add_array( - _w, std::distance(_vec.begin(), _vec.end()), _parent); + _w, static_cast(std::distance(_vec.begin(), _vec.end())), + _parent); const auto new_parent = typename ParentType::Array{&arr}; for (const auto& v : _vec) { Parser, ProcessorsType>::write(_w, v,