summaryrefslogtreecommitdiff
path: root/absl/flags/internal
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-09-12 16:04:42 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-09-12 16:05:39 -0700
commit5a547f8bbd310850bb8123446110730abafdad56 (patch)
tree3407227cb7ea1bac60e341c42cf5da32a3ed6ff1 /absl/flags/internal
parent0a066f31d981d69f7bde961055691906dabd4a3c (diff)
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
Diffstat (limited to 'absl/flags/internal')
-rw-r--r--absl/flags/internal/flag.cc4
-rw-r--r--absl/flags/internal/usage.cc3
2 files changed, 3 insertions, 4 deletions
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 <typename StorageT>
StorageT* FlagImpl::OffsetValue() const {
char* p = reinterpret_cast<char*>(const_cast<FlagImpl*>(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<StorageT*>(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<int>(token.size()) >= max_line_len_)) {
+ if (!new_line && (line_len_ + token.size() >= max_line_len_)) {
EndLine();
new_line = true;
}