From df4c9d7bdb559cc1e36623b69639d0a0f973a007 Mon Sep 17 00:00:00 2001 From: surtur Date: Sat, 29 Jan 2022 23:54:26 +0100 Subject: [PATCH] accumulator: add noexcept where reasonable --- accumulator.cpp | 10 +++++----- accumulator.h | 15 +++++++-------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/accumulator.cpp b/accumulator.cpp index c51f2de..b33c071 100644 --- a/accumulator.cpp +++ b/accumulator.cpp @@ -29,17 +29,17 @@ Accumulator::Accumulator() noexcept { Accumulator::~Accumulator() noexcept {} -auto Accumulator::set_reseed_ctr_to_null() -> void { +auto Accumulator::set_reseed_ctr_to_null() noexcept -> void { std::lock_guard lg(mtx); this->reseed_ctr = 0x00; } -auto Accumulator::incr_reseed_ctr() -> void { +auto Accumulator::incr_reseed_ctr() noexcept -> void { std::lock_guard lg(mtx); { ++this->reseed_ctr; } } -auto Accumulator::get_reseed_ctr() const -> uint64_t { +auto Accumulator::get_reseed_ctr() const noexcept -> uint64_t { std::lock_guard lg(mtx); return this->reseed_ctr; } @@ -54,7 +54,7 @@ auto Accumulator::_p_pools_equal( } // check if given source id is an id of an already registered entropy source -auto Accumulator::src_is_registered(const uint8_t& id) -> bool { +auto Accumulator::src_is_registered(const uint8_t& id) noexcept -> bool { std::atomic reg{false}; static uint8_t _src_id{}; @@ -77,7 +77,7 @@ auto Accumulator::src_is_registered(const uint8_t& id) -> bool { auto Accumulator::set_pools_ptr( std::shared_ptr> - p_pools) -> void { + p_pools) noexcept -> void { this->_p_pools = p_pools; } diff --git a/accumulator.h b/accumulator.h index 20907ec..6071c1f 100644 --- a/accumulator.h +++ b/accumulator.h @@ -37,11 +37,11 @@ protected: public: constexpr static const unsigned int init_pool_num{0}; - auto set_reseed_ctr_to_null() -> void; + auto set_reseed_ctr_to_null() noexcept -> void; - auto incr_reseed_ctr() -> void; + auto incr_reseed_ctr() noexcept -> void; - auto get_reseed_ctr() const -> uint64_t; + auto get_reseed_ctr() const noexcept -> uint64_t; auto _p_pools_equal( std::shared_ptr bool; + [[maybe_unused]] auto src_is_registered(const uint8_t& id) noexcept -> bool; - auto set_pools_ptr( - std::shared_ptr< - std::array> p_pools) - -> void; + auto set_pools_ptr(std::shared_ptr< + std::array> + p_pools) noexcept -> void; auto set_gen(fortuna::generator::Generator& Gen) -> void;