summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicente Olivert Riera <Vincent.Riera@imgtec.com>2015-01-12 17:10:02 +0000
committerAdam Jackson <ajax@redhat.com>2015-06-03 09:05:39 -0400
commit8b7e1f362bf6940eb863fd02395bf8155d10604b (patch)
treee635792528cddb8275e9161fef608f7f52dfbce7
parentc424458c93cb36708c6074ecaf6566d6b5818c87 (diff)
backtrace.c: Fix word cast to a pointer
backtrace.c uses a word size provided by libunwind. In some architectures like MIPS, libunwind makes that word size 64-bit for all variants of the architecture. In the lines #90 and #98, backtrace.c tries to do a cast to a pointer, which fails in all MIPS variants with 32-bit pointers, like MIPS32 or MIPS64 n32, because it's trying to do a cast from a 64-bit wide variable to a 32-bit pointer: Making all in os make[2]: Entering directory `/home/test/test/1/output/build/xserver_xorg-server-1.15.1/os' CC WaitFor.lo CC access.lo CC auth.lo CC backtrace.lo backtrace.c: In function 'xorg_backtrace': backtrace.c:90:20: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] if (dladdr((void *)(pip.start_ip + off), &dlinfo) && dlinfo.dli_fname && ^ backtrace.c:98:13: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] (void *)(pip.start_ip + off)); ^ cc1: some warnings being treated as errors make[2]: *** [backtrace.lo] Error 1 make[2]: *** Waiting for unfinished jobs.... Making the cast to a pointer-sized integer, and then to a pointer fixes the problem. Related: https://bugs.freedesktop.org/show_bug.cgi?id=79939 Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Keith Packard <keithp@keithp.com> (cherry picked from commit baa50f60acd9e9f4293107435645ab072b6110e1)
-rw-r--r--os/backtrace.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/os/backtrace.c b/os/backtrace.c
index 3d1195b86..fd129ef21 100644
--- a/os/backtrace.c
+++ b/os/backtrace.c
@@ -87,7 +87,7 @@ xorg_backtrace(void)
procname[1] = 0;
}
- if (dladdr((void *)(pip.start_ip + off), &dlinfo) && dlinfo.dli_fname &&
+ if (dladdr((void *)(uintptr_t)(pip.start_ip + off), &dlinfo) && dlinfo.dli_fname &&
*dlinfo.dli_fname)
filename = dlinfo.dli_fname;
else
@@ -95,7 +95,7 @@ xorg_backtrace(void)
ErrorFSigSafe("%u: %s (%s%s+0x%x) [%p]\n", i++, filename, procname,
ret == -UNW_ENOMEM ? "..." : "", (int)off,
- (void *)(pip.start_ip + off));
+ (void *)(uintptr_t)(pip.start_ip + off));
ret = unw_step(&cursor);
if (ret < 0)