Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3505821pxb; Mon, 4 Apr 2022 19:09:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRHfpc7uxlScaMe1l70mJ9Wmf50ugjTSmdeAsY3qh0ETg8m8Q08skmNyEY7DoVtOJbdKsu X-Received: by 2002:a63:ad45:0:b0:382:2459:5bc6 with SMTP id y5-20020a63ad45000000b0038224595bc6mr970310pgo.474.1649124569742; Mon, 04 Apr 2022 19:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649124569; cv=none; d=google.com; s=arc-20160816; b=LzIzbv2JL3oOjm2X1DTkzBxy1s3k50WIF7WRiBlwsumrNBUm+IiyFpGzGO/c0K0yPP tsFHwCx/b5Kj/I11q/FXEOyrP7SeFoYsi43SZjOkdLUI2WahMURLX47jR1So5Dttx0b3 0tLsdULtyxhq26eIIs6S1uq0VbB/M1BQtWKnwBpqA5Y0Ihzxa5HAvFuUlNLFgQgStPxj 5VBQ71FvulfZndmCaG0aG5j7ltdCJKQ+2AULO06IKrZ5OdbGdDqqjdWZZ5NxwQ/UfltS 4TRr/lSp+YeVBRRldOELvK1oLMBAoBMyJkx+jk9nYGBsyzAgQbLHy0tiGMXvATCTjZ0s ewZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date:dkim-signature; bh=HgjUYAn5zy8VBzEx1URiJxTFwjP91TAGQJx9luH2liI=; b=0KNEYsRbxySsIUuugxAMYaRWZkmCc9mbUU9glpixowQ4sAqYD6FTTaSVppqZ4/r4Ku toFq4NWMbwma8kZTx6wIs6RxIS7gpczxRWGvm0dBR2LhgEbuZk7Lrn7wXk2b8lAL436E JS4i3yI6+uspqHAbrVeZCHQqpA21n0PP/rAZE7NaneUB3ogmT62QhffpUYzJwLoUaNy8 euIvDM+NyuzrJiecnDQ7w4xBIqW/sC8M6v3NECp9QsqvsSZ1MdGC6KD2CHvqThMJKoqN rN3P6auCmT2qzxg1azLEqgwM1fCuDddHWD54o659vfqPbkQEaochNcZ1+BwodeIU33M2 2bqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="N68qT/cl"; 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 b22-20020a631b16000000b003816043eeffsi13010042pgb.244.2022.04.04.19.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:09:29 -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="N68qT/cl"; 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 8A79E82303; Mon, 4 Apr 2022 17:32:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359506AbiDCQzs (ORCPT + 99 others); Sun, 3 Apr 2022 12:55:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359579AbiDCQz0 (ORCPT ); Sun, 3 Apr 2022 12:55:26 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BD2ABCBD for ; Sun, 3 Apr 2022 09:53:30 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id g8so5959026qke.2 for ; Sun, 03 Apr 2022 09:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=HgjUYAn5zy8VBzEx1URiJxTFwjP91TAGQJx9luH2liI=; b=N68qT/clnRGCwOqBfHQ1AlXyxPbosDIBo8Znf5RG+rBhSLumUBaKqpJhPz4lvzOJNt jvAjAG9mZzc5WjH8kf07ZKHmpBO4pnZFpGX12lE5VKQf0bmGKSL8O4ck5+AEBNL9SpYW u+G9/Z9pPlkA/f4CIn349klUwzNwyqfT7oWb7IEKc75en/nK8Noq01FsiYxHqE5Ors7H zrXPIV2dlptNgKv8D4HVEnADJl7oCf7Cgfa0n5maEhBS991BvzTTLQ2Xbs6/bd9gIvDj Mb8ym5wtcQF1NT/BKbt9Kxt9wl00XYZO9ZfmlOwcNjmKVgggVebryqp/vy0Y7NOXlzQc FSBw== 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:subject:message-id:mime-version :content-disposition; bh=HgjUYAn5zy8VBzEx1URiJxTFwjP91TAGQJx9luH2liI=; b=SIjS002jL2AOPn9s52DRIvoBJZKPMPUws4v9DGscj8CELWkhU1aIcMsfMOJgexAleW ABPd5DPw/2fny5YmVuXC8XSSfoqQCUgiWQwnk8fyZokTaOKca1/sGlUR77BxzdCZhnE+ OHuaCwDRLHtq0/EtreLEfcwYAW5ZbF8uBd+FP9+UY1ladL2RRGhZnEPY6gDlwq+9yA+b Vo6I7XQRqEHviftBf545FQ3q1Jo3EG8ok8kbyhe77N5c9V1RSRsyFowiJEdXpK9Tflt5 lSHawRLUHpF8dpHwFpZrEPHQeHCLD+Z4JI6+pB7Z7jY9uD0VK7O4w15ARD13AvjjajlW e8MQ== X-Gm-Message-State: AOAM531+aOI8ns9pUzvSLWLi2DO4prADCnt202bLkzqq7Vvni9+0TJsV ncanEN3SUKk1SJEWJ+Jj3Ohn+dBAs8xhdw== X-Received: by 2002:a37:b906:0:b0:67e:4497:c3cc with SMTP id j6-20020a37b906000000b0067e4497c3ccmr11943914qkf.260.1649004809714; Sun, 03 Apr 2022 09:53:29 -0700 (PDT) Received: from euclid ([71.58.109.160]) by smtp.gmail.com with ESMTPSA id 78-20020a370551000000b0067e3a58c090sm4771733qkf.82.2022.04.03.09.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 09:53:29 -0700 (PDT) Date: Sun, 3 Apr 2022 12:53:25 -0400 From: Sevinj Aghayeva To: Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, outreachy@lists.linux.dev Subject: [PATCH] staging: rtl8712: simplify control flow Message-ID: <20220403165325.GA374638@euclid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 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