Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp576892iob; Thu, 28 Apr 2022 08:09:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFyNREvnA3VVRLPexVppM1bNXgxIYaMWGNDZYoxLscQEAdxKplvk8/r2eIZpmLqDm97Hog X-Received: by 2002:aa7:8b0e:0:b0:50d:4310:c11f with SMTP id f14-20020aa78b0e000000b0050d4310c11fmr9311077pfd.49.1651158593600; Thu, 28 Apr 2022 08:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651158593; cv=none; d=google.com; s=arc-20160816; b=SApTvfZNGsksMiMUhIoJIM3Mmvx9swdS3Ye/geSb8/B5ATBEb6Nfu6Z8LR8u0CTEQk 372GTAYKYfG/ycRM6sbZAETKunjw2OGy6GN+NOZoTz3n8CEXCWtAnXYAVGgyeaCqYMhQ ggyJAJrNOvlPmNwkcnaNY07UMyLiuVAoJmpWCkSaZrC81/b+/GT9aUy17EyjRY2Bz174 chjA8dA12fdvuPb7b/AyoBrdOnloueXm0TIuHSuLdcuut8Vn2SXyl8sOYpaOv2UnM/li U50HUsaXQNOvVw/64d6RnK8Was8wTAtPcS7mAocvt3siVmdDq6TwogSDAxURejT+Ocr0 lcWA== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=OG6hUPY6sAUTqTJViKJ1E1LWjNyEwooQAig3aG1iSlg=; b=qljwvezgLRAqpimlPrCSRoHAXYNwUBaHxPA+PqXu2NlLJpRE/CQYXz5UuXzwgZmJCR XeNXtWs60EIjlxlpzM8vMiVUA2Ski/cgsPQOg4QFv/u1ITYTSYMoShSIgL1U2UtJHOz2 KYoVixY4sbE85sZvKL9gp+kG/GMjI3y9zIMWyzuoVB7uvideFGtDS0lxW3HRn/6VHcOt IlGu+/QgXhHY0GpD5jKsFyjsASDrBHY4VjMgRQY5lqxRqX+MqkaM5Uzq6KKrYT9d9iyA VNy5wlSPxB+5ZsgTXGYKPOSH3QEv39O4uevKRKwawCB19dM+RumKS0ytVwWscuySnn8h v0/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cdoei2hJ; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nl18-20020a17090b385200b001d2b6b6e2b0si9541502pjb.182.2022.04.28.08.09.36; Thu, 28 Apr 2022 08:09:53 -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=@redhat.com header.s=mimecast20190719 header.b=cdoei2hJ; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231184AbiD1JtM (ORCPT + 99 others); Thu, 28 Apr 2022 05:49:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347959AbiD1Jfx (ORCPT ); Thu, 28 Apr 2022 05:35:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 18BC19548B for ; Thu, 28 Apr 2022 02:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651138359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OG6hUPY6sAUTqTJViKJ1E1LWjNyEwooQAig3aG1iSlg=; b=cdoei2hJcSbHuHkYZQ3MvgS8axm0jut80Hqzf014rP13NYK2DibnzS+WZwyUSUWh+ODxEc o7onngKKqisVXVVI8w7dfaBqYGc5CQU80N+R3Zn60/Mh03JYd2kL6neHZLRNmTmElkawc4 NuBRgM6eEICO7jQAST6tKQuCxF/kbgE= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-618-CzAHaEGHOGeH_Iyu-boiIA-1; Thu, 28 Apr 2022 05:32:37 -0400 X-MC-Unique: CzAHaEGHOGeH_Iyu-boiIA-1 Received: by mail-qk1-f199.google.com with SMTP id u7-20020ae9d807000000b00680a8111ef6so2830502qkf.17 for ; Thu, 28 Apr 2022 02:32:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=OG6hUPY6sAUTqTJViKJ1E1LWjNyEwooQAig3aG1iSlg=; b=XFs3SvfkbnhKEjvww/xH13I6Fe++3rrsiJKRoZcNEPdPHqZ+sPgVw049PUO599v/Y9 NmhozVnkSEGzqDFdIOaiGu0cAN+4Bu/Jl3J3IkfpXa7S/KZ26vhXfZnr508AP0UNtS31 9kyWGL1CXLeGOPbxy+6plE90jczvc2ybvQIWVOplcRKO1pr7tTgqqippR/OEgG/iZ874 YaZXO3m4xnDJWLAHNBMpNCcEePVh2tPPi6eqLWJvL28pVNf3BWZjd+eR8FJCCfrjG7A1 izM/usUy776BtuIvhiLZ+nXcCaBIPkVuz22Q4I3yki7UIJtAQr+TtE0bBgcr/YbpoZwx +dmA== X-Gm-Message-State: AOAM532D3qa7bqt91eDUD0AGRrnVNAVtVfqxcamGHbJUkfGQLAHAM8Dg zFoUhi63jGp1a22NodtPZKRLXLo9k9T2pQ2Wx5aYKofaQ1iLTbGzSxqdr9NdeaLCfAhXFtG0uyL BZpTJN2kwd2teB0v+sNccoa9m X-Received: by 2002:a05:622a:2cb:b0:2f3:646b:54b6 with SMTP id a11-20020a05622a02cb00b002f3646b54b6mr15456758qtx.380.1651138356462; Thu, 28 Apr 2022 02:32:36 -0700 (PDT) X-Received: by 2002:a05:622a:2cb:b0:2f3:646b:54b6 with SMTP id a11-20020a05622a02cb00b002f3646b54b6mr15456733qtx.380.1651138356147; Thu, 28 Apr 2022 02:32:36 -0700 (PDT) Received: from gerbillo.redhat.com (146-241-117-160.dyn.eolo.it. [146.241.117.160]) by smtp.gmail.com with ESMTPSA id k66-20020a37ba45000000b0069c5adb2f2fsm9620433qkf.6.2022.04.28.02.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 02:32:35 -0700 (PDT) Message-ID: Subject: Re: [PATCH net-next v5 08/18] net: sparx5: Replace usage of found with dedicated list iterator variable From: Paolo Abeni To: Jakob Koschel , "David S. Miller" Cc: Jakub Kicinski , 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 , Arnd Bergmann , Jason Gunthorpe , Christophe JAILLET , 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." Date: Thu, 28 Apr 2022 11:32:28 +0200 In-Reply-To: <20220427160635.420492-9-jakobkoschel@gmail.com> References: <20220427160635.420492-1-jakobkoschel@gmail.com> <20220427160635.420492-9-jakobkoschel@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Hello, On Wed, 2022-04-27 at 18:06 +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 > --- > .../microchip/sparx5/sparx5_mactable.c | 25 +++++++++---------- > 1 file changed, 12 insertions(+), 13 deletions(-) > > diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c b/drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c > index a5837dbe0c7e..bb8d9ce79ac2 100644 > --- a/drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c > +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c > @@ -362,8 +362,7 @@ static void sparx5_mact_handle_entry(struct sparx5 *sparx5, > unsigned char mac[ETH_ALEN], > u16 vid, u32 cfg2) > { > - struct sparx5_mact_entry *mact_entry; > - bool found = false; > + struct sparx5_mact_entry *mact_entry = NULL, *iter; > u16 port; > > if (LRN_MAC_ACCESS_CFG_2_MAC_ENTRY_ADDR_TYPE_GET(cfg2) != > @@ -378,28 +377,28 @@ static void sparx5_mact_handle_entry(struct sparx5 *sparx5, > return; > > mutex_lock(&sparx5->mact_lock); > - list_for_each_entry(mact_entry, &sparx5->mact_entries, list) { > - if (mact_entry->vid == vid && > - ether_addr_equal(mac, mact_entry->mac)) { > - found = true; > - mact_entry->flags |= MAC_ENT_ALIVE; > - if (mact_entry->port != port) { > + list_for_each_entry(iter, &sparx5->mact_entries, list) { > + if (iter->vid == vid && > + ether_addr_equal(mac, iter->mac)) { I'm sorry for the late feedback. If you move the 'mact_entry = iter;' statement here, the diffstat will be slightly smaller and the patch more readable, IMHO. There is similar situation in the next patch. Cheers, Paolo