linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 3/9] ath9k: cleanup: u32 => bool
@ 2010-05-08 16:22 Dan Carpenter
  2010-05-10  7:38 ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2010-05-08 16:22 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: Jouni Malinen, Sujith Manoharan, Vasanthakumar Thiagarajan,
	Senthil Balasubramanian, John W. Linville, Felix Fietkau,
	linux-wireless, ath9k-devel

This is used as a boolean variable so changing it to a boolean type is a
cleanup.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
index b2c17c9..f685b8b 100644
--- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c
@@ -1082,7 +1082,7 @@ static bool ar5008_hw_ani_control(struct ath_hw *ah,
 		const int m2Thresh[] = { 127, 0x40 };
 		const int m2CountThr[] = { 31, 16 };
 		const int m2CountThrLow[] = { 63, 48 };
-		u32 on = param ? 1 : 0;
+		bool on = param ? 1 : 0;
 
 		REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
 			      AR_PHY_SFCORR_LOW_M1_THRESH_LOW,
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index 80431a2..0c34154 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -771,7 +771,7 @@ static bool ar9003_hw_ani_control(struct ath_hw *ah,
 		const int m2Thresh[] = { 127, 0x40 };
 		const int m2CountThr[] = { 31, 16 };
 		const int m2CountThrLow[] = { 63, 48 };
-		u32 on = param ? 1 : 0;
+		bool on = param ? 1 : 0;
 
 		REG_RMW_FIELD(ah, AR_PHY_SFCORR_LOW,
 			      AR_PHY_SFCORR_LOW_M1_THRESH_LOW,

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch 3/9] ath9k: cleanup: u32 => bool
  2010-05-08 16:22 [patch 3/9] ath9k: cleanup: u32 => bool Dan Carpenter
@ 2010-05-10  7:38 ` Johannes Berg
  2010-05-10 14:46   ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2010-05-10  7:38 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Luis R. Rodriguez, Jouni Malinen, Sujith Manoharan,
	Vasanthakumar Thiagarajan, Senthil Balasubramanian,
	John W. Linville, Felix Fietkau, linux-wireless, ath9k-devel

On Sat, 2010-05-08 at 18:22 +0200, Dan Carpenter wrote:

> +		bool on = param ? 1 : 0;

umm, if you're going to use bool then use true/false too.

johannes


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 3/9] ath9k: cleanup: u32 => bool
  2010-05-10  7:38 ` Johannes Berg
@ 2010-05-10 14:46   ` Dan Carpenter
  2010-05-10 15:00     ` Pavel Roskin
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2010-05-10 14:46 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Luis R. Rodriguez, Jouni Malinen, Sujith Manoharan,
	Vasanthakumar Thiagarajan, Senthil Balasubramanian,
	John W. Linville, Felix Fietkau, linux-wireless, ath9k-devel

On Mon, May 10, 2010 at 09:38:26AM +0200, Johannes Berg wrote:
> On Sat, 2010-05-08 at 18:22 +0200, Dan Carpenter wrote:
> 
> > +		bool on = param ? 1 : 0;
> 
> umm, if you're going to use bool then use true/false too.
> 
> johannes

The 1 and 0 are used as array indexes so it looks funny to use true and
false.

Let's just drop this patch.  I wrote it to silence a smatch false 
positive but I should/will just fix smatch instead.

Smatch complains we negate a non-boolean type here:

                if (!on != aniState->ofdmWeakSigDetectOff) {

It's a quite common bug to forget that negation has higher precendence 
than compare operations.  In this case, it's clear from code that "on" is
either 1 or 0 so smatch should not complain.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 3/9] ath9k: cleanup: u32 => bool
  2010-05-10 14:46   ` Dan Carpenter
@ 2010-05-10 15:00     ` Pavel Roskin
  0 siblings, 0 replies; 4+ messages in thread
From: Pavel Roskin @ 2010-05-10 15:00 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Johannes Berg, Luis R. Rodriguez, Jouni Malinen, Sujith Manoharan,
	Vasanthakumar Thiagarajan, Senthil Balasubramanian,
	John W. Linville, Felix Fietkau, linux-wireless, ath9k-devel

Quoting Dan Carpenter <error27@gmail.com>:

> Smatch complains we negate a non-boolean type here:
>
>                 if (!on != aniState->ofdmWeakSigDetectOff) {
>
> It's a quite common bug to forget that negation has higher precendence
> than compare operations.  In this case, it's clear from code that "on" is
> either 1 or 0 so smatch should not complain.

We could rename ofdmWeakSigDetectOff to ofdmWeakSigDetectOn and change  
the logic appropriately.  Positive logic is easier to understand in  
the long run.

ofdmWeakSigDetectOn could be boolean and "on" could be int, since it's  
an index.  The comparison could use !!on to convert int to boolean.

-- 
Regards,
Pavel Roskin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-05-10 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-08 16:22 [patch 3/9] ath9k: cleanup: u32 => bool Dan Carpenter
2010-05-10  7:38 ` Johannes Berg
2010-05-10 14:46   ` Dan Carpenter
2010-05-10 15:00     ` Pavel Roskin

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).