[PATCH] lib: crc32: crc32_generic_shift: fix comment on iteration count

From: Nicolai Stange
Date: Wed Oct 21 2015 - 11:49:19 EST


In crc32_generic_shift(), the linear startup phase is commented
with a statement saying that "up to 32 bits" will be shifted in
a linear way.

However, the loop following that comment, namely

for (i = 0; i < 8 * (int)(len & 3); i++) {...}

shifts only up to 8*3=24 bits.

Given the fact, that the binary method for exponentiation sets in
at 2^2*8=32, the loop's bounds are correct: it handles the cases
that any of the two least significant bits are set in len, i.e.
the cases 2^1*8 and 2^0*8 which sum to 24.

Fix the comment.

Signed-off-by: Nicolai Stange <nicstange@xxxxxxxxx>
---
lib/crc32.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/crc32.c b/lib/crc32.c
index 9a907d4..a1d17db 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -242,7 +242,7 @@ static u32 __attribute_const__ crc32_generic_shift(u32 crc, size_t len,
u32 power = polynomial; /* CRC of x^32 */
int i;

- /* Shift up to 32 bits in the simple linear way */
+ /* Shift up to 24 bits in the simple linear way */
for (i = 0; i < 8 * (int)(len & 3); i++)
crc = (crc >> 1) ^ (crc & 1 ? polynomial : 0);

--
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/