From patchwork Wed Apr 27 16:06:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Koschel X-Patchwork-Id: 1623118 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=ktlHSelC; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KpNzW2wSMz9s5V for ; Thu, 28 Apr 2022 02:11:35 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KpNzW2485z2xlF for ; Thu, 28 Apr 2022 02:11:35 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=ktlHSelC; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::636; helo=mail-ej1-x636.google.com; envelope-from=jakobkoschel@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=ktlHSelC; dkim-atps=neutral Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KpNtk6HGzz3bdF for ; Thu, 28 Apr 2022 02:07:26 +1000 (AEST) Received: by mail-ej1-x636.google.com with SMTP id l7so4396521ejn.2 for ; Wed, 27 Apr 2022 09:07:26 -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=245ljFOcK4bX9VP9+A9a3D1ngL6frQzTxV1ZAFIZRuk4NTfKuRfFAv84v91tbSZa/s qcuatUqtJT/K7gYtzCJOzznE6jp3L5RW+wBsQbo+IIdjKiAhTWBLLz178XBQymbGSB0z 2Zqm6qkj0Yxhnvd16moElKRSM4TRSwxnCwUDO1j9BZiIopR6GGiXQVp2DD/nV2kUtakb yV4NvrDCXUuXQ7zxTmplcAvJMoKrkoHS2H+MeLa2tjNW9G09shHO/2knx9tIJN3ccWP9 N2bGCvCOG7dZzyVKlDz2RfaWERqbg10kW+gMq2R8gY9v4ThjmH/MYBdWGifN8BvvvygR E0/A== X-Gm-Message-State: AOAM533+zKlK+rBQUJ2uPnFZ7I8YSDONB38Sb9VoY9GN6q0CRLcA9DFo vtuXFilH9zZQBG+eRaPWwVw= X-Google-Smtp-Source: ABdhPJyurPa9HKBRwXWzgBxCXBgmg7VG+zuYm1075t+N+Dlk6AGeeP2bXD9LJOaRPq4H7qfCukLjOQ== 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" 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 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Alexei Starovoitov , Eric Dumazet , Paul Mackerras , Ariel Elior , Florian Fainelli , Daniel Borkmann , Steen Hegelund , John Fastabend , Andrii Nakryiko , "Bos, H.J." , Jason Gunthorpe , linux-arm-kernel@lists.infradead.org, Martin Habets , Paolo Abeni , Vivien Didelot , Jiri Pirko , Arnd Bergmann , KP Singh , Christophe JAILLET , Jakob Koschel , Jakub Kicinski , Brian Johannesmeyer , Lars Povlsen , Colin Ian King , Manish Chopra , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, UNGLinuxDriver@microchip.com, Yonghong Song , Edward Cree , Casper Andersson , Xu Wang , Cristiano Giuffrida , bpf@vger.kernel.org, Vladimir Oltean , linuxppc-dev@lists.ozlabs.org, Martin KaFai Lau , Mike Rapoport Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 {