All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: crc32: crc32_generic_shift: fix comment on iteration count
@ 2015-10-21 15:49 Nicolai Stange
  0 siblings, 0 replies; only message in thread
From: Nicolai Stange @ 2015-10-21 15:49 UTC (permalink / raw)
  To: linux-kernel

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-10-21 15:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-21 15:49 [PATCH] lib: crc32: crc32_generic_shift: fix comment on iteration count Nicolai Stange

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.