[PATCH] staging: rtl8723au: core: Fix endianness warnings

Roberta Dobrescu roberta.dobrescu at gmail.com
Tue Oct 7 14:15:15 EEST 2014


This patch fixes endianness issues detected by sparse, such as:
	- warning: cast to restricted __le16
	- warning: cast to restricted __le32
	- warning: incorrect type in assignment (different base types)
		expected unsigned short [unsigned] status
		got restricted __le16 [usertype] <noident>
	- warning: incorrect type in assignment (different base types)
		expected unsigned short [unsigned] [assigned] [usertype] len
		got restricted __be16 [usertype] <noident>
	- warning: incorrect type in assignment (different base types)
		expected unsigned short [unsigned] [assigned] [usertype] <noident>
		got restricted __le32 [usertype] <noident>

Signed-off-by: Roberta Dobrescu <roberta.dobrescu at gmail.com>
---
 drivers/staging/rtl8723au/core/rtw_mlme.c     |  4 ++--
 drivers/staging/rtl8723au/core/rtw_mlme_ext.c |  4 ++--
 drivers/staging/rtl8723au/core/rtw_recv.c     |  2 +-
 drivers/staging/rtl8723au/core/rtw_security.c | 12 ++++++------
 drivers/staging/rtl8723au/core/rtw_xmit.c     |  2 +-
 drivers/staging/rtl8723au/include/wifi.h      |  6 +++---
 6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c
index 1f60064..45ccd2a 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme.c
@@ -2165,9 +2165,9 @@ bool rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie,
 
 		memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap));
 
-		ht_capie.cap_info = IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
+		ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
 			IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 |
-			IEEE80211_HT_CAP_TX_STBC | IEEE80211_HT_CAP_DSSSCCK40;
+			IEEE80211_HT_CAP_TX_STBC | IEEE80211_HT_CAP_DSSSCCK40);
 
 		GetHalDefVar8192CUsb(padapter, HAL_DEF_RX_PACKET_OFFSET,
 				     &rx_packet_offset);
diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
index fcba087..5b88e58 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
@@ -3809,7 +3809,7 @@ void issue_action_BA23a(struct rtw_adapter *padapter,
 
 	pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr) + 1;
 
-	status = cpu_to_le16(status);
+	cpu_to_le16s(&status);
 
 	switch (action) {
 	case WLAN_ACTION_ADDBA_REQ:
@@ -3848,7 +3848,7 @@ void issue_action_BA23a(struct rtw_adapter *padapter,
 				   &mgmt->u.action.u.addba_req.capab);
 
 		BA_timeout_value = 5000;/*  5ms */
-		BA_timeout_value = cpu_to_le16(BA_timeout_value);
+		cpu_to_le16s(&BA_timeout_value);
 		put_unaligned_le16(BA_timeout_value,
 				   &mgmt->u.action.u.addba_req.timeout);
 
diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c
index 5bc7734..0326992 100644
--- a/drivers/staging/rtl8723au/core/rtw_recv.c
+++ b/drivers/staging/rtl8723au/core/rtw_recv.c
@@ -1608,7 +1608,7 @@ static int wlanhdr_to_ethhdr (struct recv_frame *precvframe)
 	ether_addr_copy(ptr + ETH_ALEN, pattrib->src);
 
 	if (!bsnaphdr) {
-		len = htons(len);
+		cpu_to_be16s(&len);
 		memcpy(ptr + 12, &len, 2);
 	}
 
diff --git a/drivers/staging/rtl8723au/core/rtw_security.c b/drivers/staging/rtl8723au/core/rtw_security.c
index 76371ae..5c49c7f 100644
--- a/drivers/staging/rtl8723au/core/rtw_security.c
+++ b/drivers/staging/rtl8723au/core/rtw_security.c
@@ -189,7 +189,7 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter,
 			length = pattrib->last_txcmdsz - pattrib->hdrlen -
 				pattrib->iv_len- pattrib->icv_len;
 
-			*((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));
+			*((__le32 *)crc) = cpu_to_le32(getcrc32(payload, length));
 
 			arcfour_init(&mycontext, wepkey, 3 + keylength);
 			arcfour_encrypt(&mycontext, payload, payload, length);
@@ -197,7 +197,7 @@ void rtw_wep_encrypt23a(struct rtw_adapter *padapter,
 		} else {
 			length = pxmitpriv->frag_len - pattrib->hdrlen -
 				pattrib->iv_len - pattrib->icv_len;
-			*((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));
+			*((__le32 *)crc) = cpu_to_le32(getcrc32(payload, length));
 			arcfour_init(&mycontext, wepkey, 3 + keylength);
 			arcfour_encrypt(&mycontext, payload, payload, length);
 			arcfour_encrypt(&mycontext, payload + length, crc, 4);
@@ -246,7 +246,7 @@ void rtw_wep_decrypt23a(struct rtw_adapter *padapter,
 	arcfour_encrypt(&mycontext, payload, payload, length);
 
 	/* calculate icv and compare the icv */
-	*((u32 *)crc) = le32_to_cpu(getcrc32(payload, length - 4));
+	*((u32 *)crc) = getcrc32(payload, length - 4);
 
 	if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] ||
 	    crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) {
@@ -680,7 +680,7 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
 				if ((curfragnum+1) == pattrib->nr_frags) {	/* 4 the last fragment */
 					length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len- pattrib->icv_len;
 					RT_TRACE(_module_rtl871x_security_c_, _drv_info_, ("pattrib->iv_len =%x, pattrib->icv_len =%x\n", pattrib->iv_len, pattrib->icv_len));
-					*((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));/* modified by Amy*/
+					*((__le32 *)crc) = cpu_to_le32(getcrc32(payload, length));/* modified by Amy*/
 
 					arcfour_init(&mycontext, rc4key, 16);
 					arcfour_encrypt(&mycontext, payload, payload, length);
@@ -689,7 +689,7 @@ int rtw_tkip_encrypt23a(struct rtw_adapter *padapter,
 				}
 				else{
 					length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ;
-					*((u32 *)crc) = cpu_to_le32(getcrc32(payload, length));/* modified by Amy*/
+					*((__le32 *)crc) = cpu_to_le32(getcrc32(payload, length));/* modified by Amy*/
 					arcfour_init(&mycontext, rc4key, 16);
 					arcfour_encrypt(&mycontext, payload, payload, length);
 					arcfour_encrypt(&mycontext, payload+length, crc, 4);
@@ -770,7 +770,7 @@ int rtw_tkip_decrypt23a(struct rtw_adapter *padapter,
 			arcfour_init(&mycontext, rc4key, 16);
 			arcfour_encrypt(&mycontext, payload, payload, length);
 
-			*((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4));
+			*((u32 *)crc) = getcrc32(payload, length-4);
 
 			if (crc[3]!= payload[length-1] || crc[2]!= payload[length-2] || crc[1]!= payload[length-3] || crc[0]!= payload[length-4])
 			{
diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
index 7a80381..4ff75c9 100644
--- a/drivers/staging/rtl8723au/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
@@ -1282,7 +1282,7 @@ s32 rtw_put_snap23a(u8 *data, u16 h_proto)
 	snap->oui[0] = oui[0];
 	snap->oui[1] = oui[1];
 	snap->oui[2] = oui[2];
-	*(u16 *)(data + SNAP_SIZE) = htons(h_proto);
+	*(__be16 *)(data + SNAP_SIZE) = htons(h_proto);
 	return SNAP_SIZE + sizeof(u16);
 }
 
diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h
index fd3da3b..98824a7 100644
--- a/drivers/staging/rtl8723au/include/wifi.h
+++ b/drivers/staging/rtl8723au/include/wifi.h
@@ -28,7 +28,7 @@
 struct AC_param {
 	unsigned char		ACI_AIFSN;
 	unsigned char		CW;
-	unsigned short	TXOP_limit;
+	__le16 TXOP_limit;
 }  __packed;
 
 struct WMM_para_element {
@@ -39,9 +39,9 @@ struct WMM_para_element {
 
 struct ADDBA_request {
 	unsigned char		dialog_token;
-	unsigned short	BA_para_set;
+	__le16 BA_para_set;
 	unsigned short	BA_timeout_value;
-	unsigned short	BA_starting_seqctrl;
+	__le16 BA_starting_seqctrl;
 }  __packed;
 
 
-- 
1.9.1



More information about the firefly mailing list