From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755273AbbJUPtR (ORCPT ); Wed, 21 Oct 2015 11:49:17 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:33047 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751701AbbJUPtQ (ORCPT ); Wed, 21 Oct 2015 11:49:16 -0400 From: Nicolai Stange 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 Message-ID: <87pp0843ye.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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