Skip to contentSkip to conversation

staging: rtl8732bs: Fix sparse warnings

PATCH In review Aakash Hemadri 3 participants 7 messages Aug 16, 2021 – Aug 18, 2021 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: rtl8732bs: Fix sparse warnings

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.

Aakash Hemadri (2):
staging: rtl8732bs: incorrect type in assignment
staging: rtl8723bs: cast to restricted __le32

 rtw_security.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/2 staging: rtl8732bs: incorrect type in assignment

Cast u32 to __le32 with __cpu_to_le32 to fix sparse warning:

warning: incorrect type in assignment (different base types) expected restricted __le32 [usertype]
got unsigned int

---
 drivers/staging/rtl8723bs/core/rtw_security.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_security.c +7 -4
index a99f439328f1..381deeea99d0 100644
@@ -8,6 +8,7 @@
 #include <drv_types.h>
 #include <rtw_debug.h>
 #include <crypto/aes.h>
+#include <linux/byteorder/little_endian.h>
 
 static const char * const _security_type_str[] = {
 	"N/A",
@@ -69,7 +70,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
 
 				length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
 
-				*((__le32 *)crc) = ~crc32_le(~0, payload, length);
+				*((__le32 *)crc) = __cpu_to_le32(~crc32_le(~0, payload, length));
 
 				arc4_setkey(ctx, wepkey, 3 + keylength);
 				arc4_crypt(ctx, payload, payload, length);
@@ -77,7 +78,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
 
 			} else {
 				length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
-				*((__le32 *)crc) = ~crc32_le(~0, payload, length);
+				*((__le32 *)crc) = __cpu_to_le32(~crc32_le(~0, payload, length));
 				arc4_setkey(ctx, wepkey, 3 + keylength);
 				arc4_crypt(ctx, payload, payload, length);
 				arc4_crypt(ctx, payload + length, crc, 4);
@@ -506,7 +507,8 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
 
 				if ((curfragnum+1) == pattrib->nr_frags) {	/* 4 the last fragment */
 					length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
-					*((__le32 *)crc) = ~crc32_le(~0, payload, length);
+					*((__le32 *)crc) =
+						__cpu_to_le32(~crc32_le(~0, payload, length));
 
 					arc4_setkey(ctx, rc4key, 16);
 					arc4_crypt(ctx, payload, payload, length);
@@ -514,7 +516,8 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
 
 				} else {
 					length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len;
-					*((__le32 *)crc) = ~crc32_le(~0, payload, length);
+					*((__le32 *)crc) =
+						__cpu_to_le32(~crc32_le(~0, payload, length));
 
 					arc4_setkey(ctx, rc4key, 16);
 					arc4_crypt(ctx, payload, payload, length);
Signature · 1 line
2.32.0
#2 lore raw

PATCH 2/2 staging: rtl8723bs: fix cast to restricted __le32

In reply to Aakash Hemadri

Fix sparse warning:
warning: cast to restricted __le32

---
 drivers/staging/rtl8723bs/core/rtw_security.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_security.c +2 -2
index 381deeea99d0..5320b1a46dfb 100644
@@ -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])
Signature · 1 line
2.32.0
#3 lore raw
In reply to Aakash Hemadri
Quoted 17 lines · Aakash Hemadri

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

Quoted 8 lines

This can be applied cleanly on next-20210816, and is compile tested.

Aakash Hemadri (2):
staging: rtl8732bs: incorrect type in assignment
staging: rtl8723bs: cast to restricted __le32

 rtw_security.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

This series does not apply to my tree at all. Please fix up and rebase and resubmit, after reading the mailing list archives for others that have attempted do do this type of work in the past for this issue.

It is not a trivial change that is needed...

thanks,

greg k-h

#4 lore raw
Quoted 7 lines · CEST Greg Kroah-Hartman
Quoted 6 lines · Aakash Hemadri

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

Quoted 7 lines
Quoted 1 line

[...]

This series does not apply to my tree at all. Please fix up and rebase and resubmit, after reading the mailing list archives for others that have attempted do do this type of work in the past for this issue.

It is not a trivial change that is needed...

Dear Greg,

As I've already pointed out in another message of this thread, your tree has already these sparse warnings fixed by me with commit aef1c966a364 (that you applied with a "much nicer!" comment).

So, when Aakash rebases against your current tree, he will not anymore see those sparse warnings.

Thanks,

Fabio

Quoted 5 lines

thanks,

greg k-h

#6 lore raw
In reply to Greg Kroah-Hartman
Quoted 5 lines · Greg Kroah-Hartman

This series does not apply to my tree at all. Please fix up and rebase and resubmit, after reading the mailing list archives for others that have attempted do do this type of work in the past for this issue.

It is not a trivial change that is needed...

Will check what went wrong, and see what I can do.

Thanks,
Aakash Hemadri

#5 lore raw
In reply to Fabio M. De Francesco
Quoted 16 lines · Fabio M. De Francesco
Quoted 7 lines · CEST Greg Kroah-Hartman
Quoted 6 lines · Aakash Hemadri

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

Quoted 7 lines
Quoted 1 line

[...]

This series does not apply to my tree at all. Please fix up and rebase and resubmit, after reading the mailing list archives for others that have attempted do do this type of work in the past for this issue.

It is not a trivial change that is needed...

Quoted 8 lines

Dear Greg,

As I've already pointed out in another message of this thread, your tree has already these sparse warnings fixed by me with commit aef1c966a364 (that you applied with a "much nicer!" comment).

So, when Aakash rebases against your current tree, he will not anymore see those sparse warnings.

Thanks for the patch Fabio! Will rebase and work on something new!

Thanks,
Aakash Hemadri