From: Dan Carpenter <dan.carpenter@oracle.com>
To: ath9k-devel@lists.ath9k.org
Subject: [ath9k-devel] [RFC] ath9k_hw: precedence bug in ath9k_hw_set_ofdm_nil()
Date: Tue, 10 Apr 2012 13:57:25 +0300 [thread overview]
Message-ID: <20120410105725.GA5589@mwanda> (raw)
In-Reply-To: <4F840442.5060706@openwrt.org>
On Tue, Apr 10, 2012 at 11:58:26AM +0200, Felix Fietkau wrote:
> > if ((aniState->noiseFloor >= aniState->rssiThrHigh) &&
> > - (!aniState->ofdmWeakSigDetectOff !=
> > + (aniState->ofdmWeakSigDetectOff !=
> Looking at other Atheros code, I think this patch is wrong, it should
> be: aniState->ofdmWeakSigDetectOff == entry_ofdm->ofdm_weak_signal_on
>
> While a bit confusing, the behavior of the original code was correct,
> aniState->ofdmWeakSigDetectOff is used as a boolean.
>
> This code badly needs a cleanup, the whole mess with *on vs *off
> variables is quite confusing.
>
Yep. It's bad to name variables xxx_off because it leads triple
negatives like we see here.
I guess that "if (!off != on) { ..." might be more readable than
"if (off == on) { ...". There are a couple ways to silence this
warning in Smatch.
The first way would be to add parenthesis like,
"((!off) != on) {...". I think it helps because it makes the negate
stand out and you don't have to think about how the precedence
rules works. Other people think it's a needless parenthesis for
something that is obvious.
The other way would be to make either ->ofdmWeakSigDetectOff or
->ofdm_weak_signal_on be type bool. I think this would make the
code clearer.
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Felix Fietkau <nbd@openwrt.org>
Cc: "Luis R. Rodriguez" <mcgrof@qca.qualcomm.com>,
Rajkumar Manoharan <rmanohar@qca.qualcomm.com>,
Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>,
ath9k-devel@venema.h4ckr.net, kernel-janitors@vger.kernel.org,
Jouni Malinen <jouni@qca.qualcomm.com>,
linux-wireless@vger.kernel.org,
"John W. Linville" <linville@tuxdriver.com>,
Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Subject: Re: [ath9k-devel] [RFC] ath9k_hw: precedence bug in ath9k_hw_set_ofdm_nil()
Date: Tue, 10 Apr 2012 10:57:25 +0000 [thread overview]
Message-ID: <20120410105725.GA5589@mwanda> (raw)
In-Reply-To: <4F840442.5060706@openwrt.org>
On Tue, Apr 10, 2012 at 11:58:26AM +0200, Felix Fietkau wrote:
> > if ((aniState->noiseFloor >= aniState->rssiThrHigh) &&
> > - (!aniState->ofdmWeakSigDetectOff !> > + (aniState->ofdmWeakSigDetectOff !> Looking at other Atheros code, I think this patch is wrong, it should
> be: aniState->ofdmWeakSigDetectOff = entry_ofdm->ofdm_weak_signal_on
>
> While a bit confusing, the behavior of the original code was correct,
> aniState->ofdmWeakSigDetectOff is used as a boolean.
>
> This code badly needs a cleanup, the whole mess with *on vs *off
> variables is quite confusing.
>
Yep. It's bad to name variables xxx_off because it leads triple
negatives like we see here.
I guess that "if (!off != on) { ..." might be more readable than
"if (off = on) { ...". There are a couple ways to silence this
warning in Smatch.
The first way would be to add parenthesis like,
"((!off) != on) {...". I think it helps because it makes the negate
stand out and you don't have to think about how the precedence
rules works. Other people think it's a needless parenthesis for
something that is obvious.
The other way would be to make either ->ofdmWeakSigDetectOff or
->ofdm_weak_signal_on be type bool. I think this would make the
code clearer.
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Felix Fietkau <nbd@openwrt.org>
Cc: "Luis R. Rodriguez" <mcgrof@qca.qualcomm.com>,
Rajkumar Manoharan <rmanohar@qca.qualcomm.com>,
Vasanthakumar Thiagarajan <vthiagar@qca.qualcomm.com>,
ath9k-devel@venema.h4ckr.net, kernel-janitors@vger.kernel.org,
Jouni Malinen <jouni@qca.qualcomm.com>,
linux-wireless@vger.kernel.org,
"John W. Linville" <linville@tuxdriver.com>,
Senthil Balasubramanian <senthilb@qca.qualcomm.com>
Subject: Re: [ath9k-devel] [RFC] ath9k_hw: precedence bug in ath9k_hw_set_ofdm_nil()
Date: Tue, 10 Apr 2012 13:57:25 +0300 [thread overview]
Message-ID: <20120410105725.GA5589@mwanda> (raw)
In-Reply-To: <4F840442.5060706@openwrt.org>
On Tue, Apr 10, 2012 at 11:58:26AM +0200, Felix Fietkau wrote:
> > if ((aniState->noiseFloor >= aniState->rssiThrHigh) &&
> > - (!aniState->ofdmWeakSigDetectOff !=
> > + (aniState->ofdmWeakSigDetectOff !=
> Looking at other Atheros code, I think this patch is wrong, it should
> be: aniState->ofdmWeakSigDetectOff == entry_ofdm->ofdm_weak_signal_on
>
> While a bit confusing, the behavior of the original code was correct,
> aniState->ofdmWeakSigDetectOff is used as a boolean.
>
> This code badly needs a cleanup, the whole mess with *on vs *off
> variables is quite confusing.
>
Yep. It's bad to name variables xxx_off because it leads triple
negatives like we see here.
I guess that "if (!off != on) { ..." might be more readable than
"if (off == on) { ...". There are a couple ways to silence this
warning in Smatch.
The first way would be to add parenthesis like,
"((!off) != on) {...". I think it helps because it makes the negate
stand out and you don't have to think about how the precedence
rules works. Other people think it's a needless parenthesis for
something that is obvious.
The other way would be to make either ->ofdmWeakSigDetectOff or
->ofdm_weak_signal_on be type bool. I think this would make the
code clearer.
regards,
dan carpenter
next prev parent reply other threads:[~2012-04-10 10:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-10 9:04 [ath9k-devel] [RFC] ath9k_hw: precedence bug in ath9k_hw_set_ofdm_nil() Dan Carpenter
2012-04-10 9:04 ` Dan Carpenter
2012-04-10 9:04 ` Dan Carpenter
2012-04-10 9:58 ` [ath9k-devel] " Felix Fietkau
2012-04-10 9:58 ` Felix Fietkau
2012-04-10 9:58 ` Felix Fietkau
2012-04-10 10:57 ` Dan Carpenter [this message]
2012-04-10 10:57 ` Dan Carpenter
2012-04-10 10:57 ` Dan Carpenter
2012-04-10 12:50 ` Rajkumar Manoharan
2012-04-10 12:51 ` Rajkumar Manoharan
2012-04-10 12:50 ` Rajkumar Manoharan
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=20120410105725.GA5589@mwanda \
--to=dan.carpenter@oracle.com \
--cc=ath9k-devel@lists.ath9k.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.