Skip to contentSkip to conversation

Staging: wlan-ng: hfa384x_usb: Fixed sparse warning cast to restricted __le16

PATCH In review Jaya Durga 3 participants 3 messages Jun 16, 2017 – Jun 23, 2017 Staging

lore
Share & tools
lore

Jaya Durga

author
#0 lore raw

PATCH 1/1 Staging: wlan-ng: hfa384x_usb: Fixed sparse warning cast to restricted __le16

when building with make C=1 CF=-D__CHECK_ENDIAN__

drivers/staging/wlan-ng/hfa384x_usb.c:3383:36: warning: cast to restricted __le16

fixed by using the le16_to_cpus function.

---
 drivers/staging/wlan-ng/hfa384x_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wlan-ng/hfa384x_usb.c +0 -0
index a812e55..0e95e45 100644
@@ -3380,7 +3380,7 @@ static void hfa384x_usbin_rx(struct wlandevice *wlandev, struct sk_buff *skb)
	u16 fc;

	/* Byte order convert once up front. */
-	usbin->rxfrm.desc.status = le16_to_cpu(usbin->rxfrm.desc.status);
+	le16_to_cpus(&usbin->rxfrm.desc.status);
	usbin->rxfrm.desc.time = le32_to_cpu(usbin->rxfrm.desc.time);

	/* Now handle frame based on port# */

--
1.9.1

maintainer
#1 lore raw
Quoted 10 lines · Jaya Durga

when building with make C=1 CF=-D__CHECK_ENDIAN__

drivers/staging/wlan-ng/hfa384x_usb.c:3383:36: warning: cast to restricted __le16

fixed by using the le16_to_cpus function.

---
 drivers/staging/wlan-ng/hfa384x_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Does not apply to my tree :(

#2 lore raw
In reply to Jaya Durga
Quoted 16 lines · Jaya Durga

when building with make C=1 CF=-D__CHECK_ENDIAN__

drivers/staging/wlan-ng/hfa384x_usb.c:3383:36: warning: cast to restricted __le16

fixed by using the le16_to_cpus function.

---
 drivers/staging/wlan-ng/hfa384x_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wlan-ng/hfa384x_usb.c +0 -0
index a812e55..0e95e45 100644

drivers/staging/wlan-ng/hfa384x_usb.c static void hfa384x_usbin_rx(struct wlandevice *wlandev, struct sk_buff *skb) · line 3383

Quoted 5 lines
drivers/staging/wlan-ng/hfa384x_usb.c +1 -1
@@ -3380,7 +3380,7 @@ static void hfa384x_usbin_rx(struct wlandevice *wlandev, struct sk_buff *skb)
        u16 fc;
 
        /* Byte order convert once up front. */
-       usbin->rxfrm.desc.status = le16_to_cpu(usbin->rxfrm.desc.status);
+       le16_to_cpus(&usbin->rxfrm.desc.status);

Why is a cpu ordered value stored into a field that is documented to be little endian? When this happens we can't rely on this variable being little endian, can we? With the way things are now, at least it's flagged by some tool. Come this patch, it won't be.

I don't think this patch fixes anything; it just tells sparse to shut up.

Frans