Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1298718

Re: [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?: operator

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?: operator
Date 2015-12-28 19:00 +0100
Message-ID <qKKfp-5mY-3@gated-at.bofh.it> (permalink)
References <qKGls-2JC-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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@gmail.com>
> ---
>  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-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?:  operator Ivan Safonov <insafonov@gmail.com> - 2015-12-28 14:50 +0100
  Re: [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?:  operator Joe Perches <joe@perches.com> - 2015-12-28 19:00 +0100
    Re: [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?:  operator Ivan Safonov <insafonov@gmail.com> - 2015-12-28 19:40 +0100
      Re: [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?:  operator Joe Perches <joe@perches.com> - 2015-12-29 01:40 +0100
        Re: [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?:  operator Ivan Safonov <insafonov@gmail.com> - 2015-12-29 05:10 +0100

csiph-web