Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp408531pxb; Thu, 7 Apr 2022 08:40:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxu3zEhGZOgKv1+37sDQ/+UjoJJPGTncnpgwGd9afDzJKtvHvcH5mFOJFaIJm8eMPFtzb2P X-Received: by 2002:a17:902:da83:b0:156:aa83:8409 with SMTP id j3-20020a170902da8300b00156aa838409mr14939811plx.22.1649346021834; Thu, 07 Apr 2022 08:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649346021; cv=none; d=google.com; s=arc-20160816; b=UHgPZqx5+ZYjoxDDJBQOHnF592TZBS6IFd/lomdi4FO01CVQnuFaCIZJjNcVoBLXca 08CSh1PRfSp/a1j8qMidSnko6c4PERrgmMfZqtvU62POwXdZHhtknghNz8Hrf49yFrgF OvoZjbRFZx+FsmwzHYHQKLynvv6PmJX3LdSOJ4GVNTKHLM/vy9LgKm/RG4S47YyMLrHY xypxNQVY5HL+ROLu5ZPUQjqaMlcViwiL0PtI0cToYqSI9A+Fd7h6A0YOiwyxEZZmSq/F zrVcmkdik3k6x7qI+9BZ+UyXoMdofFbog/b0RqXAxasRkKzLVJ8219Jcfq7WU3Rz5jYM tbuQ== 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=y4Pr090XMJdWC/DFcBeDDVj+LNsTMLYKFYstx7+jurs=; b=Tb4GFi9k3b+ies72CYI7FCVjTIcXbMKKju1wgchrOXUMLS/Ke9LhmZsKR/PVtWpHxI uYrHhG3V2LmtkFy0Vgg3PdzOYO3BeYLJ0GrTJ4YyX1F2pMXeXsctZMvUlu59Ht++P/Ne 27bZC4taWT8CS00Xi4QeFtuMJhfWFjOlwVsM+o7H3vjdJmD5fvwWhUE6N7xWsdFtrW8+ XNHDfJnNatpRSAtmWrnO5aa0RQa9xFjq3Mq3UBHT27N1fcz6BjP++zCzbA22sT6SEJ70 BOjHbyTXChAuJ5PONb2/x2w5nNDmMEX3pVvVqcso7xInZcnUuxIxZcnxCWDcntT82PZq 5ZVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nNuQkSMC; 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 f26-20020a63101a000000b00381c3d50395si19149264pgl.246.2022.04.07.08.39.49; Thu, 07 Apr 2022 08:40: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=nNuQkSMC; 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 S244438AbiDGKed (ORCPT + 99 others); Thu, 7 Apr 2022 06:34:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244307AbiDGKdj (ORCPT ); Thu, 7 Apr 2022 06:33:39 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BCEDDA6E0; Thu, 7 Apr 2022 03:31:20 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id k2so5843428edj.9; Thu, 07 Apr 2022 03:31:19 -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=y4Pr090XMJdWC/DFcBeDDVj+LNsTMLYKFYstx7+jurs=; b=nNuQkSMCzLU1sEOB3kq25UUx35GFYl6QVT99wdmylAxE9TixTKmDmoqMFWdlbqiWZP I3kc8fEKcgXlSy83s+c0lRBGVAHJEWI14YpuOLndz3WHyzs7RLvuY/L5jpLgy2VXqiWT XQwh6mAxC9rRU/MR6v9XW+wUQVVEOTvTmVXHjIAtQWksNpk44d3f4eaYMV/Ys5xgW0v9 binB3V+mZmDmJuRNiEbhTx36DO8zxBDOH6jcmiVJLU3GAGr2SdjmTgaIJRTM1VLnwUyN HqfyTsMQcIfkBrPyHbBLbFKivOQQn6H7EoI68pLa9qZa4b5aV/5ifQDEIQMvxl8t4KRy QpeQ== 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=y4Pr090XMJdWC/DFcBeDDVj+LNsTMLYKFYstx7+jurs=; b=fJnnYpkjjAI7urKgGEDoOod70DP7P5/x+M0JTs2T4WtjV9OUuJ7OCyNHeeICjbM6xn lEeSkDIQor45OyhrZSU/KhNlw7MWVTtiIkMEiAZ6TYy2XvW2FHEk5H1cyaUUfkg6Mrh6 l+Dr3YiEFocTNBfc8ONwbhhxEMP8mN4dpsI8XP5VYs8b8yimVeAdCvMhemZq+R5V8m03 76J3cj9jT7FbuEmFuYyaOum11VyekxG4Q5sMIGoqRAANMSK2MCzEKUzyI8k8X0czghII wiUnbCueQriA8EQ6m8sFIoEugiEdGf/LX+R8FGc1SMzK32iNpHgux4WyFZJWWtGkHlFF 02FQ== X-Gm-Message-State: AOAM533pX0ZInu7oAPlpRYqa2uLLErNffWlrZRX25Wf3Cnt2T0tiq1id fmw9fy7izw/Rme3ChxHOsBs= X-Received: by 2002:a05:6402:1111:b0:416:2ac8:b98e with SMTP id u17-20020a056402111100b004162ac8b98emr13450111edv.236.1649327478576; Thu, 07 Apr 2022 03:31:18 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id c5-20020a170906d18500b006ce371f09d4sm7413573ejz.57.2022.04.07.03.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 03:31:18 -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 , Casper Andersson , Bjarni Jonasson , Jakob Koschel , Colin Ian King , Michael Walle , Christophe JAILLET , Arnd Bergmann , Eric Dumazet , Di Zhu , Xu Wang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH net-next 14/15] ipvlan: Remove usage of list iterator variable for the loop body Date: Thu, 7 Apr 2022 12:28:59 +0200 Message-Id: <20220407102900.3086255-15-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220407102900.3086255-1-jakobkoschel@gmail.com> References: <20220407102900.3086255-1-jakobkoschel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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 In preparation to limit the scope of the list iterator variable to the list traversal loop, use a dedicated pointer to iterate through the list [1]. Since that variable should not be used past the loop iteration, a separate variable is used to 'remember the current location within the loop'. By avoiding the use of the iterator variable after the loop, we can lower the scope of it to the list traversal macros in the future. To either continue iterating from that position or start a new iteration (if the previous iteration was complete) list_prepare_entry() is used. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel --- drivers/net/ipvlan/ipvlan_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index 696e245f6d00..063d7c30e944 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -9,7 +9,7 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval, struct netlink_ext_ack *extack) { - struct ipvl_dev *ipvlan; + struct ipvl_dev *ipvlan, *tmp = NULL; unsigned int flags; int err; @@ -26,8 +26,10 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval, flags & ~IFF_NOARP, extack); } - if (unlikely(err)) + if (unlikely(err)) { + tmp = ipvlan; goto fail; + } } if (nval == IPVLAN_MODE_L3S) { /* New mode is L3S */ @@ -43,6 +45,7 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval, return 0; fail: + ipvlan = list_prepare_entry(tmp, &port->ipvlans, pnode); /* Undo the flags changes that have been done so far. */ list_for_each_entry_continue_reverse(ipvlan, &port->ipvlans, pnode) { flags = ipvlan->dev->flags; -- 2.25.1