diff --git a/CHANGES b/CHANGES index 774ed21c..9521bf7e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +2.8.0-dev.121 | 2024-10-18 10:12:55 -0700 + + * Fix bugprone and modernize clang-tidy findings (Dominik Charousset) + + * Pin prometheus to 1.2.4 (Arne Welzel, Corelight) + 2.8.0-dev.117 | 2024-09-14 15:58:08 +0200 * Fix type 3 messages in broker-throughput (Dominik Charousset) diff --git a/VERSION b/VERSION index faf56175..14dae926 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.8.0-dev.117 +2.8.0-dev.121 diff --git a/libbroker/broker/detail/memory_backend.cc b/libbroker/broker/detail/memory_backend.cc index 29125fed..99fb7736 100644 --- a/libbroker/broker/detail/memory_backend.cc +++ b/libbroker/broker/detail/memory_backend.cc @@ -109,7 +109,7 @@ expected memory_backend::expiries() const { for (auto& p : store_) { if (p.second.second) - rval.emplace_back(expirable(p.first, *p.second.second)); + rval.emplace_back(p.first, *p.second.second); } return {std::move(rval)}; diff --git a/libbroker/broker/error.cc b/libbroker/broker/error.cc index f9d5a21c..bcb2691c 100644 --- a/libbroker/broker/error.cc +++ b/libbroker/broker/error.cc @@ -216,7 +216,8 @@ bool convertible_to_ec(uint8_t src) noexcept { } template -bool convertible_to_error_impl(const List& xs) noexcept { +bool convertible_to_error_impl(const List& xs) noexcept( + std::is_same_v) { if (!contains(xs)) { // There is one special case: default errors with enum value "none" fail to // convert to ec but are still legal. @@ -234,11 +235,11 @@ bool convertible_to_error_impl(const List& xs) noexcept { || contains(args); } -bool convertible_to_error(const vector& xs) noexcept { +bool convertible_to_error(const vector& xs) { return convertible_to_error_impl(xs); } -bool convertible_to_error(const data& src) noexcept { +bool convertible_to_error(const data& src) { return convertible_to_error_impl(src.to_list()); } diff --git a/libbroker/broker/error.hh b/libbroker/broker/error.hh index 1c5cad8c..970e7961 100644 --- a/libbroker/broker/error.hh +++ b/libbroker/broker/error.hh @@ -276,22 +276,22 @@ struct can_convert_predicate { /// Checks whethter `src` is convertible to a `caf::error` with /// `category() == caf::atom("broker")`. -bool convertible_to_error(const data& src) noexcept; +bool convertible_to_error(const data& src); + +/// @copydoc convertible_to_error +bool convertible_to_error(const vector& xs); /// Checks whethter `src` is convertible to a `caf::error` with /// `category() == caf::atom("broker")`. bool convertible_to_error(const variant& src) noexcept; -/// @copydoc convertible_to_error -bool convertible_to_error(const vector& xs) noexcept; - template <> struct can_convert_predicate { - static bool check(const data& src) noexcept { + static bool check(const data& src) { return convertible_to_error(src); } - static bool check(const vector& src) noexcept { + static bool check(const vector& src) { return convertible_to_error(src); } diff --git a/libbroker/broker/format/bin.hh b/libbroker/broker/format/bin.hh index ec0d4ea0..aea76518 100644 --- a/libbroker/broker/format/bin.hh +++ b/libbroker/broker/format/bin.hh @@ -203,7 +203,7 @@ std::enable_if_t, OutIter> encode(T value, } else if constexpr (std::is_unsigned_v) { return write_unsigned(value, out); } else { - static_assert(std::is_signed::value); + static_assert(std::is_signed_v); using unsigned_t = std::make_unsigned_t; return write_unsigned(static_cast(value), out); } @@ -435,8 +435,8 @@ public: } template - const T& field(std::string_view, const T& value) { - return value; + decltype(auto) field(std::string_view, T&& value) { + return std::forward(value); } bool fields() { diff --git a/libbroker/broker/internal/channel.hh b/libbroker/broker/internal/channel.hh index d32ec5e2..78af7e15 100644 --- a/libbroker/broker/internal/channel.hh +++ b/libbroker/broker/internal/channel.hh @@ -198,9 +198,10 @@ public: } void shipped(int64_t num) { + auto dbl_num = static_cast(num); if (unacknowledged) { - unacknowledged->Decrement(num); - processed->Increment(num); + unacknowledged->Decrement(dbl_num); + processed->Increment(dbl_num); } } }; @@ -844,8 +845,9 @@ public: void try_consume_buffer() { auto i = buf_.begin(); for (; i != buf_.end() && i->seq == next_seq_; ++i) { - if (i->content) { - backend_->consume(this, *i->content); + auto& content = i->content; + if (content) { + backend_->consume(this, *content); } else { if (auto err = backend_->consume_nil(this)) { buf_.erase(buf_.begin(), i); diff --git a/libbroker/broker/internal/flow_scope.hh b/libbroker/broker/internal/flow_scope.hh index 44e39d36..abfc7d84 100644 --- a/libbroker/broker/internal/flow_scope.hh +++ b/libbroker/broker/internal/flow_scope.hh @@ -50,7 +50,7 @@ public: if (deregister_cb_) { try { deregister_cb_(stats_); - } catch (...) { + } catch (...) { // NOLINT // The callbacks may not throw. However, we can't specify them noexcept // because std::function does not support noexcept signatures. Hence, // this catch-all to silence tool warnings. diff --git a/libbroker/broker/internal/master_actor.cc b/libbroker/broker/internal/master_actor.cc index 3f232a85..1533e20f 100644 --- a/libbroker/broker/internal/master_actor.cc +++ b/libbroker/broker/internal/master_actor.cc @@ -76,7 +76,7 @@ master_state::master_state( detail::die("failed to get master expiries while initializing"); } if (auto entries = backend->size(); entries && *entries > 0) { - metrics.entries->Set(*entries); + metrics.entries->Set(static_cast(*entries)); } BROKER_INFO("attached master" << id << "to" << store_name); } diff --git a/libbroker/broker/subnet.cc b/libbroker/broker/subnet.cc index 6fc16175..9483cd24 100644 --- a/libbroker/broker/subnet.cc +++ b/libbroker/broker/subnet.cc @@ -78,8 +78,8 @@ bool convert(const std::string& str, subnet& sn) { sn = subnet{addr, static_cast(len)}; return true; } - } catch (std::exception&) { - // nop + } catch (const std::exception&) { + return false; } } return false;