Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2130023pxb; Fri, 25 Mar 2022 11:36:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/PUoCS4eQCLnukDELfwxzqqyenSgExL34ig28Ivj3fW6hs8kwznF5za2mUVEfo1ll4+Au X-Received: by 2002:a63:1266:0:b0:381:5071:e942 with SMTP id 38-20020a631266000000b003815071e942mr750297pgs.86.1648233411144; Fri, 25 Mar 2022 11:36:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648233411; cv=none; d=google.com; s=arc-20160816; b=UAXwdjwdwpOS+Iyn8kZgM8XqebpDkyl/N8PUP5meKp7D40g7yn+o0BMLnTjR+LEYpm WjWvUL0vJWfBNpYjhN+ATHcXHotGpfGXReVR8WMjVfC7jDVLxE/QVdbbxbcqo9ZWsMrR aa9XpKVIYWtHiZTWxflLzv6lRYuH/CKQjJlU/7K1bgNXYs2SRSiSr+12jYChfm23q7+5 Jn52Mom/hG3gbrWXU9MTd5suIm7u+DPgjTbmdPWto5/3hOYuZspnBjA2L7cUOa/Apf3b qmyYdQ5yrRRZF3YNySYMittTQvRU0aEGZHid+pPWZRjNMrMRF4qDr0RTXBxcPvO4FCuc 3RJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=7fjXSK3Yvyz7mSD5V7xuckH+eT1koYaMuBSGDuDa7Jg=; b=eHuF4v0fqz45fWB8lgixDun8cIyMtu5WWFSR9BU/EvhLvYhmkOX1tNP/Kgg5wn6Mus iK/clv5D2doeIaE/nXC3mrZu6TpYFK5jWWiO5KhUVy4GlFt2vbDPWfe1mkzF7Rw6fiEB 5PLT8pMRQEf8mwdE6SbjOqFDEsH/TYiB+pdFVLpZ6Ad1y8aZ1wqy2TQLmpSdTmwAbtd+ I1gY0MSxHAoXm/R3F8MOjmiioKctDVpkA5a1kOZznDEQ80pYD//36smTL8LgkAw/BYBX Fjxxy0CzkEGjMbzt+o0EFS7tYRbpJmoYwUz7j25epbCeKWRzWfP6fC3weNzHtM1z2G9n u4pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=j9Vj4vJz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 67-20020a630746000000b00385d87195b4si3265677pgh.90.2022.03.25.11.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 11:36:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=j9Vj4vJz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C75661959DA; Fri, 25 Mar 2022 10:57:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358716AbiCYQ6T (ORCPT + 99 others); Fri, 25 Mar 2022 12:58:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377376AbiCYQ6F (ORCPT ); Fri, 25 Mar 2022 12:58:05 -0400 Received: from mail-vk1-xa29.google.com (mail-vk1-xa29.google.com [IPv6:2607:f8b0:4864:20::a29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B17343ED2E; Fri, 25 Mar 2022 09:56:25 -0700 (PDT) Received: by mail-vk1-xa29.google.com with SMTP id m84so4542584vke.1; Fri, 25 Mar 2022 09:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7fjXSK3Yvyz7mSD5V7xuckH+eT1koYaMuBSGDuDa7Jg=; b=j9Vj4vJzsRg1iLTzat+VUMVIwbpF2OjBrUJLXaU2urPVF2IpHN9mumemI7oSEUSpSS 7b27OFfmiVkavRZQ7+T4Q1zse7cIQKk/dYGGNTo9SrMz8fOCyq/JmKX4GTMerWB35KFf DZtxQyYrMlfsaNO9YV0o6tPtGigmFt539hcKgmhOx7qZfRX8G0Uu6FjXT5YOTvuxqP5o DewQyiRA1EqU2ewDRLp8mSVZVSb4aNU1u+nYCJf+LVzB66KI/LZ7SsPokBlKnSCQ6CNq 6e0RMzOE+5KTnscXPIv+79D+tlmCuujJIzGWg6Vg6wkXVrnApZgHQ76uQkOexFE+Z6Fl 0tsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7fjXSK3Yvyz7mSD5V7xuckH+eT1koYaMuBSGDuDa7Jg=; b=Ih3gVSI4oQXNJrCSBkhFD6/O7zlvJrBSh8q3DerRuDBAG2BRJMF0gRTlW0Fg50jLVp 4Tz6TgeXrSuMmXPcrInF+DcyhOH9oBc5IS5ngdq6xOyKIoAqEcSIwL2cRrepFL0sqP/Q g/Q7yNIpDUDJZwQmbClAVa1wo2rCtb1VSJVDAf8+aXPElSJM8TXoLRmi1U82Mw3LeG7Z jtwrz9EVP1fSGSOi02k5/W+SHMfktdyEdD8mO26MOBdphNZKIxPX9/ebLw3MfvgxAgV9 fOZieGsRUBuEq0bE3q+NBFJkLihekUcYRu4ZzJ7ZXhuEJD+hiTR9k3gvzZIhcne77jUz L6ug== X-Gm-Message-State: AOAM531f8TepZ9hCYT+oMeMJKqo6ESht3JM5brtewmTPWo6fzklEjPxv fkEPyAxnWFFl96RtEjq2BrZxOHsGXC8uO8z1d30= X-Received: by 2002:a05:6122:8c8:b0:32a:7010:c581 with SMTP id 8-20020a05612208c800b0032a7010c581mr5548291vkg.32.1648227384124; Fri, 25 Mar 2022 09:56:24 -0700 (PDT) MIME-Version: 1.0 References: <20220324072050.62242-1-jakobkoschel@gmail.com> In-Reply-To: <20220324072050.62242-1-jakobkoschel@gmail.com> From: Ilya Dryomov Date: Fri, 25 Mar 2022 17:56:58 +0100 Message-ID: Subject: Re: [PATCH] rbd: replace usage of found with dedicated list iterator variable To: Jakob Koschel Cc: Dongsheng Yang , Jens Axboe , Ceph Development , linux-block , LKML , Mike Rapoport , Brian Johannesmeyer , Cristiano Giuffrida , "Bos, H.J." Content-Type: text/plain; charset="UTF-8" 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 On Thu, Mar 24, 2022 at 8:21 AM 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/block/rbd.c | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > > diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c > index b844432bad20..e5f891d058e8 100644 > --- a/drivers/block/rbd.c > +++ b/drivers/block/rbd.c > @@ -756,24 +756,23 @@ static struct rbd_client *__rbd_get_client(struct rbd_client *rbdc) > */ > static struct rbd_client *rbd_client_find(struct ceph_options *ceph_opts) > { > - struct rbd_client *client_node; > - bool found = false; > + struct rbd_client *client_node = NULL, *iter; > > if (ceph_opts->flags & CEPH_OPT_NOSHARE) > return NULL; > > spin_lock(&rbd_client_list_lock); > - list_for_each_entry(client_node, &rbd_client_list, node) { > - if (!ceph_compare_options(ceph_opts, client_node->client)) { > - __rbd_get_client(client_node); > + list_for_each_entry(iter, &rbd_client_list, node) { > + if (!ceph_compare_options(ceph_opts, iter->client)) { > + __rbd_get_client(iter); > > - found = true; > + client_node = iter; > break; > } > } > spin_unlock(&rbd_client_list_lock); > > - return found ? client_node : NULL; > + return client_node; > } > > /* > > base-commit: f443e374ae131c168a065ea1748feac6b2e76613 > -- > 2.25.1 > Applied. Thanks, Ilya