[patch] Fix compiler warnings
Jan Kratochvil
jan.kratochvil at redhat.com
Wed Aug 6 21:11:22 UTC 2008
Hi,
fixed various strict-aliasing / size casts / uninitialized warnings.
The patch is based on the sizeof (long) == sizeof (void *) assumption.
Regards,
Jan
-------------- next part --------------
2008-08-06 Jan Kratochvil <jan.kratochvil at redhat.com>
Fix compiler warnings.
* signal.c (sys_signal): Cast to SIG_* to the matching type LONG.
* strace.c (trace): Variables PSR and PC are now signed.
* syscall.c (syscall_enter): Variable RBS_END is now signed long.
Remove/add the RBS_END casts appropriately.
* util.c [IA64] (arg_setup): Variable BSP is now signed long.
Remove/add the BSP casts appropriately.
<ia32>: Initialize *STATE.
--- signal.c 18 Jul 2008 01:02:41 -0000 1.66
+++ signal.c 6 Aug 2008 19:43:13 -0000
@@ -1176,13 +1176,13 @@ struct tcb *tcp;
printsignal(tcp->u_arg[0]);
tprintf(", ");
switch (tcp->u_arg[1]) {
- case (int) SIG_ERR:
+ case (long) SIG_ERR:
tprintf("SIG_ERR");
break;
- case (int) SIG_DFL:
+ case (long) SIG_DFL:
tprintf("SIG_DFL");
break;
- case (int) SIG_IGN:
+ case (long) SIG_IGN:
#ifndef USE_PROCFS
if (tcp->u_arg[0] == SIGTRAP) {
tcp->flags |= TCB_SIGTRAPPED;
@@ -1204,11 +1204,11 @@ struct tcb *tcp;
}
else {
switch (tcp->u_rval) {
- case (int) SIG_ERR:
+ case (long) SIG_ERR:
tcp->auxstr = "SIG_ERR"; break;
- case (int) SIG_DFL:
+ case (long) SIG_DFL:
tcp->auxstr = "SIG_DFL"; break;
- case (int) SIG_IGN:
+ case (long) SIG_IGN:
tcp->auxstr = "SIG_IGN"; break;
default:
tcp->auxstr = NULL;
--- strace.c 25 Jul 2008 15:42:34 -0000 1.87
+++ strace.c 6 Aug 2008 20:09:51 -0000
@@ -2421,11 +2421,12 @@ Process %d attached (waiting for parent)
}
if (!cflag
&& (qual_flags[WSTOPSIG(status)] & QUAL_SIGNAL)) {
- unsigned long addr = 0, pc = 0;
+ unsigned long addr = 0;
+ long pc = 0;
#if defined(PT_CR_IPSR) && defined(PT_CR_IIP) && defined(PT_GETSIGINFO)
# define PSR_RI 41
struct siginfo si;
- unsigned long psr;
+ long psr;
upeek(pid, PT_CR_IPSR, &psr);
upeek(pid, PT_CR_IIP, &pc);
--- syscall.c 27 May 2008 23:18:29 -0000 1.94
+++ syscall.c 6 Aug 2008 20:09:51 -0000
@@ -1963,20 +1963,21 @@ struct tcb *tcp;
#elif defined (IA64)
{
if (!ia32) {
- unsigned long *out0, *rbs_end, cfm, sof, sol, i;
+ unsigned long *out0, cfm, sof, sol, i;
+ long rbs_end;
/* be backwards compatible with kernel < 2.4.4... */
# ifndef PT_RBS_END
# define PT_RBS_END PT_AR_BSP
# endif
- if (upeek(pid, PT_RBS_END, (long *) &rbs_end) < 0)
+ if (upeek(pid, PT_RBS_END, &rbs_end) < 0)
return -1;
if (upeek(pid, PT_CFM, (long *) &cfm) < 0)
return -1;
sof = (cfm >> 0) & 0x7f;
sol = (cfm >> 7) & 0x7f;
- out0 = ia64_rse_skip_regs(rbs_end, -sof + sol);
+ out0 = ia64_rse_skip_regs((unsigned long *) rbs_end, -sof + sol);
if (tcp->scno >= 0 && tcp->scno < nsyscalls
&& sysent[tcp->scno].nargs != -1)
--- util.c 18 Jul 2008 01:19:36 -0000 1.77
+++ util.c 6 Aug 2008 20:09:51 -0000
@@ -1300,21 +1300,25 @@ typedef unsigned long *arg_setup_state;
static int
arg_setup(struct tcb *tcp, arg_setup_state *state)
{
- unsigned long *bsp, cfm, sof, sol;
+ unsigned long cfm, sof, sol;
+ long bsp;
- if (ia32)
+ if (ia32) {
+ /* Satisfy a false GCC warning. */
+ *state = NULL;
return 0;
+ }
- if (upeek(tcp->pid, PT_AR_BSP, (long *) &bsp) < 0)
+ if (upeek(tcp->pid, PT_AR_BSP, &bsp) < 0)
return -1;
if (upeek(tcp->pid, PT_CFM, (long *) &cfm) < 0)
return -1;
sof = (cfm >> 0) & 0x7f;
sol = (cfm >> 7) & 0x7f;
- bsp = ia64_rse_skip_regs(bsp, -sof + sol);
+ bsp = (long) ia64_rse_skip_regs((unsigned long *) bsp, -sof + sol);
- *state = bsp;
+ *state = (unsigned long *) bsp;
return 0;
}
More information about the Strace-devel
mailing list