From 58180a2db0172849b542d950f6ee286fbeb1e91f Mon Sep 17 00:00:00 2001 From: "Paul \"Dettorer\" Hervot" Date: Sun, 29 Nov 2015 10:58:10 +0100 Subject: [PATCH] Profiler: Fix casts and signedness on integer values --- src/common/profiler.cpp | 6 +++--- src/common/profiler.h | 2 +- src/common/profiler_reporting.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common/profiler.cpp b/src/common/profiler.cpp index 7792edd2f..71df6d029 100644 --- a/src/common/profiler.cpp +++ b/src/common/profiler.cpp @@ -59,7 +59,7 @@ unsigned int ProfilingManager::RegisterTimingCategory(TimingCategory* category, info.name = name; info.parent = TimingCategoryInfo::NO_PARENT; - unsigned int id = (unsigned int)timing_categories.size(); + unsigned int id = static_cast(timing_categories.size()); timing_categories.push_back(std::move(info)); return id; @@ -140,7 +140,7 @@ static AggregatedDuration AggregateField(const std::vector& v, size_t result.max = std::max(result.max, value); } if (len != 0) - result.avg /= len; + result.avg /= static_cast(len); return result; } @@ -177,7 +177,7 @@ ProfilingManager& GetProfilingManager() { } SynchronizedRef GetTimingResultsAggregator() { - static SynchronizedWrapper aggregator(30); + static SynchronizedWrapper aggregator(static_cast(30)); return SynchronizedRef(aggregator); } diff --git a/src/common/profiler.h b/src/common/profiler.h index 3e967b4bc..2f34ee622 100644 --- a/src/common/profiler.h +++ b/src/common/profiler.h @@ -64,7 +64,7 @@ public: */ Duration GetAccumulatedTime() { return Duration(std::atomic_exchange_explicit( - &accumulated_duration, (Duration::rep)0, + &accumulated_duration, static_cast(0), std::memory_order_relaxed)); } diff --git a/src/common/profiler_reporting.h b/src/common/profiler_reporting.h index df98e05b7..09a91b1f6 100644 --- a/src/common/profiler_reporting.h +++ b/src/common/profiler_reporting.h @@ -14,7 +14,7 @@ namespace Common { namespace Profiling { struct TimingCategoryInfo { - static const unsigned int NO_PARENT = -1; + static const unsigned int NO_PARENT = std::numeric_limits::max(); TimingCategory* category; const char* name;