Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4722580ioa; Wed, 27 Apr 2022 09:40:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8rR7bpf8g5f8K2qmsRr7Rxg0r2S8GmkLVpBcvOMd1bdrtdTyn5X0VHC5bI4JfcxajKPfA X-Received: by 2002:a17:902:9887:b0:151:6e1c:7082 with SMTP id s7-20020a170902988700b001516e1c7082mr28782923plp.162.1651077619182; Wed, 27 Apr 2022 09:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651077619; cv=none; d=google.com; s=arc-20160816; b=dL/dFbc2wsZrBCS1nwhBS75IpPYpbxZHqwzZeFjKZTxxOnfpHP9OH/1VXi8AFLD0+t bm3e1tfvBQtGY3q+iloG7Qf5FwwKStGNl1kiU363O5XAuX3i43/xreop33ZmXXatU6cn GLIM64NjDTwlHEBw01Xd0r32QUp1lG69PPcgU/IMp2NaTnZSYJMhZo2BSrtkUolVK8UD A764tCqGLkHNg24NIS4DH/AHP6Uxk8Dp3SibITCH8SPl74haFhu0kiwRGvCFoazdaOhe iCLqO0Cw1n9uR1eeSNKNkUh7aaMw6q+1Ha+WMt0n5hs7Ho8Qev1PgZnHP5+ICPFNHGXF nujQ== 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=F5CWUEv1vjhsP5g+KRR0GTAJ+wUhkJAp7IXSJfTRMkw=; b=0VSTuTwMuNl3AprPiebR8HE7Bo806mjPuKiGvIy9jL8YID/vfRJVE51qdDpku1+h42 i3YB1MFdu9bB8PSVs/kPNXhcBWpHvx6fxxYkk56+N92QD13aRyNVP9k3J0zLSiEU27NH WwANk43d5Oq8w2JdCKsFi0FuFNlqCP0zhbRhu4hLVsAwSeIjGwcYx68LSt3Ofk8k9elH z+NaMFqr3RPY+UNc1jg4L+yyTyPOOVFZ/TLntI3HZ5lnh6OePl6PKhwB0QtFeldXMQum WgfeBLhv74jBtMHWk7C44d+hPWoR5BkbdNXO929Rdr+ZyzbIMb4d5+W9Cxdmugdnh9EN d3Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ktlHSelC; 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 i16-20020a17090a7e1000b001d26e95f5f5si1971739pjl.182.2022.04.27.09.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 09:40:19 -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=ktlHSelC; 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 315DCC42C9; Wed, 27 Apr 2022 09:09:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242326AbiD0QMy (ORCPT + 99 others); Wed, 27 Apr 2022 12:12:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242146AbiD0QL5 (ORCPT ); Wed, 27 Apr 2022 12:11:57 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DC0D49B49A; Wed, 27 Apr 2022 09:08:14 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id y3so4325892ejo.12; Wed, 27 Apr 2022 09:08:13 -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=F5CWUEv1vjhsP5g+KRR0GTAJ+wUhkJAp7IXSJfTRMkw=; b=ktlHSelCUdklQ1hSXzFqDWqmG9X1pagBePVGyp1NoHlyisKtGYRGKxHG0NbsK9ea2F bhUDjmLPsJix5VWIrG0R6YVTR0iVf7pKs5UKcBwfinw7buQ2xfs2xgXnxjP5uHwH1Fh5 031mQadxuy5wGLM7giP9IvPldFIqfXRNx2GcDZTenUfBHGcZUgyT+r+hd3BqcVI4j9t4 hA70ebcnZB/TVpR0t4sXya7kC/hDNsgNpQN45hCTVEIOJK0tJbe469jj+Ud6VdJnMayZ xGRq0JTxwhSO1bgIPan3wYqGsmhT3lH5TWc/hgRLeKyPzXBoXJJeUQtDzj9W3tyroZne 6WBA== 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=F5CWUEv1vjhsP5g+KRR0GTAJ+wUhkJAp7IXSJfTRMkw=; b=ts7R7FmsMoV7cfVke5KkzGrk53QxxoCzgOwqLUUWqhLgKqyRfLAxHzE8JZ/iqXoz/C 6S1EGHTSp27w3xuUvZGElFZh0ZmA8orhQvhCTdn+Yc6qgQ2bAep/V+7aH2sMnySdaORb ADEFiQLHRAfMPvx/3kne8YRV2P1zwgdDoJTmO8X4PjTop05UjHlacR/wOOO4vkfhDayT YdCdD4tbC4LEIAGH24DWGX1/8w9q4JrVwYykZTgboy/X2NH3sRx3gkL27j1rRjTyI/9R 8iMsKSRfyYESsBJa6iPKI7SzNnr3AHlGPZTeXozDKLQ99s2w/2PLyCG6JH1eEP3rsCSi pbNA== X-Gm-Message-State: AOAM530JA+3KZE9lvoqveAuBgfgDw7NE+MY1S7oo7R3qDEtFHlxRONZ7 2+DBA+nRyqnFH7Sw+dFZh3g= X-Received: by 2002:a17:907:c1e:b0:6f3:97f3:cb6b with SMTP id ga30-20020a1709070c1e00b006f397f3cb6bmr14922818ejc.80.1651075643582; Wed, 27 Apr 2022 09:07:23 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id n5-20020a170906378500b006efb4ab6f59sm6984098ejc.86.2022.04.27.09.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 09:07:23 -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 , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Casper Andersson , Jakob Koschel , Arnd Bergmann , Jason Gunthorpe , Christophe JAILLET , Colin Ian King , Eric Dumazet , Xu Wang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, bpf@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH net-next v5 07/18] net: dsa: Replace usage of found with dedicated list iterator variable Date: Wed, 27 Apr 2022 18:06:24 +0200 Message-Id: <20220427160635.420492-8-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220427160635.420492-1-jakobkoschel@gmail.com> References: <20220427160635.420492-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 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 Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- 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