linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] ath9k_hw: min_t() casts u32 to int
@ 2011-10-17  7:28 Dan Carpenter
  2011-10-18 20:19 ` Pavel Roskin
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2011-10-17  7:28 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: Jouni Malinen, Vasanthakumar Thiagarajan, Senthil Balasubramanian,
	John W. Linville, linux-wireless, ath9k-devel, kernel-janitors

The code here treats very large values of "limit" as less than
MAX_POWER_RATE because of the cast to int.  We should do the compare
as u32 instead.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index e0c8549..f9abbb7 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -2526,7 +2526,7 @@ void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
 	struct ath9k_channel *chan = ah->curchan;
 	struct ieee80211_channel *channel = chan->chan;
 
-	reg->power_limit = min_t(int, limit, MAX_RATE_POWER);
+	reg->power_limit = min_t(u32, limit, MAX_RATE_POWER);
 	if (test)
 		channel->max_power = MAX_RATE_POWER / 2;
 

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

* Re: [patch] ath9k_hw: min_t() casts u32 to int
  2011-10-17  7:28 [patch] ath9k_hw: min_t() casts u32 to int Dan Carpenter
@ 2011-10-18 20:19 ` Pavel Roskin
  0 siblings, 0 replies; 2+ messages in thread
From: Pavel Roskin @ 2011-10-18 20:19 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Luis R. Rodriguez, Jouni Malinen, Vasanthakumar Thiagarajan,
	Senthil Balasubramanian, John W. Linville, linux-wireless,
	ath9k-devel, kernel-janitors

On Mon, 17 Oct 2011 10:28:23 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> The code here treats very large values of "limit" as less than
> MAX_POWER_RATE because of the cast to int.  We should do the compare
> as u32 instead.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Pavel Roskin <proski@gnu.org>

I don't think it can actually happen.  ath9k_hw_set_txpowerlimit() is
called twice.  In one case, limit is MAX_RATE_POWER, in another case,
it's an argument of type u16.  Still, it's better not to have the code
that looks wrong.

ath9k_cmn_update_txpow() also has code that _looks_ wrong.  *txpower is
not assigned a value if the new power happens to be equal to the
current one.  Also, the second argument (cur_txpow) is not used.
Returning a value by a pointer seems unnecessary if the function returns
void.  It could simply return the new tx power.  I'll submit a patch
shortly.

-- 
Regards,
Pavel Roskin

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

end of thread, other threads:[~2011-10-18 20:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-17  7:28 [patch] ath9k_hw: min_t() casts u32 to int Dan Carpenter
2011-10-18 20:19 ` 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).