From: Nicolai Stange <nicstange@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] lib: crc32: crc32_generic_shift: fix comment on iteration count
Date: Wed, 21 Oct 2015 17:49:13 +0200 [thread overview]
Message-ID: <87pp0843ye.fsf@gmail.com> (raw)
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
reply other threads:[~2015-10-21 15:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pp0843ye.fsf@gmail.com \
--to=nicstange@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.