From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F20E2C433F5 for ; Fri, 15 Apr 2022 16:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kxVibcDPzs+fz4U/b1YoUlcZIr334zvzNEvK0jHQP0A=; b=uhkVP7NOhCw4D6 C0WhfEvMcixfmkWNS/2TSMBACGabYlQ1UQJfS+Rp/fqR+afznKDzCnn3Fw2wpj3qKNBsiySHmnyfJ md4e6gksXU8VNxOPuhOdCysqgE/mYbxqoZ/NS6H5ozq573uhNRGRrEvwdUVu4DLtFKkDQ3QrDONtI WRbUt76hSc9bXef9+/1DH+z1wU4zVHDokz2zbH49c7puOV143ZSZOhzVcpMvaoPhRNx13RbsiC01d q4lgF8aJuV3O4eSs5AYnJCXJFZ7vNc+m2LYR5Tuqam1Mnyk7sYXXYJ/PcL7LCJIuP/tEFQ1sJe/bQ dXGEo6Ny7aIDz9JgIbNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfOeF-00AsG2-Nj; Fri, 15 Apr 2022 16:18:16 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfORQ-00AmgA-RV for linux-arm-kernel@lists.infradead.org; Fri, 15 Apr 2022 16:05:10 +0000 Received: by mail-ej1-x636.google.com with SMTP id r13so16063172ejd.5 for ; Fri, 15 Apr 2022 09:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=112dwm8QpeyoKYHzXDlM/vsE5hIZxIAtes3nuwV/SSo=; b=q1bzqzL3lBdyltYHc9DTIT5JLPdLODWLZph8x8M5S6Lrx38YGPco66753ypyqSZHdS TsBVCJ5EpLAbAmZd7rn35rz5+5MFo5cmcPhwTg2EsuyzzljP5OF0i5quSN5Bq79dJupT XxChUcD2MsVarL7yLizfAjcN3B0NTqgueTBK61H9jo+fIJq2L7zfnVfyEtuLdKfBrIhL iDzvx73Aqc0XvRiY1AXXQbSKFoZMT0Gp0iczLfr/jN0opuxhWCDc6rZaQadXhtc1zVzT V6fOjszCUEV1CJPEyDoo3WVMYNJOQYRIdd2ngW2MNMxLobrauU5wyg1fn/2XkaL6GqdW ZQzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=112dwm8QpeyoKYHzXDlM/vsE5hIZxIAtes3nuwV/SSo=; b=ALf2g2mKhIahxsqdCMkuEhFotBwYtLqizQ8I6bdrSxDMEm9OvsiuLyLSz43tP4hvRX Yp7sJ+qQKy4wwzOKnr/IcqsS1ztxQts/d+71y7Jf+Pphgb3vFDLqg87q12E/Fdy08qiJ kutiNnmVfn2rRXDIVvopb55UIbTKWfcjVja4xWsvxNYjkSsGX0fVI7QZT/gKLuD4XTRu d2PsOtqqiOX8BoS3wtxV55G08BSpxHtyPf8ax1GI9eodaT4i8XayNeuQPzICxnQW9Xik hNQ9yZtyqdvg9ZMkhZ6ouRpzEuicPVMz9R+/8p9Av20aGNBjOnYw0A/DqzjBbCDIDstK 9aeA== X-Gm-Message-State: AOAM530puV5rys9JN2J/ruMwvLbPmEAnErZMqf1Rfg3BsseF6lb3PZ9p N5e60e+BQC3fpKol3aO+RDI= X-Google-Smtp-Source: ABdhPJw48aM/ILhX7ieEo4E/2JT/l4q8QZCfn54tMQSw+A5qviAhPCWJlSaz9aHJH2xpZA3vw595cw== X-Received: by 2002:a17:907:6e88:b0:6da:8f01:7a8f with SMTP id sh8-20020a1709076e8800b006da8f017a8fmr6648623ejc.619.1650038696267; Fri, 15 Apr 2022 09:04:56 -0700 (PDT) Received: from skbuf ([188.26.57.45]) by smtp.gmail.com with ESMTPSA id r18-20020a05640251d200b0041d1600ab09sm3036190edd.54.2022.04.15.09.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 09:04:55 -0700 (PDT) Date: Fri, 15 Apr 2022 19:04:52 +0300 From: Vladimir Oltean To: Jakob Koschel Cc: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Vivien Didelot , Florian Fainelli , 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 , Bjarni Jonasson , Christophe JAILLET , Arnd Bergmann , 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: Re: [PATCH net-next v4 07/18] net: dsa: Replace usage of found with dedicated list iterator variable Message-ID: <20220415160452.z4m4j3sulcteqggs@skbuf> References: <20220415122947.2754662-1-jakobkoschel@gmail.com> <20220415122947.2754662-8-jakobkoschel@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220415122947.2754662-8-jakobkoschel@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220415_090500_940690_B34FD93C X-CRM114-Status: GOOD ( 22.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 15, 2022 at 02:29:36PM +0200, Jakob Koschel wrote: > 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 > --- I absolutely hate the robotic commit message, but the change looks like it works, so: Reviewed-by: Vladimir Oltean > 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 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel