Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp809631pxb; Tue, 12 Apr 2022 14:04:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUBRXBfQzGTa/MDMAmq5f5gyHGCCq9Qu2f4hIRqlyQxoiiA+wgvmn+iz2Ewb3j9U0dGu+L X-Received: by 2002:a17:902:ccd1:b0:154:359:7e17 with SMTP id z17-20020a170902ccd100b0015403597e17mr39269714ple.42.1649797449148; Tue, 12 Apr 2022 14:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649797449; cv=none; d=google.com; s=arc-20160816; b=FmlMMEzbqCEPYHW0G8dR711LDWm3wf/xn6xuCr04mcVwL7Ygyx+DwmDBSQ+fvqssOB sDEAFUC1UXlAgVGimHesljLsGR8D60CyDmKcNqBbtwIEyiMLRrKpJcAM/c7GidrCmprY bIaLsCkQ4tJWkeTbDWg6Dqih7+WrAXCo9vrnSWF2mz19YRLqn6qrZyp9BJ/1ebnbm/OM ROetWXlthvWV9E+i1v9twbyo5tnLNK4ZNw0ifj76Bw7a0ST3C/3rGC6ZixNQp5FJn8YD ZvAbLjC3Ue1jWbCYO3+YxwB0a3GVFCcJUGcFE3rcu98g2uo0hZ9OgZd8tkagSJD6eIAd hI5A== 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=tmQCxrz2kpYsAlDqx+WFXRFroT4SMtQIJmuZDDJkVvUGtRIm3bYZnodWrn2jGe/i46 v1zOVboMGsJ94UGXVNti3yaQUisu9OGfPBAw9TmJTfjuUfRQ/Ga2ePpbWRNecAswHCx+ PHKeSLCmDOT2qbXyOq6ZZPSG61mvkSmzqRi367E1n/jmqB5cEbR2AMt0n00X92gsq83/ LAbnLwIoY3jyc8zAIYjktKOp++VxHf50BsGX8PZBk6mKUsuYmWenVaZnKpq43vm+3kJd fZCjBNJNdT8wp/MC2SVAdPIXyqg6EyRwdx9LZyCP9Ou87ak8PqBM4IWFol3YabcPFsrC MCbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="M+2Q/55I"; 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 c139-20020a624e91000000b004fa3a8e008asi12000772pfb.321.2022.04.12.14.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:04:09 -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="M+2Q/55I"; 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4FBB4DB2F4; Tue, 12 Apr 2022 13:24:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354371AbiDLMux (ORCPT + 99 others); Tue, 12 Apr 2022 08:50:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355293AbiDLMsJ (ORCPT ); Tue, 12 Apr 2022 08:48:09 -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 518F45F45; Tue, 12 Apr 2022 05:16:38 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id bh17so36918688ejb.8; Tue, 12 Apr 2022 05:16:38 -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=M+2Q/55ImUNO2WPmUemvwrDQVJ6b3qx60DyU6K3kHps52GjVORJwZyDaKNbLFeERof 92+kRsFwWXMNlMEQGJrIQJ/JEc7gwtc9lj3lNPy476NV85Swle/tJmzqXcomttvIYniX I16StuBQxsXTy9TNXpP9f/h33ZL6nDvRR2ldRIXa96rWlK6VroMZpzS0YnVkMF2Oeuml Sqtb3AGJMU2x+uuPwVgXgb8e5U/EBEwSMD+nQUGZfbFDVKAq7e3linokGpWnhXpCoUjU kIGN96Y0xvo1tEz3FGUsN609MJurjnqQkBIT0l2vH0N6qX/9Yk8SRoyEQiH+GP9y+8X4 nS7w== 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=KIj8F+hv96QBPK19tC5PzCss/GmTCXY2uk9h9r7aqQZv7YcH6dia9XwMjPS+ZtbZUI /pAFtJDagvwFlTzf0+nF4nC3H+Kj/lXVa76/fCGMbbQYoRQMr5EjMbfwm+DV7VSlUkZr iAjeSTaVcvJ+zx39E4KIB1zKrro/DkYoRgkpI5arc81VeGuV/ElPPU/tC4yv62qb5A1Q 8QRDIoT0tdA94ULHhUvR9qIGv7wEH55D9Ma99eSj3GGYzIW9aZl8YgLnVDTIvhJDceO9 HVGdgPpoxgy8Mq4tyJxEXPwqK68WrMDJwsZgqoolLWtxzrWGktB/QBcDKvZ3ghzVgkVC jwew== X-Gm-Message-State: AOAM5317suYyTCGe2XIcXJu1b3vNM3VQ1BQa9wajkyPTPGByeihh2UGw 5SEWFr2+7VLUaHJIKcfhQwA= X-Received: by 2002:a17:906:a08b:b0:6cf:65bc:e7de with SMTP id q11-20020a170906a08b00b006cf65bce7demr35119993ejy.220.1649765796899; Tue, 12 Apr 2022 05:16:36 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 05:16:36 -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 10/18] qed: Replace usage of found with dedicated list iterator variable Date: Tue, 12 Apr 2022 14:15:49 +0200 Message-Id: <20220412121557.3553555-11-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 --- 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