From: Benny Halevy Date: Thu, 8 Nov 2007 13:34:09 +0000 (+0800) Subject: [LIB] crc32c: Keep intermediate crc state in cpu order X-Git-Tag: v2.6.24-rc3~173^2 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef19454bd437b2ba14c9cda1de85debd9f383484;p=linux-2.6 [LIB] crc32c: Keep intermediate crc state in cpu order crypto/crc32.c:chksum_final() is computing the digest as *(__le32 *)out = ~cpu_to_le32(mctx->crc); so the low-level crc32c_le routines should just keep the crc in cpu order, otherwise it is getting swabbed one too many times on big-endian machines. Signed-off-by: Benny Halevy Signed-off-by: Herbert Xu --- diff --git a/lib/libcrc32c.c b/lib/libcrc32c.c index 802f11f0bf..b5c3287d8e 100644 --- a/lib/libcrc32c.c +++ b/lib/libcrc32c.c @@ -33,7 +33,6 @@ #include #include #include -#include MODULE_AUTHOR("Clay Haapala "); MODULE_DESCRIPTION("CRC32c (Castagnoli) calculations"); @@ -161,15 +160,13 @@ static const u32 crc32c_table[256] = { */ u32 __pure -crc32c_le(u32 seed, unsigned char const *data, size_t length) +crc32c_le(u32 crc, unsigned char const *data, size_t length) { - u32 crc = __cpu_to_le32(seed); - while (length--) crc = crc32c_table[(crc ^ *data++) & 0xFFL] ^ (crc >> 8); - return __le32_to_cpu(crc); + return crc; } #endif /* CRC_LE_BITS == 8 */