Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp69594pxh; Thu, 7 Apr 2022 14:15:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNnDQhYniAna3F45PTaW7kvfJ1UjQHwpDMw8XseBw94GwH3yjI3DKPwmX+88PJYQiiKNZg X-Received: by 2002:a17:90a:d3d1:b0:1bb:fdc5:182 with SMTP id d17-20020a17090ad3d100b001bbfdc50182mr18104334pjw.206.1649366110763; Thu, 07 Apr 2022 14:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649366110; cv=none; d=google.com; s=arc-20160816; b=Roz+iQZNXEHn4DY7rwUAMaWQ6t8u7DzwI0Mf0arFvuUZaRhZuNc519RhKsXaITFqAe jAL5wJo1a21Bkb5Roqo+5kZvNBBY5e8iOYzNLUlBx4lop0ZtF0G1jHSiYdAzIJ/4k8mj 4t83XGgOJiCdrUoibhq9oY64ayNTKqn9ucBNY29fWFS8GeQe0yQr5zXMbHa7NxFTDfQE xR0ftAyGcU0PqCUO3PXPBF/nHDFe16oE/epsSXp+IRI3RgJu8vTyJ+npmlYmbrfuUS+A //SoO+DuqvO/056FhAcrmWYQeN8iJOoDB9qKi2H7ct4W9qFMDplI68qzRiI8u8/7N0Xo L2WQ== 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=vgJhsUA0t53G3i/our+ohO3psku9eyW28VU5QSKiZig=; b=dhC+fuu6Be2DcRrNbDwknhjpvgOIIZwVLJqPGAoKpNkE/wUaV/Ws/dHWVm5zz10shw utCfFXWWTC4zueyHIFKfls4EFIMMGlNCcfwj7dwKVW7/hZGmukDF47BcUis/EFYuL5h+ VB2ur9PooLVt7Xnm8IISc+6LfRQqDiMLHviBWrNDpWL8p1kh+70KxLh1V8M8FyY8kbRc 4VzAHcSWMy22Qdx+cAq8frgHNJhcuYzI7hyUIo2U19PT713Km+MuElizSLnZnoPN76IE lHtAPMwq1tiof2gv1Kzffcj4Ko5iWDjx3mv6Ln+z0TPgmDdq6OP6+6FcpMq3HzS0QA/R bpQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ck9VMXlw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z17-20020a056a00241100b004fa70a4ef46si22181638pfh.110.2022.04.07.14.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 14:15:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ck9VMXlw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 771002A83B8; Thu, 7 Apr 2022 13:06:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244323AbiDGKeV (ORCPT + 99 others); Thu, 7 Apr 2022 06:34:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244330AbiDGKdi (ORCPT ); Thu, 7 Apr 2022 06:33:38 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D12F7D3999; Thu, 7 Apr 2022 03:31:18 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id q26so5848479edc.7; Thu, 07 Apr 2022 03:31:18 -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=vgJhsUA0t53G3i/our+ohO3psku9eyW28VU5QSKiZig=; b=ck9VMXlwjAkrJBjF/n1CbKYDRKjFW2L1sPR2cfn0O4RDS+4QiOHeU1rYTT4S9ncl+G o5azQ4trV0k6BexbuKXvDPcfd6d2avbwCYSYjZU2vIeAZL1SDwryL0Y9Z/si11u9czY8 HzSmojIwKa9wGHtHA7Rw1QF6JO72eOMQZIlf93BwLEg4gdnjSLVBRiuAO8dVakaZb4kz SOSvnRA47mFgah3zGWtDP9mGpxSHfD8Utvl8jF8xYbBMw/zcDA+AHsBZNp4IxEZ19BHf XWEAPp3jBv3UnL1paAnMyKvp5qfSTKVSfzz4UUD+u3vqppZpYWgxHW3KPf144WduY8wu hZWA== 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=vgJhsUA0t53G3i/our+ohO3psku9eyW28VU5QSKiZig=; b=pbbsoK7wNAt7wyzsWuzJ7D7HnfLneEW/ip2QPU6WXSdpcKwu29qEKxp86o5BOgCd0L +MVNYsgb43AcSJ6igf47bugvg1KnBj1YInTkIZy2n+jjT05c8M+VuP+13NjIX0eJq96d umZ3ZJflOcwf85uW1bYa67ABHogHcl4fWV6E2yTA0zdSbPaabkSkFDXPFvacf5b9XS4X Rtjp7zULBGh6+UgRNfWqIvAkhBWr7H6ER/nlj9XtLMeoSOQEU7pjQib2S17Kl1u4iyGj xLFxZK2uLGNcPq1q4MZfTcIDoTsyj6qAv5iJYCerdFIQrgDC0h21unTBtnAzYogRwj7K wGig== X-Gm-Message-State: AOAM530BenG5mLE7GQZ+6fT6GeeLLSqCw2qdSvj/RZjPnoMCVxBVXTz5 NLajF/uE57Ody65RE6a+AqU= X-Received: by 2002:a05:6402:5191:b0:41c:e08c:ae21 with SMTP id q17-20020a056402519100b0041ce08cae21mr13474506edd.268.1649327477350; Thu, 07 Apr 2022 03:31:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 03:31:17 -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 13/15] ps3_gelic: Replace usage of found with dedicated list iterator variable Date: Thu, 7 Apr 2022 12:28:58 +0200 Message-Id: <20220407102900.3086255-14-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=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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 --- .../net/ethernet/toshiba/ps3_gelic_wireless.c | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c index dc14a66583ff..c8a016c902cd 100644 --- a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c +++ b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c @@ -1495,14 +1495,14 @@ static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan, */ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl) { + struct gelic_wl_scan_info *target = NULL, *iter, *tmp; struct gelic_eurus_cmd *cmd = NULL; - struct gelic_wl_scan_info *target, *tmp; struct gelic_wl_scan_info *oldest = NULL; struct gelic_eurus_scan_info *scan_info; unsigned int scan_info_size; union iwreq_data data; unsigned long this_time = jiffies; - unsigned int data_len, i, found, r; + unsigned int data_len, i, r; void *buf; pr_debug("%s:start\n", __func__); @@ -1539,14 +1539,14 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl) wl->scan_stat = GELIC_WL_SCAN_STAT_GOT_LIST; /* mark all entries are old */ - list_for_each_entry_safe(target, tmp, &wl->network_list, list) { - target->valid = 0; + list_for_each_entry_safe(iter, tmp, &wl->network_list, list) { + iter->valid = 0; /* expire too old entries */ - if (time_before(target->last_scanned + wl->scan_age, + if (time_before(iter->last_scanned + wl->scan_age, this_time)) { - kfree(target->hwinfo); - target->hwinfo = NULL; - list_move_tail(&target->list, &wl->network_free_list); + kfree(iter->hwinfo); + iter->hwinfo = NULL; + list_move_tail(&iter->list, &wl->network_free_list); } } @@ -1569,22 +1569,22 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl) continue; } - found = 0; + target = NULL; oldest = NULL; - list_for_each_entry(target, &wl->network_list, list) { - if (ether_addr_equal(&target->hwinfo->bssid[2], + list_for_each_entry(iter, &wl->network_list, list) { + if (ether_addr_equal(&iter->hwinfo->bssid[2], &scan_info->bssid[2])) { - found = 1; + target = iter; pr_debug("%s: same BBS found scanned list\n", __func__); break; } if (!oldest || - (target->last_scanned < oldest->last_scanned)) - oldest = target; + (iter->last_scanned < oldest->last_scanned)) + oldest = iter; } - if (!found) { + if (!target) { /* not found in the list */ if (list_empty(&wl->network_free_list)) { /* expire oldest */ -- 2.25.1