[PATCH:libXrandr] Add some casts for gcc with more warnings enabled.

Alan Coopersmith alan.coopersmith at oracle.com
Fri Jun 7 20:23:04 PDT 2013


On 06/ 2/13 01:17 PM, Thomas Klausner wrote:
> ---
>   src/XrrProvider.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/XrrProvider.c b/src/XrrProvider.c
> index 309e321..cc339cd 100644
> --- a/src/XrrProvider.c
> +++ b/src/XrrProvider.c
> @@ -77,7 +77,7 @@ XRRGetProviderResources(Display *dpy, Window window)
>       xrpr->nproviders = rep.nProviders;
>       xrpr->providers = (RRProvider *)(xrpr + 1);
>
> -    _XRead32(dpy, xrpr->providers, rep.nProviders << 2);
> +    _XRead32(dpy, (RRProvider *)xrpr->providers, rep.nProviders << 2);
>
>       if (nbytes > nbytesRead)
>         _XEatData (dpy, (unsigned long) (nbytes - nbytesRead));
> @@ -156,7 +156,7 @@ XRRGetProviderInfo(Display *dpy, XRRScreenResources *resources, RRProvider provi
>       _XRead32(dpy, xpi->outputs, rep.nOutputs << 2);
>
>       _XRead32(dpy, xpi->associated_providers, rep.nAssociatedProviders << 2);
> -    _XRead32(dpy, xpi->associated_capability, rep.nAssociatedProviders << 2);
> +    _XRead32(dpy, (RRProvider *)xpi->associated_capability, rep.nAssociatedProviders << 2);
>
>       _XReadPad(dpy, xpi->name, rep.nameLength);
>       xpi->name[rep.nameLength] = '\0';
>

I don't understand this patch, since it's not casting to the type the function
prototype expects, nor does it clear any of the gcc warnings for me.   The first
one is especially strange, since xrpr->providers is already defined in the
structure definition as being of type RRProvider *.

gcc still says:

XrrProvider.c: In function 'XRRGetProviderResources':
XrrProvider.c:80:5: warning: pointer targets in passing argument 2 of '_XRead32' 
differ in signedness [-Wpointer-sign]
In file included from XrrProvider.c:31:0:
/net/also.us.oracle.com/export/alanc/X.Org/amd64-gcc/install/usr/X11R7/include/X11/Xlibint.h:600:13: 
note: expected 'long int *' but argument is of type 'RRProvider *'
XrrProvider.c: In function 'XRRGetProviderInfo':
XrrProvider.c:155:5: warning: pointer targets in passing argument 2 of 
'_XRead32' differ in signedness [-Wpointer-sign]
In file included from XrrProvider.c:31:0:
/net/also.us.oracle.com/export/alanc/X.Org/amd64-gcc/install/usr/X11R7/include/X11/Xlibint.h:600:13: 
note: expected 'long int *' but argument is of type 'RRCrtc *'
XrrProvider.c:156:5: warning: pointer targets in passing argument 2 of 
'_XRead32' differ in signedness [-Wpointer-sign]
In file included from XrrProvider.c:31:0:
/net/also.us.oracle.com/export/alanc/X.Org/amd64-gcc/install/usr/X11R7/include/X11/Xlibint.h:600:13: 
note: expected 'long int *' but argument is of type 'RROutput *'
XrrProvider.c:158:5: warning: pointer targets in passing argument 2 of 
'_XRead32' differ in signedness [-Wpointer-sign]
In file included from XrrProvider.c:31:0:
/net/also.us.oracle.com/export/alanc/X.Org/amd64-gcc/install/usr/X11R7/include/X11/Xlibint.h:600:13: 
note: expected 'long int *' but argument is of type 'RRProvider *'
XrrProvider.c:159:5: warning: pointer targets in passing argument 2 of 
'_XRead32' differ in signedness [-Wpointer-sign]
In file included from XrrProvider.c:31:0:
/net/also.us.oracle.com/export/alanc/X.Org/amd64-gcc/install/usr/X11R7/include/X11/Xlibint.h:600:13: 
note: expected 'long int *' but argument is of type 'RRProvider *'


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


More information about the xorg-devel mailing list