Re: [PATCH 1/3] protocol: Add macros to help convert QXLPHYSICAL to/from pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> On 32 bit systems the QXLPHYSICAL integer size deos not match the size
> of a pointer so special care must be taken in the conversions to avoid
> compiler errors with -Werror.
> 
> Signed-off-by: Francois Gouget <fgouget@xxxxxxxxxxxxxxx>
> ---
>  spice/qxl_dev.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/spice/qxl_dev.h b/spice/qxl_dev.h
> index 9e753c4..01cfe81 100644
> --- a/spice/qxl_dev.h
> +++ b/spice/qxl_dev.h
> @@ -101,8 +101,10 @@ enum {
>      QXL_IO_RANGE_SIZE
>  };
>  
> -typedef uint64_t QXLPHYSICAL;
>  typedef int32_t QXLFIXED; //fixed 28.4
> +typedef uint64_t QXLPHYSICAL;
> +#define PTR_TO_QXLPHYSICAL(ptr) ((QXLPHYSICAL)(intptr_t)ptr)
> +#define QXLPHYSICAL_TO_PTR(ptrtype, phy) ((ptrtype)(intptr_t)phy)
>  
>  typedef struct SPICE_ATTR_PACKED QXLPointFix {
>      QXLFIXED x;
> --
> 2.6.4

Due to operator precedence would be better to enclose parameters inside brackets,
like

#define PTR_TO_QXLPHYSICAL(ptr) ((QXLPHYSICAL)(intptr_t)(ptr))
#define QXLPHYSICAL_TO_PTR(ptrtype, phy) ((ptrtype)(intptr_t)(phy))

Why did you change type definition order? I think macro definitions can
be separate from type definition by a space (empty line).

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]