[PATCH] dmx: force -fno-strict-aliasing for xinput example

Peter Hutterer peter.hutterer at who-t.net
Sun Dec 4 16:37:26 PST 2011


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.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
If I understand this correctly, this is endemic to virtually any XI
application. Point could be made to disable strict aliasing for the whole
examples directory here instead of just the xinput example here but none of
the others complain as of yet.

 configure.ac |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index d2aaeb1..3443583 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1968,6 +1968,7 @@ dnl Linux sources in DMX require <linux/keyboard.h>
 	AC_SUBST(DMXXMUEXAMPLES_DEP_LIBS)
 	PKG_CHECK_MODULES([DMXXIEXAMPLES_DEP], [$LIBDMX $LIBXI $LIBXEXT x11])
 	AC_SUBST(DMXXIEXAMPLES_DEP_LIBS)
+	DMXXIEXAMPLES_DEP_CFLAGS+="-fno-strict-aliasing"
 	PKG_CHECK_MODULES([XTSTEXAMPLES_DEP], [$LIBXTST $LIBXEXT x11])
 	AC_SUBST(XTSTEXAMPLES_DEP_LIBS)
 	PKG_CHECK_MODULES([XRESEXAMPLES_DEP], [xres $LIBXEXT x11])
-- 
1.7.7.1


More information about the xorg-devel mailing list