From 934f613818ffcb26c942dff4a80be9a4031c662c Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 17 Aug 2022 08:34:34 -0700 Subject: Fix "unsafe narrowing" warnings in absl, 4/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 .cc files in strings/, except /internal/.) Bug: chromium:1292951 PiperOrigin-RevId: 468205572 Change-Id: Ifce3f1a7a4b2b2c359bf7700a11279bebfef8a15 --- absl/strings/cord_buffer.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'absl/strings/cord_buffer.h') diff --git a/absl/strings/cord_buffer.h b/absl/strings/cord_buffer.h index 09a74ad5..15494b31 100644 --- a/absl/strings/cord_buffer.h +++ b/absl/strings/cord_buffer.h @@ -411,8 +411,12 @@ class CordBuffer { // Power2 functions static bool IsPow2(size_t size) { return absl::has_single_bit(size); } - static size_t Log2Floor(size_t size) { return absl::bit_width(size) - 1; } - static size_t Log2Ceil(size_t size) { return absl::bit_width(size - 1); } + static size_t Log2Floor(size_t size) { + return static_cast(absl::bit_width(size) - 1); + } + static size_t Log2Ceil(size_t size) { + return static_cast(absl::bit_width(size - 1)); + } // Implementation of `CreateWithCustomLimit()`. // This implementation allows for future memory allocation hints to -- cgit v1.2.3