diff options
author | Abseil Team <absl-team@google.com> | 2022-07-28 07:45:06 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-07-28 07:46:07 -0700 |
commit | 7f51ef5ed2740dab2bbf53c4dd5931b6e8ec6a5b (patch) | |
tree | 72096ff69ed2b4dac6db4e1bcc5d85d3ecb0ef8d /absl/strings/internal/str_format | |
parent | c7e60ccfcd708a73008ed2df040162c66697bc18 (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/internal/str_format')
-rw-r--r-- | absl/strings/internal/str_format/parser.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/absl/strings/internal/str_format/parser.h b/absl/strings/internal/str_format/parser.h index 32b91d03..a81bac83 100644 --- a/absl/strings/internal/str_format/parser.h +++ b/absl/strings/internal/str_format/parser.h @@ -155,10 +155,11 @@ bool ParseFormatString(string_view src, Consumer consumer) { static_cast<const char*>(memchr(p, '%', static_cast<size_t>(end - p))); if (!percent) { // We found the last substring. - return consumer.Append(string_view(p, end - p)); + return consumer.Append(string_view(p, static_cast<size_t>(end - p))); } // We found a percent, so push the text run then process the percent. - if (ABSL_PREDICT_FALSE(!consumer.Append(string_view(p, percent - p)))) { + if (ABSL_PREDICT_FALSE(!consumer.Append( + string_view(p, static_cast<size_t>(percent - p))))) { return false; } if (ABSL_PREDICT_FALSE(percent + 1 >= end)) return false; @@ -189,7 +190,8 @@ bool ParseFormatString(string_view src, Consumer consumer) { p = ConsumeUnboundConversion(percent + 1, end, &conv, &next_arg); if (ABSL_PREDICT_FALSE(p == nullptr)) return false; if (ABSL_PREDICT_FALSE(!consumer.ConvertOne( - conv, string_view(percent + 1, p - (percent + 1))))) { + conv, string_view(percent + 1, + static_cast<size_t>(p - (percent + 1)))))) { return false; } } else { |