[PATCH v2 xserver 4/4] dmx: force -fno-strict-aliasing for xinput example

Gaetan Nadon memsize at videotron.ca
Fri Dec 9 04:45:04 PST 2011


From: Peter Hutterer <peter.hutterer at who-t.net>

Compiler warning:
xinput.c:272: warning: dereferencing pointer 'e' does break strict-aliasing
rules

The code itself is the usual XInput client-side code:
        XEvent event;
        XDeviceMotionEvent *e = (XDeviceMotionEvent *)&event;
        XNextEvent(display, &event);
        printf("%d\n", e->type);

Since XDeviceMotionEvent is not guaranteed the same size as XEvent, clients
must use pointer aliasing as above when using the XNextEvent API. Disable
strict aliasing for this example.

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
Reviewed-by: Gaetan Nadon <memsize at videotron.ca>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
---
 hw/dmx/examples/Makefile.am |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/dmx/examples/Makefile.am b/hw/dmx/examples/Makefile.am
index 003c143..d594b85 100644
--- a/hw/dmx/examples/Makefile.am
+++ b/hw/dmx/examples/Makefile.am
@@ -43,7 +43,7 @@ dmxrminput_CFLAGS = $(DMXEXAMPLES_DEP_CFLAGS) $(BASE_CFLAGS)
 
 xinput_SOURCES = xinput.c
 xinput_LDADD = $(DMXXIEXAMPLES_DEP_LIBS)
-xinput_CFLAGS = $(DMXXIEXAMPLES_DEP_CFLAGS) $(BASE_CFLAGS)
+xinput_CFLAGS = $(DMXXIEXAMPLES_DEP_CFLAGS) $(BASE_CFLAGS) $(NO_STRICT_ALIASING_CFLAG)
 
 xtest_SOURCES = xtest.c
 xtest_LDADD = $(XTSTEXAMPLES_DEP_LIBS)
-- 
1.7.4.1



More information about the xorg-devel mailing list