[PATCH] dmx: force -fno-strict-aliasing for xinput example
Gaetan Nadon
memsize at videotron.ca
Wed Dec 7 05:50:47 PST 2011
On Mon, 2011-12-05 at 13:51 +1000, Peter Hutterer wrote:
> On Sun, Dec 04, 2011 at 09:16:41PM -0500, Gaetan Nadon wrote:
> > 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.
>
> right, of course. I'll fix that up.
>
> > 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
>
> tbh, I'm not 100% what other conditions need to be true here. I can't
> reproduce it on my machine but on our build-systems it produces the above
> warning without this fix.
Most likely they add warning compiler options on the build machine.
Consider adding $(CWARNFLAGS) in the makefile. I was somewhat surprised
to see it was missing.
You may want to wait until util-macros v 1.16 where Jeremy reorged the
warning flags and separated them from fno-strict-aliasing which will fit
nicely with this patch.
>
> Cheers,
> Peter
>
> > > 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/20111207/5797e77a/attachment-0001.htm>
-------------- 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/20111207/5797e77a/attachment-0001.pgp>
More information about the xorg-devel
mailing list