[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 1/2] xen-detect: fix strict-aliasing compilation warning.
With gcc 4.8.3, compiling xen-detect gives a compilation warning if you're optimising: $ cc -Wall -Os xen-detect.c xen-detect.c: In function âcheck_for_xenâ: xen-detect.c:65:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] *(uint32_t *)(signature + 0) = regs[1]; ^ Signed-off-by: John Haxby <john.haxby@xxxxxxxxxx> --- tools/misc/xen-detect.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tools/misc/xen-detect.c b/tools/misc/xen-detect.c index 787b5da..19c66d1 100644 --- a/tools/misc/xen-detect.c +++ b/tools/misc/xen-detect.c @@ -54,28 +54,27 @@ static void cpuid(uint32_t idx, uint32_t *regs, int pv_context) static int check_for_xen(int pv_context) { - uint32_t regs[4]; - char signature[13]; + union + { + uint32_t regs[4]; + char signature[17]; + } u; uint32_t base; for ( base = 0x40000000; base < 0x40010000; base += 0x100 ) { - cpuid(base, regs, pv_context); - - *(uint32_t *)(signature + 0) = regs[1]; - *(uint32_t *)(signature + 4) = regs[2]; - *(uint32_t *)(signature + 8) = regs[3]; - signature[12] = '\0'; + cpuid(base, u.regs, pv_context); + u.signature[16] = '\0'; - if ( !strcmp("XenVMMXenVMM", signature) && (regs[0] >= (base + 2)) ) + if ( !strcmp("XenVMMXenVMM", u.signature+4) && (u.regs[0] >= (base + 2)) ) goto found; } return 0; found: - cpuid(base + 1, regs, pv_context); - return regs[0]; + cpuid(base + 1, u.regs, pv_context); + return u.regs[0]; } static jmp_buf sigill_jmp; -- 1.9.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |