mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] crypto: crc32: create crc table only once
@ 2023-12-12  7:54 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2023-12-12  7:54 UTC (permalink / raw)
  To: Barebox List

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




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

only message in thread, other threads:[~2023-12-12  7:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-12  7:54 [PATCH] crypto: crc32: create crc table only once Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox