Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2112729pxb; Fri, 25 Mar 2022 11:18:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycEXORPEzLMprp3KuptkVnYdWs5iagWbBVFRmR23YRG2bure9gNwzCsp7SIaYsvoZJ0+r8 X-Received: by 2002:a65:4081:0:b0:381:6ff8:f4ba with SMTP id t1-20020a654081000000b003816ff8f4bamr633759pgp.457.1648232305999; Fri, 25 Mar 2022 11:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648232305; cv=none; d=google.com; s=arc-20160816; b=g+h3iY6Yud/+bY6JCWZeN6AAEXFOKBrOsbY6RjFlLn0+87cOl4thoDfVYqXXutwhcc dm0Qg1RuzxLuPA3xTgKm8gQm3vKhLdg3LSalQzgNaU1UWesMgVYMKUvTW0Vlm35lo+X8 bu2H42WGTZG5n9+6c06ZUWsXXYU3tgmwjZMEXP1iE6AGGIjHv0VBf8WeOdWUbZD5ECbq nCZpkme4y3aS0VQIXgFRKqP13eMIci8qnXqRNVj4KSHZuIKi71iT8b29tdliFld4flb3 k5A90miVsL2NPncx5e+EoLQkVnKcqI/4WZjTvCVqXW3mZSNzWYqZVpMOEyNPUKPCAZs8 HuGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :subject:cc:to:mime-version:user-agent:from:date:message-id :dkim-signature; bh=kZCJsDwuqFmPdGnVK+OvD0sFJ1NQAHf3rkQ/uko1Ypo=; b=bRH4OGlQT+mB8yIKyrW3zGwo0ZTU2mC9ZX+b3OlHqVU5itGZz7I8h2SqCjq1VKUG1d jQ4ColUN1KhRGwemgRLRylwmvbNw7gBVUdIsz/8ie+a1NM1Sfpa8M4kDCVIgWF4yIbTR mhLA2YXkwfIctcUu+L7Ur3P3GOCGqsYyC2CUbU+WyCOAHc6VUV0HGTKh/Tx0wE9KTjwP Y9daA84kxgfG/Swiu8qfUZuNMYmhDypKz5WQiNN4yGUQo8xsffKlQ9oMQ5u5+QnczTEq wHEq6DM4nGT1Q/ErGn/MuZwmZwucV3NeBDOVf8c5pf/ZOz8p/GMzAf+XHLReuiTFO8QZ Jy4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="TLgs+/f1"; 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 p14-20020a1709028a8e00b001541c9df632si2885243plo.400.2022.03.25.11.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 11:18:25 -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="TLgs+/f1"; 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 C225815B87B; Fri, 25 Mar 2022 10:46:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351361AbiCXPoM (ORCPT + 99 others); Thu, 24 Mar 2022 11:44:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351343AbiCXPoL (ORCPT ); Thu, 24 Mar 2022 11:44:11 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48238A1447 for ; Thu, 24 Mar 2022 08:42:39 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id p15so9967067ejc.7 for ; Thu, 24 Mar 2022 08:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-transfer-encoding; bh=kZCJsDwuqFmPdGnVK+OvD0sFJ1NQAHf3rkQ/uko1Ypo=; b=TLgs+/f1fDU/asNFSeTTbfgjarvjKtaY7VH4v6LErCV5kTHXrowQmCYq+4ZwYBZ1k5 L7DtOzlE30HO8bY0DShfaoOTFaobumChKR+E5mRqWzSrjrJQsNG4bJLwRQqSwxejBLfA R8B1oNJ32Xs4hsmgRL7crsc7hH5IIa+gMaTKeUYSZq++tzRI3Dxk5PxyHA9bE7bNBWuQ AdtT4WVvDon+nZLvjLoviTiD/LznDmH+itMDO73OCUUCXwZTN3ndBHAztu2kArqId9cj YSMP98LdTwuy1WuvppskGjKRUl9O9vDXstuP3g0sW8QSUmHz3pQKJhoLe1fcOzQdAVnP vpYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-transfer-encoding; bh=kZCJsDwuqFmPdGnVK+OvD0sFJ1NQAHf3rkQ/uko1Ypo=; b=nLOFVQVZnDP7Da+z386NE9SzRBO6fRBLdff3zFAZU8WiSnqlQQip2mSFySxvDOH1bC 2YaNv3Kzi/YkAm5cboKANcrtcdRs9i0eGKkOeF5FFUbFvujPDGRMkJdlQB8FLkkHdZzA Nh38K09Jvs6ZyZ6H8d1Ya8ewzS3/L6xcjAZNvbE1B6ai/eq8PfcgS9rebfvGFkHSQdsy 5G8tKt0U6LrMQnu0H6VlSfXmmrHX5iqvOCt+pNqz95pZBsEYnT3+7QBa25TQOz3mcMXs ZgDJIqAtP1+rR918Uz5RUd80dYSOPHLLwJjhSNjn8ouRs/mMut6Md3MsrWhrjwbNNCHU WUvw== X-Gm-Message-State: AOAM532a2twpO7tuj7MFxyMYZi+ZEaVNt+eYvy3e/il+Vofb8u77ojPH Xk2HDJ2brrGOy94PEjvK8SM= X-Received: by 2002:a17:906:58cb:b0:6df:f696:9b32 with SMTP id e11-20020a17090658cb00b006dff6969b32mr6597382ejs.384.1648136557640; Thu, 24 Mar 2022 08:42:37 -0700 (PDT) Received: from [109.186.89.7] (109-186-89-7.bb.netvision.net.il. [109.186.89.7]) by smtp.gmail.com with ESMTPSA id u4-20020aa7db84000000b004136c2c357csm1549665edt.70.2022.03.24.08.42.35 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 24 Mar 2022 08:42:37 -0700 (PDT) Message-ID: <623C9137.3000803@gmail.com> Date: Thu, 24 Mar 2022 17:41:43 +0200 From: Eli Billauer User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100907 Fedora/3.0.7-1.fc12 Thunderbird/3.0.7 MIME-Version: 1.0 To: Jakob Koschel CC: Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Mike Rapoport , Brian Johannesmeyer , Cristiano Giuffrida , "Bos, H.J." Subject: Re: [PATCH] char: xillybus: replace usage of found with dedicated list iterator variable References: <20220324070939.59297-1-jakobkoschel@gmail.com> In-Reply-To: <20220324070939.59297-1-jakobkoschel@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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,NICE_REPLY_A, 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 Thanks. Acked-by: Eli Billauer On 24/03/22 09:09, Jakob Koschel wrote: > 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/ > Signed-off-by: Jakob Koschel > --- > drivers/char/xillybus/xillybus_class.c | 26 ++++++++++++-------------- > 1 file changed, 12 insertions(+), 14 deletions(-) > > diff --git a/drivers/char/xillybus/xillybus_class.c b/drivers/char/xillybus/xillybus_class.c > index 5046486011c8..0f238648dcfe 100644 > --- a/drivers/char/xillybus/xillybus_class.c > +++ b/drivers/char/xillybus/xillybus_class.c > @@ -174,18 +174,17 @@ void xillybus_cleanup_chrdev(void *private_data, > struct device *dev) > { > int minor; > - struct xilly_unit *unit; > - bool found = false; > + struct xilly_unit *unit = NULL, *iter; > > mutex_lock(&unit_mutex); > > - list_for_each_entry(unit,&unit_list, list_entry) > - if (unit->private_data == private_data) { > - found = true; > + list_for_each_entry(iter,&unit_list, list_entry) > + if (iter->private_data == private_data) { > + unit = iter; > break; > } > > - if (!found) { > + if (!unit) { > dev_err(dev, "Weird bug: Failed to find unit\n"); > mutex_unlock(&unit_mutex); > return; > @@ -216,22 +215,21 @@ int xillybus_find_inode(struct inode *inode, > { > int minor = iminor(inode); > int major = imajor(inode); > - struct xilly_unit *unit; > - bool found = false; > + struct xilly_unit *unit = NULL, *iter; > > mutex_lock(&unit_mutex); > > - list_for_each_entry(unit,&unit_list, list_entry) > - if (unit->major == major&& > - minor>= unit->lowest_minor&& > - minor< (unit->lowest_minor + unit->num_nodes)) { > - found = true; > + list_for_each_entry(iter,&unit_list, list_entry) > + if (iter->major == major&& > + minor>= iter->lowest_minor&& > + minor< (iter->lowest_minor + iter->num_nodes)) { > + unit = iter; > break; > } > > mutex_unlock(&unit_mutex); > > - if (!found) > + if (!unit) > return -ENODEV; > > *private_data = unit->private_data; > > base-commit: f443e374ae131c168a065ea1748feac6b2e76613 >