[PATCH] dmx: force -fno-strict-aliasing for xinput example
Gaetan Nadon
memsize at videotron.ca
Sun Dec 4 18:16:41 PST 2011
On Mon, 2011-12-05 at 10:37 +1000, Peter Hutterer wrote:
> 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"
Shouldn't this be similar to line 93 above?
if test "x$GCC" = xyes ; then
XSERVER_CFLAGS="$XSERVER_CFLAGS -fno-strict-aliasing"
fi
One cannot presume that only gcc will ever compile this code, unless I
missed some equivalent test somewhere.
I don't get any warning in my build output and I don't see any -W option
(patch not applied):
gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../../../include
-I/home/nadon/xorg/src/inst/include -g -O2 -MT xinput-xinput.o -MD -MP
-MF .deps/xinput-xinput.Tpo -c -o xinput-xinput.o `test -f 'xinput.c' ||
echo './'`xinput.c
> PKG_CHECK_MODULES([XTSTEXAMPLES_DEP], [$LIBXTST $LIBXEXT x11])
> AC_SUBST(XTSTEXAMPLES_DEP_LIBS)
> PKG_CHECK_MODULES([XRESEXAMPLES_DEP], [xres $LIBXEXT x11])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20111204/7ab05154/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg-devel/attachments/20111204/7ab05154/attachment.pgp>
More information about the xorg-devel
mailing list