Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp43409pxh; Thu, 7 Apr 2022 13:26:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhcGLpq9fiQalHzgwUiysTwO5x7YsEy5eRSMYuGLx+iHZz9LIW1hwdS5SmRAuAPqb5XZ2K X-Received: by 2002:a05:6a00:218a:b0:4fd:f7a4:d4ac with SMTP id h10-20020a056a00218a00b004fdf7a4d4acmr15887141pfi.40.1649363213068; Thu, 07 Apr 2022 13:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649363213; cv=none; d=google.com; s=arc-20160816; b=zY8kdtlylPD+JXeLxzsRYtYmms+xDioRIrV8C+A5fs5pAh+hij+0GILcQSIjb9yDld tp6H1SP6/dzykIpLTbAq7MWNXl+iY14G+mxF9jLr5lcuLf7itv0rFwHUTZzOumB0jfDm g1KFtvqRM8eHO8EKfg3y7dc2fgSZIFRm1nTvjS0JIJNhI9qWIG3aBQ/e/Ul6liIDT+ue nsbP7X/O0H+dVCL89In8iWbUNxzETRH6rPnCcNuE3/pSQehdbetJCcNOgqSX3T65LwHL BeuthO2YjkBlqXhGuS++42TIHLw63pvaoHbjAYCOs0Bq/6vhHgqD3AxCKR+NXFSloalz +YOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lwv0OP8MEFPtBT1zINZmdonMBn1rL8mDzX3cu0httRY=; b=gcfPvWbudmp13bVyGKL86o+wRekLxtztnzFkIRn5ilXUeDmj6bBZy3rY/m3qb0yEWR rBvmrC8IBiiRA8YUic4VvSN4XNyIGYCjaAlbOhBOPfC/MhTRK2bfg4igANuo8o7PnF17 hyT7JxP/KkUqncwqEtpK/FfuUsA4jRBEzy8PS3kzBtp8m1hVcjaQ5+flDe+Oy9mV60EN 1Z1AfjgCCYX+K3nFIhF/uSEz1xl4xe3iyGVFhU7yyAt7ZWLMw4ENZb0NJ+ktxuwFIYeX gYIR/NJfD852vBUV5mzrsVFtgYwwOtzbNsydWHXfK+7KuObEdsUWujNeM+ajsc/fFZkQ ijCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SLDwl8ec; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id bh14-20020a056a02020e00b0039924bbc9f5si13734857pgb.262.2022.04.07.13.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:26:53 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SLDwl8ec; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 6572F1E8CDE; Thu, 7 Apr 2022 12:41:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244315AbiDGKdh (ORCPT + 99 others); Thu, 7 Apr 2022 06:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244278AbiDGKdH (ORCPT ); Thu, 7 Apr 2022 06:33:07 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41DAC81191; Thu, 7 Apr 2022 03:31:07 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id l7so4472635ejn.2; Thu, 07 Apr 2022 03:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lwv0OP8MEFPtBT1zINZmdonMBn1rL8mDzX3cu0httRY=; b=SLDwl8ec7EHCqXB62Qaclx9H9Z03BrVF3nvNnoga4I5VZfbPOpFyWx7hdMyKpLk0L5 z3nfcLccBKtNsEjzoUA6b5Pu+fz9792/cEu1a27jasM7TUKJWd/x+wWRJyaEVG4FdaRV /7s7hdtpwXHZct226CzucQgj6TqxEzUFHbtZr/VonFHBffWW79CYktfmQ9cipx2/pzx9 lyAro41HtSPSzqW3d8BPaCWe0xbIcwf+6tOYAWs0w9/jXvCXf8/8ygF0xw4p2xVw0OaZ UK11nbosIluBfvkigCP3YQVGh5ttPc7NasebUN3VfoUdIN1TxlNQODRBfjH6mGpbozZ9 xB9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lwv0OP8MEFPtBT1zINZmdonMBn1rL8mDzX3cu0httRY=; b=g9WszYj/wG9/QKpE+vGtjL/KuAXuo9nBoKkBimgXVJe5ERuUUZdZfkBtVlWiWC50Jq CJpEVJN3zxxxCe1xdZovThgPGuHXxkfkb9/XavZXsbUuLmKL5qTythjkMgBKhvYX7DAW Y72fYePjL1XTCL1LwKh0Ftol5pRQ9z2cw0AIRvRue9RJUl3dFGlxxZeCcD3J1CMUIfoh O4aZTUigWGI4NRm7R/M0j7h7JZZnoklwmCwps6hR2LDG/Lh29Tq3nFeoyx+RYV9WEAxO KPRmDXp9/+TI+MA+SVWrMitfvyJBLbnZ8BMrDmvPNdK95lnH71aaNIMepmrHuChg8Dd8 Aq8A== X-Gm-Message-State: AOAM531ZIjfGtEiTN5Y1nVX45cbn44gZJSm1akloRjcfKYfU8hQ8kswU +y2m3b+KsuSGHNXWH3fUnBc= X-Received: by 2002:a17:906:6a05:b0:6e7:f5c8:1d55 with SMTP id qw5-20020a1709066a0500b006e7f5c81d55mr12571266ejc.443.1649327465747; Thu, 07 Apr 2022 03:31:05 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id c5-20020a170906d18500b006ce371f09d4sm7413573ejz.57.2022.04.07.03.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 03:31:05 -0700 (PDT) From: Jakob Koschel To: "David S. Miller" Cc: Jakub Kicinski , Paolo Abeni , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Ariel Elior , Manish Chopra , Edward Cree , Martin Habets , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Jiri Pirko , Casper Andersson , Bjarni Jonasson , Jakob Koschel , Colin Ian King , Michael Walle , Christophe JAILLET , Arnd Bergmann , Eric Dumazet , Di Zhu , Xu Wang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH net-next 04/15] net: dsa: Replace usage of found with dedicated list iterator variable Date: Thu, 7 Apr 2022 12:28:49 +0200 Message-Id: <20220407102900.3086255-5-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220407102900.3086255-1-jakobkoschel@gmail.com> References: <20220407102900.3086255-1-jakobkoschel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body. To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable instead of a found boolean [1]. This removes the need to use a found variable and simply checking if the variable was set, can determine if the break/goto was hit. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel --- net/dsa/dsa.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 89c6c86e746f..645522c4dd4a 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -112,22 +112,21 @@ const struct dsa_device_ops *dsa_find_tagger_by_name(const char *buf) const struct dsa_device_ops *dsa_tag_driver_get(int tag_protocol) { - struct dsa_tag_driver *dsa_tag_driver; + struct dsa_tag_driver *dsa_tag_driver = NULL, *iter; const struct dsa_device_ops *ops; - bool found = false; request_module("%s%d", DSA_TAG_DRIVER_ALIAS, tag_protocol); mutex_lock(&dsa_tag_drivers_lock); - list_for_each_entry(dsa_tag_driver, &dsa_tag_drivers_list, list) { - ops = dsa_tag_driver->ops; + list_for_each_entry(iter, &dsa_tag_drivers_list, list) { + ops = iter->ops; if (ops->proto == tag_protocol) { - found = true; + dsa_tag_driver = iter; break; } } - if (found) { + if (dsa_tag_driver) { if (!try_module_get(dsa_tag_driver->owner)) ops = ERR_PTR(-ENOPROTOOPT); } else { -- 2.25.1