From patchwork Fri Apr 15 12:29:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Koschel X-Patchwork-Id: 1617783 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=VTgQeHrk; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KfwnN6Zx7z9sFs for ; Fri, 15 Apr 2022 22:36:56 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KfwnN5WJPz3dw1 for ; Fri, 15 Apr 2022 22:36:56 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=VTgQeHrk; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::632; helo=mail-ej1-x632.google.com; envelope-from=jakobkoschel@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=VTgQeHrk; dkim-atps=neutral Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Kfwfb1Ny3z3bcv for ; Fri, 15 Apr 2022 22:31:03 +1000 (AEST) Received: by mail-ej1-x632.google.com with SMTP id l7so15185024ejn.2 for ; Fri, 15 Apr 2022 05:31:02 -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=VTgQeHrkpIHgOEGZvW6m7lK+ww/hBIaLxp/ed1YbHFERxY7K8zgmthq8r0MO/eDheA 64RJAUDP0PCNupTiFSXSD0K9TwZw/VBqVra2httvVSuGRa0rtzP8UWtbBnmILYXL6Z2H sr5X4+IEfwB6d5kKRo4eDMfm2O1ZmyozhlUEFzHkyPeS+S7EEuZSM7ink8BrFdT5ZLz3 GIxrZW9NwL5XcJZvTEmI8dg0NdKEWbX31YU7MxwkMeQJhRou9/SCt1Ujs+st1SvtgpVw 9aQDWxS22TjT0DPrnK2A3NtIzbFZtU+RaSWnUyyUovnBEkNcZnYSmXiUDfvziK0b2SLX cyEA== 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=t4k9a2p0KAiBPt3BVTTtLkKza3eUmsEr5Ap9eLUSU9An+Nmp112JjdWenPj0Sh8z64 sKriWlsNxCQF4BHP95OONIJzzFSisFIe+RRMDph0mW7kCIfAmIFgGfdrLowaKT/zxvZh wBGQAlE8nW/xYV5QEG+oNbXR9yHFMdTQrzts6TZRCuKsHMqmJB0aSED9cIqkaN8Xmwc+ zQda3A1ni0wWJWynVJGmeW/yCwRBS6DsyPTkITBV7+ram14RHZdXk/82catNISL3tuPD KU0B2+LrxL/ru4vA7MIDLEjJyoE6VMDEEuNCcPVJ1qHBlViMS+2zk7jckEax86QY2mL7 8uEg== X-Gm-Message-State: AOAM532je28QMrlDnH3COTkF7va/jKpiLbMVhh0PlFSwvgt1NQTyAOA0 Jv3CDnFI/n82CPFSkMAA2oA= X-Google-Smtp-Source: ABdhPJxoOHJKRpfHC4KfhLHKEeHHtK1KA32Oh4BvD5pxRHzbDl+DHwOIhAvuB9jirqfyrBrH+vb+KQ== X-Received: by 2002:a17:907:9485:b0:6da:aa54:a88 with SMTP id dm5-20020a170907948500b006daaa540a88mr6248462ejc.427.1650025859818; Fri, 15 Apr 2022 05:30:59 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id bo14-20020a170906d04e00b006ce98d9c3e3sm1649533ejb.194.2022.04.15.05.30.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 05:30:59 -0700 (PDT) From: Jakob Koschel To: "David S. Miller" Subject: [PATCH net-next v4 10/18] qed: Replace usage of found with dedicated list iterator variable Date: Fri, 15 Apr 2022 14:29:39 +0200 Message-Id: <20220415122947.2754662-11-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220415122947.2754662-1-jakobkoschel@gmail.com> References: <20220415122947.2754662-1-jakobkoschel@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , Song Liu , Alexei Starovoitov , Eric Dumazet , Paul Mackerras , Ariel Elior , Florian Fainelli , Daniel Borkmann , Steen Hegelund , John Fastabend , Andrii Nakryiko , "Bos, H.J." , linux-arm-kernel@lists.infradead.org, Martin Habets , Paolo Abeni , Vivien Didelot , Bjarni Jonasson , Jiri Pirko , Arnd Bergmann , KP Singh , Christophe JAILLET , Jakob Koschel , Jakub Kicinski , Brian Johannesmeyer , Lars Povlsen , Colin Ian King , Manish Chopra , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, UNGLinuxDriver@microchip.com, Yonghong Song , Edward Cree , Casper Andersson , Xu Wang , Cristiano Giuffrida , bpf@vger.kernel.org, Vladimir Oltean , linuxppc-dev@lists.ozlabs.org, Martin KaFai Lau , Mike Rapoport Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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