Received: by 2002:a05:6a10:3150:0:0:0:0 with SMTP id m16csp3146366pxc; Tue, 12 Apr 2022 14:53:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEf45AGPL9Z7SQ1SSnkgN2RfP0GqjYihTH71oItxTI6RsthF6EK9l99vLsCJcVN1D738sj X-Received: by 2002:a05:6a00:1988:b0:4fa:c15d:190d with SMTP id d8-20020a056a00198800b004fac15d190dmr39230375pfl.44.1649800410945; Tue, 12 Apr 2022 14:53:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649800410; cv=none; d=google.com; s=arc-20160816; b=eXjTH5a8N1KPZhJacdXcj6jqs8Qg2zOkHd2QQC6HEJQEG018YvukSjl/O9rRCoJV6Z RuG6/zfcIOppZ3mg87ohTb+mfTeI7TqX40XK7WLY9ftWp09MQGUF+Ot1ScmdG4EAOckJ OU/hHMMVyrr6KArO4h17W5zuiOSk/01Wss8lYXIBDg2VVij/fiSrz+rVVRMExYnJq8NT 5D57QfPkVoKUDgThgELzd86qR+1m6+h40nn4A1yBEKzRaIwofwc9p7R4HQQm4JZddGcl RjMvgQhYDlEWLNf+tcAYg8oOEmOgvmYOrfLXG5nOL8RCv6lE0lh97h5dsdtWzNliMr/6 A9+w== 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=A3UAwQf1PEgymUIh53m3CAQzVixWt9JlbOpOlCGpLKqz2hyLPKTyLW+KVaoUslsRpq c3SSjvzyLjfgTXe/uyNY9Y7cvn3RcLSGSvivlNkqhYuW9bAyvV5H93hULpniNEaXDhvP 7qHg4qdFovaXur+/Lr5zkA3tQm9E1/Xmj8wau/xIwcUohgk8I5b9bX8QslYCRasUkMmS gTgr+pCTm2Ksx4vkapWl79AXwq+ruPAKwBxdM6BT/cnkark/sohYc6bDtDxupxIPakw0 Y+aEt2SuMQBxQ2Mw7SqWLa3cqG4Ev3Bqnff423vP81utvrIaT76lE202ZPeucssaShZq a/bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dLGG+W1Q; 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 v188-20020a6261c5000000b004fa3a8e0096si12216342pfb.333.2022.04.12.14.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:53:30 -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=dLGG+W1Q; 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 38CC711CF66; Tue, 12 Apr 2022 13:47:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350707AbiDLMvw (ORCPT + 99 others); Tue, 12 Apr 2022 08:51:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355267AbiDLMsJ (ORCPT ); Tue, 12 Apr 2022 08:48:09 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8DB122293; Tue, 12 Apr 2022 05:16:23 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id bg10so36959822ejb.4; Tue, 12 Apr 2022 05:16:23 -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=dLGG+W1QjtHthDDhe+f38oZpmGxVOt8eok0rdcZmZGotUR9zQdPegeYKMvVVn6hhN8 qALqEdKKNFIGUH/HxVhE21OebCrqrKHMzIYGsTB5yEGRljbDOMsMTyLG9yR0dWwY86qh zMJf4D5teJhK+o/3/TSV9rVZ6vpMgLcWjBGrVwtkw/9kEVxy6uZo+dM1QTZhM5/zPIG6 ZiUdEbTmhE4U8OEgTBt6TEp+l0s0P1gPVwHjLBwdpt+N/HFRxSQyJ1LPJZv7nCJlarU6 V4JNB5zawviACWFRP45EzqRiDHEUyVoR6F2/OjAOoeLW8M1Bf3abkJu4gBUNbFDMvZRg KhPA== 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=2o6qBFN+z2yQWiNrJULDWWeNGx0X9YpgFjJAmMqI/PCW3NcYbq1OQeClK0+hTSCiXk B55DUgwehXrKwMqAYl55lY1nv0JEGguIOEv8k++yUBReo+uySVbGbYti+ooXY/K3HAhL 41xIH9iD6SnFgw78aMbOPROlrPyhvZwcN3g8SUtjXJUYbaEM1coP+Y83nqZwCFitoZZF 3er7kpP4xE89YT7GcZBXz2eZwXDWYg4ZBnrqMlfyXIDOE9WUkxExhYxzVEmemce/ERyH iiBGrLVOBygGDR3rLFnHQ/El111iI5K5CtyCtSHHNfyzSuLB7QoN3OBMcljPa03SJJRJ ZUHQ== X-Gm-Message-State: AOAM532d88gweg/SflrfVcl2DXjS9ENJETCIWKuPNwBk3rKkOoA1Wc1S 7xY6ss1BM3u2vXBYUYXeQ+g= X-Received: by 2002:a17:907:6e0d:b0:6e0:59ae:21f1 with SMTP id sd13-20020a1709076e0d00b006e059ae21f1mr35335459ejc.362.1649765782495; Tue, 12 Apr 2022 05:16:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 05:16:22 -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 01/18] connector: Replace usage of found with dedicated list iterator variable Date: Tue, 12 Apr 2022 14:15:40 +0200 Message-Id: <20220412121557.3553555-2-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/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