[PATCH 5/5] test: Fix compiler warning on 64-bit.

Mark Kettenis mark.kettenis at xs4all.nl
Mon Jan 27 12:30:24 PST 2014


> From: Eric Anholt <eric at anholt.net>
> Date: Mon, 27 Jan 2014 11:36:09 -0800
> 
> We all know that XIDs are 32 bits, even if 32-bit headers call them
> "long".
> ---
>  test/hashtabletest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/test/hashtabletest.c b/test/hashtabletest.c
> index ceadfa7..a37dfb5 100644
> --- a/test/hashtabletest.c
> +++ b/test/hashtabletest.c
> @@ -12,7 +12,7 @@ static void
>  print_xid(void* ptr, void* v)
>  {
>      XID *x = v;
> -    printf("%ld", *x);
> +    printf("%d", (uint32_t)*x);
>  }

There is no guarantee that uint32_t isn't long either!  And of course
using %d to print an unsigned integer isn't quite right either.

Either make this

    printf("%lu", (unsigned long)*x);

or

    printf("%u", (unsigned int)*x);

Cheers,

Mark


More information about the xorg-devel mailing list