From: Pavel Roskin <proski@gnu.org>
To: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: <ath6kl-devel@qualcomm.com>, <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH] ath6kl: fix incorrect use of IEEE80211_NUM_BANDS
Date: Fri, 20 Jul 2012 18:08:34 -0400 [thread overview]
Message-ID: <20120720180834.608b1138@mj> (raw)
In-Reply-To: <5008F829.8020902@qca.qualcomm.com>
On Fri, 20 Jul 2012 09:18:17 +0300
Kalle Valo <kvalo@qca.qualcomm.com> wrote:
> On 07/20/2012 12:11 AM, Pavel Roskin wrote:
> > On Thu, 19 Jul 2012 14:08:44 +0300
> > Kalle Valo <kvalo@qca.qualcomm.com> wrote:
> >> On 07/12/2012 08:48 PM, Pavel Roskin wrote:
> >>> On Thu, 12 Jul 2012 12:13:12 +0300
> >>> Kalle Valo <kvalo@qca.qualcomm.com> wrote:
> >>>
> >>>> + /* only check 2.4 and 5 GHz bands, skip the rest */
> >>>> + for (band = 0; band <= IEEE80211_BAND_5GHZ; band++) {
> >>>
> >>> There is something inelegant here. The code is mixing an integer
> >>> and an enum. I'd rather go with one or those:
> >>>
> >>> two enums:
> >>> for (band = IEEE80211_BAND_2GHZ; band <= IEEE80211_BAND_5GHZ;
> >>> band++) {
> >>
> >> I somewhat see your point. But IMHO zero is commonly used when
> >> iterating over an enum to denote the first value and I don't see
> >> how IEEE80211_BAND_2GHZ helps here.
> >
> > It's the lowest band we support. What if the 900MHz band is added
> > one day?
>
> Then that should be added to the end of the enum, not beginning. I
> think it would be bad if we change enum values on the fly.
Actually, it should be OK. It's not like it would affect the
userspace.
I believe that properly written code should not rely on the numeric
values of enums. Well, if 0 means something very special (like no
error), it should not be changed. The (ab)uses of enums for bitmasks
should be exempted too. But IEEE80211_BAND_2GHZ is just one of the
bands.
--
Regards,
Pavel Roskin
next prev parent reply other threads:[~2012-07-20 22:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-12 9:13 [PATCH] ath6kl: fix incorrect use of IEEE80211_NUM_BANDS Kalle Valo
2012-07-12 17:48 ` Pavel Roskin
2012-07-19 11:08 ` Kalle Valo
2012-07-19 21:11 ` Pavel Roskin
2012-07-20 6:18 ` Kalle Valo
2012-07-20 22:08 ` Pavel Roskin [this message]
2012-08-14 14:11 ` Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120720180834.608b1138@mj \
--to=proski@gnu.org \
--cc=ath6kl-devel@qualcomm.com \
--cc=kvalo@qca.qualcomm.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).