summaryrefslogtreecommitdiff
path: root/absl/strings/cord.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-08-04 05:04:38 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-08-04 05:05:57 -0700
commit07360899e64ded32e9a5e304bd6a3b6a0ff266bc (patch)
treeb50237b302c3c10c03413b5bd92aa0f311f4a2ff /absl/strings/cord.cc
parent16af2bbcb9dd1770c64483aed8cd7d4ae7061064 (diff)
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: 465285043 Change-Id: I37e9d1b4c4e9aa655b720da1467927af2aba995e
Diffstat (limited to 'absl/strings/cord.cc')
-rw-r--r--absl/strings/cord.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/absl/strings/cord.cc b/absl/strings/cord.cc
index b34c03a2..523379e4 100644
--- a/absl/strings/cord.cc
+++ b/absl/strings/cord.cc
@@ -20,6 +20,7 @@
#include <cstdio>
#include <cstdlib>
#include <iomanip>
+#include <ios>
#include <iostream>
#include <limits>
#include <ostream>
@@ -184,7 +185,7 @@ inline void Cord::InlineRep::reduce_size(size_t n) {
assert(tag >= n);
tag -= n;
memset(data_.as_chars() + tag, 0, n);
- set_inline_size(static_cast<char>(tag));
+ set_inline_size(tag);
}
inline void Cord::InlineRep::remove_prefix(size_t n) {
@@ -1098,7 +1099,7 @@ Cord Cord::ChunkIterator::AdvanceAndReadBytes(size_t n) {
: current_leaf_;
const char* data = payload->IsExternal() ? payload->external()->base
: payload->flat()->Data();
- const size_t offset = current_chunk_.data() - data;
+ const size_t offset = static_cast<size_t>(current_chunk_.data() - data);
auto* tree = CordRepSubstring::Substring(payload, offset, n);
subcord.contents_.EmplaceTree(VerifyTree(tree), method);
@@ -1308,7 +1309,7 @@ static bool VerifyNode(CordRep* root, CordRep* start_node,
std::ostream& operator<<(std::ostream& out, const Cord& cord) {
for (absl::string_view chunk : cord.Chunks()) {
- out.write(chunk.data(), chunk.size());
+ out.write(chunk.data(), static_cast<std::streamsize>(chunk.size()));
}
return out;
}