From ce433f8090da6784cdee754defcbf325fc66f274 Mon Sep 17 00:00:00 2001 From: Chris Metcalf Date: Wed, 12 Nov 2014 15:00:06 -0500 Subject: tile: avoid undefined behavior with regs[TREG_TP] etc Recent compilers warn about accesses to arrays past the end, which is supported for pt_regs and sigcontext with the intended alias past the end of regs[] to sp, tp, and lr using TREG_SP, TREG_TP, and TREG_LR. Make the intended usage explict by providing an anonymous union of regs[56] on the one hand, and a short __regs[53] on the other followed by the sp, tp, and lr fields, so the aliasing is done explicitly and is visible to the compiler. Reviewed-by: Jeff Epler Signed-off-by: Chris Metcalf --- arch/tile/include/uapi/asm/sigcontext.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'arch/tile/include/uapi/asm/sigcontext.h') diff --git a/arch/tile/include/uapi/asm/sigcontext.h b/arch/tile/include/uapi/asm/sigcontext.h index 6348e59d3724..39ff5d1a232d 100644 --- a/arch/tile/include/uapi/asm/sigcontext.h +++ b/arch/tile/include/uapi/asm/sigcontext.h @@ -24,10 +24,16 @@ * but is simplified since we know the fault is from userspace. */ struct sigcontext { - __uint_reg_t gregs[53]; /* General-purpose registers. */ - __uint_reg_t tp; /* Aliases gregs[TREG_TP]. */ - __uint_reg_t sp; /* Aliases gregs[TREG_SP]. */ - __uint_reg_t lr; /* Aliases gregs[TREG_LR]. */ + __extension__ union { + /* General-purpose registers. */ + __uint_reg_t gregs[56]; + __extension__ struct { + __uint_reg_t __gregs[53]; + __uint_reg_t tp; /* Aliases gregs[TREG_TP]. */ + __uint_reg_t sp; /* Aliases gregs[TREG_SP]. */ + __uint_reg_t lr; /* Aliases gregs[TREG_LR]. */ + }; + }; __uint_reg_t pc; /* Program counter. */ __uint_reg_t ics; /* In Interrupt Critical Section? */ __uint_reg_t faultnum; /* Fault number. */ -- cgit v1.2.3-59-g8ed1b