[PATCH 3/3] Fix compilation warnings on ARM
Denys Vlasenko
dvlasenk at redhat.com
Fri Dec 5 11:46:34 UTC 2008
On Thu, 2008-12-04 at 05:06 +0300, Dmitry V. Levin wrote:
> 2008-11-13 Kirill A. Shutemov <kas at altlinux.org>
>
> Fix compilation warnings on ARM.
> * signal.c (sys_sigreturn) [ARM]: Fix cast.
> * syscall.c (decode_subcall) Do not define on ARM EABI.
> (get_scno) [ARM]: Fix cast.
> (syscall_fixup, syscall_enter): Do not define pid variable on ARM.
>
> --- signal.c
> +++ signal.c
> @@ -1242,7 +1242,7 @@ struct tcb *tcp;
> if (entering(tcp)) {
> tcp->u_arg[0] = 0;
>
> - if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (void *)®s) == -1)
> + if (ptrace(PTRACE_GETREGS, tcp->pid, NULL, (unsigned long)®s) == -1)
1. Why? I am sure whoever will read this code later won't
understand why it is cast to long, not ptr.
2. Can we somehow make it so that we can ensure proper casts
on all ptrace calls at once?
> return 0;
>
> if (umove(tcp, regs.ARM_sp, &sc) < 0)
> --- syscall.c
> +++ syscall.c
> @@ -582,7 +582,7 @@ static const struct subcall subcalls_table[] = {
> };
> #endif /* FREEBSD */
>
> -#if !(defined(LINUX) && ( defined(ALPHA) || defined(MIPS) ))
> +#if !(defined(LINUX) && ( defined(ALPHA) || defined(MIPS) || defined(__ARM_EABI__) ))
>
> static void
> decode_subcall(tcp, subcall, nsubcalls, style)
> @@ -1006,7 +1006,7 @@ struct tcb *tcp;
> /*
> * Read complete register set in one go.
> */
> - if (ptrace(PTRACE_GETREGS, pid, NULL, (void *)®s) == -1)
> + if (ptrace(PTRACE_GETREGS, pid, NULL, (unsigned long)®s) == -1)
> return -1;
>
> /*
> @@ -1034,7 +1034,7 @@ struct tcb *tcp;
> * Get the ARM-mode system call number
> */
> errno = 0;
> - scno = ptrace(PTRACE_PEEKTEXT, pid, (void *)(regs.ARM_pc - 4), NULL);
> + scno = ptrace(PTRACE_PEEKTEXT, pid, (void *)(regs.ARM_pc - 4), 0);
Why is it better? If anything, it has bigger chances to be wrong,
int can be narrower than long or void*, if kernel would fetch
3rd param as long, it might end up != 0 (on some arches).
--
vda
More information about the Strace-devel
mailing list