Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp55482lfv; Tue, 12 Apr 2022 17:05:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1nIsAn9CkhJYAp5ltgDLcNtBcXWc5v+R5Hcx6dmCwkCiG2qtGOtmi/M063Jq+NtT/WyL5 X-Received: by 2002:a17:902:70c1:b0:154:667f:e361 with SMTP id l1-20020a17090270c100b00154667fe361mr40266008plt.148.1649808318525; Tue, 12 Apr 2022 17:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649808318; cv=none; d=google.com; s=arc-20160816; b=snQ13aOCYZbCGbu8qmuJGW89VmeSOEg7ZhacsqWZm/L4bzCF1QsH8oNHq3EX13S9Zc +OirALiNoMlDDTRlmaf02n6vqKmS99OilYkBD3OSkxs97emAk1aTwVNVTKjso7Ro3tDS lAZo9zMi1UiGGKDrk5OcbVuLxxElyq4PDZv7qJ6H0YUVETduqkr/iOE9KXdlpZJnEd4C vOVtkIamRnfvDxoIsT5nDGNzbH6ZDMcwTzKRawVPKmKIDbMn2PD5ZSyuc9FOP+b+P170 SFTGk6nmocAhNCYcowhIjlBNXeP9evKqIUHmU8tePh+qQbRD/pxkLZQm9QWgFxzo9/eB 7BqA== 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=YO1BT4txDUf3pcHDVsDOrc7T0muIbSiY9OuvApCAbIER7SqewybzwC18WJ1wq+hTEO jbrPea6/Jc/tEay/r3fwRMAa8kLypUPscG2zyb6ZBbFfyIXq4KoYin9F1gNOYYkZ6Jaa whbdoCNaKGsHlf3a1WGRN/ZSEbhXe4fw+1mD+bhzbzvtvlsHCLwF/Aqe2MRTuQ98UzGj jiFbvNdl8ORsmMFViBIub+bS6QOGne3mFDMLKLsmRos/TzImoy9DHcKQftf1HGmOQDCQ oGt6W9dZyFh1keKNi5wZjg15D/D7mrcvsIGyu0tQw/G2uI2UBBOBKJBL1yVuG+zIfakJ bcTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MbpelD1k; 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 g6-20020a056a001a0600b004fa7782f609si13410455pfv.24.2022.04.12.17.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 17:05:18 -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=MbpelD1k; 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 2389854FA0; Tue, 12 Apr 2022 15:02:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354627AbiDLMy7 (ORCPT + 99 others); Tue, 12 Apr 2022 08:54:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355299AbiDLMsK (ORCPT ); Tue, 12 Apr 2022 08:48:10 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 604D3DEC7; Tue, 12 Apr 2022 05:16:47 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id g18so11988787ejc.10; Tue, 12 Apr 2022 05:16:47 -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=MbpelD1kO9fpd+TInbPP84SQTrTYFohS7QmbpAgzqeblyAZFn3SqJtplp4zUHPDIN+ TiPBFcZy1uzoaGj6w8UCN6eSvYKqFm/GpqOxZZDGhiOnnw64ZPG+a3cL8ayI5PBKEmiV Bm5PiVvPrfxKiQYkNWj/y67f/behHd+xZYG6SJ27oZudVrF4fvY8p1PDKl019RGHD90r od4La0PkXqCWYS8vORcSOuwIokgKkz4LnPqN9FF8H6Gz4v61Oxb2jWhUrpJgNql9m2mM RmUwLOrTNPjZ+TlQ2pnRdHrWNs7b6qt/pSyuJ7YK37HQvNRjkmsEEhMx0Y0j+so2ZdhI C92A== 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=ajjky8+bEmdeOr93RrGzX1xaw8vSjxMEPkqwP2eBT1dM/2hoB1Y8jQCkNRka0pVEkt ltXpwPy6sr72fgewMNgW0WwTB6fevGusPtASdirTYcjcQBSptda2eGHqTwUGjiFUtSnP D43+Tw4Rwy18CWD3cwi6J73Jrt//QBVldeG3zoKqsBl+ktFltbLRDaptSGL8yjrmGdlF xrnyPQPS1G8WhbFyve0J5OHCpgjRRjfYWoNkwEj5LorwWRmcI+f/TJD33dLUzKn+5uHa +rQN8OMCoiqJZvA+a+BRAahVQ27NV1VuOiGEpYjEGs/QkCjPu8IbFpmrPO+HwzAQIIPe hFWw== X-Gm-Message-State: AOAM530MFvkphX+jdEQR+Sd4dy/JD5BpQ3kgOB7PpSXYmr8gaR8zrGFl uNE4wG+wVzWxHbVz5wv39P4= X-Received: by 2002:a17:906:a046:b0:6b9:20c:47c1 with SMTP id bg6-20020a170906a04600b006b9020c47c1mr34222677ejb.615.1649765805743; Tue, 12 Apr 2022 05:16:45 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id b5-20020a17090630c500b006e8044fa76bsm8827900ejb.143.2022.04.12.05.16.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 05:16:45 -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 , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Casper Andersson , Bjarni Jonasson , Jakob Koschel , Christophe JAILLET , Michael Walle , Jason Gunthorpe , Colin Ian King , 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, bpf@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH net-next v3 16/18] ps3_gelic: Replace usage of found with dedicated list iterator variable Date: Tue, 12 Apr 2022 14:15:55 +0200 Message-Id: <20220412121557.3553555-17-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220412121557.3553555-1-jakobkoschel@gmail.com> References: <20220412121557.3553555-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