[PATCH:libXrandr] Add cast to fix gcc warning.

Thomas Klausner wiz at NetBSD.org
Sun Jun 30 15:13:08 PDT 2013


On Sun, Jun 30, 2013 at 02:26:00PM -0700, Alan Coopersmith wrote:
> On 06/30/13 04:37 AM, Thomas Klausner wrote:
> >-    _XRead32(dpy, xpi->associated_capability, rep.nAssociatedProviders << 2);
> >+    _XRead32(dpy, (long int *)xpi->associated_capability, rep.nAssociatedProviders << 2);
> 
> This gets rid of one warning, but brings up another in clang:
> 
> XrrProvider.c:159:19: warning: cast from 'unsigned int *' to 'long *' increases
> required alignment from 4 to 8 [-Wcast-align]
>     _XRead32(dpy, (long int *)xpi->associated_capability,
> rep.nAssociatedProviders << 2);
>                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Which is true, and is tied to Xlib's historic brain damage that requires all
> 32-bit values from the protocol to be returned in variables of type "long",
> even if those are 64-bit values.
> 
> Unfortunately, I think this means it's uncovered a real bug, in which randr
> is returning a pointer to an unsigned int array, but calling _XRead32 to
> fill it in as an unsigned long array, and no amount of casting can fix that.

I don't think I can fix this. Should I file a bug report or what's the
best way to proceed here?
 Thomas


More information about the xorg-devel mailing list