Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys



On Wed, Oct 15, 2003 at 08:44:09AM +0900, Atsushi Onoe wrote:
> > Modified Files:
> >     src/sys/dev/ic: ath.c
> >     src/sys/net80211: ieee80211.c
> > 
> > Log Message:
> > Do not index arrays using enum constants, since enums can be
> > re-ordered and extended. Instead, use a switch-statement or a
> > key->value table with appropriate bounds-checking.
> 
> The enum ieee80211_phymode is also used as index for ic_sup_rates[]
> of ieee80211com, and the enum constants are explicitly assigned their
> value for this reason.
> 
> Though the log message itself looks correct, the change (at least for
> ieee80211.c) doesn't make sense to me.

I see what you're saying, but ic_sup_rates is a little different
case than the others.  It does not matter which rate table
ic_sup_rates[IEEE80211_MODE_11A] selects, as long as it is a different
table than ic_sup_rates[IEEE80211_MODE_11B] selects. Also, ic_sup_rates[]
is protected from an overflow because its size is IEEE80211_MODE_MAX.

Compare with ieee80211_phymode_name. If
ieee80211_phymode_name[IEEE80211_MODE_11A] selects a different
mode string than "11a", that is bad. Moreover, it is very bad if
ieee80211_phymode_name[mode] goes off the end of the list.

Dave

-- 
David Young             OJC Technologies
dyoung%ojctech.com@localhost      Urbana, IL * (217) 278-3933



Home | Main Index | Thread Index | Old Index