]> git.ozlabs.org Git - ccan/commitdiff
bitmap: add endianness casts
authorEmilio G. Cota <cota@braap.org>
Thu, 19 Dec 2013 06:00:15 +0000 (01:00 -0500)
committerDavid Gibson <david@gibson.dropbear.id.au>
Wed, 25 Dec 2013 07:09:16 +0000 (18:09 +1100)
sparse yells at us when it realises we are implicitly casting an
endian type (big endian) to a plain unsigned long.

Get rid of this warning by telling sparse that we know what
we are doing.

Signed-off-by: Emilio G. Cota <cota@braap.org>
ccan/bitmap/bitmap.h

index f43449d79f20f6b280a8d1a8881a3e4fe0ff3610..50086c065303d06f435c472eed11439cf8048e49 100644 (file)
@@ -38,9 +38,9 @@ static inline bitmap *bitmap_alloc(int nbits)
 static inline bitmap_word bitmap_bswap(bitmap_word w)
 {
        if (BITMAP_WORD_BITS == 32)
-               return cpu_to_be32(w);
+               return (ENDIAN_CAST bitmap_word)cpu_to_be32(w);
        else if (BITMAP_WORD_BITS == 64)
-               return cpu_to_be64(w);
+               return (ENDIAN_CAST bitmap_word)cpu_to_be64(w);
 }
 
 #define BITMAP_WORD(_bm, _n)   ((_bm)[(_n) / BITMAP_WORD_BITS].w)