ath5k: fix endianness of bitwise ops when installing mic
PATCH 1/1 ath5k: fix endianness of bitwise ops when installing mic
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 intChanges-licensed-under: ISC
--- drivers/net/wireless/ath5k/pcu.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath5k/pcu.c +2 -2
@@ -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 ];
Signature · 4 lines
1.6.0.4 -- Bob Copeland %% www.bobcopeland.com
Quoted 24 lines · Bob Copeland
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 intChanges-licensed-under: ISC
Reported-by Johannes Berg <[email protected]>Signed-off-by Bob Copeland <[email protected]>--- drivers/net/wireless/ath5k/pcu.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/net/wireless/ath5k/pcu.c +0
-0
drivers/net/wireless/ath5k/pcu.c int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry, · line 1102
Quoted 5 lines
drivers/net/wireless/ath5k/pcu.c +1
-1@@ -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
Quoted 6 lines · Larry Finger
drivers/net/wireless/ath5k/pcu.c int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry, · line 1102
Quoted 3 lines
drivers/net/wireless/ath5k/pcu.c +1
-1key_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).
Signature · 1 line
Bob Copeland %% www.bobcopeland.com