summaryrefslogtreecommitdiff
path: root/absl/strings/substitute.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-07-28 07:45:06 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-07-28 07:46:07 -0700
commit7f51ef5ed2740dab2bbf53c4dd5931b6e8ec6a5b (patch)
tree72096ff69ed2b4dac6db4e1bcc5d85d3ecb0ef8d /absl/strings/substitute.h
parentc7e60ccfcd708a73008ed2df040162c66697bc18 (diff)
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
Diffstat (limited to 'absl/strings/substitute.h')
-rw-r--r--absl/strings/substitute.h32
1 files changed, 24 insertions, 8 deletions
diff --git a/absl/strings/substitute.h b/absl/strings/substitute.h
index 6d2b08ab..692fd03c 100644
--- a/absl/strings/substitute.h
+++ b/absl/strings/substitute.h
@@ -125,28 +125,44 @@ class Arg {
}
Arg(short value) // NOLINT(*)
: piece_(scratch_,
- numbers_internal::FastIntToBuffer(value, scratch_) - scratch_) {}
+ static_cast<size_t>(
+ numbers_internal::FastIntToBuffer(value, scratch_) -
+ scratch_)) {}
Arg(unsigned short value) // NOLINT(*)
: piece_(scratch_,
- numbers_internal::FastIntToBuffer(value, scratch_) - scratch_) {}
+ static_cast<size_t>(
+ numbers_internal::FastIntToBuffer(value, scratch_) -
+ scratch_)) {}
Arg(int value) // NOLINT(runtime/explicit)
: piece_(scratch_,
- numbers_internal::FastIntToBuffer(value, scratch_) - scratch_) {}
+ static_cast<size_t>(
+ numbers_internal::FastIntToBuffer(value, scratch_) -
+ scratch_)) {}
Arg(unsigned int value) // NOLINT(runtime/explicit)
: piece_(scratch_,
- numbers_internal::FastIntToBuffer(value, scratch_) - scratch_) {}
+ static_cast<size_t>(
+ numbers_internal::FastIntToBuffer(value, scratch_) -
+ scratch_)) {}
Arg(long value) // NOLINT(*)
: piece_(scratch_,
- numbers_internal::FastIntToBuffer(value, scratch_) - scratch_) {}
+ static_cast<size_t>(
+ numbers_internal::FastIntToBuffer(value, scratch_) -
+ scratch_)) {}
Arg(unsigned long value) // NOLINT(*)
: piece_(scratch_,
- numbers_internal::FastIntToBuffer(value, scratch_) - scratch_) {}
+ static_cast<size_t>(
+ numbers_internal::FastIntToBuffer(value, scratch_) -
+ scratch_)) {}
Arg(long long value) // NOLINT(*)
: piece_(scratch_,
- numbers_internal::FastIntToBuffer(value, scratch_) - scratch_) {}
+ static_cast<size_t>(
+ numbers_internal::FastIntToBuffer(value, scratch_) -
+ scratch_)) {}
Arg(unsigned long long value) // NOLINT(*)
: piece_(scratch_,
- numbers_internal::FastIntToBuffer(value, scratch_) - scratch_) {}
+ static_cast<size_t>(
+ numbers_internal::FastIntToBuffer(value, scratch_) -
+ scratch_)) {}
Arg(float value) // NOLINT(runtime/explicit)
: piece_(scratch_, numbers_internal::SixDigitsToBuffer(value, scratch_)) {
}