From 13b80dfd9430c2f61108aea72f9e4e48fdf207ab Mon Sep 17 00:00:00 2001 From: Florian Schmaus <flow@cs.fau.de> Date: Tue, 26 Jan 2021 12:49:12 +0100 Subject: [PATCH] Address clang-tidy reports --- emper/io/Future.hpp | 18 +++++++++--------- emper/io/Stats.hpp | 4 ++-- emper/lib/adt/LockedSet.hpp | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/emper/io/Future.hpp b/emper/io/Future.hpp index 76baee9c..772cd74e 100644 --- a/emper/io/Future.hpp +++ b/emper/io/Future.hpp @@ -117,12 +117,12 @@ class Future : public Logger<LogSubsystem::IO> { cancel(); } - inline auto isRetrieved() -> bool { return state.retrieved; } - inline auto isSubmitted() -> bool { return state.submitted; } - inline auto isCompleted() -> bool { return state.completed; } - inline auto isCancelled() -> bool { return state.cancelled; } - inline auto isDependency() -> bool { return state.dependency; } - inline auto isForgotten() -> bool { return state.forgotten; } + [[nodiscard]] auto isRetrieved() const -> bool { return state.retrieved; } + [[nodiscard]] auto isSubmitted() const -> bool { return state.submitted; } + [[nodiscard]] auto isCompleted() const -> bool { return state.completed; } + [[nodiscard]] auto isCancelled() const -> bool { return state.cancelled; } + [[nodiscard]] auto isDependency() const -> bool { return state.dependency; } + [[nodiscard]] auto isForgotten() const -> bool { return state.forgotten; } /* * @brief reset the Future @@ -222,9 +222,9 @@ class Future : public Logger<LogSubsystem::IO> { friend auto operator<<(std::ostream& os, const Future* f) -> std::ostream& { if (f) { return os << *f; - } else { - return os << "Future nullptr"; } + + return os << "Future nullptr"; } }; @@ -280,7 +280,7 @@ class PartialCompletableFuture : public Future { /** * Used for Stats::recordCompletion double dispatch */ - virtual void recordCompletion(Stats& stats, int32_t res) override { + void recordCompletion(Stats& stats, int32_t res) override { if constexpr (emper::STATS) { recordCompletionInternal(stats, res); } diff --git a/emper/io/Stats.hpp b/emper/io/Stats.hpp index 08824aa1..95afacb1 100644 --- a/emper/io/Stats.hpp +++ b/emper/io/Stats.hpp @@ -68,7 +68,7 @@ class Stats { * 6: immediate resubmissions */ - typedef std::map<Operation, std::map<CompletionType, uint64_t>> CompletionMap; + using CompletionMap = std::map<Operation, std::map<CompletionType, uint64_t>>; CompletionMap io_uring_completions = { {Operation::SEND, @@ -128,7 +128,7 @@ class Stats { void recordCompletion(const WritevFuture& f, const int32_t& res) { size_t exp = 0; - auto iov = reinterpret_cast<const struct iovec*>(f.buf); + const auto* iov = reinterpret_cast<const struct iovec*>(f.buf); for (unsigned i = 0; i < f.len; ++i) { exp += iov[i].iov_len; } diff --git a/emper/lib/adt/LockedSet.hpp b/emper/lib/adt/LockedSet.hpp index e3e1b192..7c4cccfd 100644 --- a/emper/lib/adt/LockedSet.hpp +++ b/emper/lib/adt/LockedSet.hpp @@ -27,7 +27,7 @@ class LockedSet { _set.insert(first, last); } - size_t erase(const Key& key) { + auto erase(const Key& key) -> size_t { std::lock_guard<std::mutex> lock(_mutex); return _set.erase(key); } -- GitLab