Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3473629pxb; Mon, 4 Apr 2022 18:06:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydgWg0nzMSHXKYRqYJkcyc4pC38zanj470+Hv58cCUwpdIUXYcC7VPGGmCFQYt941XWbKi X-Received: by 2002:a17:902:e547:b0:156:c4e4:c0c7 with SMTP id n7-20020a170902e54700b00156c4e4c0c7mr945742plf.61.1649120762707; Mon, 04 Apr 2022 18:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649120762; cv=none; d=google.com; s=arc-20160816; b=q3b/rD1I01RNkTTrinQuEuhifWhhf+3lq7nKEMTw0/gJVbDsOjpTc/CoU451l8jT4b uHEcLGwdb6ythlgUPKp/NJVszpfTyxLzwbcbSFNGtLmvY8rJDHbYrG+xQYnfTajvg4Ej GQpPMhsPDf2WILU2M1BT2RSSduwgGVAj13hc/6qK51lFU+koFHuuIe85go6nYMFicJ1y Mi8K6ZbKcXfPOYstphYOX8rwt0e2epz3W1GURerHST2Fd0SWYoj/Qbyb7Rtr/gCG9r6C XXSDJd6P9h2vvNbsiSlKqL+jQwV7lFhrr0uywRL9XbT7TCLnyQfPj6YR3htgVPjwpdQp R3ZQ== 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=/81xVbmtDHf2WP/8R42ewco+CVAZUSyt+UDb78zyCNY=; b=rt84AbYkYU1q069+7/UrRisGE9NiRuF8KwcRmKM+1zH2oswF4g1y+SnO6mz6s41/1u WfAcSYt/3G0eqN4mt/LRyh9HLF94Ls0IZfGrCgjLdqQi0Oqtd19Pkv1LznWqbi9cWiCE EKOkCF2rEfSaod/TdYDVfhx3WLUs38TuAcvecHxz5aKptKaXqlR7dE4CGOC95i1/8Ztd 9Hgni8qeLGTl91meT9KzarZWvMG23uab1Ua4CdCjM99UsqLOEvkQzvKdakzmnWLAM62C d4qW5/46eVS92wncXH8rNJl/1F1/Rmp6HiUhN+OOdxBsXiME3CrrZOOvqaaW4woctxYe eH9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WaOiAQ9H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e7-20020a170903240700b00153ebb12a5dsi10199617plo.514.2022.04.04.18.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:06:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WaOiAQ9H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4A83B12658D; Mon, 4 Apr 2022 17:03:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243955AbiDDCsW (ORCPT + 99 others); Sun, 3 Apr 2022 22:48:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376936AbiDDCsV (ORCPT ); Sun, 3 Apr 2022 22:48:21 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B18C0387A7 for ; Sun, 3 Apr 2022 19:46:25 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id jo24so6508840qvb.5 for ; Sun, 03 Apr 2022 19:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/81xVbmtDHf2WP/8R42ewco+CVAZUSyt+UDb78zyCNY=; b=WaOiAQ9HUXu2dOsc71oDP61MKAQzGHcuv5C4UTqGyUnJupaRgsFAy47D3pKUuRBbxG c3G87jn1HfDnnGdGswOb53F2E8S0Tp9IAqATQN9hBsu4bJX3b79ZX1oJ5p4fm8mfj1bO ArAjJDXnGRWi5x96GFpZmSdbssHeDhHMz6JFfzdnUP06beIBV+lDCk8QpCsHvKxKn5ty 9H9/KV6kum8IVy+U+0FY/CAiCrrsnNDui7FqdHpvtjuSMuKOXNgj7gXyy2eoWFRVH0Us fM2PVIhsBvN2kxpA2/cbVgguAnRTlIZcuA/f09bV46s6fokwMULxsvfmIObSJ2AoRgZv gmqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/81xVbmtDHf2WP/8R42ewco+CVAZUSyt+UDb78zyCNY=; b=RYeKGgM3+SgA4ILYFUfMzd0rjp43TkTfxuYc7QOopAgnBzTMRy9TqQU0zx8Zf1+pqf dd6tpTZpdlWE7sT8jjMiEH6nerd/XaFQbILYsYEdbigQmxUcP3FHiqZahYa9glaX8Sms m4UANBtzsPRTtKQNnOjpdI3H0p1RgS1QCvI/1bRrVES9tBLmb85juD+QQnqcpE1OlMSI htzgO+/USekvRprLwPsn3uzxuVrjFKZWIOMNM+qHHDy/52KMUVgcFyBOQoQ1sKgPjp6H +QYHmP9ihd8Ixzr01YlEcWPoRAICvhq/P8CoMb5usqQ2a8M0Vww1KW0nz4soKcKAmJ3K TG5g== X-Gm-Message-State: AOAM532Xwml6GJh4PjzFWxlczdx1Zp+ucRED844s8BCE1e7sFZMLR1RE XOz4XVM2hBunLLxyMXE5Xwla2ampl3B/WAVZ X-Received: by 2002:ad4:5bc2:0:b0:443:901b:39a with SMTP id t2-20020ad45bc2000000b00443901b039amr17615989qvt.78.1649040384788; Sun, 03 Apr 2022 19:46:24 -0700 (PDT) Received: from euclid ([71.58.109.160]) by smtp.gmail.com with ESMTPSA id b13-20020ac85bcd000000b002e06856b04fsm7728729qtb.51.2022.04.03.19.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 19:46:24 -0700 (PDT) Date: Sun, 3 Apr 2022 22:46:15 -0400 From: Sevinj Aghayeva To: Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, outreachy@lists.linux.dev Cc: Larry Finger , Phillip Potter Subject: Re: [PATCH v2] staging: r8188eu: simplify control flow Message-ID: <20220404024615.GA410484@euclid> References: <20220403164250.GA371601@euclid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220403164250.GA371601@euclid> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 My apologies for forgetting to Cc the maintainers! Added them now. On Sun, Apr 03, 2022 at 12:42:50PM -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 > --- > > v1 -> v2: Put the conditional in a single line to avoid checkpatch > complaint. > > drivers/staging/r8188eu/core/rtw_mlme.c | 25 ++++++------------------- > 1 file changed, 6 insertions(+), 19 deletions(-) > > diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c > index f94b1536a177..cddd8ab80236 100644 > --- a/drivers/staging/r8188eu/core/rtw_mlme.c > +++ b/drivers/staging/r8188eu/core/rtw_mlme.c > @@ -1637,26 +1637,13 @@ 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); > + struct security_priv *p = &Adapter->securitypriv; > + int i; > > - if (i == NUM_PMKID_CACHE) { > - i = -1;/* Could not find. */ > - } else { > - /* There is one Pre-Authentication Key for the specific BSSID. */ > - } > - return 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 >