linux-user: avoid gcc array overrun warning for sparc
PATCH 1/1 linux-user: avoid gcc array overrun warning for sparc
Suppress a gcc array bounds overrun warning when filling in the SPARC signal frame by adjusting our definition of the structure so that the fp and callers_pc membes are part of the ins[] array rather than separate fields; since qemu has no need to access the fields individually there is no need to follow the kernel's structure field naming exactly.
---
This is a fix for another warning that the armel gcc gives:linux-user/signal.c:1979: error: array subscript is above array bounds so if it passes review I think it's a good candidate for putting in 0.14.
linux-user/signal.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
linux-user/signal.c +4 -3
@@ -1817,9 +1817,10 @@ struct target_sigcontext {/* A Sparc stack frame */ struct sparc_stackf {abi_ulong locals[8 ]; -abi_ulong ins[6 ]; -struct sparc_stackf *fp; -abi_ulong callers_pc; +abi_ulong ins[8 ]; +/* It's simpler to treat fp and callers_pc as elements of ins[] +* since we never need to access them ourselves. +*/ char *structptr;abi_ulong xargs[6 ];abi_ulong xxargs[1 ];
Signature · 1 line
1.7.1
Quoted 4 lines · Peter Maydell
linux-user/signal.c +0
-0@@ -1817,9 +1817,10 @@ struct target_sigcontext { /* A Sparc stack frame */
linux-user/signal.c struct target_sigcontext { · line 1824
Quoted 10 lines
linux-user/signal.c +4
-3struct sparc_stackf { abi_ulong locals[8]; - abi_ulong ins[6]; - struct sparc_stackf *fp; - abi_ulong callers_pc; + abi_ulong ins[8]; + /* It's simpler to treat fp and callers_pc as elements of ins[] + * since we never need to access them ourselves. + */ char *structptr;
Incidentally, I think the presence of a host pointer in a target structure definition is a (different) bug which might cause problems when the target and host have different pointer sizes...
-- PMM
Quoted 11 lines · Peter Maydell
Quoted 10 lines · Peter Maydell
linux-user/signal.c +1
-3@@ -1817,9 +1817,10 @@ struct target_sigcontext { /* A Sparc stack frame */ struct sparc_stackf { abi_ulong locals[8]; - abi_ulong ins[6]; - struct sparc_stackf *fp; - abi_ulong callers_pc; + abi_ulong ins[8];
Quoted 8 lines
linux-user/signal.c struct target_sigcontext { · line 1824
Quoted 4 lines
linux-user/signal.c +3
-0+ /* It's simpler to treat fp and callers_pc as elements of ins[] + * since we never need to access them ourselves. + */ char *structptr;Incidentally, I think the presence of a host pointer in a target structure definition is a (different) bug which might cause problems when the target and host have different pointer sizes...
Right, it was copied from Linux. I can't see where it was used. UREG_FP use cases look OK.
Blue Swirl
AppliedThanks, applied.
Quoted 37 lines · Peter Maydell
Suppress a gcc array bounds overrun warning when filling in the SPARC signal frame by adjusting our definition of the structure so that the fp and
callers_pcmembes are part of the ins[] array rather than separate fields; since qemu has no need to access the fields individually there is no need to follow the kernel's structure field naming exactly.Signed-off-by Peter Maydell <[email protected]>---
This is a fix for another warning that the armel gcc gives:linux-user/signal.c:1979: error: array subscript is above array bounds so if it passes review I think it's a good candidate for putting in 0.14.linux-user/signal.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)linux-user/signal.c +4
-4@@ -1817,9 +1817,10 @@ struct target_sigcontext { /* A Sparc stack frame */ struct sparc_stackf { abi_ulong locals[8]; - abi_ulong ins[6]; - struct sparc_stackf *fp; - abi_ulong callers_pc; + abi_ulong ins[8]; + /* It's simpler to treat fp and callers_pc as elements of ins[] + * since we never need to access them ourselves. + */ char *structptr; abi_ulong xargs[6]; abi_ulong xxargs[1]; --1.7.1