From 7f51ef5ed2740dab2bbf53c4dd5931b6e8ec6a5b Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 28 Jul 2022 07:45:06 -0700 Subject: Fix "unsafe narrowing" warnings in absl, 1/n. Addresses failures with the following, in some files: -Wshorten-64-to-32 -Wimplicit-int-conversion -Wsign-compare -Wsign-conversion -Wtautological-unsigned-zero-compare (This specific CL focuses on .h and win32 .inc files.) Bug: chromium:1292951 PiperOrigin-RevId: 463835431 Change-Id: If8e5f7f651d5cd96035e23e4623bdb08a7fedabe --- absl/profiling/internal/sample_recorder.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'absl/profiling') diff --git a/absl/profiling/internal/sample_recorder.h b/absl/profiling/internal/sample_recorder.h index 5f65983b..ef1489b1 100644 --- a/absl/profiling/internal/sample_recorder.h +++ b/absl/profiling/internal/sample_recorder.h @@ -77,8 +77,8 @@ class SampleRecorder { // samples that have been dropped. int64_t Iterate(const std::function& f); - int32_t GetMaxSamples() const; - void SetMaxSamples(int32_t max); + size_t GetMaxSamples() const; + void SetMaxSamples(size_t max); private: void PushNew(T* sample); @@ -88,7 +88,7 @@ class SampleRecorder { std::atomic dropped_samples_; std::atomic size_estimate_; - std::atomic max_samples_{1 << 20}; + std::atomic max_samples_{1 << 20}; // Intrusive lock free linked lists for tracking samples. // @@ -186,7 +186,7 @@ T* SampleRecorder::PopDead(Targs... args) { template template T* SampleRecorder::Register(Targs&&... args) { - int64_t size = size_estimate_.fetch_add(1, std::memory_order_relaxed); + size_t size = size_estimate_.fetch_add(1, std::memory_order_relaxed); if (size > max_samples_.load(std::memory_order_relaxed)) { size_estimate_.fetch_sub(1, std::memory_order_relaxed); dropped_samples_.fetch_add(1, std::memory_order_relaxed); @@ -229,12 +229,12 @@ int64_t SampleRecorder::Iterate( } template -void SampleRecorder::SetMaxSamples(int32_t max) { +void SampleRecorder::SetMaxSamples(size_t max) { max_samples_.store(max, std::memory_order_release); } template -int32_t SampleRecorder::GetMaxSamples() const { +size_t SampleRecorder::GetMaxSamples() const { return max_samples_.load(std::memory_order_acquire); } -- cgit v1.2.3