aboutsummaryrefslogtreecommitdiff
path: root/absl/debugging/internal/stacktrace_x86-inl.inc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-08-29 14:14:51 -0700
committerCopybara-Service <copybara-worker@google.com>2022-08-29 14:15:52 -0700
commitd9382f72901dd2bd40d38834eb591cea784e90e5 (patch)
tree39086e30a602efa312fa3a4389ae41032c5be411 /absl/debugging/internal/stacktrace_x86-inl.inc
parent75691f1c3292969c5a85288a3cee8ae831203302 (diff)
downloadabseil-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/stacktrace_x86-inl.inc')
-rw-r--r--absl/debugging/internal/stacktrace_x86-inl.inc12
1 files changed, 8 insertions, 4 deletions
diff --git a/absl/debugging/internal/stacktrace_x86-inl.inc b/absl/debugging/internal/stacktrace_x86-inl.inc
index 1b5d8235..1354cb37 100644
--- a/absl/debugging/internal/stacktrace_x86-inl.inc
+++ b/absl/debugging/internal/stacktrace_x86-inl.inc
@@ -140,13 +140,14 @@ static uintptr_t GetFP(const void *vuc) {
// TODO(bcmills): -momit-leaf-frame-pointer is currently the default
// behavior when building with clang. Talk to the C++ toolchain team about
// fixing that.
- if (bp >= sp && bp - sp <= kMaxFrameBytes) return bp;
+ if (bp >= sp && bp - sp <= kMaxFrameBytes)
+ return static_cast<uintptr_t>(bp);
// If bp isn't a plausible frame pointer, return the stack pointer instead.
// If we're lucky, it points to the start of a stack frame; otherwise, we'll
// get one frame of garbage in the stack trace and fail the sanity check on
// the next iteration.
- return sp;
+ return static_cast<uintptr_t>(sp);
}
#endif
return 0;
@@ -310,7 +311,8 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count,
int n = 0;
void **fp = reinterpret_cast<void **>(__builtin_frame_address(0));
- size_t stack_low = getpagesize(); // Assume that the first page is not stack.
+ // Assume that the first page is not stack.
+ size_t stack_low = static_cast<size_t>(getpagesize());
size_t stack_high = std::numeric_limits<size_t>::max() - sizeof(void *);
while (fp && n < max_depth) {
@@ -327,7 +329,9 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count,
result[n] = *(fp + 1);
if (IS_STACK_FRAMES) {
if (next_fp > fp) {
- sizes[n] = (uintptr_t)next_fp - (uintptr_t)fp;
+ sizes[n] = static_cast<int>(
+ reinterpret_cast<uintptr_t>(next_fp) -
+ reinterpret_cast<uintptr_t>(fp));
} else {
// A frame-size of 0 is used to indicate unknown frame size.
sizes[n] = 0;