From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751335AbdJDQ0u (ORCPT ); Wed, 4 Oct 2017 12:26:50 -0400 Received: from smtprelay0229.hostedemail.com ([216.40.44.229]:35232 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750966AbdJDQ0t (ORCPT ); Wed, 4 Oct 2017 12:26:49 -0400 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:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3872:4321:4605:5007:7808:10004:10400:10848:11026:11232:11473:11657:11658:11914:12043:12048:12438:12555:12740:12895:13069:13161:13229:13311:13357:13439:13894:14096:14097:14659:14721:21080:21433:21434:21451:21627:30012:30054:30055:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: beds20_3b2b578bc1c2e X-Filterd-Recvd-Size: 2881 Message-ID: <1507134405.4434.10.camel@perches.com> Subject: Re: [PATCH 1/3] wireless: iwlwifi: use bool instead of int From: Joe Perches To: Christoph =?ISO-8859-1?Q?B=F6hmwalder?= , johannes.berg@intel.com, emmanuel.grumbach@intel.com, luciano.coelho@intel.com, kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 04 Oct 2017 09:26:45 -0700 In-Reply-To: <20171004155700.18048-2-christoph@boehmwalder.at> References: <20171004155700.18048-1-christoph@boehmwalder.at> <20171004155700.18048-2-christoph@boehmwalder.at> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-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 On Wed, 2017-10-04 at 17:56 +0200, Christoph Böhmwalder wrote: > Change a usage of int in a boolean context to use the bool type instead, as it > makes the intent of the function clearer and helps clarify its semantics. > > Also eliminate the if/else and just return the boolean result directly, > making the code more readable. > > Signed-off-by: Christoph Böhmwalder > --- > drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c b/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c > index b7cd813ba70f..0eb815ae97e8 100644 > --- a/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c > +++ b/drivers/net/wireless/intel/iwlwifi/iwl-phy-db.c > @@ -267,14 +267,12 @@ int iwl_phy_db_set_section(struct iwl_phy_db *phy_db, > } > IWL_EXPORT_SYMBOL(iwl_phy_db_set_section); > > -static int is_valid_channel(u16 ch_id) > +static bool is_valid_channel(u16 ch_id) > { > - if (ch_id <= 14 || > - (36 <= ch_id && ch_id <= 64 && ch_id % 4 == 0) || > - (100 <= ch_id && ch_id <= 140 && ch_id % 4 == 0) || > - (145 <= ch_id && ch_id <= 165 && ch_id % 4 == 1)) > - return 1; > - return 0; > + return (ch_id <= 14 || > + (36 <= ch_id && ch_id <= 64 && ch_id % 4 == 0) || > + (100 <= ch_id && ch_id <= 140 && ch_id % 4 == 0) || > + (145 <= ch_id && ch_id <= 165 && ch_id % 4 == 1)); > } This might be more intelligble as separate tests static bool is_valid_channel(u16 ch_id) { if (ch_id <= 14) return true; if ((ch_id % 4 == 0) && ((ch_id >= 36 && ch_id <= 64) || (ch_id >= 100 && ch_id <= 140))) return true; if ((ch_id % 4 == 1) && (chid >= 145 && ch_id <= 165)) return true; return false; } The compiler should produce the same object code.