Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3359784pxb; Mon, 4 Apr 2022 14:37:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzf8UGPehxkQbzVVKWccvO6rVTz1iLNcD1AJEm+SCBBrmRuwT2O9Pq5CyrL7olWhLv3QqXN X-Received: by 2002:a63:dc53:0:b0:381:7f41:3a2d with SMTP id f19-20020a63dc53000000b003817f413a2dmr172050pgj.126.1649108277199; Mon, 04 Apr 2022 14:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649108277; cv=none; d=google.com; s=arc-20160816; b=i2ZFevbCaw/2jDCjpzfBm2w9aHZRg43xJkOmVYl3tf6R0LCsqzsBP9EzDyf7XYWDxc DW+SVjBxOlwU1+yjNsKwB73swsFWXsMw7nSCXEjJ7cZ6Fsk9mBIaTNeD0Wl8yQceS3eS 9NguAJZPWMvN+iGBVOGRQ2lv7/9XB122dqzr43r/n+vW6EbXhXOvl7VjloEa2JYQND72 iAIzU08qE38iCbFqhyrluqjRUBXzX6NIgXJLi6u1s1F0pKsdV1pP3E0PnbLdiLWY1bwM 2mLbEStvjY/PjJJDueww28ka24ESt34FlhJxpb64m9OudwQPFRgXItzcWNZ6NgFdfR7d cOKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hxdxKUF/RSHkGuapqH+jXfJnqPmLO0jdDbBsgbNKCbY=; b=Rr2KBjFAg1o4G42fUnSp+6MzMq5PP0/2C9iRagjazuBvbC+1CeK5d4zsDqdym0n1AG KGJMze0iQxDwKt+xNhs4NUK54Edmb2TQH/0JH6h5acw+9d49OqqyNTV/kwTj+3eT2224 i4OTQr9r3p2JVwZ8BvdWbGBjrCIJT7qDKdytlRntJAbwg6KjnoyW+TMbuXASRjCcCLOu IjE1CHxv3zj5YevesHW6laU23JXLEvCrRPjEZyy9lNdyyB1xkYvsjIw30fKUsc2K5prD R36gACVupSNAVd9fKtI+WG2+DwHXYHCEHcuVE6LCYAFEBrXXS9NSbOWmW+8fN23NMqux P6og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ds4iHXgj; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a170903120700b00153b2d165c6si12391784plh.462.2022.04.04.14.37.29; Mon, 04 Apr 2022 14:37:57 -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=@gmail.com header.s=20210112 header.b=Ds4iHXgj; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355185AbiDCQOw (ORCPT + 99 others); Sun, 3 Apr 2022 12:14:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242688AbiDCQOu (ORCPT ); Sun, 3 Apr 2022 12:14:50 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EEAA2613F for ; Sun, 3 Apr 2022 09:12:56 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id q14so9982708ljc.12 for ; Sun, 03 Apr 2022 09:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hxdxKUF/RSHkGuapqH+jXfJnqPmLO0jdDbBsgbNKCbY=; b=Ds4iHXgjTCZfVEy93RSwlwI+SDuIks25SRaKMs+hkkxCZnfgzcSEl3Lu2gfVuXr7Us 7T/cQ9u2F0RaGR8LXF5CjDgdaMDsMEHlx0HmtahTc1a0Oa1Ls5YGFxdJX5hUFHY8M23R x3ed+wt018Tl0i+dgbjFoM8bVwKW1OQ4mAqJd7YMWaE4sCGXDeNUh+qj3kf5oLRKbyFO v3kC9kWUmyyuq4YULcDpyFdlgEVE5P6emem74FXA2hqwKB8ZRabDnSD9n7XQpBEancrY jlvt245X0z3Bc3uROA/MaC+4zu0UmT9FTVsW3upJ1qyJqxmiln72pQ2CIsfyHC7fK2vH IrIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hxdxKUF/RSHkGuapqH+jXfJnqPmLO0jdDbBsgbNKCbY=; b=bT9e2V0o3YXoFO0WwFm1FwgSjJBGTjlmGlMAcAxzoTP4Hrw5tIg6i05qW2MJPRMEKB kczJN0DUhdN8W+JiPy6oZoI8OzzwVaqDwdX+tlpntdJjA8v9RFs/EtoIjqjpGbOIsXXK Q71cvXCNVZti+rKALa3e0jvJnzLuOlbkZXeeTaZ01H944qTs84fkB9VqknriscWwJZJb Kq8uHhE2jAxMISQP9cDed8b8kd5drA4x2gQUJ6Bo45sj0d6C2td3SYlgr1Oebo2ZckvL PFUyUCFWB/nj8B3P7wOLhrXmj+iobh5uy84jefeY7xbv0gM3+AaJIXYKv8ZbeX+7KIPs +uQQ== X-Gm-Message-State: AOAM532pnAlmmIa9BCXgs/N2UANuS4h2OPxyApLYW1WK3LW9fDnlRoaW eCMJSyuRPGrZNsaIKf3n6zI2GMwCPPJqtj8W+2o= X-Received: by 2002:a05:651c:1543:b0:249:a2bd:4a74 with SMTP id y3-20020a05651c154300b00249a2bd4a74mr19161414ljp.375.1649002374610; Sun, 03 Apr 2022 09:12:54 -0700 (PDT) MIME-Version: 1.0 References: <20220403155111.GA333187@euclid> In-Reply-To: From: Sevinj Aghayeva Date: Sun, 3 Apr 2022 12:12:43 -0400 Message-ID: Subject: Re: [PATCH] staging: r8188eu: simplify control flow To: Pavel Skripkin Cc: Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, outreachy@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 Hi Pavel, On Sun, Apr 3, 2022 at 11:59 AM Pavel Skripkin wrote: > > Hi Sevinj, > > On 4/3/22 18:51, 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 > > --- > > [code snip] > > > + 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; > > } > > > > /* */ > > Looks good, but let's not introduce new checkpatch issue: > > CHECK: Alignment should match open parenthesis > #62: FILE: drivers/staging/r8188eu/core/rtw_mlme.c:1645: > + if ((p->PMKIDList[i].bUsed) && > + (!memcmp(p->PMKIDList[i].Bssid, bssid, ETH_ALEN))) Thanks for catching this. I wasn't seeing this in my checkpatch output, and after some digging, I could reproduce it with --strict option. I think the tutorial at https://kernelnewbies.org/PatchPhilosophy doesn't mention this option, so perhaps we should update it?! > > > > > With regards, > Pavel Skripkin -- Sevinj.Aghayeva