From 5a547f8bbd310850bb8123446110730abafdad56 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 12 Sep 2022 16:04:42 -0700 Subject: Fix "unsafe narrowing" warnings in absl, 8/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 */internal/.) Bug: chromium:1292951 PiperOrigin-RevId: 473868797 Change-Id: Ibe0b76e33f9e001d59862beaac54fb47bacd39b2 --- absl/flags/internal/flag.cc | 4 ++-- absl/flags/internal/usage.cc | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'absl/flags') diff --git a/absl/flags/internal/flag.cc b/absl/flags/internal/flag.cc index 55892d77..cc656f9d 100644 --- a/absl/flags/internal/flag.cc +++ b/absl/flags/internal/flag.cc @@ -406,7 +406,7 @@ template StorageT* FlagImpl::OffsetValue() const { char* p = reinterpret_cast(const_cast(this)); // The offset is deduced via Flag value type specific op_. - size_t offset = flags_internal::ValueOffset(op_); + ptrdiff_t offset = flags_internal::ValueOffset(op_); return reinterpret_cast(p + offset); } @@ -486,7 +486,7 @@ bool FlagImpl::ReadOneBool() const { } void FlagImpl::ReadSequenceLockedData(void* dst) const { - int size = Sizeof(op_); + size_t size = Sizeof(op_); // Attempt to read using the sequence lock. if (ABSL_PREDICT_TRUE(seq_lock_.TryRead(dst, AtomicBufferValue(), size))) { return; diff --git a/absl/flags/internal/usage.cc b/absl/flags/internal/usage.cc index 949709e8..a3b13ed3 100644 --- a/absl/flags/internal/usage.cc +++ b/absl/flags/internal/usage.cc @@ -148,8 +148,7 @@ class FlagHelpPrettyPrinter { } // Write the token, ending the string first if necessary/possible. - if (!new_line && - (line_len_ + static_cast(token.size()) >= max_line_len_)) { + if (!new_line && (line_len_ + token.size() >= max_line_len_)) { EndLine(); new_line = true; } -- cgit v1.2.3