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

Alan Coopersmith alan.coopersmith at oracle.com
Sun Jun 30 14:26:00 PDT 2013


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.

-- 
	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


More information about the xorg-devel mailing list