[PATCH 5/9] dri1: warning fix

Mark Kettenis mark.kettenis at xs4all.nl
Fri Dec 31 03:28:30 PST 2010


> From: Daniel Stone <daniel at fooishbar.org>
> Date: Fri, 31 Dec 2010 02:00:19 +0000
> 
> From: Adam Jackson <ajax at redhat.com>
> 
> dri.c: In function ‘DRIScreenInit’:
> dri.c:434: warning: cast from pointer to integer of different size

Is just pacifying the compiler the right solution here?  At least the
name of the variable that's being casted (frameBufferPhysicalAddress)
suggests that this may potentially be a true 64-bit address.  Casting
to uintptr_t first makes the warning go away, but not the problem.

The proper solution is to make drm_handle_t a type with the proper
width.  On OpenBSD we have:

typedef unsigned long drm_handle_t;     /**< To mapped regions */

Since all OpenBSD architectures are either ILP32 or LP64, that works
just fine.  Perhaps the same should be done on Linux?

If the resulting ABI break is something that can't be handled (or
can't be handled right now), perhaps add a check that the address
realy fits into a drm_handle_t instead of silently truncating it?

> Signed-off-by: Adam Jackson <ajax at redhat.com>
> Reviewed-by: Daniel Stone <daniel at fooishbar.org>
> ---
>  hw/xfree86/dri/dri.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
> index 1d83630..3c64ae4 100644
> --- a/hw/xfree86/dri/dri.c
> +++ b/hw/xfree86/dri/dri.c
> @@ -431,7 +431,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
>      if (!pDRIPriv->pDriverInfo->dontMapFrameBuffer)
>      {
>  	if (drmAddMap( pDRIPriv->drmFD,
> -		       (drm_handle_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress,
> +		       (uintptr_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress,
>  		       pDRIPriv->pDriverInfo->frameBufferSize,
>  		       DRM_FRAME_BUFFER,
>  		       0,
> -- 
> 1.7.2.3
> 
> _______________________________________________
> 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