All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiabing Wan <wanjiabing@vivo.com>
To: Wan Jiabing <wanjiabing@vivo.com>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Fabio Aiuto <fabioaiuto83@gmail.com>,
	 Ross Schmidt <ross.schm.dev@gmail.com>,
	 Qiang Ma <maqianga@uniontech.com>,
	 Marco Cesati <marcocesati@gmail.com>,
	linux-staging@lists.linux.dev,  linux-kernel@vger.kernel.org
Subject: Re:[PATCH] staging: rtl8723bs: core: fix some incorrect type warnings
Date: Thu, 3 Jun 2021 16:36:55 +0800 (GMT+08:00)	[thread overview]
Message-ID: <AO6AtgBODjnoS0IYaAQ1bKoy.3.1622709415201.Hmail.wanjiabing@vivo.com> (raw)
In-Reply-To: <1622708703-8561-1-git-send-email-wanjiabing@vivo.com>

 
 
Hi,all

I fix these warnings by refering other patches.

Actually, I don't understand clearly what I did.  

But there are no warnings after this fix.

So if this fix were totally wrong, please told me and 
gave me some suggestions.

It is important for me to fix a sparse bug.

Thanks,
Jiabing

>Fix some "incorrect type in assignment" in rtw_security.c.
>
>The sparse warings:
>drivers/staging//rtl8723bs/core/rtw_security.c:72:50: warning: incorrect type in assignment
>drivers/staging//rtl8723bs/core/rtw_security.c:72:50:    expected restricted __le32 [usertype]
>drivers/staging//rtl8723bs/core/rtw_security.c:72:50:    got unsigned int
>drivers/staging//rtl8723bs/core/rtw_security.c:80:50: warning: incorrect type in assignment
>drivers/staging//rtl8723bs/core/rtw_security.c:80:50:    expected restricted __le32 [usertype]
>drivers/staging//rtl8723bs/core/rtw_security.c:80:50:    got unsigned int
>drivers/staging//rtl8723bs/core/rtw_security.c:124:33: warning: cast to restricted __le32
>drivers/staging//rtl8723bs/core/rtw_security.c:509:58: warning: incorrect type in assignment
>drivers/staging//rtl8723bs/core/rtw_security.c:509:58:    expected restricted __le32 [usertype]
>drivers/staging//rtl8723bs/core/rtw_security.c:509:58:    got unsigned int
>drivers/staging//rtl8723bs/core/rtw_security.c:517:58: warning: incorrect type in assignment
>drivers/staging//rtl8723bs/core/rtw_security.c:517:58:    expected restricted __le32 [usertype]
>drivers/staging//rtl8723bs/core/rtw_security.c:517:58:    got unsigned int
>drivers/staging//rtl8723bs/core/rtw_security.c:621:41: warning: cast to restricted __le32
>
>Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
>---
> drivers/staging/rtl8723bs/core/rtw_security.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
>diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c
>index a99f439..4760999 100644
>--- a/drivers/staging/rtl8723bs/core/rtw_security.c
>+++ b/drivers/staging/rtl8723bs/core/rtw_security.c
>@@ -36,7 +36,7 @@ const char *security_type_str(u8 value)
> void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
> {																	/*  exclude ICV */
> 
>-	unsigned char crc[4];
>+	u8 crc[4];
> 
> 	signed int	curfragnum, length;
> 	u32 keylength;
>@@ -69,7 +69,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 +77,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);
>@@ -121,7 +121,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));
>+		*((__le32 *)crc) = cpu_to_le32(~crc32_le(~0, payload, length - 4));
> 
> 	}
> }
>@@ -506,7 +506,7 @@ 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 +514,7 @@ 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);
>@@ -618,7 +618,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));
>+			*((__le32 *)crc) = cpu_to_le32(~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.7.4
>



  reply	other threads:[~2021-06-03  8:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03  8:24 [PATCH] staging: rtl8723bs: core: fix some incorrect type warnings Wan Jiabing
2021-06-03  8:36 ` Jiabing Wan [this message]
2021-06-03  8:36   ` Jiabing Wan
2021-06-03  9:17   ` [PATCH] " Greg Kroah-Hartman
2021-06-03  9:18 ` Greg Kroah-Hartman
2021-06-04  2:19   ` Jiabing Wan
2021-06-04  2:19     ` Jiabing Wan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AO6AtgBODjnoS0IYaAQ1bKoy.3.1622709415201.Hmail.wanjiabing@vivo.com \
    --to=wanjiabing@vivo.com \
    --cc=fabioaiuto83@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=maqianga@uniontech.com \
    --cc=marcocesati@gmail.com \
    --cc=ross.schm.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.