From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D439C433F5 for ; Thu, 7 Apr 2022 10:31:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244285AbiDGKdL (ORCPT ); Thu, 7 Apr 2022 06:33:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244265AbiDGKdE (ORCPT ); Thu, 7 Apr 2022 06:33:04 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D202063BEE; Thu, 7 Apr 2022 03:31:03 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id a6so9996541ejk.0; Thu, 07 Apr 2022 03:31:03 -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=kTFV0s1DjklFKRy0TxWbeuj3zyRHFlGqWxH8nk8PEziPdH89zJ1oEWCvPebSyljT7t 35la7ZWPkDDKsLVhEAApa9g88yhD63+pyT8BlwBuYAPTEgueqtF1sdFEWR5UcBp65VMx HOLWtbTxXIBd2kSmcA4s8II/S+vr3eEeHlitrPYWKGN9NvHT7aQc98MiahddFrObEkRX oqgXKsIRyM/+oWEyboW7eQT08MSgJs1f2RKCWSGK2HrAZG1DcfurHSRM8THpWtIME5Ml efjWAnlzN/ExmS0f440FnRzvRPuBSY3nLe3+faUuHbLFeXj3B2TITC0/8tWm+brWuhH6 Gbbw== 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=I0YtiX0nsTXQo8oJvLCoNlHny3X/iQEWFV2dLJUIImQuyoqTbDDOZwQD4Jwyuf3Gu1 neysuTI8S+/D+KY/I/KHTtxCGYA7Eciwsh+g1lTAVVNwkbCTzLHglh6EsAhiBhnFVj3f lKU/IF7rTbFrzmoqsFE2YtGRdI5s2l8Yuj+8+iYP3HYDOQQkIWRnvTvnBLeQwrYtxaxk /rTxoqUV1AQxDcbmtH860E7y4WYPPmoLZBXVjktyOX3rc0DihBCUPfHDrt5Oh8kEt/9i k86v0Uz5NGKA47MnPNbpgHCHoIMeD54tFoB8W8q4Fcav8DIXhfw+xoZiYvUmttFfh9nl LwHA== X-Gm-Message-State: AOAM530RhxFPpvfVDGS8uk79QCYNQxjvlPahWzjJEnLHmcFOECMFrZ5x KaLoDCcXD48xRevUS1QvI4c= X-Google-Smtp-Source: ABdhPJx0s8F+/Psbc0WRtBOGXMMQgcpVlU8uStqX8d6g32cAFKeTa6M6kXCz4rf1z38mgVMSQlqn+g== X-Received: by 2002:a17:907:1624:b0:6db:8caa:d71 with SMTP id hb36-20020a170907162400b006db8caa0d71mr12894106ejc.723.1649327462239; Thu, 07 Apr 2022 03:31:02 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id c5-20020a170906d18500b006ce371f09d4sm7413573ejz.57.2022.04.07.03.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 03:31:01 -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 , Casper Andersson , Bjarni Jonasson , Jakob Koschel , Colin Ian King , Michael Walle , Christophe JAILLET , 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, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH net-next 01/15] connector: Replace usage of found with dedicated list iterator variable Date: Thu, 7 Apr 2022 12:28:46 +0200 Message-Id: <20220407102900.3086255-2-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220407102900.3086255-1-jakobkoschel@gmail.com> References: <20220407102900.3086255-1-jakobkoschel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 08C7DC433EF for ; Thu, 7 Apr 2022 10:32:21 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KYyPH4hHtz3bpX for ; Thu, 7 Apr 2022 20:32:19 +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=kTFV0s1D; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2a00:1450:4864:20::62b; helo=mail-ej1-x62b.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=kTFV0s1D; dkim-atps=neutral Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) (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 4KYyMw3HMxz2yWN for ; Thu, 7 Apr 2022 20:31:06 +1000 (AEST) Received: by mail-ej1-x62b.google.com with SMTP id ot30so9803754ejb.12 for ; Thu, 07 Apr 2022 03:31:06 -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=kTFV0s1DjklFKRy0TxWbeuj3zyRHFlGqWxH8nk8PEziPdH89zJ1oEWCvPebSyljT7t 35la7ZWPkDDKsLVhEAApa9g88yhD63+pyT8BlwBuYAPTEgueqtF1sdFEWR5UcBp65VMx HOLWtbTxXIBd2kSmcA4s8II/S+vr3eEeHlitrPYWKGN9NvHT7aQc98MiahddFrObEkRX oqgXKsIRyM/+oWEyboW7eQT08MSgJs1f2RKCWSGK2HrAZG1DcfurHSRM8THpWtIME5Ml efjWAnlzN/ExmS0f440FnRzvRPuBSY3nLe3+faUuHbLFeXj3B2TITC0/8tWm+brWuhH6 Gbbw== 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=3/G5t49j5Tj/W9FRbYx3ErRTFOmifmDoFvvdtOBT4zmnKDNfGCGI+IM/EnI/Hsfann 5ylK7ASVzqJcfITuH3XKAdpuXRmW2l3pPF0dNvN3zROwvCQqNDEv1KK5/mX//l2sglgp 1wL+KwyK2R3Oz0L3NEmhfd94i7XHGwKJeEjnVvgrdSmvjoZTypQUtF9C3deltJVYW+lh kLfgBQtTzAyMBX14JrEx/Um4/l1nYB2TKdqsRhUpFDJBuYZ/gGCDyaDfWjPQx3mUg97m lBwBW34LEzELoyKwdM2pYlkjprmo/EydRlO/bSUHM7YBQjau7RrjC+vRH4jdLrpew1hJ UNDg== X-Gm-Message-State: AOAM533pDYGYq9z+JC1H5Pb2nRxifowsdX4O66qCx7ZzXUsh+4AQNey/ BZJWDZqygY2iY5fLEt1TnC4= X-Google-Smtp-Source: ABdhPJx0s8F+/Psbc0WRtBOGXMMQgcpVlU8uStqX8d6g32cAFKeTa6M6kXCz4rf1z38mgVMSQlqn+g== X-Received: by 2002:a17:907:1624:b0:6db:8caa:d71 with SMTP id hb36-20020a170907162400b006db8caa0d71mr12894106ejc.723.1649327462239; Thu, 07 Apr 2022 03:31:02 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id c5-20020a170906d18500b006ce371f09d4sm7413573ejz.57.2022.04.07.03.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 03:31:01 -0700 (PDT) From: Jakob Koschel To: "David S. Miller" Subject: [PATCH net-next 01/15] connector: Replace usage of found with dedicated list iterator variable Date: Thu, 7 Apr 2022 12:28:46 +0200 Message-Id: <20220407102900.3086255-2-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220407102900.3086255-1-jakobkoschel@gmail.com> References: <20220407102900.3086255-1-jakobkoschel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 , Cristiano Giuffrida , Eric Dumazet , Paul Mackerras , Ariel Elior , Florian Fainelli , Manish Chopra , Steen Hegelund , "Bos, H.J." , linux-arm-kernel@lists.infradead.org, Martin Habets , Paolo Abeni , Vivien Didelot , Bjarni Jonasson , Jiri Pirko , Arnd Bergmann , Brian Johannesmeyer , Christophe JAILLET , Jakob Koschel , Jakub Kicinski , Di Zhu , Lars Povlsen , Colin Ian King , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, UNGLinuxDriver@microchip.com, Edward Cree , Michael Walle , Xu Wang , Vladimir Oltean , linuxppc-dev@lists.ozlabs.org, Casper Andersson , Mike Rapoport Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.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/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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 061BDC4332F for ; Thu, 7 Apr 2022 10:32:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xbjidfZkl6jj6noLfa/2qF0xzgO9b9J995g5XlNZmb0=; b=QGnBOTijhOn6UM e6yF76hXVyuggQaBwEsU/UbZaDk/09GCQ26Mg5HGL6+bExFy1kf7l3O2exr6WRy0QiZR0iqpN3tBQ n1b/pcdAuIYP2GAwauojTcv+USqeqHvkwYrfgntPJBr9u7SrXjF+VPHXSvg4DCtn1LLK7sUg5px/v TkQhRBznULfo55nEW83YBb50AeIeV/tShqSX1Iyc7rH34NWu/eB9te+cIeOp3/ZBIpiDFp26QKGop 0ZeKS6ev2hBdwoatnmuGlwEZtpMhCxkuybTcMatNTIVfqEMW8iH02Npm/oDT0KgA3JOzrkeXDRInV /apasYKfpxffniVnfzRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncPQE-00BENz-UL; Thu, 07 Apr 2022 10:31:27 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncPPu-00BE96-3b for linux-arm-kernel@lists.infradead.org; Thu, 07 Apr 2022 10:31:08 +0000 Received: by mail-ej1-x62f.google.com with SMTP id l26so9927913ejx.1 for ; Thu, 07 Apr 2022 03:31:03 -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=kTFV0s1DjklFKRy0TxWbeuj3zyRHFlGqWxH8nk8PEziPdH89zJ1oEWCvPebSyljT7t 35la7ZWPkDDKsLVhEAApa9g88yhD63+pyT8BlwBuYAPTEgueqtF1sdFEWR5UcBp65VMx HOLWtbTxXIBd2kSmcA4s8II/S+vr3eEeHlitrPYWKGN9NvHT7aQc98MiahddFrObEkRX oqgXKsIRyM/+oWEyboW7eQT08MSgJs1f2RKCWSGK2HrAZG1DcfurHSRM8THpWtIME5Ml efjWAnlzN/ExmS0f440FnRzvRPuBSY3nLe3+faUuHbLFeXj3B2TITC0/8tWm+brWuhH6 Gbbw== 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=C1IhTOA54xs38/JQhLPJFvq4kSMuJPVAo4DUgP68b94CgJ8P+f+4dlGndrurs7pi1c FCvH83dCMFT1H9aP1HEs/2QlLt0hQmg2eLj8IWcUt9Y/wwNqUylqKqQ7W/xxAe85wm+P DjelvR7lNIMHCxYoZBlAb1aMOLnjBL15HDsezNKeOLU6ai8CRsTqGdPeSijRK0iP1FAG lhlqUI/8RQ8wLf3I5W2x9Dp09Vn8hiTIW8D1cWKFjTmMufdZsHnAS4APNuOz68OkTPk6 NQtxfYZ+YDwqt1QNz/rlnCHuTDnvThXxA48nCXT6FDk1rzlLvuI5SDFAdEcv76e2SPEJ Q2ww== X-Gm-Message-State: AOAM532mBeHheA2rKYeEbq843uKeu2yOX08Lhh4AlVg2F3KKCy8YvaGI uaHSrRRNCiZ94bjtnPWpWMI= X-Google-Smtp-Source: ABdhPJx0s8F+/Psbc0WRtBOGXMMQgcpVlU8uStqX8d6g32cAFKeTa6M6kXCz4rf1z38mgVMSQlqn+g== X-Received: by 2002:a17:907:1624:b0:6db:8caa:d71 with SMTP id hb36-20020a170907162400b006db8caa0d71mr12894106ejc.723.1649327462239; Thu, 07 Apr 2022 03:31:02 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id c5-20020a170906d18500b006ce371f09d4sm7413573ejz.57.2022.04.07.03.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 03:31:01 -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 , Casper Andersson , Bjarni Jonasson , Jakob Koschel , Colin Ian King , Michael Walle , Christophe JAILLET , 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, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH net-next 01/15] connector: Replace usage of found with dedicated list iterator variable Date: Thu, 7 Apr 2022 12:28:46 +0200 Message-Id: <20220407102900.3086255-2-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220407102900.3086255-1-jakobkoschel@gmail.com> References: <20220407102900.3086255-1-jakobkoschel@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_033106_233239_4643D59B X-CRM114-Status: GOOD ( 16.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel