Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp25925pxh; Thu, 7 Apr 2022 12:55:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyR+4Xy4Ug8KbItSHYe76PUn2OO+xXipl93gW0YrMIMA4oBd5gzCc07YuLPMtBekAPuNnzQ X-Received: by 2002:a17:90b:3149:b0:1c7:5aea:c800 with SMTP id ip9-20020a17090b314900b001c75aeac800mr17419733pjb.237.1649361312968; Thu, 07 Apr 2022 12:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649361312; cv=none; d=google.com; s=arc-20160816; b=J+isNvuPrLYzXMr3yyiitzH0sEy8yVJnEWLe0yEnJrbxbpVRZrqO6cjyIqA/N1qhIv PlJX5fWizUqfdOW3g6MqSCnWZ1HpQzXb/3NeKHh+rNJHojBBsBCQiop3e9PPa7MPJGmm sIhDUsynLFcIsHrMSTtc/D+DZn3hpnXt8rTMqJnb97wO7XdvgJGZ82LAAhrWWvCj8d/V vxu4yC4oX3s/IN41W2Q4xU2yL0EHlBiyn5/J8j9LRelQS5jomAi25lC9FEAnimeHuY2b qD0354vmYNvpt7PegXhlNogE7w9oQiDRTiiimouhQESjtX0tYULJjkj5XHWZnhZLzy1M YjFw== 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=LXuHnml0JyQ7WUWtSyqxCdcrvdOAihH7ECEcB+ac3FQ=; b=qCLezd4ktpNaEwwlnF6EuHtb0DcpRnk1WQm1r3RU1DvzuENozV0Z3AfQiqEpSiKlf8 qeo5qPiAV5C6j23cvoCYjDOqr14iT+LF+geF3mm9VbCNTkjbUdbRZRx2XZol51PjeqE0 KmyAL2jj7jTH5HW3biWgyji35DZA5U7Zm1zLhTFDwDucZlvlVeEg6liRibS2BLL7NNLJ djW15qfsxG0LambTNPhaYlydiKqmZ06SPzMbJwnFM2+ctSlkGahfNPFXnw3GFc98eWi/ YP9VS/M1Zk7GTspE1s+AVDmuytogWrv+C2C0dy06kfCELq70S4JxF+bZhlDXxJxE6d5+ ufLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UO2thwdF; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id h7-20020a056a00170700b004fa843103dbsi21145577pfc.193.2022.04.07.12.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 12:55:12 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UO2thwdF; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 AA76627CE2E; Thu, 7 Apr 2022 12:24:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244336AbiDGKdp (ORCPT + 99 others); Thu, 7 Apr 2022 06:33:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244293AbiDGKdO (ORCPT ); Thu, 7 Apr 2022 06:33:14 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64F138A6CA; Thu, 7 Apr 2022 03:31:11 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id k2so5842990edj.9; Thu, 07 Apr 2022 03:31:11 -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=LXuHnml0JyQ7WUWtSyqxCdcrvdOAihH7ECEcB+ac3FQ=; b=UO2thwdFQIwezldvMHYU+ye9tZTtvNLlmY23CqaOO92X4B+g3Vio1ebPrFn37X1c0p zDbJw8xG5ELmkRDNCHYKPMI6PByu/T+4XKDeTFYfPla4cyhVWpnCRRUdzWrD8r22LLiq LYWvm+jsWpIjYe1mJBw+pCIxqKLhlg9b6+hrW5jm8hdd0QcgIywz1NLJf9epRNitoMI3 rRDr5g2GEjDr5MbV2LR/fi/Y6grbdZtQbvDOP/qP6A1cGNrZczf+/zEAs/8wKBpia+Tc 5acHVDvHJ+ZyqqccAaCclfK/iv8Ms/hvIG93ImicRaO4ty/nHntQ4MaVGTVRAcKTuwWE ZXpg== 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=LXuHnml0JyQ7WUWtSyqxCdcrvdOAihH7ECEcB+ac3FQ=; b=BvZm+NOtnQXiCHa8ZHfUn8pq/OxCBU5OfgBi3bWI2fpSi/d73r9Ox95hC2Lzl8mKj5 QybHInEBKuehQfDmDYjFhpDi9Gom1J7yxu8y9k6g8MP2LF+N2HDwBuzGR0wzatJshKtA SIX3At4+b/IMyLNfAq3VghNYG4gVR2ktz6Cb39BsdfuJOGt7xF1ZsQZMQ/Q5NPvMBAal xLoQUhI57PyWiQOnwvZwMH0YVRyPVJtRrHRnAmjfFRDgFdxVFJgQuoAUjNm0RetqXpLi QNL0+euc8jUW11fstLFjM0jt6QKIxOKqRYs8+XwKE4hUBka5s1GiOf5DL+zJggbiWPlt +Okg== X-Gm-Message-State: AOAM530uuz7pyUdUsrS7ou3qlPIWaPsmceegNHsfOY4AcZARZpU7h24i vwaJ6+PFUSwUPAK2EqHesg8= X-Received: by 2002:a05:6402:2706:b0:418:fcb2:3a02 with SMTP id y6-20020a056402270600b00418fcb23a02mr13435824edd.111.1649327469766; Thu, 07 Apr 2022 03:31:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 03:31:09 -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 07/15] qed: Replace usage of found with dedicated list iterator variable Date: Thu, 7 Apr 2022 12:28:52 +0200 Message-Id: <20220407102900.3086255-8-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 --- drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 26 ++++++++++----------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c index 1d1d4caad680..198c9321bf51 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c +++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c @@ -1630,38 +1630,36 @@ static struct qed_iwarp_listener * qed_iwarp_get_listener(struct qed_hwfn *p_hwfn, struct qed_iwarp_cm_info *cm_info) { - struct qed_iwarp_listener *listener = NULL; + struct qed_iwarp_listener *listener = NULL, *iter; static const u32 ip_zero[4] = { 0, 0, 0, 0 }; - bool found = false; - list_for_each_entry(listener, + list_for_each_entry(iter, &p_hwfn->p_rdma_info->iwarp.listen_list, list_entry) { - if (listener->port == cm_info->local_port) { - if (!memcmp(listener->ip_addr, + if (iter->port == cm_info->local_port) { + if (!memcmp(iter->ip_addr, ip_zero, sizeof(ip_zero))) { - found = true; + listener = iter; break; } - if (!memcmp(listener->ip_addr, + if (!memcmp(iter->ip_addr, cm_info->local_ip, sizeof(cm_info->local_ip)) && - (listener->vlan == cm_info->vlan)) { - found = true; + iter->vlan == cm_info->vlan) { + listener = iter; break; } } } - if (found) { + if (listener) DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "listener found = %p\n", listener); - return listener; - } + else + DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "listener not found\n"); - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "listener not found\n"); - return NULL; + return listener; } static int -- 2.25.1