This patchset fixes the below sparse warnings
rtw_security.c:72:50: warning: incorrect type in assignment (different base types)
rtw_security.c:72:50: expected restricted __le32 [usertype]
rtw_security.c:72:50: got unsigned int
rtw_security.c:80:50: warning: incorrect type in assignment (different base types)
rtw_security.c:80:50: expected restricted __le32 [usertype]
rtw_security.c:80:50: got unsigned int
rtw_security.c:124:33: warning: cast to restricted __le32
rtw_security.c:509:58: warning: incorrect type in assignment (different base types)
rtw_security.c:509:58: expected restricted __le32 [usertype]
rtw_security.c:509:58: got unsigned int
rtw_security.c:517:58: warning: incorrect type in assignment (different base types)
rtw_security.c:517:58: expected restricted __le32 [usertype]
rtw_security.c:517:58: got unsigned int
rtw_security.c:621:41: warning: cast to restricted __le32
This can be applied cleanly on next-20210816, and is compile tested.
Please ignore the duplicate of this patchset, I did not CC staging.
Message ID: <[email protected]>
Aakash Hemadri (2):
staging: rtl8732bs: incorrect type in assignment
staging: rtl8723bs: cast to restricted __le32
drivers/staging/rtl8723bs/core/rtw_security.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
--
2.32.0
Fix sparse warning:
warning: cast to restricted __le32
Signed-off-by: Aakash Hemadri <[email protected]>
---
drivers/staging/rtl8723bs/core/rtw_security.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
index 381deeea99d0..5320b1a46dfb 100644
--- a/drivers/staging/rtl8723bs/core/rtw_security.c
+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
@@ -122,7 +122,7 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
arc4_crypt(ctx, payload, payload, length);
/* calculate icv and compare the icv */
- *((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4));
+ *((u32 *)crc) = ~crc32_le(~0, payload, length - 4);
}
}
@@ -621,7 +621,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
arc4_setkey(ctx, rc4key, 16);
arc4_crypt(ctx, payload, payload, length);
- *((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4));
+ *((u32 *)crc) = ~crc32_le(~0, payload, length - 4);
if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
crc[1] != payload[length - 3] || crc[0] != payload[length - 4])
--
2.32.0
On Monday, August 16, 2021 7:35:05 PM CEST Aakash Hemadri wrote:
> This patchset fixes the below sparse warnings
>
> rtw_security.c:72:50: warning: incorrect type in assignment (different base
types)
> rtw_security.c:72:50: expected restricted __le32 [usertype]
> rtw_security.c:72:50: got unsigned int
>
> [...]
>
> This can be applied cleanly on next-20210816, and is compile tested.
This warnings have been fixed time ago against staging-testing:
please see commit aef1c966a364.
Thanks,
Fabio
> Please ignore the duplicate of this patchset, I did not CC staging.
> Message ID: <[email protected]>
>
> Aakash Hemadri (2):
> staging: rtl8732bs: incorrect type in assignment
> staging: rtl8723bs: cast to restricted __le32
>
> drivers/staging/rtl8723bs/core/rtw_security.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
On Monday, August 16, 2021 8:48:48 PM CEST Fabio M. De Francesco wrote:
> On Monday, August 16, 2021 7:35:05 PM CEST Aakash Hemadri wrote:
> > This patchset fixes the below sparse warnings
> >
> > [...]
> >
> This warnings have been fixed time ago against staging-testing:
> please see commit aef1c966a364.
Hi Aakash,
I see at least two of your messages never made it to
linux-staging list because the address is incorrect (you did not write in CC
[email protected], instead you used the nonexistent
[email protected]):
https://lore.kernel.org/lkml/[email protected]/
https://lore.kernel.org/lkml/[email protected]/
Please, send them again to the correct address.
Thanks,
Fabio
From: Aakash Hemadri
> Sent: 16 August 2021 18:35
>
> Fix sparse warning:
> warning: cast to restricted __le32
How many different copies of this crappy copy are there?
>
...
> diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c
> b/drivers/staging/rtl8723bs/core/rtw_security.c
> index 381deeea99d0..5320b1a46dfb 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_security.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_security.c
> @@ -122,7 +122,7 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe)
> arc4_crypt(ctx, payload, payload, length);
>
> /* calculate icv and compare the icv */
> - *((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4));
> + *((u32 *)crc) = ~crc32_le(~0, payload, length - 4);
You've removed a byteswap which is needed on BE architectures.
> }
> }
> @@ -621,7 +621,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
> arc4_setkey(ctx, rc4key, 16);
> arc4_crypt(ctx, payload, payload, length);
>
> - *((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4));
> + *((u32 *)crc) = ~crc32_le(~0, payload, length - 4);
>
> if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
> crc[1] != payload[length - 3] || crc[0] != payload[length - 4])
As above - crc32_le() does a 'little-endian crc' but returns a host-ordered value.
The (horrid) array cast means you need to store a LE value.
There are a dozen better ways to do this - I'm bored of quoting them.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)