Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp776236pxb; Tue, 12 Apr 2022 13:09:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn2ggkuD7o5UJ9BO0/xojUYrUGqUhUI/Bi/lmp6PpkSYBw4QUrb7rsyUfT8NfqZYd7Hpwz X-Received: by 2002:a65:5c48:0:b0:382:2c7:28e9 with SMTP id v8-20020a655c48000000b0038202c728e9mr32574389pgr.472.1649794165689; Tue, 12 Apr 2022 13:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649794165; cv=none; d=google.com; s=arc-20160816; b=cSXV785TfCUP9c++ls9wLt0tF0n6uUdEaIZypn/b/GCYPgMwKv9cZYoHzOBytKogyA 5Qh120ftGVl9ftstTlu8OxlgBJsxMAL4rmhLP4OdYpBOQuGbasPwKhtfQIW89bcNrDgJ U6R+dPlnMq9BMjFQLh0HUQy/HRNUjdBop7R/cE1T5qzY7fy8NN0xPcE18MI4GHVuEQUt pvyWjBJhcNclA26fM4nFDSm/Lgj12B/2OLNSvDB1ua7Us2xEEswUpgYuy69gcIB+mB6q RwOgMWqtTF54e6gWQQ8JYDkC+G5+ac9Z2ZE2T89Mbr3L1ulXXjnGz0bO/cJ/ET/V8W0b +KCg== 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=bjesYRddaQjIvj48cQfn6plcO8N9T/PEukfmlXXU3Z2ERy8ekPadImwBvx3jhh0Xzh PmY1bE5on7qkq5gugTvJni7T/Pmzv4dlwnT8OtPd0Osm5zlQSbm0sIUJ09u7+s7TbAb2 fls6c0YiKGFSU78aONzovXxoA+ajGdj43hDUMk7MuRHEoMe+zGdbRrDTPWFOPmPpRXTv 0xqiybU6QYQ6AGNCck+2vLuajFNFXHZbnktDIGk5ijrIU16dxHGu9QAJm3b6Jco9YJns k4038TtbkWZ06feF77GuLpUYzGL/BpAfHx3AoeXCMzqD/IyHVoKsQaRvzXB93z97Rvvv WxRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aoDWjjGv; 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 y17-20020a631811000000b00398ecc4479dsi3858555pgl.139.2022.04.12.13.09.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 13:09:25 -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=aoDWjjGv; 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 BD03571A0C; Tue, 12 Apr 2022 12:57:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232086AbiDLMKj (ORCPT + 99 others); Tue, 12 Apr 2022 08:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351592AbiDLMCk (ORCPT ); Tue, 12 Apr 2022 08:02:40 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BF8F238; Tue, 12 Apr 2022 03:59:02 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id bg10so36566885ejb.4; Tue, 12 Apr 2022 03:59:02 -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=aoDWjjGvs8H8yV45D3QuJ9H1mPo83/jIJGuOj1UpFJ8MPHj2wmJ2oNQyVYGjD9hwgT 0xZ8dHSNv/Oq9Aba8FmB5PoM8ATn2/vxZDDRV3BMeUZBWLJNX+fDyMt5OScKlN7uMbjA JmeAfahBug2GpC5HqsB/JKtqbKu99F75AQXzfj6BX+3A2gO1+1iQduJ1GtTYZeK3TSSW bxdDdDXK6vzKPZqYRf9rDKpMV/2PzZvu+MhpG5ge7Z9f7BUmwBeEF7GnWs6EOwRQisIw ll4crz3AHeFACf/yUyn4P59IiZ1EwuizU4cEmM00Zz+1Zte2KliFKeVpEiDvdS5g3qeJ PIVA== 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=ishqW/9raCd0aVooOaQxqBgH6a4gbgxhvXvejOnCoa5nkuk71bPun4flclx76xpkhf B/lXgdnK5tpt+NiAifxWRFMSZ+Sbjs5aY/DQTCWlZCMGxioX4ETg2heWWrY/sFSW2Plf 0FrzuxigRuG96uc7epVDVPq55g0mlh8+JL52exKgq9mLEq5ubqGXFmTlC5EX7gZbyegw MpEOclU0j5a5dSvgTaL9tyTB1Pe9ibVH02ccLwLpCOcu9bTNGepc2bz58N6U/gz0nMlh bek/FuIF1rD8u0T8CCB9bWt8TWdw9eq9yvRRkTwFSbzdunzrjNjLnjDT1pB/MIIoG8Wi etrQ== X-Gm-Message-State: AOAM530jj1SdtkalUJO6IZR5B7j0oUoFuIWkWg0Jq1G3OmFaox11gbxA 0CHOHaF22D4pWvuCOY/70dU= X-Received: by 2002:a17:907:72c7:b0:6e8:442c:1722 with SMTP id du7-20020a17090772c700b006e8442c1722mr20430201ejc.120.1649761141020; Tue, 12 Apr 2022 03:59:01 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id f1-20020a056402194100b00416b174987asm16986370edz.35.2022.04.12.03.58.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 03:59:00 -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 , Colin Ian King , Arnd Bergmann , Michael Walle , Christophe JAILLET , 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 v2 07/18] net: dsa: Replace usage of found with dedicated list iterator variable Date: Tue, 12 Apr 2022 12:58:19 +0200 Message-Id: <20220412105830.3495846-8-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220412105830.3495846-1-jakobkoschel@gmail.com> References: <20220412105830.3495846-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