Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3066857pxb; Mon, 4 Apr 2022 07:04:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzQRxS6bxUMgs7mFzyqrztDOK6Qfy2Hg94zXv9XUbwV/3n9v9Peh9W7Q0Z/P8WhBeMGk9P X-Received: by 2002:a50:a412:0:b0:41c:c2f5:3171 with SMTP id u18-20020a50a412000000b0041cc2f53171mr156028edb.341.1649081089324; Mon, 04 Apr 2022 07:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649081089; cv=none; d=google.com; s=arc-20160816; b=mNxuc6CcHHbnS2TPqMeWZgDy9omdyRWiCc/7Ep3BLmMyntaIxJVxJKCgZbgPYr/Nvx NK1w3SEWupDaUwugp8fznQzu/2NyhnJaJ2JuT/COazBuJtPv3e9RxI3bedPNqUyoENtr xLliFGV44h/APNZCrNY+4yQC10iW0gUq1XgxQ4k74+7nHGif1/4CHtk5YM7kngGvP41S A7uj9gJI2tYm8lo3iBS9sGn+pq8jmxz4jtK0jPSt2H3Rj1tZCV18GgXEpYY8KCwwRq5Q 8QtI880k85ut9H/c3DWAbzumrT/KlE/x+m28O6SlNLDoBsKhsWw82wbnJcqlWwRHIjJk GP1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vjF+XmzKjOxFZSpCdSkTsILJi4dhM2KdwwWdJtp4Mig=; b=MfRuWN4WxMurRL1ruo/sT1m+hNW1NJ264fFFlvDtogB42tWH9WyOg9auaXKmtwSqiN MLX3v8yLkpcw9roMX8N/RcfB7EBTPVR345xFTZ5aAgr4LF7Q8yL+B/CgV+jhkZe4nS4M 1yhjevgHjHhZqLqlB5rjR7UpxSY+w4bwBEnlVtairSDVZkntEzA9Fe9Gt15zYiO61WL/ UI0yC3CtVmQJXnZ0MAhOZzWCCQaMmhKWFKuaa49EBtHHa++pxHmXM3bjxt3sS3MIjC5a CaSa3AlIXjtulVKlW96KYsr6dLGTIcoZK3i5u7vFtj2ViD/0dgQiaTfWFTqKDA7nvCxf kICQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="J/Xl9068"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a50e1ca000000b00418f9facfd7si6958587edl.43.2022.04.04.07.04.20; Mon, 04 Apr 2022 07:04:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="J/Xl9068"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352782AbiDAVf6 (ORCPT + 99 others); Fri, 1 Apr 2022 17:35:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235549AbiDAVf4 (ORCPT ); Fri, 1 Apr 2022 17:35:56 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE942632A for ; Fri, 1 Apr 2022 14:34:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648848845; x=1680384845; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=gQWF+3nXXQTVuvvNU3qL73QaPoVzfmUyNSXaNlhBWWg=; b=J/Xl9068GygZmUU/Mv8TLpSKOVgGPTkY9VJ4mrAU0gkrCl9fZAnoJIJ8 FhCy486YYGqtYF9klb+fp/rDnF7vLGxXwA3/4S1vtjUTWTL1rs/dWyZz9 Lh66k9yhA6jbNWelOE4YP4R/P4b/lg3fCx7u2kUb0X6h9tMKeQLLNN6WO 2+kpitB/fdiDqsCMDoXVh6bPxCWYvIENca7lDDUPCATD6g/g3E1cY+CWG ifxHu9kQnghxie1+DPYN//lhVMf28bAoI9vGivMENIfiBbwyiX1RjjJoE S/YfYZsVfbuBi/uDWmI8pANU0c3GXX5i2Rqe0ElpFMObnSqV6iSyObCXo w==; X-IronPort-AV: E=McAfee;i="6200,9189,10304"; a="346673491" X-IronPort-AV: E=Sophos;i="5.90,228,1643702400"; d="scan'208";a="346673491" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2022 14:34:05 -0700 X-IronPort-AV: E=Sophos;i="5.90,228,1643702400"; d="scan'208";a="656042806" Received: from kmislam-mobl1.amr.corp.intel.com (HELO localhost) ([10.212.112.89]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2022 14:34:05 -0700 Date: Fri, 1 Apr 2022 14:34:04 -0700 From: Ira Weiny To: Sevinj Aghayeva Cc: Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, outreachy@lists.linux.dev Subject: Re: [PATCH] staging: rtl8723bs: simplify control flow Message-ID: References: <20220401114635.GA567659@euclid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220401114635.GA567659@euclid> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 01, 2022 at 07:46:35AM -0400, Sevinj Aghayeva wrote: > The function iterates an index from 0 to NUM_PMKID_CACHE and returns > the first index for which the condition is true. If no such index is > found, the function returns -1. Current code has a complex control > flow that obfuscates this simple task. Replace it with a loop. > > Also, given the shortened function body, replace the long variable > name psecuritypriv with a short variable name p. > > Reported by checkpatch: > > WARNING: else is not generally useful after a break or return > > Signed-off-by: Sevinj Aghayeva Wow! Nice find! This is a huge clean up. Extra kudos recognizing that it is not just the else statement which is broken here! The only issue for the patch is that I don't see any maintainer emailed? However, I don't see a maintainer listed in the MAINTAINERS file so ... Reviewed-by: Ira Weiny > --- > drivers/staging/rtl8723bs/core/rtw_mlme.c | 28 ++++++----------------- > 1 file changed, 7 insertions(+), 21 deletions(-) > > diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c > index d5bb3a5bd2fb..3eacf8f9d236 100644 > --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c > +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c > @@ -2036,28 +2036,14 @@ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ > > static int SecIsInPMKIDList(struct adapter *Adapter, u8 *bssid) > { > - struct security_priv *psecuritypriv = &Adapter->securitypriv; > - int i = 0; > - > - do { > - if ((psecuritypriv->PMKIDList[i].bUsed) && > - (!memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN))) { > - break; > - } else { > - i++; > - /* continue; */ > - } > - > - } while (i < NUM_PMKID_CACHE); > - > - if (i == NUM_PMKID_CACHE) { > - i = -1;/* Could not find. */ > - } else { > - /* There is one Pre-Authentication Key for the specific BSSID. */ > - } > - > - return i; > + struct security_priv *p = &Adapter->securitypriv; > + int i; > > + for (i = 0; i < NUM_PMKID_CACHE; i++) > + if ((p->PMKIDList[i].bUsed) && > + (!memcmp(p->PMKIDList[i].Bssid, bssid, ETH_ALEN))) > + return i; > + return -1; > } > > /* */ > -- > 2.25.1 >