Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp268580pxb; Thu, 7 Apr 2022 05:15:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKnk0DmEf780D7af8/iCbt4arKFJ5JNKT1Z/gnh/E72wsx9P+vHCGOKh5AWJk2t4QNT7VQ X-Received: by 2002:a17:907:2d0a:b0:6df:87bd:4cd5 with SMTP id gs10-20020a1709072d0a00b006df87bd4cd5mr12966330ejc.423.1649333731912; Thu, 07 Apr 2022 05:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649333731; cv=none; d=google.com; s=arc-20160816; b=RyMSpvpj0neenS9C+VGFUvHvMn2bIYOpQ9i9tvQnQjUt1y9oo6UZjX1TvrW3SkvGMS gShLK/saPW3qjPMOGGHeaVcKECgm+V3aKCZnKUrr8ezcqPv9Q8+Ug8buYzpD+AwlmY0V B5mHPjdf5v3FO5TAxVhXio86+RrdlpafR3ZlIRqIdMmJNB6NqsV2B0rfhMIMFvTkrt+f ppfOU9JF+o7hMaNEe91v3OHJzr4R6zUA3En1TmppnYc2cGlp05ZJixg6MksEdePlrqp8 CtyzS/lWoLTM6YCokGv38HzcE6QCOhZQYjsZIW98pfsWAxf+t7yrvuOBj1CrgGaWqxzd jjOQ== 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=b8gmeRGyKvY60Wlu7/HBhNHv1s7dtw+FyXDzerRAS7FzTuhJ3371KPmYO8S6XeQnqd Ux8/3/31EFfDF091k4VpRALHUQsiN6NZHFfW/diKy5S37hz0T3EoRpsyfbiWIgtvI3SD 0aqfSfAeG5rDRtZb4eawqZDsOw36q/xUnkmQjhESo/flTRb/G4Z4lOXqP1rojvhK24D9 yQOKY5GAGU2U/NFLv6SLXdKf8NNVO7cX3BDgqh6yPK0wr+4ioOSRvS6ALpmxMUEBFqRu rU67GNKGKE5Am/ijFKpJvc3bfcoxufTvtmzSJSfLMS7336Yn48JwaxfEMKJQOKYV2vJt zCiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kTFV0s1D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j14-20020a50e0ce000000b00419628a9fcasi13571580edl.54.2022.04.07.05.15.03; Thu, 07 Apr 2022 05:15:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kTFV0s1D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244282AbiDGKdK (ORCPT + 99 others); Thu, 7 Apr 2022 06:33:10 -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-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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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