Skip to contentSkip to conversation

staging: rtl8192e: Change cpu_to_le16 to le16_to_cpu

PATCH In review Arno Tiemersma 2 participants 2 messages May 9, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: rtl8192e: Change cpu_to_le16 to le16_to_cpu

Since the function auth_parse returns a u16, and
struct rtllib_authentication.status is defined as an __le16, it seems that

	return cpu_to_le16(a->status);

should be

	return le16_to_cpu(a->status);

This change silences the following sparse warnings:
drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
warning: cast from restricted __le16
drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
warning: incorrect type in return expression (different base types)
drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
expected unsigned short
drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
got restricted __le16 [usertype] <noident>

---
v2 since I did not have the right e-mail address for Mateusz Kulikowski

 drivers/staging/rtl8192e/rtllib_softmac.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_softmac.c +1 -1
index 8f5e88b..98afd3b 100644
@@ -1814,7 +1814,7 @@ static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen)
 				return -ENOMEM;
 		}
 	}
-	return cpu_to_le16(a->status);
+	return le16_to_cpu(a->status);
 }
 
 static int auth_rq_parse(struct sk_buff *skb, u8 *dest)
Signature · 1 line
2.1.4
#1 lore raw
Quoted 20 lines · Arno Tiemersma

Since the function auth_parse returns a u16, and
struct rtllib_authentication.status is defined as an __le16, it seems that

	return cpu_to_le16(a->status);

should be

	return le16_to_cpu(a->status);

This change silences the following sparse warnings:
drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
warning: cast from restricted __le16
drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
warning: incorrect type in return expression (different base types)
drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
expected unsigned short
drivers/staging/rtl8192e/rtllib_softmac.c:1817:16:
got restricted __le16 [usertype] <noident>

Quoted 1 line

Your patch seems reasonable. The caller only cares about zero non-zero.

It feels like there are a bunch of endian bugs which Sparse misses in this file. For example, ->frame_ctl is endian but it's never converted and it's compared against cpu endian in the switch statements. (I haven't double checked. Do your own homework before sending patches).

regards,
dan carpenter