mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] crypto: crc32: create crc table only once
Date: Tue, 12 Dec 2023 08:54:09 +0100	[thread overview]
Message-ID: <20231212075409.1500489-1-s.hauer@pengutronix.de> (raw)

We use crc_table[0] != 0 as indicator if we have already generated the
crc table. crc_table[0] will be generated as 0x0 though, so we end up
generating the crc table over and over again. Use crc_table[1] as
indicator instead.

Fixes: b00801710b ("crypto: crc32: allocate crc_table statically")
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 crypto/crc32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/crc32.c b/crypto/crc32.c
index 287dfa3303..49d0b49c65 100644
--- a/crypto/crc32.c
+++ b/crypto/crc32.c
@@ -56,7 +56,7 @@ static void make_crc_table(void)
 	/* terms of polynomial defining this crc (except x^32): */
 	static const char p[] = { 0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26 };
 
-	if (crc_table[0])
+	if (crc_table[1])
 		return;
 
 	/* make exclusive-or pattern from polynomial (0xedb88320L) */
-- 
2.39.2




                 reply	other threads:[~2023-12-12  7:56 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=20231212075409.1500489-1-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox