Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3522607pxb; Mon, 4 Apr 2022 19:48:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFXtrpAiC/OgP8lXT4edW70cb/YxhXHvgW8rbjH/i9vsYwn4hLG9weHF9ih89s0QmPRXDB X-Received: by 2002:a63:44f:0:b0:385:fa8a:1889 with SMTP id 76-20020a63044f000000b00385fa8a1889mr1032881pge.160.1649126902695; Mon, 04 Apr 2022 19:48:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649126902; cv=none; d=google.com; s=arc-20160816; b=ttQgWLR77jSKYI0poQSu2SpIQoRI95vHjAsq2mvBeu/t9pUDry541xL0llFxxxoPb3 V4lWMDqz1v8pWyXVE2XWNj/5B5T/+uDQ/xqjPhrn89GZYz2bgCrnmq1PsI+kpINkawIn fz2zcp598/3ChoMuzpj0Qcv2aExptggHAg2qSUYI4hD5Mzbwk7YTH4cMICE+3zuSrqhO xCEsOF4Ov1E+ogdgLY31TbjlduFgeJ/OAd32+XiXzmZ19XYzZgcsuK1UfeEYk1nykvng xBJqTsjdG4yjmNWSDpjJaZ8CbknqkJxycHPj2f7yf2KTqbrAEj0WsOQZla8chpknsGku axJw== 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=wsLsGGE6HZAHiQo4OADVHc+WEijVYyrts9GPXNxbj+Q=; b=K7bqjOYi4ae77Fo7RLAWSNTwQGrT2TqZb8coelMeKMdO2zzcx+YaphT0s6TZ/PI5XE Ky3Wp88X8yVtlxkpEnHN3W04f0tFSh0qyMGZmtvdbkvffPAiEK7icsDhpYBymuvKJecO G79SUbgbNQ7QriOK6KvMmB97e7DWwZOpKo+P3D/pvR3Qje9ks+1Af/GsrZ5U4SBjZ9ZJ 3S2vvnQI2uNUvo8fhKRiG4zQPbxYHyQ+ZS9o35dWHYUEvy+b19+IM/s5edYnF4C+95oK YRFsrNGsymKrvgyVbCbrxftRa0Qc9JemfVU4ynvNZgwL3lmpme+MbJJE2RTJElNkmc21 ftGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nVEdY9wT; 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 h34-20020a631222000000b003816043efd3si10680187pgl.456.2022.04.04.19.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:48:22 -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=nVEdY9wT; 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 879CE3F1311; Mon, 4 Apr 2022 18:11:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376943AbiDDCtm (ORCPT + 99 others); Sun, 3 Apr 2022 22:49:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354115AbiDDCtl (ORCPT ); Sun, 3 Apr 2022 22:49:41 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89BEF344D5 for ; Sun, 3 Apr 2022 19:47:46 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id h196so6613733qke.12 for ; Sun, 03 Apr 2022 19:47:46 -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=wsLsGGE6HZAHiQo4OADVHc+WEijVYyrts9GPXNxbj+Q=; b=nVEdY9wTdUl2M5C0fwaRvMdn8h0o+pbl2zp8lwgOZR1TDX7QgQOIxfoMPWtm11f34e kYRaVkwW+mUexHIJYZv3aofkqyIXaBSeyDa043A+f0XzGna93/SdyIMo78ZheATCZC6b FBIA2YUOijW2SdmMpRssDvOmVv9c+A2oGkxtNAtHZmF07psOZVIrNQWJW6MXODKSRfS9 RJJPEdbyUObh9e7p3Lf57zOHBWMT5gAGKptTqIxC2r7+q7r+hE3pkQp9wygl9baOagvY n40ZZMmzDdmcG3/E+Ox73dOKItrvwmKnJPZ+xxoZ3C+llWOHkiwocqNVEUkZCcinNvbf 45Ng== 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=wsLsGGE6HZAHiQo4OADVHc+WEijVYyrts9GPXNxbj+Q=; b=0YV2/nuHIRJkAOiDoYRcUjOU3rILZYbydnwPfXzLqLJqa+P7eHXeQIFmEkYtKT+XLv 6GWsVRr7aMz413gnfNRzZcAhdSaVLKPYCuZpA0rIjPIsCshRJC+SEmRKLevIbAypqyte dyq/8p/+Qrhr/0sI6JoEm1rUNYgvYODPL8+ynTTRqDZXyJjiIrH9J4dyAkEg7LAGB0PT 67wcrkog3WKjWed2wKjIDkgAE/GuK3dTFCZKioxwhyfMMZeVdvONuMpIpaW9Gpv0sqAC yBMpi8e7aqrMTOuhBqxRjZurlv9fKBRg9JcCzcVoGNDlJ9pqFR/7Z/0+G6dNPix/DIVX iYbQ== X-Gm-Message-State: AOAM533EJQtUebD84WSbQv8q38sIR1JgQWxjjcEYni76DOi19V2sj/3u eBY6RiIEGCd823f6XfwK/wCsPpJQjLTwrbJN X-Received: by 2002:a05:620a:40d5:b0:67d:f2cb:a38c with SMTP id g21-20020a05620a40d500b0067df2cba38cmr12643183qko.197.1649040465623; Sun, 03 Apr 2022 19:47:45 -0700 (PDT) Received: from euclid ([71.58.109.160]) by smtp.gmail.com with ESMTPSA id n9-20020a05622a11c900b002e1c508ba41sm7326067qtk.19.2022.04.03.19.47.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 19:47:45 -0700 (PDT) Date: Sun, 3 Apr 2022 22:47:38 -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 , Florian Schilhabel Subject: Re: [PATCH] staging: rtl8712: simplify control flow Message-ID: <20220404024738.GB410484@euclid> References: <20220403165325.GA374638@euclid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220403165325.GA374638@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! Adding them now. On Sun, Apr 03, 2022 at 12:53:25PM -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 > --- > drivers/staging/rtl8712/rtl871x_mlme.c | 25 ++++++------------------- > 1 file changed, 6 insertions(+), 19 deletions(-) > > diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c > index 92b7c9c07df6..b93b33092932 100644 > --- a/drivers/staging/rtl8712/rtl871x_mlme.c > +++ b/drivers/staging/rtl8712/rtl871x_mlme.c > @@ -1284,26 +1284,13 @@ int r8712_restruct_wmm_ie(struct _adapter *adapter, u8 *in_ie, u8 *out_ie, > */ > 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; > - i++; > - > - } 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; > } > > sint r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie, > -- > 2.25.1 >