[PATCH v2] dix: silence compiler warning comparing CARD32 to -1
Michel Dänzer
michel at daenzer.net
Fri Oct 31 01:41:37 PDT 2014
On 31.10.2014 13:10, Peter Hutterer wrote:
> window.c:3246:36: warning: comparison of constant -1 with expression of type
> 'CARD32' (aka 'unsigned int') is always true
> [-Wtautological-constant-out-of-range-compare]
> if (optional->backingBitPlanes != ~0L)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> Changes to v1:
> - use ~0U instead of the (CARD32) cast
>
> ~0UL causes another warning for shortening long to int.
>
> dix/window.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/dix/window.c b/dix/window.c
> index d43ef03..22e9e49 100644
> --- a/dix/window.c
> +++ b/dix/window.c
> @@ -3243,7 +3243,7 @@ CheckWindowOptionalNeed(WindowPtr w)
> return;
> if (optional->userProps != NULL)
> return;
> - if (optional->backingBitPlanes != ~0L)
> + if (optional->backingBitPlanes != ~0U)
> return;
> if (optional->backingPixel != 0)
> return;
>
Taking a closer look, this might generate a warning on x32, which seems
to define CARD32 as unsigned long... And there's precedent in this file
for the (CARD32) cast. Anyway, both versions have my
Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
More information about the xorg-devel
mailing list