rtw_security: tidy up crc32_init()

This commit is contained in:
Christian Bremvåg 2019-11-10 15:05:48 +01:00 committed by GitHub
parent 72f45df5ff
commit 3d109826af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -178,29 +178,29 @@ static u8 crc32_reverseBit(u8 data)
static void crc32_init(void) static void crc32_init(void)
{ {
int i, j;
u32 c;
u8 *p = (u8 *)&c, *p1;
u8 k;
if (bcrc32initialized == 1) if (bcrc32initialized == 1)
goto exit; 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) { for (i = 0; i < 256; ++i) {
k = crc32_reverseBit((u8)i); k = crc32_reverseBit((u8)i);
for (c = ((u32)k) << 24, j = 8; j > 0; --j) for (c = ((u32)k) << 24, j = 8; j > 0; --j)
c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
p1 = (u8 *)&crc32_table[i]; p1 = (u8 *)&crc32_table[i];
p1[0] = crc32_reverseBit(p[3]); p1[0] = crc32_reverseBit(p[3]);
p1[1] = crc32_reverseBit(p[2]); p1[1] = crc32_reverseBit(p[2]);
p1[2] = crc32_reverseBit(p[1]); p1[2] = crc32_reverseBit(p[1]);
p1[3] = crc32_reverseBit(p[0]); p1[3] = crc32_reverseBit(p[0]);
}
bcrc32initialized = 1;
} }
bcrc32initialized = 1;
exit: exit:
return; return;
} }
@ -217,8 +217,6 @@ static u32 getcrc32(u8 *buf, sint len)
for (p = buf; len > 0; ++p, --len) for (p = buf; len > 0; ++p, --len)
crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8); crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8);
return ~crc; /* transmit complement, per CRC-32 spec */ return ~crc; /* transmit complement, per CRC-32 spec */
}
/* /*
Need to consider the fragment situation 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 security_priv *psecuritypriv = &padapter->securitypriv;
struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL)
return; return;