Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2446827pxb; Sun, 17 Apr 2022 23:32:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKglY5iWp/+RwFpyDxK4drIAJMXZprq0x+wTt6K7LoYCkkkoZhYHW1zf92GxBBRYn+EwHI X-Received: by 2002:aa7:d543:0:b0:416:13eb:6fec with SMTP id u3-20020aa7d543000000b0041613eb6fecmr10973526edr.348.1650263541547; Sun, 17 Apr 2022 23:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650263541; cv=none; d=google.com; s=arc-20160816; b=S2b9fcjMoKx5TH4NHHHjeS+e1fREA+Wac7pFiyQtFfCY/Japn5dyuXswE6uT+g3N01 uk/39z6bG0qCTOCxOlBivlCZ1WUT9m4Wp9aJ5mfFjHn99FkI7yBBRrs9l5ymaV4X3uLf EnXt5q/ThDvDaKz950V/ggVorNsFE6TgQHyD6D9zMg8XjAtiLBbTf8bSeyeCgBJjTsV9 t+UcpiVFpJE1cIWwoPPFjFW3X8bE9BvQxKOuN4GZynZ9DCeIgMplKh+A2g8vfj2Tsh9G oupdSGsUJkwHB0sZMWxWN8MRf2CIEP+vZgV6hG2CEJKuJ4URX5jtVT0QsfBf845C1ptz aiOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=5Xp410sF+GGnn+k64Aem0Bq20nF9FpJBZpOgxpPYfOM=; b=MsZoeYVhw73jzCgZKP5iFHUs8WDfXufsICuW7wJxg6qGlUQ4tRed2bgFbkgXRdQTfQ RLXKeiP/bpBharONNaB5fFMyfCjsr9UtcyP6AdKD+Jxul5H139zNYSFZ9Hc72VH8WJ19 Af00Og2xrM0Dh753ajyIo+tpk+RYq0imfG/T8+M9OaJOq53gKBKoPQpv/cFaTwSyMyNi fs0DZaQtgKDXZByWuHtLmN4mB76HP1tDmQV3TpYWHI2ifyztt341ExaW4A9RkZkzlSS4 geZYlppPwQRb+URe3zLOnrsFn1gPqTEua8beCZmHM3uo4jzz7Pnn6doh77lS9cZogjkk U8tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=M84mj+tp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ie21-20020a170906df1500b006e892eb4a2esi5005716ejc.1008.2022.04.17.23.31.58; Sun, 17 Apr 2022 23:32:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=M84mj+tp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230466AbiDPTms (ORCPT + 99 others); Sat, 16 Apr 2022 15:42:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232908AbiDPTmh (ORCPT ); Sat, 16 Apr 2022 15:42:37 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF53033342; Sat, 16 Apr 2022 12:40:04 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id t12so9538305pll.7; Sat, 16 Apr 2022 12:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=5Xp410sF+GGnn+k64Aem0Bq20nF9FpJBZpOgxpPYfOM=; b=M84mj+tp2XRkS5+g1JBD/J8nfprjEP9Xx2ytgoZNWcMBTTP42X6ZRSpXcO7hFe9/Oo 02aTUR9pmaftVGumtn+BD0zsgzRHDeeUYHwEZC46IvXiynXEGk8BVJKSu95AVDXsZt/p t4JHw/IOVAdlggDWBqPfnE7MIrjLrPcArBrvKK0bI1L4x2vd1vZfodtEunrv9+5jLivM RzhLPK+IwE7X9yHdqZHpyQL945co1l+I2H3dg4bprjOYNxzRhsDn2KREvTF9IHC/cj2R tr0HjN9UjNAV+ZBbsyTRaWC4SvKM2xUt/7A9G6LwnqiPikL7XXqAcKH2zVuvh1Mt9ONg hC9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=5Xp410sF+GGnn+k64Aem0Bq20nF9FpJBZpOgxpPYfOM=; b=k7ctjhvL4hv/DpSOY9p9YX6kXZ7v993j3568MvNOrjhCY+DZf4ufiCZh73U6CpXZ55 DmX+PLO1Ij0U9x2ZDV0e7PKQxV1kmNelvsIODGw6A+J6YVySxlKEJsZOK1axW8NqaJjT wWLfdvy0tbKvMFkDi9uFu1xOo87oN5g5YlTP/B8DLJJCqty8zu9Oh2azfyV4yLR3NQQn /6DerDpVrZbcJbqulCfoTPu5zbcB8IBHp8aZgYpDrmSAI7ka7dC5ri92UeQAfVA9DKF+ fFZ85dbyuxnnwEDUYYmddmAaSau60CrtjOajXDe4sFHKxBkKcy9bYnDCDnzbZJGLJkgm 1a3w== X-Gm-Message-State: AOAM533uDczH6vdbQrk84eT3ThaCY0Yj1yxruf4iDFHVglrDMJB5iv9v tjVOu8YnYlpATJpe0SzJivI= X-Received: by 2002:a17:902:ea0d:b0:158:5910:d683 with SMTP id s13-20020a170902ea0d00b001585910d683mr4720898plg.95.1650138004440; Sat, 16 Apr 2022 12:40:04 -0700 (PDT) Received: from [192.168.1.3] (ip72-194-116-95.oc.oc.cox.net. [72.194.116.95]) by smtp.gmail.com with ESMTPSA id a19-20020a17090aa51300b001cde7228b61sm8322237pjq.47.2022.04.16.12.40.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 16 Apr 2022 12:40:03 -0700 (PDT) Message-ID: <725e814d-da65-b77d-1a6e-a029d594944f@gmail.com> Date: Sat, 16 Apr 2022 12:40:00 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH net-next v4 02/18] net: dsa: sja1105: remove use of iterator after list_for_each_entry() loop Content-Language: en-US To: Jakob Koschel , "David S. Miller" Cc: Jakub Kicinski , Paolo Abeni , Andrew Lunn , Vivien Didelot , 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 , 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." , Vladimir Oltean References: <20220415122947.2754662-1-jakobkoschel@gmail.com> <20220415122947.2754662-3-jakobkoschel@gmail.com> From: Florian Fainelli In-Reply-To: <20220415122947.2754662-3-jakobkoschel@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On 4/15/2022 5:29 AM, Jakob Koschel wrote: > From: Vladimir Oltean > > The link below explains that there is a desire to syntactically change > list_for_each_entry() and list_for_each() such that it becomes > impossible to use the iterator variable outside the scope of the loop. > > Although sja1105_insert_gate_entry() makes legitimate use of the > iterator pointer when it breaks out, the pattern it uses may become > illegal, so it needs to change. > > It is deemed acceptable to use a copy of the loop iterator, and > sja1105_insert_gate_entry() only needs to know the list_head element > before which the list insertion should be made. So let's profit from the > occasion and refactor the list iteration to a dedicated function. > > An additional benefit is given by the fact that with the helper function > in place, we no longer need to special-case the empty list, since it is > equivalent to not having found any gating entry larger than the > specified interval in the list. We just need to insert at the tail of > that list (list_add vs list_add_tail on an empty list does the same > thing). > > Link: https://patchwork.kernel.org/project/netdevbpf/patch/20220407102900.3086255-3-jakobkoschel@gmail.com/#24810127 > Signed-off-by: Vladimir Oltean > Signed-off-by: Jakob Koschel Reviewed-by: Florian Fainelli -- Florian