Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1679538 > unrolled thread

[PATCH 1/1] staging: ks7010: Fix cast to restricted __le16 in ks_wlan_net.c

Started byJanusz Lisiecki <janusz.lisiecki@gmail.com>
First post2017-07-02 19:30 +0200
Last post2017-07-03 06:50 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/1] staging: ks7010: Fix cast to restricted __le16 in ks_wlan_net.c Janusz Lisiecki <janusz.lisiecki@gmail.com> - 2017-07-02 19:30 +0200
    Re: [PATCH 1/1] staging: ks7010: Fix cast to restricted __le16 in ks_wlan_net.c Luc Van Oostenryck <luc.vanoostenryck@gmail.com> - 2017-07-02 21:40 +0200
      Re: [PATCH 1/1] staging: ks7010: Fix cast to restricted __le16 in  ks_wlan_net.c Janusz Lisiecki <janusz.lisiecki@gmail.com> - 2017-07-02 23:00 +0200
        Re: [PATCH 1/1] staging: ks7010: Fix cast to restricted __le16 in ks_wlan_net.c Luc Van Oostenryck <luc.vanoostenryck@gmail.com> - 2017-07-02 23:30 +0200
          Re: [PATCH 1/1] staging: ks7010: Fix cast to restricted __le16 in  ks_wlan_net.c Janusz Lisiecki <janusz.lisiecki@gmail.com> - 2017-07-03 06:50 +0200

#1679538 — [PATCH 1/1] staging: ks7010: Fix cast to restricted __le16 in ks_wlan_net.c

FromJanusz Lisiecki <janusz.lisiecki@gmail.com>
Date2017-07-02 19:30 +0200
Subject[PATCH 1/1] staging: ks7010: Fix cast to restricted __le16 in ks_wlan_net.c
Message-ID<tYQR3-58Q-9@gated-at.bofh.it>
This patch fixes the following Sparse warnings in ks_wlan_net.c:
drivers/staging/ks7010/ks_wlan_net.c:1359:24: warning: cast to restricted __le16
Both sides of assignment are u16 so (as 'ap' is local_ap_t type and 'capability' member,
have the same as local 'capabilities' type of u16) 'le16_to_cpu' is not needed

Signed-off-by: Janusz Lisiecki <janusz.lisiecki@gmail.com>
---
 drivers/staging/ks7010/ks_wlan_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 0c778aa..9a7fbe2 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -1356,7 +1356,7 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev,
 
 	/* Add mode */
 	iwe.cmd = SIOCGIWMODE;
-	capabilities = le16_to_cpu(ap->capability);
+	capabilities = ap->capability;
 	if (capabilities & (BSS_CAP_ESS | BSS_CAP_IBSS)) {
 		if (capabilities & BSS_CAP_ESS)
 			iwe.u.mode = IW_MODE_INFRA;
-- 
1.9.1

[toc] | [next] | [standalone]


#1679555

FromLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Date2017-07-02 21:40 +0200
Message-ID<tYSSS-6BU-19@gated-at.bofh.it>
In reply to#1679538
On Sun, Jul 2, 2017 at 4:27 PM, Janusz Lisiecki
<janusz.lisiecki@gmail.com> wrote:
> This patch fixes the following Sparse warnings in ks_wlan_net.c:
> drivers/staging/ks7010/ks_wlan_net.c:1359:24: warning: cast to restricted __le16
> Both sides of assignment are u16 so (as 'ap' is local_ap_t type and 'capability' member,
> have the same as local 'capabilities' type of u16) 'le16_to_cpu' is not needed

It could be that it's ap->capability's type that is wrong (not
annotated with __le16).
Isn't it?

Is ap->capability supposed to hold a little-endian value or a native
order value?

-- Luc

[toc] | [prev] | [next] | [standalone]


#1679561 — Re: [PATCH 1/1] staging: ks7010: Fix cast to restricted __le16 in ks_wlan_net.c

FromJanusz Lisiecki <janusz.lisiecki@gmail.com>
Date2017-07-02 23:00 +0200
SubjectRe: [PATCH 1/1] staging: ks7010: Fix cast to restricted __le16 in ks_wlan_net.c
Message-ID<tYU8i-7p8-25@gated-at.bofh.it>
In reply to#1679555
W dniu 2017-07-02 o 21:38, Luc Van Oostenryck pisze:
> On Sun, Jul 2, 2017 at 4:27 PM, Janusz Lisiecki
> <janusz.lisiecki@gmail.com> wrote:
>> This patch fixes the following Sparse warnings in ks_wlan_net.c:
>> drivers/staging/ks7010/ks_wlan_net.c:1359:24: warning: cast to restricted __le16
>> Both sides of assignment are u16 so (as 'ap' is local_ap_t type and 'capability' member,
>> have the same as local 'capabilities' type of u16) 'le16_to_cpu' is not needed
> It could be that it's ap->capability's type that is wrong (not
> annotated with __le16).
> Isn't it?
>
> Is ap->capability supposed to hold a little-endian value or a native
> order value?
>
> -- Luc
As I see in ks_hostif.c all assignments to link_ap_info_t->capability 
threat this value as native order (i.e get_ap_information, 
get_current_ap). As this is not a structure which comes from HW we can 
do the way you suggested. Still, as all other places in code threats 
this as native order value I decided to change only one place than many 
other around to fix Sparse warning.

Pozdrawiam,
Janusz Lisiecki

[toc] | [prev] | [next] | [standalone]


#1679564

FromLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
Date2017-07-02 23:30 +0200
Message-ID<tYUBk-7Xp-23@gated-at.bofh.it>
In reply to#1679561
On Sun, Jul 2, 2017 at 10:49 PM, Janusz Lisiecki
<janusz.lisiecki@gmail.com> wrote:
> W dniu 2017-07-02 o 21:38, Luc Van Oostenryck pisze:
>
>> On Sun, Jul 2, 2017 at 4:27 PM, Janusz Lisiecki
>> <janusz.lisiecki@gmail.com> wrote:
>>>
>>> This patch fixes the following Sparse warnings in ks_wlan_net.c:
>>> drivers/staging/ks7010/ks_wlan_net.c:1359:24: warning: cast to restricted
>>> __le16
>>> Both sides of assignment are u16 so (as 'ap' is local_ap_t type and
>>> 'capability' member,
>>> have the same as local 'capabilities' type of u16) 'le16_to_cpu' is not
>>> needed
>>
>> It could be that it's ap->capability's type that is wrong (not
>> annotated with __le16).
>> Isn't it?
>>
>> Is ap->capability supposed to hold a little-endian value or a native
>> order value?
>>
>> -- Luc
>
> As I see in ks_hostif.c all assignments to link_ap_info_t->capability threat
> this value as native order (i.e get_ap_information, get_current_ap). As this
> is not a structure which comes from HW we can do the way you suggested.
> Still, as all other places in code threats this as native order value I
> decided to change only one place than many other around to fix Sparse
> warning.

Fine, but then please put this explanation in the commit message.
In others words, be very clear that the change is because ap->capability is in
native order and thus the conversion le16_to_cpu() is wrong and must be removed.

-- Luc

[toc] | [prev] | [next] | [standalone]


#1679641 — Re: [PATCH 1/1] staging: ks7010: Fix cast to restricted __le16 in ks_wlan_net.c

FromJanusz Lisiecki <janusz.lisiecki@gmail.com>
Date2017-07-03 06:50 +0200
SubjectRe: [PATCH 1/1] staging: ks7010: Fix cast to restricted __le16 in ks_wlan_net.c
Message-ID<tZ1t7-4u1-9@gated-at.bofh.it>
In reply to#1679564
W dniu 2017-07-02 o 23:23, Luc Van Oostenryck pisze:
> On Sun, Jul 2, 2017 at 10:49 PM, Janusz Lisiecki
> <janusz.lisiecki@gmail.com> wrote:
>> W dniu 2017-07-02 o 21:38, Luc Van Oostenryck pisze:
>>
>>> On Sun, Jul 2, 2017 at 4:27 PM, Janusz Lisiecki
>>> <janusz.lisiecki@gmail.com> wrote:
>>>> This patch fixes the following Sparse warnings in ks_wlan_net.c:
>>>> drivers/staging/ks7010/ks_wlan_net.c:1359:24: warning: cast to restricted
>>>> __le16
>>>> Both sides of assignment are u16 so (as 'ap' is local_ap_t type and
>>>> 'capability' member,
>>>> have the same as local 'capabilities' type of u16) 'le16_to_cpu' is not
>>>> needed
>>> It could be that it's ap->capability's type that is wrong (not
>>> annotated with __le16).
>>> Isn't it?
>>>
>>> Is ap->capability supposed to hold a little-endian value or a native
>>> order value?
>>>
>>> -- Luc
>> As I see in ks_hostif.c all assignments to link_ap_info_t->capability threat
>> this value as native order (i.e get_ap_information, get_current_ap). As this
>> is not a structure which comes from HW we can do the way you suggested.
>> Still, as all other places in code threats this as native order value I
>> decided to change only one place than many other around to fix Sparse
>> warning.
> Fine, but then please put this explanation in the commit message.
> In others words, be very clear that the change is because ap->capability is in
> native order and thus the conversion le16_to_cpu() is wrong and must be removed.
>
> -- Luc
Done. I hope my message is more verbose and clear this time.

Pozdrawiam,
Janusz Lisiecki


Pozdrawiam,
Janusz Lisiecki

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web