Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3543138pxb; Mon, 4 Apr 2022 20:37:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyU0xJk5sAyoryCUFIR4NcGaCqZZ++4m2+tmgPjQsNxAbx9PpXGbGDUPKJTESJgu2Zz9Au+ X-Received: by 2002:a17:902:e885:b0:156:b4e6:173c with SMTP id w5-20020a170902e88500b00156b4e6173cmr1328269plg.161.1649129865324; Mon, 04 Apr 2022 20:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649129865; cv=none; d=google.com; s=arc-20160816; b=B2XVBoqofeJ4uLVlcK2aQABntWGehX+SxH37iMu1cK6O3y3km6FxPnUpWZfSpJhOU9 E7g2/KFicaDbjE9FLRtSgmbOEIPfFG7r3SJVR5J+X/o7rf8uN0ZakTFrAn/Rzsjxstg4 0+hcGQq8BdyV4K9pwWdgGAA4Qw/GywfFiJZp/smMo0u1zvPXFfPm3DofNLy+IRvF9sC2 QfzcK7vCUx+HwFJ5/cJm3MtSdp2cZlvP/lXV13zuWZzA4PNV5L52GLVn4J4jwJL5aVLa ZOdgpn763axPP0o0r3ARawN8T4UODgiTShoAw1bNSy3FBTcqurSFsoT+pp1GPDk2iWMY 8U0A== 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=hXiWPffxpHbWQ2eIaoK3c/FiSIjbtVnbbyc5wOi1X2k=; b=aXWUzqWc/cTjFsxhKQNdf0XYmDFyJVy9DDJ6GA7bJeU3uJdALDWHQoKacK7X7Z7IBo m3vXBsOQg87Wp5Cwc4XPSIc8UFGJESzYnoHPSLnVLj173jF5NnIyvr2lt4kK3GfK6Js1 KJPScpys0iISWzyQxUkBK45GnZpHCUqEBKJxIwMLJIPWaDRAT6n0d8fkBttErxfSJbgb 2YjR6quz59yVJsrp+51NH6H109Rs9JYN+F1eXjkMNpG0N8N2WLnOAHrNG+Nj+HPNvAkf PChZs1rDyHV8mIXnYbrCnr7DWBokEJcFLFB1oWiAKurgZXIU9IevXGRg0GiAPfMdDlCi 871w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KC0T5noq; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x8-20020a63db48000000b003816043ee80si12409388pgi.117.2022.04.04.20.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:37:45 -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=@redhat.com header.s=mimecast20190719 header.b=KC0T5noq; 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=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9E4AA15E238; Mon, 4 Apr 2022 18:51:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378071AbiDDOr1 (ORCPT + 99 others); Mon, 4 Apr 2022 10:47:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379689AbiDDOpJ (ORCPT ); Mon, 4 Apr 2022 10:45:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D8B13389 for ; Mon, 4 Apr 2022 07:42:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649083337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hXiWPffxpHbWQ2eIaoK3c/FiSIjbtVnbbyc5wOi1X2k=; b=KC0T5noqfmU2spQqb8t9kaEs+S7HaGie9N7S7YS4L3iF8FyrM0TRZWnYz1DrrRnWf5tsFe onRxrsAubXGO+S19rhqwlZnV2lxCV/j+P7qHws2F1S0ghfdKN2bG9DdFKuFzt4N4Yr/r5G xGrhaYBRtxHMKRBjCQxKQwbLU57GNJU= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-100-iuZBHrvUNPGLHF6zZUm4uQ-1; Mon, 04 Apr 2022 10:42:16 -0400 X-MC-Unique: iuZBHrvUNPGLHF6zZUm4uQ-1 Received: by mail-wm1-f72.google.com with SMTP id t2-20020a7bc3c2000000b003528fe59cb9so5074384wmj.5 for ; Mon, 04 Apr 2022 07:42:15 -0700 (PDT) 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=hXiWPffxpHbWQ2eIaoK3c/FiSIjbtVnbbyc5wOi1X2k=; b=JsFtD10Dl2Dd53VNSTwcTG2mbeV7Hoou/liAyBPgHVLOUXUKKjc2ruz+lVzj+W3XnI Lwm+4g+msI1a6/36IIlwbVOr380TRt0sowd2H4nx7VSf9kItxbG3Drj63uuRccNK0H4q UYMnnaDiK0I30mR4EPPD+1lIPbsqXHB+VicLsftK+QTXCn4zqi1yN7Qlq5ea67OgIuHQ jI3dNsfUDD3NcEBeqARvnxZvaT3WXKiqAYqXUOk5/KssQ42Ffwhv6+lrbdNoXnwY2UkL RFIvf7iz59B28w/BASy6J+Grrh6nClyLDpMF74k11h2nG2b3Bt75s1CBFSkS60neov+l CZLw== X-Gm-Message-State: AOAM530itp5SL+CBCnnziQ6l/y5/Zd/8MO1D8iTMYzTcezlbK3zdzzwL pThNsmVlptMvuv0TIjAOaFZJ0MkXRVj/MmTuU9svwF7DaeW9sgrf3AZtCvgYcyogKzE1Gz25Zgl dJWO3PyxPvwbmC4bygvcUaZtvK1fBdg3mdzj8sGiX X-Received: by 2002:a5d:4684:0:b0:206:160d:e0c9 with SMTP id u4-20020a5d4684000000b00206160de0c9mr2639821wrq.493.1649083334825; Mon, 04 Apr 2022 07:42:14 -0700 (PDT) X-Received: by 2002:a5d:4684:0:b0:206:160d:e0c9 with SMTP id u4-20020a5d4684000000b00206160de0c9mr2639801wrq.493.1649083334618; Mon, 04 Apr 2022 07:42:14 -0700 (PDT) MIME-Version: 1.0 References: <20220331223857.902911-1-jakobkoschel@gmail.com> <20220331223857.902911-2-jakobkoschel@gmail.com> In-Reply-To: <20220331223857.902911-2-jakobkoschel@gmail.com> From: Andreas Gruenbacher Date: Mon, 4 Apr 2022 16:42:03 +0200 Message-ID: Subject: Re: [PATCH 2/2] gfs2: replace usage of found with dedicated list iterator variable To: Jakob Koschel Cc: Bob Peterson , cluster-devel , LKML , Mike Rapoport , Brian Johannesmeyer , Cristiano Giuffrida , "Bos, H.J." Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 Jakob, On Fri, Apr 1, 2022 at 12:40 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/ [1] > Signed-off-by: Jakob Koschel > --- > fs/gfs2/quota.c | 13 ++++++------- > fs/gfs2/recovery.c | 22 ++++++++++------------ > 2 files changed, 16 insertions(+), 19 deletions(-) > > diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c > index be0997e24d60..dafd04fb9164 100644 > --- a/fs/gfs2/quota.c > +++ b/fs/gfs2/quota.c > @@ -443,7 +443,7 @@ static int qd_check_sync(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd, > > static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) > { > - struct gfs2_quota_data *qd = NULL; > + struct gfs2_quota_data *qd = NULL, *iter; > int error; > int found = 0; > > @@ -454,15 +454,14 @@ static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) > > spin_lock(&qd_lock); > > - list_for_each_entry(qd, &sdp->sd_quota_list, qd_list) { > - found = qd_check_sync(sdp, qd, &sdp->sd_quota_sync_gen); > - if (found) > + list_for_each_entry(iter, &sdp->sd_quota_list, qd_list) { > + found = qd_check_sync(sdp, iter, &sdp->sd_quota_sync_gen); > + if (found) { > + qd = iter; we might as well get rid of 'found' here like in the below two changes. Let me fix that up. > break; > + } > } > > - if (!found) > - qd = NULL; > - > spin_unlock(&qd_lock); > > if (qd) { > diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c > index 016ed1b2ca1d..2bb085a72e8e 100644 > --- a/fs/gfs2/recovery.c > +++ b/fs/gfs2/recovery.c > @@ -55,17 +55,16 @@ int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk, > int gfs2_revoke_add(struct gfs2_jdesc *jd, u64 blkno, unsigned int where) > { > struct list_head *head = &jd->jd_revoke_list; > - struct gfs2_revoke_replay *rr; > - int found = 0; > + struct gfs2_revoke_replay *rr = NULL, *iter; > > - list_for_each_entry(rr, head, rr_list) { > - if (rr->rr_blkno == blkno) { > - found = 1; > + list_for_each_entry(iter, head, rr_list) { > + if (iter->rr_blkno == blkno) { > + rr = iter; > break; > } > } > > - if (found) { > + if (rr) { > rr->rr_where = where; > return 0; > } > @@ -83,18 +82,17 @@ int gfs2_revoke_add(struct gfs2_jdesc *jd, u64 blkno, unsigned int where) > > int gfs2_revoke_check(struct gfs2_jdesc *jd, u64 blkno, unsigned int where) > { > - struct gfs2_revoke_replay *rr; > + struct gfs2_revoke_replay *rr = NULL, *iter; > int wrap, a, b, revoke; > - int found = 0; > > - list_for_each_entry(rr, &jd->jd_revoke_list, rr_list) { > - if (rr->rr_blkno == blkno) { > - found = 1; > + list_for_each_entry(iter, &jd->jd_revoke_list, rr_list) { > + if (iter->rr_blkno == blkno) { > + rr = iter; > break; > } > } > > - if (!found) > + if (!rr) > return 0; > > wrap = (rr->rr_where < jd->jd_replay_tail); > -- > 2.25.1 > Thanks, Andreas