From 28ea21b241e495dcec724a9640c8608c64428cf3 Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 6 Dec 2024 12:08:29 +0200 Subject: [PATCH] Fixed some analizer warnings --- bench/async_bench.cpp | 2 +- bench/bench.cpp | 4 ++-- include/spdlog/fmt/bin_to_hex.h | 7 ++----- include/spdlog/stopwatch.h | 7 ++----- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/bench/async_bench.cpp b/bench/async_bench.cpp index 60de0386..4eb6ce4a 100644 --- a/bench/async_bench.cpp +++ b/bench/async_bench.cpp @@ -150,5 +150,5 @@ void bench_mt(int howmany, std::shared_ptr logger, int thread_co auto delta = high_resolution_clock::now() - start; auto delta_d = duration_cast>(delta).count(); - spdlog::info("Elapsed: {} secs\t {:L}/sec", delta_d, int(howmany / delta_d)); + spdlog::info("Elapsed: {} secs\t {:L}/sec", delta_d, static_cast(howmany / delta_d)); } diff --git a/bench/bench.cpp b/bench/bench.cpp index 02cd6f70..2885f4f9 100644 --- a/bench/bench.cpp +++ b/bench/bench.cpp @@ -116,7 +116,7 @@ void bench(int howmany, std::shared_ptr log) { auto delta_d = duration_cast>(delta).count(); spdlog::info(spdlog::fmt_lib::format(std::locale("en_US.UTF-8"), "{:<30} Elapsed: {:0.2f} secs {:>16L}/sec", log->name(), - delta_d, size_t(howmany / delta_d))); + delta_d, static_cast(howmany / delta_d))); } void bench_mt(int howmany, std::shared_ptr log, size_t thread_count) { @@ -142,7 +142,7 @@ void bench_mt(int howmany, std::shared_ptr log, size_t thread_co auto delta = high_resolution_clock::now() - start; auto delta_d = duration_cast>(delta).count(); spdlog::info(spdlog::fmt_lib::format(std::locale("en_US.UTF-8"), "{:<30} Elapsed: {:0.2f} secs {:>16L}/sec", log->name(), - delta_d, size_t(howmany / delta_d))); + delta_d, static_cast(howmany / delta_d))); } /* diff --git a/include/spdlog/fmt/bin_to_hex.h b/include/spdlog/fmt/bin_to_hex.h index ae3c1588..280e8e0f 100644 --- a/include/spdlog/fmt/bin_to_hex.h +++ b/include/spdlog/fmt/bin_to_hex.h @@ -88,10 +88,8 @@ inline details::dump_info to_hex(const It range_begin, const It range_end, s } // namespace spdlog -namespace fmt { - template -struct formatter, char> { +struct fmt::formatter, char> { const char delimiter = ' '; bool put_newlines = true; bool put_delimiters = true; @@ -202,5 +200,4 @@ struct formatter, char> { spdlog::fmt_lib::format_to(inserter, SPDLOG_FMT_STRING("{:04X}: "), pos); } } -}; -} // namespace fmt +}; // namespace fmt diff --git a/include/spdlog/stopwatch.h b/include/spdlog/stopwatch.h index f101749e..cdd9b8b4 100644 --- a/include/spdlog/stopwatch.h +++ b/include/spdlog/stopwatch.h @@ -51,13 +51,10 @@ public: } // namespace spdlog // Support for fmt formatting (e.g. "{:012.9}" or just "{}") -namespace fmt { - template <> -struct formatter : formatter { +struct fmt::formatter : formatter { template auto format(const spdlog::stopwatch &sw, FormatContext &ctx) const -> decltype(ctx.out()) { return formatter::format(sw.elapsed().count(), ctx); } -}; -} // namespace fmt +}; // namespace fmt