Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1810294pxb; Sat, 2 Apr 2022 04:32:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzio+KCWhBzuCVRMDLcVFoc1wGLRM/D640WAmpiG27T6GK/pwyGzqAdSuOyMRz40YsiiwFP X-Received: by 2002:a17:907:168a:b0:6da:9167:47dc with SMTP id hc10-20020a170907168a00b006da916747dcmr3418281ejc.126.1648899157064; Sat, 02 Apr 2022 04:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648899157; cv=none; d=google.com; s=arc-20160816; b=R8U/jzjh0XB4vkTNx9PDr5Y2YykU1fe7zC1EUCV4WcPftTH7gA82WRzDweq0vNGjs4 cZxdTS7wu9DBUCB1xe0OX+Ce4gI/TvlEGLwbPFw6tfJcSWCv5QmXEvGPO8+L9QzuO+HT 8lgT9p7W794dJGOOwTJh25bpy927RKX1Pr8QsrpHt7wwShuo0j/eIlbRip9Y4uQ9zUyK tt+MiDWqlgpCtP1dnijl+19GB+9RGT4vDLvpiJqX8iWKIxP86oM5u7kxSbYo7WHiPL9a PJqwpUAkM+2gotSNpoKTHS17TZW2GQjL8l+UGN2dc6i//vqyKv4QYytDpjrpQmGbXAyQ vv+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=Dbd+FeFljOdDtTjz0SE9OURXlnjXbAIwzSzKI/SK8Hs=; b=oFbXV9J32ZBLT8qdyQp7J8ts4kbTlBVyvEffsu0vYikl2q7bEn6FLyDa/zDIHZ0TbX Tn0ENOe6N8Q48I8Br6aGkrVp/Bo6EJ50q7JDAtKIjlZG4y0z+TyNpWts4ZysqdBsrWaY tVgK58aUvnvytJ3b/0bdpzyRin0Yj7h3b4wPsLGbgDlhDH9aB/wAc6cTkJT44fGFJ+d6 GSCx+7sxXZJ1Xcytpa2cKR/r/OLC309/KfHShmVq9KdmL+bS0wyywp7IfGM1xphTU6AO RRsydJpNoJbYlTanpo0Oa2pBqGYUuDuhQ+X4/cYM/P+foo9ysXbQs7kdwmerkmKqe2un ptlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oPmqCMSQ; 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 ew8-20020a170907950800b006df76385b80si3018962ejc.32.2022.04.02.04.32.06; Sat, 02 Apr 2022 04:32:37 -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=oPmqCMSQ; 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 S242790AbiCaXJO (ORCPT + 99 others); Thu, 31 Mar 2022 19:09:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242767AbiCaXJH (ORCPT ); Thu, 31 Mar 2022 19:09:07 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32115241A13; Thu, 31 Mar 2022 16:07:19 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id c10so2244011ejs.13; Thu, 31 Mar 2022 16:07:19 -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=Dbd+FeFljOdDtTjz0SE9OURXlnjXbAIwzSzKI/SK8Hs=; b=oPmqCMSQjmk62BS1YZ2/0YxmoKih7cVsZOjbV01H/cpzCZXanTD3d+oAcdX2qAT8Oo OJ6zmB/cbMgqWwCjTZX9YHglYfvNyKkXL0dBQkpvJ6bOSJwen1FY9tRttbCFwqBF6TzO RNlET5odbw5xuBYazYYMj+FmmmY80K9h7Ow3n/vLJdKOBgKwTKSfoRwHd+yrX7i06b4H kHN3WV21ODDDom6U3LE578k/SU6cdEFz8PPfbV9MG3nFI9F3iaf96ynZYO5hLR//USCT MEBACGkXBQ+aaKwzYBllBhXZ5d97CXEhh/L0cJjrvxe1Y7Hn1Uod9pfnWatBNNsyDhCY LMTg== 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=Dbd+FeFljOdDtTjz0SE9OURXlnjXbAIwzSzKI/SK8Hs=; b=pvLXYK9V8cE20/5OJHtbSZg86WHYzVjhMt6b7SCbmhuhL/1ojAARojB5F+QFnXhSxu JcJ6Z8yfLoNFVikq5L/ZieHF9S56qdz6N6RPGACH3fVf2R3GwwyboYKvusPgzMKW533W M71LvSdisDSi1PiNLiY+EomSp6YOzJjT1XDsO11zrZm9mzHVV7X72p6VMTF331Fr9Ewo KkUa/DF5/VCAJkenS3o92dsP9fgVula12/bXvDtUczZ/hH1qq2fRt+3kS1ZbZQUhnvYv OxA6b+oB/R6VwK0oN9sPNioEtcXmZM9En1Zib4hL/eWugUs6JmxgGTlEEasfTx5HdfO1 wMZA== X-Gm-Message-State: AOAM533Wpo7+f58m/kIE7+LKhGo+DGJACP5z9caSP5Tj3ODlN2BTt/dZ q6jfhYNb2tzgBPAwdKKX4rU= X-Received: by 2002:a17:906:2a85:b0:6ce:36bd:bcd9 with SMTP id l5-20020a1709062a8500b006ce36bdbcd9mr6819245eje.318.1648768037754; Thu, 31 Mar 2022 16:07:17 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id p12-20020a17090635cc00b006e055c9c91esm297131ejb.101.2022.03.31.16.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 16:07:17 -0700 (PDT) From: Jakob Koschel To: Jonathan Cameron Cc: Lars-Peter Clausen , Dan Carpenter , Jakob Koschel , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." Subject: [PATCH 3/3] iio: sysfs-trigger: replace usage of found with dedicated list iterator variable Date: Fri, 1 Apr 2022 01:06:32 +0200 Message-Id: <20220331230632.957634-3-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220331230632.957634-1-jakobkoschel@gmail.com> References: <20220331230632.957634-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/iio/trigger/iio-trig-sysfs.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/iio/trigger/iio-trig-sysfs.c b/drivers/iio/trigger/iio-trig-sysfs.c index 2a4b75897910..f1a8704e6cc1 100644 --- a/drivers/iio/trigger/iio-trig-sysfs.c +++ b/drivers/iio/trigger/iio-trig-sysfs.c @@ -176,16 +176,15 @@ static int iio_sysfs_trigger_probe(int id) static int iio_sysfs_trigger_remove(int id) { - bool foundit = false; - struct iio_sysfs_trig *t; + struct iio_sysfs_trig *t = NULL, *iter; mutex_lock(&iio_sysfs_trig_list_mut); - list_for_each_entry(t, &iio_sysfs_trig_list, l) - if (id == t->id) { - foundit = true; + list_for_each_entry(iter, &iio_sysfs_trig_list, l) + if (id == iter->id) { + t = iter; break; } - if (!foundit) { + if (!t) { mutex_unlock(&iio_sysfs_trig_list_mut); return -EINVAL; } -- 2.25.1