mirror of
https://github.com/proski/madwifi
synced 2024-11-22 14:31:22 +03:00
Fix the last sparse warning - find key index in a loop
ath_key_alloc() was using pointer subtraction to determine the group key index. This is not optimal, as it's done by dividing a pointer-sized integer by a number that is generally not a power of two. Since there are only 4 (IEEE80211_WEP_NKID) keys to try, it's easier to try them all in a loop. It also makes the code more reliable, as it now detects the cases when the key pointer is within the valid range, but doesn't point to the beginning of an array element. git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@2954 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
parent
3f9f5f6a53
commit
09e5677445
14
ath/if_ath.c
14
ath/if_ath.c
@ -3607,16 +3607,22 @@ ath_key_alloc(struct ieee80211vap *vap, const struct ieee80211_key *k)
|
||||
* multi-station operation.
|
||||
*/
|
||||
if ((k->wk_flags & IEEE80211_KEY_GROUP) && !sc->sc_mcastkey) {
|
||||
ieee80211_keyix_t keyix;
|
||||
int i;
|
||||
ieee80211_keyix_t keyix = IEEE80211_KEYIX_NONE;
|
||||
|
||||
if (!(&vap->iv_nw_keys[0] <= k &&
|
||||
k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])) {
|
||||
for (i = 0; i < IEEE80211_WEP_NKID; i++) {
|
||||
if (k == &vap->iv_nw_keys[i]) {
|
||||
keyix = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (keyix == IEEE80211_KEYIX_NONE) {
|
||||
/* should not happen */
|
||||
DPRINTF(sc, ATH_DEBUG_KEYCACHE,
|
||||
"%s: bogus group key\n", __func__);
|
||||
return IEEE80211_KEYIX_NONE;
|
||||
}
|
||||
keyix = k - vap->iv_nw_keys;
|
||||
|
||||
/* XXX: We pre-allocate the global keys so have no way
|
||||
* to check if they've already been allocated. */
|
||||
return keyix;
|
||||
|
Loading…
Reference in New Issue
Block a user