Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp765075pxb; Tue, 12 Apr 2022 12:52:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfpP6VXUL6evTo+PLQNUZHxnit7bAmKR2LpV0TTR4IoGSilqTqjbkRcqqmCr1tS7oK/HXJ X-Received: by 2002:a17:902:a610:b0:158:9fdd:332a with SMTP id u16-20020a170902a61000b001589fdd332amr46247plq.94.1649793124022; Tue, 12 Apr 2022 12:52:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649793124; cv=none; d=google.com; s=arc-20160816; b=IgNPTtjDkt/t/ijXoWJxBDQScSCgyAeihaskqQhNmNrOfYMEV/Vq8gVw891CK4ktab uqcLzohJPHs8zODdNLvsY0YKhh/WzuE8jMGbBRuqOvaLnMT5QRVlR9tJ4UIMGXeIMU6/ cBoa/Iu47pqGIWeH02DVkb4/k9tm4uDavdPCe4xZ7vsW79TLhtGDnKfN6gjBzIV254q2 zYE2Tp9FKmALyvmvG6QphToiTtQmBmzuLourt/6HsmscDGkeKIPAwjXVlRaktjgFjtHy hyGqrB24fHFYEB7BtIzytQxqb0t+nlysWhY28KyaPfAhsLtKzpGdbnrB4YVlHM7LDsx0 Ju6A== 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=X16Iheu2hhVLFYv8fYBCLXVby3Nm59BPmnfYzQsTkG7dZriKd58Vtyrcj/sW8GJ6mX 8ZUFBO/ery0pi8hbZ362yB/Enbd6l+ZJCSXCk4ObI1ieCTf/d7iIGRwARVeOdOB6zQxa YQMaplS6SAQZWTRbat05MnumflhpoOEhnHhCSfZ8Ja7YNdKMZLk4335mt6lUTL3M94Io uVrYFl0N1QVh4Od9pVq+/dFUOwpe/uNalGDzBE3D+4kJxx2H7RBGo8xCzzp7iX/dmlsn 1WNozMMT0AfwycOQCJi6hZCo+37NwDfaAeN8P2QkevhEBmvAks2GxrSyhWHQH5FzYt2h fEYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Dq5bCJRt; 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 i70-20020a638749000000b003816043f00dsi1415019pge.514.2022.04.12.12.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 12:52:04 -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=Dq5bCJRt; 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 73A5566C91; Tue, 12 Apr 2022 12:47:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345871AbiDLMFD (ORCPT + 99 others); Tue, 12 Apr 2022 08:05:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351230AbiDLMCg (ORCPT ); Tue, 12 Apr 2022 08:02:36 -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 51903652F6; Tue, 12 Apr 2022 03:58:54 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id ks6so11907313ejb.1; Tue, 12 Apr 2022 03:58:54 -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=Dq5bCJRtJE/e5zpt/g8uhjtXlNwlyc03WzbQtD9O5T08zaWWGjT/Ag4jl2RIuRXgby Qwp1u9x/IB/Ce8Tr45SP1TAHER+/BcDWmUe1rY27Gvh6LjoodLltMn89thpgVkWeCzNg rqa57oY9y6kks3VOOo5Bt/lyTCqXhUw7SHfUjEfDpc0MOnBo7ayHkNlFz/W0nSRwnPSM CrrAOtLgT3H8lrbkk5yFPrIkAf058eIaUNe+Jx7oKA0AvzHA9Qvgw8EjkcuX4nXj1tRe jVAH1HjMl1CSS9c8ic4HOkcYXj/hvp8Ub278a1c0JTZmcJDOxO79xPUVK1J8PTb2H7wl 0mEA== 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=XX/ekewCcxjpLoxFokyRvMs9vwd42qVwDFSugNGa2/9oqI2HBAe5meFPM70IVPldY2 FHD9YcKxPi8GGc0g/IWchO4gPezlkYE06NknZ1BqTK/y5K3LXrrtYTMiSOJ9uMDOBZOj 6XBLGX+3DnIfYIg6g6V1MfLSCGFf52CGVx8dxhgDagS2r8qtfePiNIhqlR/MbfNWBS+d HgSgy/tmzt7B4WV5Tqe/cY8f2Ebj1mVUSigLKNJODp3mITdBPaWnH7kII2i4WHbQvgUg TK7/Xz08/z0EPpHswCPBqWF4k3yKisKj4vh2i5JO1pQVpCloOFLT3G3tMn/tl4Rpzpkd 98xA== X-Gm-Message-State: AOAM530cc5agXRMN4/Mr2oXS6Qtp/PcBawtnKWKLDIVWOgQaYyZFnQ85 NDVdqsC5zMvjDqnaeBShmVM= X-Received: by 2002:a17:907:3f86:b0:6df:ad43:583 with SMTP id hr6-20020a1709073f8600b006dfad430583mr34406710ejc.535.1649761132855; Tue, 12 Apr 2022 03:58:52 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id f1-20020a056402194100b00416b174987asm16986370edz.35.2022.04.12.03.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 03:58:52 -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 , Colin Ian King , Arnd Bergmann , Michael Walle , Christophe JAILLET , 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 v2 01/18] connector: Replace usage of found with dedicated list iterator variable Date: Tue, 12 Apr 2022 12:58:13 +0200 Message-Id: <20220412105830.3495846-2-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220412105830.3495846-1-jakobkoschel@gmail.com> References: <20220412105830.3495846-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/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