diff options
author | Abseil Team <absl-team@google.com> | 2022-08-29 14:14:51 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-08-29 14:15:52 -0700 |
commit | d9382f72901dd2bd40d38834eb591cea784e90e5 (patch) | |
tree | 39086e30a602efa312fa3a4389ae41032c5be411 /absl/debugging/internal/demangle.cc | |
parent | 75691f1c3292969c5a85288a3cee8ae831203302 (diff) | |
download | abseil-d9382f72901dd2bd40d38834eb591cea784e90e5.tar.gz abseil-d9382f72901dd2bd40d38834eb591cea784e90e5.tar.bz2 abseil-d9382f72901dd2bd40d38834eb591cea784e90e5.zip |
Fix "unsafe narrowing" warnings in absl, 7/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 debugging/internal/.)
Bug: chromium:1292951
PiperOrigin-RevId: 470812243
Change-Id: I5578030bb42ba73cb83d4df84f89e431ceac8992
Diffstat (limited to 'absl/debugging/internal/demangle.cc')
-rw-r--r-- | absl/debugging/internal/demangle.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc index 161de846..f2832915 100644 --- a/absl/debugging/internal/demangle.cc +++ b/absl/debugging/internal/demangle.cc @@ -253,11 +253,13 @@ static bool StrPrefix(const char *str, const char *prefix) { return prefix[i] == '\0'; // Consumed everything in "prefix". } -static void InitState(State *state, const char *mangled, char *out, - int out_size) { +static void InitState(State* state, + const char* mangled, + char* out, + size_t out_size) { state->mangled_begin = mangled; state->out = out; - state->out_end_idx = out_size; + state->out_end_idx = static_cast<int>(out_size); state->recursion_depth = 0; state->steps = 0; @@ -451,7 +453,7 @@ static bool MaybeAppendDecimal(State *state, int val) { // one-past-the-end and manipulate one character before the pointer. char *p = &buf[kMaxLength]; do { // val=0 is the only input that should write a leading zero digit. - *--p = (val % 10) + '0'; + *--p = static_cast<char>((val % 10) + '0'); val /= 10; } while (p > buf && val != 0); @@ -1974,7 +1976,7 @@ static bool Overflowed(const State *state) { } // The demangler entry point. -bool Demangle(const char *mangled, char *out, int out_size) { +bool Demangle(const char* mangled, char* out, size_t out_size) { State state; InitState(&state, mangled, out, out_size); return ParseTopLevelMangledName(&state) && !Overflowed(&state) && |