Search Linux Wireless

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/29/2015 12:56 AM, Joe Perches wrote:
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

X is fixed constant. In this case X is {0, 1, 2}.

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

therm_on = (thermometer < 0) ? 0 : (thermometer == 0) =>
therm_on = (true) ? 0 : (thermometer == 0) =>

therm_on is 0


therm_on = thermometer == 0 =>

therm_on = false


false is equal to 0


Value of the thermometer variable isanerror code, or athermometercode. The thermometercode is never equal to the error code (thermometercode >= 0, error code <0).
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux