linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath5k: fix endianness of bitwise ops when installing mic
@ 2008-12-10  4:05 Bob Copeland
  2008-12-10  4:30 ` Larry Finger
  0 siblings, 1 reply; 3+ messages in thread
From: Bob Copeland @ 2008-12-10  4:05 UTC (permalink / raw)
  To: linux-wireless, linville; +Cc: johannes, ath5k-devel

Fix these bugs found by sparse:

    ath5k/pcu.c:1102:21: warning: restricted __le32 degrades to integer
    ath5k/pcu.c:1102:13: warning: incorrect type in assignment (different base types)
    ath5k/pcu.c:1102:13:    expected restricted __le32 <noident>
    ath5k/pcu.c:1102:13:    got unsigned int
    ath5k/pcu.c:1104:20: warning: restricted __le32 degrades to integer
    ath5k/pcu.c:1104:13: warning: incorrect type in assignment (different base types)
    ath5k/pcu.c:1104:13:    expected restricted __le32 <noident>
    ath5k/pcu.c:1104:13:    got unsigned int

Changes-licensed-under: ISC

Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
 drivers/net/wireless/ath5k/pcu.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath5k/pcu.c b/drivers/net/wireless/ath5k/pcu.c
index dabe422..0cac05c 100644
--- a/drivers/net/wireless/ath5k/pcu.c
+++ b/drivers/net/wireless/ath5k/pcu.c
@@ -1099,9 +1099,9 @@ int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry,
 
 		if (ah->ah_combined_mic) {
 			key_v[0] = rxmic[0];
-			key_v[1] = (txmic[0] >> 16) & 0xffff;
+			key_v[1] = cpu_to_le32(le32_to_cpu(txmic[0]) >> 16);
 			key_v[2] = rxmic[1];
-			key_v[3] = txmic[0] & 0xffff;
+			key_v[3] = cpu_to_le32(le32_to_cpu(txmic[0]) & 0xffff);
 			key_v[4] = txmic[1];
 		} else {
 			key_v[0] = rxmic[0];
-- 
1.6.0.4

-- 
Bob Copeland %% www.bobcopeland.com


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ath5k: fix endianness of bitwise ops when installing mic
  2008-12-10  4:05 [PATCH] ath5k: fix endianness of bitwise ops when installing mic Bob Copeland
@ 2008-12-10  4:30 ` Larry Finger
  2008-12-10  4:54   ` Bob Copeland
  0 siblings, 1 reply; 3+ messages in thread
From: Larry Finger @ 2008-12-10  4:30 UTC (permalink / raw)
  To: Bob Copeland; +Cc: linux-wireless, linville, johannes, ath5k-devel

Bob Copeland wrote:
> Fix these bugs found by sparse:
> 
>     ath5k/pcu.c:1102:21: warning: restricted __le32 degrades to integer
>     ath5k/pcu.c:1102:13: warning: incorrect type in assignment (different base types)
>     ath5k/pcu.c:1102:13:    expected restricted __le32 <noident>
>     ath5k/pcu.c:1102:13:    got unsigned int
>     ath5k/pcu.c:1104:20: warning: restricted __le32 degrades to integer
>     ath5k/pcu.c:1104:13: warning: incorrect type in assignment (different base types)
>     ath5k/pcu.c:1104:13:    expected restricted __le32 <noident>
>     ath5k/pcu.c:1104:13:    got unsigned int
> 
> Changes-licensed-under: ISC
> 
> Reported-by: Johannes Berg <johannes@sipsolutions.net>
> Signed-off-by: Bob Copeland <me@bobcopeland.com>
> ---
>  drivers/net/wireless/ath5k/pcu.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath5k/pcu.c b/drivers/net/wireless/ath5k/pcu.c
> index dabe422..0cac05c 100644
> --- a/drivers/net/wireless/ath5k/pcu.c
> +++ b/drivers/net/wireless/ath5k/pcu.c
> @@ -1099,9 +1099,9 @@ int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry,
>  
>  		if (ah->ah_combined_mic) {
>  			key_v[0] = rxmic[0];
> -			key_v[1] = (txmic[0] >> 16) & 0xffff;
> +			key_v[1] = cpu_to_le32(le32_to_cpu(txmic[0]) >> 16);

Is it certain that txmic[0] will not sign extend with the >> 16 operation? Is
that why you dropped the mask with 0xffff?

Larry


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ath5k: fix endianness of bitwise ops when installing mic
  2008-12-10  4:30 ` Larry Finger
@ 2008-12-10  4:54   ` Bob Copeland
  0 siblings, 0 replies; 3+ messages in thread
From: Bob Copeland @ 2008-12-10  4:54 UTC (permalink / raw)
  To: Larry Finger; +Cc: linux-wireless, linville, johannes, ath5k-devel

On Tue, Dec 09, 2008 at 10:30:01PM -0600, Larry Finger wrote:
> >  			key_v[0] = rxmic[0];
> > -			key_v[1] = (txmic[0] >> 16) & 0xffff;
> > +			key_v[1] = cpu_to_le32(le32_to_cpu(txmic[0]) >> 16);
> 
> Is it certain that txmic[0] will not sign extend with the >> 16 operation? Is
> that why you dropped the mask with 0xffff?

Yeah, I added the mask in the first place, but dropped it here because 
txmic is an __le32, and as far as I can tell all __le types are also 
unsigned, so it shouldn't sign extend.

I'm not a language lawyer though so if anyone knows better, chime in
(I just wrote a simple C program to convince myself).

-- 
Bob Copeland %% www.bobcopeland.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-12-10  4:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-10  4:05 [PATCH] ath5k: fix endianness of bitwise ops when installing mic Bob Copeland
2008-12-10  4:30 ` Larry Finger
2008-12-10  4:54   ` Bob Copeland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).