public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public•gmane.org>
To: Ivan Safonov <insafonov-Re5JQEeQqe8AvxtiuMwx3w@public•gmane.org>,
	QCA ath9k Development
	<ath9k-devel-A+ZNKFmMK5xy9aJCnZT0Uw@public•gmane.org>
Cc: Kalle Valo <kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public•gmane.org>,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA@public•gmane.org,
	ath9k-devel-xDcbHBWguxHbcTqmT+pZeQ@public•gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public•gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public•gmane.org
Subject: Re: [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?: operator
Date: Mon, 28 Dec 2015 09:56:52 -0800	[thread overview]
Message-ID: <1451325412.3219.12.camel@perches.com> (raw)
In-Reply-To: <20151228134852.GA10572-99FyVxquhxHwodmfrJTGkIdd74u8MsAO@public.gmane.org>

On Mon, 2015-12-28 at 20:48 +0700, Ivan Safonov wrote:
> ((thermometer < 0) ? 0 : (thermometer == X)) and (thermometer == X) are equal for X >= 0.

X is not guaranteed to be >= 0 here

> Signed-off-by: Ivan Safonov <insafonov-Re5JQEeQqe8AvxtiuMwx3w@public•gmane.org>
> ---
>  drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
[]
> @@ -4097,16 +4097,16 @@ static void ar9003_hw_thermometer_apply(struct ath_hw *ah)
>  		REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
>  			      AR_PHY_65NM_CH0_RXTX4_THERM_ON_OVR, therm_on);
>  
> -	therm_on = (thermometer < 0) ? 0 : (thermometer == 0);
> +	therm_on = thermometer == 0;

This code is not equivalent.

Check what happens when thermometer is -1.

>  	REG_RMW_FIELD(ah, AR_PHY_65NM_CH0_RXTX4,
>  		      AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
>  	if (pCap->chip_chainmask & BIT(1)) {
> -		therm_on = (thermometer < 0) ? 0 : (thermometer == 1);
> +		therm_on = thermometer == 1;
>  		REG_RMW_FIELD(ah, AR_PHY_65NM_CH1_RXTX4,
>  			      AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
>  	}
>  	if (pCap->chip_chainmask & BIT(2)) {
> -		therm_on = (thermometer < 0) ? 0 : (thermometer == 2);
> +		therm_on = thermometer == 2;
>  		REG_RMW_FIELD(ah, AR_PHY_65NM_CH2_RXTX4,
>  			      AR_PHY_65NM_CH0_RXTX4_THERM_ON, therm_on);
>  	}

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public•gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-12-28 17:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-28 13:48 [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?: operator Ivan Safonov
     [not found] ` <20151228134852.GA10572-99FyVxquhxHwodmfrJTGkIdd74u8MsAO@public.gmane.org>
2015-12-28 17:56   ` Joe Perches [this message]
2015-12-28 18:38     ` Ivan Safonov
2015-12-29  0:31       ` Joe Perches
2015-12-29  4:11         ` Ivan Safonov

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=1451325412.3219.12.camel@perches.com \
    --to=joe-6d6dil74uinbdgjk7y7tuq@public$(echo .)gmane.org \
    --cc=ath9k-devel-A+ZNKFmMK5xy9aJCnZT0Uw@public$(echo .)gmane.org \
    --cc=ath9k-devel-xDcbHBWguxHbcTqmT+pZeQ@public$(echo .)gmane.org \
    --cc=insafonov-Re5JQEeQqe8AvxtiuMwx3w@public$(echo .)gmane.org \
    --cc=kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public$(echo .)gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
    --cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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