diff options
author | Abseil Team <absl-team@google.com> | 2022-08-01 08:29:37 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-08-01 08:30:25 -0700 |
commit | 16af2bbcb9dd1770c64483aed8cd7d4ae7061064 (patch) | |
tree | 358b0bc9ba9786d4af2f49546d2b06868e80e568 /absl/debugging/internal/examine_stack.cc | |
parent | dc370a82467cb35066475537b797197aee3e5164 (diff) | |
download | abseil-16af2bbcb9dd1770c64483aed8cd7d4ae7061064.tar.gz abseil-16af2bbcb9dd1770c64483aed8cd7d4ae7061064.tar.bz2 abseil-16af2bbcb9dd1770c64483aed8cd7d4ae7061064.zip |
Fix "unsafe narrowing" warnings in absl, 2/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 dirs a-h.)
Bug: chromium:1292951
PiperOrigin-RevId: 464541951
Change-Id: If23b63ccea8e9b730159ff1c7288e9300a40b6bd
Diffstat (limited to 'absl/debugging/internal/examine_stack.cc')
-rw-r--r-- | absl/debugging/internal/examine_stack.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/absl/debugging/internal/examine_stack.cc b/absl/debugging/internal/examine_stack.cc index 5bdd341e..57863228 100644 --- a/absl/debugging/internal/examine_stack.cc +++ b/absl/debugging/internal/examine_stack.cc @@ -278,13 +278,14 @@ void DumpStackTrace(int min_dropped_frames, int max_num_frames, void* stack_buf[kDefaultDumpStackFramesLimit]; void** stack = stack_buf; int num_stack = kDefaultDumpStackFramesLimit; - int allocated_bytes = 0; + size_t allocated_bytes = 0; if (num_stack >= max_num_frames) { // User requested fewer frames than we already have space for. num_stack = max_num_frames; } else { - const size_t needed_bytes = max_num_frames * sizeof(stack[0]); + const size_t needed_bytes = + static_cast<size_t>(max_num_frames) * sizeof(stack[0]); void* p = Allocate(needed_bytes); if (p != nullptr) { // We got the space. num_stack = max_num_frames; @@ -293,12 +294,13 @@ void DumpStackTrace(int min_dropped_frames, int max_num_frames, } } - size_t depth = absl::GetStackTrace(stack, num_stack, min_dropped_frames + 1); - for (size_t i = 0; i < depth; i++) { + int depth = absl::GetStackTrace(stack, num_stack, min_dropped_frames + 1); + for (int i = 0; i < depth; i++) { if (symbolize_stacktrace) { - DumpPCAndSymbol(writer, writer_arg, stack[i], " "); + DumpPCAndSymbol(writer, writer_arg, stack[static_cast<size_t>(i)], + " "); } else { - DumpPC(writer, writer_arg, stack[i], " "); + DumpPC(writer, writer_arg, stack[static_cast<size_t>(i)], " "); } } |