[PATCH v2] staging: wlan-ng: Use little-endian type

2017-07-13 Thread Aviv Palivoda
Fix the following sparse warning:
drivers/staging//wlan-ng/prism2sta.c:1691:20: warning: incorrect type in 
assignment (different base types)

The authantication data is in little endian order. Change the types to little 
endian order:
(a) Change struct hfa384x_authenticate_station_data status, algorithm members 
type to __le16.
(b) Change struct hfa384x_auth_request algorithm member type to __le16.
(c) All assignment to status are converted to little-endian prior to assignment.

Signed-off-by: Aviv Palivoda <pala...@gmail.com>
---
Changes for v2:
- Changed algorithm field to __le16.
- Explaind the reason for the change in the commit message.
---
 drivers/staging/wlan-ng/hfa384x.h   |  6 +++---
 drivers/staging/wlan-ng/prism2sta.c | 17 -
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x.h 
b/drivers/staging/wlan-ng/hfa384x.h
index 018db22..f2c5cbd 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -413,8 +413,8 @@ struct hfa384x_join_request_data {
 /*-- Configuration Record: authenticateStation (data portion only) --*/
 struct hfa384x_authenticate_station_data {
u8 address[ETH_ALEN];
-   u16 status;
-   u16 algorithm;
+   __le16 status;
+   __le16 algorithm;
 } __packed;
 
 /*-- Configuration Record: WPAData   (data portion only) --*/
@@ -733,7 +733,7 @@ struct hfa384x_assoc_status {
 
 struct hfa384x_auth_request {
u8 sta_addr[ETH_ALEN];
-   u16 algorithm;
+   __le16 algorithm;
 } __packed;
 
 /*--  Unsolicited Frame, MAC Mgmt: PSUserCount (AP Only) --*/
diff --git a/drivers/staging/wlan-ng/prism2sta.c 
b/drivers/staging/wlan-ng/prism2sta.c
index e16da34..250af0d 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -1561,7 +1561,7 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
 */
 
ether_addr_copy(rec.address, inf->info.authreq.sta_addr);
-   rec.status = P80211ENUM_status_unspec_failure;
+   rec.status = cpu_to_le16(P80211ENUM_status_unspec_failure);
 
/*
 * Authenticate based on the access mode.
@@ -1578,7 +1578,7 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
for (i = 0; i < hw->authlist.cnt; i++)
if (ether_addr_equal(rec.address,
 hw->authlist.addr[i])) {
-   rec.status = P80211ENUM_status_successful;
+   rec.status = 
cpu_to_le16(P80211ENUM_status_successful);
break;
}
 
@@ -1590,7 +1590,7 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
 * Allow all authentications.
 */
 
-   rec.status = P80211ENUM_status_successful;
+   rec.status = cpu_to_le16(P80211ENUM_status_successful);
break;
 
case WLAN_ACCESS_ALLOW:
@@ -1615,7 +1615,7 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
 
for (i = 0; i < cnt; i++, addr += ETH_ALEN)
if (ether_addr_equal(rec.address, addr)) {
-   rec.status = P80211ENUM_status_successful;
+   rec.status = 
cpu_to_le16(P80211ENUM_status_successful);
break;
}
 
@@ -1641,11 +1641,11 @@ static void prism2sta_inf_authreq_defer(struct 
wlandevice *wlandev,
addr = hw->deny.addr1[0];
}
 
-   rec.status = P80211ENUM_status_successful;
+   rec.status = cpu_to_le16(P80211ENUM_status_successful);
 
for (i = 0; i < cnt; i++, addr += ETH_ALEN)
if (ether_addr_equal(rec.address, addr)) {
-   rec.status = P80211ENUM_status_unspec_failure;
+   rec.status = 
cpu_to_le16(P80211ENUM_status_unspec_failure);
break;
}
 
@@ -1663,7 +1663,7 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
 
added = 0;
 
-   if (rec.status == P80211ENUM_status_successful) {
+   if (rec.status == cpu_to_le16(P80211ENUM_status_successful)) {
for (i = 0; i < hw->authlist.cnt; i++)
if (ether_addr_equal(rec.address,
 hw->authlist.addr[i]))
@@ -1671,7 +1671,7 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
 
if (i >= hw->authlist.cnt) {
if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
-   rec.status = P80211ENUM_status_ap_full;
+   rec.status = 
cpu_to_le16(P80211ENUM

Re: [PATCH] staging: wlan-ng: Use little-endian type

2017-07-12 Thread Aviv Palivoda
On Wed, Jul 12, 2017 at 07:26:08AM +0200, Frans Klaver wrote:
> On Tue, Jul 11, 2017 at 9:51 PM, Aviv Palivoda <pala...@gmail.com> wrote:
> > Fix the following sparse warning:
> > drivers/staging//wlan-ng/prism2sta.c:1691:20: warning: incorrect type in 
> > assignment (different base types)
> >
> > (a) Change struct hfa384x_authenticate_station_data status member type to 
> > __le16.
> > (b) All assignment to status are converted to little-endian prior to 
> > assignment.
> 
> Why is this the right thing to do?
> 
> Frans

In line 1691 the status is converted to little endian:
rec.status = cpu_to_le16(rec.status);
Currently status is u16 but is being converted to __le16 by
cpu_to_le16. This causes a sparse warning as specified in the commit message.
Converting all P80211ENUM_status_* to little endian prior to assignment will
happen by the preprocessor. While the current conversion happens at run time.

Aviv
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wlan-ng: Use little-endian type

2017-07-11 Thread Aviv Palivoda
Fix the following sparse warning:
drivers/staging//wlan-ng/prism2sta.c:1691:20: warning: incorrect type in 
assignment (different base types)

(a) Change struct hfa384x_authenticate_station_data status member type to 
__le16.
(b) All assignment to status are converted to little-endian prior to assignment.

Signed-off-by: Aviv Palivoda <pala...@gmail.com>
---
 drivers/staging/wlan-ng/hfa384x.h   |  2 +-
 drivers/staging/wlan-ng/prism2sta.c | 17 -
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x.h 
b/drivers/staging/wlan-ng/hfa384x.h
index 018db22..fa8cb4a 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -413,7 +413,7 @@ struct hfa384x_join_request_data {
 /*-- Configuration Record: authenticateStation (data portion only) --*/
 struct hfa384x_authenticate_station_data {
u8 address[ETH_ALEN];
-   u16 status;
+   __le16 status;
u16 algorithm;
 } __packed;
 
diff --git a/drivers/staging/wlan-ng/prism2sta.c 
b/drivers/staging/wlan-ng/prism2sta.c
index e16da34..250af0d 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -1561,7 +1561,7 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
 */
 
ether_addr_copy(rec.address, inf->info.authreq.sta_addr);
-   rec.status = P80211ENUM_status_unspec_failure;
+   rec.status = cpu_to_le16(P80211ENUM_status_unspec_failure);
 
/*
 * Authenticate based on the access mode.
@@ -1578,7 +1578,7 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
for (i = 0; i < hw->authlist.cnt; i++)
if (ether_addr_equal(rec.address,
 hw->authlist.addr[i])) {
-   rec.status = P80211ENUM_status_successful;
+   rec.status = 
cpu_to_le16(P80211ENUM_status_successful);
break;
}
 
@@ -1590,7 +1590,7 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
 * Allow all authentications.
 */
 
-   rec.status = P80211ENUM_status_successful;
+   rec.status = cpu_to_le16(P80211ENUM_status_successful);
break;
 
case WLAN_ACCESS_ALLOW:
@@ -1615,7 +1615,7 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
 
for (i = 0; i < cnt; i++, addr += ETH_ALEN)
if (ether_addr_equal(rec.address, addr)) {
-   rec.status = P80211ENUM_status_successful;
+   rec.status = 
cpu_to_le16(P80211ENUM_status_successful);
break;
}
 
@@ -1641,11 +1641,11 @@ static void prism2sta_inf_authreq_defer(struct 
wlandevice *wlandev,
addr = hw->deny.addr1[0];
}
 
-   rec.status = P80211ENUM_status_successful;
+   rec.status = cpu_to_le16(P80211ENUM_status_successful);
 
for (i = 0; i < cnt; i++, addr += ETH_ALEN)
if (ether_addr_equal(rec.address, addr)) {
-   rec.status = P80211ENUM_status_unspec_failure;
+   rec.status = 
cpu_to_le16(P80211ENUM_status_unspec_failure);
break;
}
 
@@ -1663,7 +1663,7 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
 
added = 0;
 
-   if (rec.status == P80211ENUM_status_successful) {
+   if (rec.status == cpu_to_le16(P80211ENUM_status_successful)) {
for (i = 0; i < hw->authlist.cnt; i++)
if (ether_addr_equal(rec.address,
 hw->authlist.addr[i]))
@@ -1671,7 +1671,7 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
 
if (i >= hw->authlist.cnt) {
if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
-   rec.status = P80211ENUM_status_ap_full;
+   rec.status = 
cpu_to_le16(P80211ENUM_status_ap_full);
} else {
ether_addr_copy(
hw->authlist.addr[hw->authlist.cnt],
@@ -1688,7 +1688,6 @@ static void prism2sta_inf_authreq_defer(struct wlandevice 
*wlandev,
 * it was added.
 */
 
-   rec.status = cpu_to_le16(rec.status);
rec.algorithm = inf->info.authreq.algorithm;
 
result = hfa384x_drvr_setconfig(hw, HFA384x_RID_AUTHENTICATESTA,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel