Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752360AbbL1R45 (ORCPT ); Mon, 28 Dec 2015 12:56:57 -0500 Received: from smtprelay0247.hostedemail.com ([216.40.44.247]:39631 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750998AbbL1R4z (ORCPT ); Mon, 28 Dec 2015 12:56:55 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3867:3868:3871:4321:5007:6261:7514:7904:10004:10400:10848:11026:11232:11473:11657:11658:11783:11914:12043:12296:12438:12517:12519:12740:13069:13311:13357:13894:14659:21080:30012:30054:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: pear12_3c1d9c61b143b X-Filterd-Recvd-Size: 2403 Message-ID: <1451325412.3219.12.camel@perches.com> Subject: Re: [PATCH] /drivers/net/wireless/ath/ath9k remove unnecessary ?: operator From: Joe Perches To: Ivan Safonov , QCA ath9k Development Cc: Kalle Valo , linux-wireless@vger.kernel.org, ath9k-devel@venema.h4ckr.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 28 Dec 2015 09:56:52 -0800 In-Reply-To: <20151228134852.GA10572@alpha.sfu-kras.ru> References: <20151228134852.GA10572@alpha.sfu-kras.ru> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.3-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1662 Lines: 43 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 > --- > ?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/