[PATCH] savage: More (intermediate) casts to silence warnings

Mark Kettenis mark.kettenis at xs4all.nl
Sat Feb 12 13:43:08 PST 2011


> From: Tormod Volden <lists.tormod at gmail.com>
> Date: Sun, 23 Jan 2011 12:47:04 +0100
> 
> From: Tormod Volden <debian.tormod at gmail.com>
> 
> savage_dga.c: In function ‘Savage_OpenFramebuffer’:
> savage_dga.c:393: warning: cast to pointer from integer of different size
> 
> savage_dri.c: In function ‘SAVAGEDRIScreenInit’:
> savage_dri.c:924: warning: cast to pointer from integer of different size
> ---
> 
> Not sure if this is really the way to go, but I have seen similar
> commits and it works for me.

This isn't really the right way to fix things.  At least the casts
should use uintptr_t instead of int.  That way you won't truncate
addresses on true 64-bit architectures.  Or just leave these warnings
there as a reminder of the misdesigned DGA and DRI APIs.  They really
should not try to store a "physical" address into a C pointer.

> The remaining warnings that I see are more tricky, since the drm_handle_t
> type in question is different on Linux and BSD:
> 
> savage_dri.c:490: warning: format ‘%08lx’ expects type ‘long unsigned int’,
> but argument 5 has type ‘drm_handle_t’
> 
> I guess we just have to live with those?
> 
> Best regards,
> Tormod
> 
>  src/savage_dga.c |    2 +-
>  src/savage_dri.c |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/savage_dga.c b/src/savage_dga.c
> index 7a9e22c..92a179e 100644
> --- a/src/savage_dga.c
> +++ b/src/savage_dga.c
> @@ -390,7 +390,7 @@ Savage_OpenFramebuffer(
>      SavagePtr psav = SAVPTR(pScrn);
>  
>      *name = NULL;	 /* no special device */
> -    *mem = (unsigned char*)psav->FbRegion.base;
> +    *mem = (unsigned char*)(int) psav->FbRegion.base;
>      *size = psav->videoRambytes;
>      *offset = 0;
>      *flags = DGA_NEED_ROOT;
> diff --git a/src/savage_dri.c b/src/savage_dri.c
> index e4ebf84..90d3442 100644
> --- a/src/savage_dri.c
> +++ b/src/savage_dri.c
> @@ -921,7 +921,7 @@ Bool SAVAGEDRIScreenInit( ScreenPtr pScreen )
>     pDRIInfo->ddxDriverMinorVersion = SAVAGE_VERSION_MINOR;
>     pDRIInfo->ddxDriverPatchVersion = SAVAGE_PATCHLEVEL;
>  
> -   pDRIInfo->frameBufferPhysicalAddress = (pointer) psav->FbRegion.base;
> +   pDRIInfo->frameBufferPhysicalAddress = (pointer)(int) psav->FbRegion.base;
>     pDRIInfo->frameBufferSize = psav->videoRambytes;
>     pDRIInfo->frameBufferStride = pScrn->displayWidth*(pScrn->bitsPerPixel/8);
>     pDRIInfo->ddxDrawableTableEntry = SAVAGE_MAX_DRAWABLES;
> -- 
> 1.7.0.4
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 
> 


More information about the xorg-devel mailing list