From 329fb06d9968034a5b0d851e0a136a25e8399c41 Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Thu, 4 Nov 2021 13:09:10 +0100 Subject: [PATCH] Fix error with Fix Werror=old-style-cast (#1272) * Fix Werror=old-style-cast Signed-off-by: Bensuperpc * Fix Werror=old-style-cast Signed-off-by: Bensuperpc * Fix Werror=old-style-cast Signed-off-by: Bensuperpc * Fix typo Signed-off-by: Bensuperpc * Fix build error with MacOS Signed-off-by: Bensuperpc * Revert "Fix build error with MacOS" This reverts commit cee213bb95d40dad78b857c49e0750fce1e5ea37. --- src/benchmark.cc | 2 +- src/colorprint.cc | 4 ++-- src/console_reporter.cc | 2 +- test/user_counters_test.cc | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/benchmark.cc b/src/benchmark.cc index ca001a9e..c7d39696 100644 --- a/src/benchmark.cc +++ b/src/benchmark.cc @@ -363,7 +363,7 @@ void RunBenchmarks(const std::vector& benchmarks, additional_run_stats.begin(), additional_run_stats.end()); per_family_reports.erase( - (int)reports_for_family->Runs.front().family_index); + static_cast(reports_for_family->Runs.front().family_index)); } } diff --git a/src/colorprint.cc b/src/colorprint.cc index afaa55dd..092a4bd1 100644 --- a/src/colorprint.cc +++ b/src/colorprint.cc @@ -102,10 +102,10 @@ std::string FormatString(const char* msg, va_list args) { return local_buff; else { // we did not provide a long enough buffer on our first attempt. - size = (size_t)ret + 1; // + 1 for the null byte + size = static_cast(ret) + 1; // + 1 for the null byte std::unique_ptr buff(new char[size]); ret = vsnprintf(buff.get(), size, msg, args); - BM_CHECK(ret > 0 && ((size_t)ret) < size); + BM_CHECK(ret > 0 && (static_cast(ret)) < size); return buff.get(); } } diff --git a/src/console_reporter.cc b/src/console_reporter.cc index 61c34da8..ac2cc087 100644 --- a/src/console_reporter.cc +++ b/src/console_reporter.cc @@ -116,7 +116,7 @@ void ConsoleReporter::PrintRunData(const Run& result) { typedef void(PrinterFn)(std::ostream&, LogColor, const char*, ...); auto& Out = GetOutputStream(); PrinterFn* printer = (output_options_ & OO_Color) ? - (PrinterFn*)ColorPrintf : IgnoreColorPrint; + static_cast(ColorPrintf) : IgnoreColorPrint; auto name_color = (result.report_big_o || result.report_rms) ? COLOR_BLUE : COLOR_GREEN; printer(Out, name_color, "%-*s ", name_field_width_, diff --git a/test/user_counters_test.cc b/test/user_counters_test.cc index 377bb32c..1cc74552 100644 --- a/test/user_counters_test.cc +++ b/test/user_counters_test.cc @@ -26,7 +26,7 @@ void BM_Counters_Simple(benchmark::State& state) { for (auto _ : state) { } state.counters["foo"] = 1; - state.counters["bar"] = 2 * (double)state.iterations(); + state.counters["bar"] = 2 * static_cast(state.iterations()); } BENCHMARK(BM_Counters_Simple); ADD_CASES(TC_ConsoleOut,