From 3d109826af8466e17624c7b724bef10f36b01da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Bremv=C3=A5g?= Date: Sun, 10 Nov 2019 15:05:48 +0100 Subject: [PATCH] rtw_security: tidy up crc32_init() --- core/rtw_security.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/core/rtw_security.c b/core/rtw_security.c index b537a26..79b6fcd 100644 --- a/core/rtw_security.c +++ b/core/rtw_security.c @@ -178,29 +178,29 @@ static u8 crc32_reverseBit(u8 data) static void crc32_init(void) { + int i, j; + u32 c; + u8 *p = (u8 *)&c, *p1; + u8 k; + if (bcrc32initialized == 1) goto exit; - else { - sint i, j; - u32 c; - u8 *p = (u8 *)&c, *p1; - u8 k; - c = 0x12340000; + c = 0x12340000; - for (i = 0; i < 256; ++i) { - k = crc32_reverseBit((u8)i); - for (c = ((u32)k) << 24, j = 8; j > 0; --j) - c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); - p1 = (u8 *)&crc32_table[i]; + for (i = 0; i < 256; ++i) { + k = crc32_reverseBit((u8)i); + for (c = ((u32)k) << 24, j = 8; j > 0; --j) + c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); + p1 = (u8 *)&crc32_table[i]; - p1[0] = crc32_reverseBit(p[3]); - p1[1] = crc32_reverseBit(p[2]); - p1[2] = crc32_reverseBit(p[1]); - p1[3] = crc32_reverseBit(p[0]); - } - bcrc32initialized = 1; + p1[0] = crc32_reverseBit(p[3]); + p1[1] = crc32_reverseBit(p[2]); + p1[2] = crc32_reverseBit(p[1]); + p1[3] = crc32_reverseBit(p[0]); } + bcrc32initialized = 1; + exit: return; } @@ -217,8 +217,6 @@ static u32 getcrc32(u8 *buf, sint len) for (p = buf; len > 0; ++p, --len) crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8); return ~crc; /* transmit complement, per CRC-32 spec */ -} - /* Need to consider the fragment situation @@ -240,8 +238,6 @@ void rtw_wep_encrypt(_adapter *padapter, u8 *pxmitframe) struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - - if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return;