Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4722517ioa; Wed, 27 Apr 2022 09:40:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEXAoiSqTMItvtlB4NDAIlv6XAQRo/FHGxLd89ZaokPzDp6YqR3PiAHdeudnXslQTiYXvk X-Received: by 2002:a63:c49:0:b0:3aa:1ad6:2c9f with SMTP id 9-20020a630c49000000b003aa1ad62c9fmr24748097pgm.360.1651077613974; Wed, 27 Apr 2022 09:40:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651077613; cv=none; d=google.com; s=arc-20160816; b=as06T5vQwc9X2tNp0T40Ag9aN+rmx/NTpe+kjFDqPwlWyQubDUBTk7/Bmak9X7htnG XSIq/2JJC5Nt72qva/gIEqHEai7VY8CBKUx+LZE5MHp3ctZDpPql5ytbixrW/mTSJ+kR hAEGSgkIRzIt0qEprsqIVKDefgZnAobqBEl/kCG2wxpmnosrQIPMX04lerUAjj2SfkV3 w+stAMp2wzKFKPTePV3xO68gj3YPtJ9B1D2CL+QCLfOq55rWOOIZMK2e67RcZvRKDgG1 hKPiUm1wPlFH6RnrWpv6yrK3wWh+iq7cjY3lQVW4KTvAuuBs4bZTQ9mw8HGc6585ZSg1 TMnQ== 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=cM7cNDbZdzDRR54XOLUdiPP1jrQ7jBG9dEAYVsbcNLE=; b=d2M7E+kiCFOwg22derpBUtigkMwhLm/XMBqk0n9+Fymm0/OxhIcB5kqB/+tLGKfMtK 8NSdzoOhkfpKAJMs4IwUMGuqJpaSx7boo8jENeU00SFmF7fqAe3xmeAWzl+QBBaVhCNh oTWRATneyJM+v2IuWTQekWyGDArVFQKa8Z8Yv0gL23KzmZ0tSvoDYJcRxqFR7k9WRAXu YgrUYd+RTomHGxP5qJaC3gDSTqs2sg56u/AufaqOqq8lCugk4Z8OGqnnPDLrwFv618WN +hN67PMuD28DFNhfL4ZXzoLDO/8pCHVVGTWxiOeoCWXx/3d7O1H4qhLjPTEWQOmVPHY3 NpyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=A8Htft4E; 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 q15-20020a17090311cf00b00153b2d1659fsi2231041plh.423.2022.04.27.09.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 09:40:13 -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=A8Htft4E; 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 EF4EE3BD057; Wed, 27 Apr 2022 09:09:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242176AbiD0QMp (ORCPT + 99 others); Wed, 27 Apr 2022 12:12:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242199AbiD0QLw (ORCPT ); Wed, 27 Apr 2022 12:11:52 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25D043656CC; Wed, 27 Apr 2022 09:07:44 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id i27so4344371ejd.9; Wed, 27 Apr 2022 09:07:44 -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=cM7cNDbZdzDRR54XOLUdiPP1jrQ7jBG9dEAYVsbcNLE=; b=A8Htft4EvwT9SqEU+mp432FPrRkA/A2mubCUNTACbh+9ZsCDSEQeCbubYFCiwV7et2 32mxvLXoLsmy0FtItW3NCx3Y+UPEdZSLQ34uE6is2mvJFMXm5umdPUJMLfzfJhTfmTi9 v1Po3076bdspN+L8sUvAzgbuQCbpJrqPGIUfhUwNKeBCU4j2xZ7cO+oHyyX9Bm/D3avW jH2X/eRwkEoQkduB1jvkosr6wCQJvcQSFprdpnTZhOOATniOAsisRbmktjQ8at7BSBVA p1AtT1AEESuli07A4n8ALTyJJVp7iEYcOTqOBMEs3Aospfy47uA1kxAMV7zbRYd6g9ao /KMg== 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=cM7cNDbZdzDRR54XOLUdiPP1jrQ7jBG9dEAYVsbcNLE=; b=Tt8b5oRg0PwOGmBhTPEtkIMVED+BRDogP53CJLI0G+uQ+3BJtTx6WSa300YjX1p86N L3G0FV4cYe1IrqcnW9wS4D5szrPL85wqVz+c4EXqEK5YoHfxmJ+lJuLdJzR4R2PITLzN qIvZ3KyEqexaXkdQkY0BS39VRWGc8Gxr3dNGx761n3dWtEk8bL0lZJlXJ/Ar3QLZytoO la+0ofxTSnx8VrmI1OfQ+P103hwop1H60n/lZfqudi5LZyrOoXFukAkBWQpODOdqlmcd yq6Z03wIa9glhRG/O5w2ewn80rByIIARuSJNBRgIvMe2y8fQwS49d1eJ7Y/1gnN+bL7s Gd7w== X-Gm-Message-State: AOAM5306pTisCcxSd3oah/WOwsYLXugkKfGFgUGoiUU9anN06CsYbnsS S4EnShIXpz85oQnmCro9VlY= X-Received: by 2002:a17:906:824a:b0:6f3:a07b:2568 with SMTP id f10-20020a170906824a00b006f3a07b2568mr12694721ejx.84.1651075635044; Wed, 27 Apr 2022 09:07:15 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id n5-20020a170906378500b006efb4ab6f59sm6984098ejc.86.2022.04.27.09.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 09:07:14 -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 , Jakob Koschel , Arnd Bergmann , Jason Gunthorpe , Christophe JAILLET , Colin Ian King , Eric Dumazet , 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 v5 01/18] connector: Replace usage of found with dedicated list iterator variable Date: Wed, 27 Apr 2022 18:06:18 +0200 Message-Id: <20220427160635.420492-2-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220427160635.420492-1-jakobkoschel@gmail.com> References: <20220427160635.420492-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 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/connector/cn_queue.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/connector/cn_queue.c b/drivers/connector/cn_queue.c index 996f025eb63c..ed77599b0b25 100644 --- a/drivers/connector/cn_queue.c +++ b/drivers/connector/cn_queue.c @@ -92,20 +92,19 @@ int cn_queue_add_callback(struct cn_queue_dev *dev, const char *name, void cn_queue_del_callback(struct cn_queue_dev *dev, const struct cb_id *id) { - struct cn_callback_entry *cbq, *n; - int found = 0; + struct cn_callback_entry *cbq = NULL, *iter, *n; spin_lock_bh(&dev->queue_lock); - list_for_each_entry_safe(cbq, n, &dev->queue_list, callback_entry) { - if (cn_cb_equal(&cbq->id.id, id)) { - list_del(&cbq->callback_entry); - found = 1; + list_for_each_entry_safe(iter, n, &dev->queue_list, callback_entry) { + if (cn_cb_equal(&iter->id.id, id)) { + list_del(&iter->callback_entry); + cbq = iter; break; } } spin_unlock_bh(&dev->queue_lock); - if (found) + if (cbq) cn_queue_release_callback(cbq); } -- 2.25.1