From patchwork Thu Mar 31 21:53:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Koschel X-Patchwork-Id: 12797720 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BB2AC433F5 for ; Thu, 31 Mar 2022 21:55:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242041AbiCaV5R (ORCPT ); Thu, 31 Mar 2022 17:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242027AbiCaV5Q (ORCPT ); Thu, 31 Mar 2022 17:57:16 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFA071DFDFD; Thu, 31 Mar 2022 14:55:27 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id x34so834960ede.8; Thu, 31 Mar 2022 14:55:27 -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:mime-version :content-transfer-encoding; bh=340G7DDlJvxfnruHeGXTFxEtC53hXW3frN9N7jMbYMo=; b=pqa1CDnLEUEUIbaKrQKpfnlyqz9Wf9ivrcPZx4GweI+V3rxNnyGYtErdnkFl0KZWPy aVQOM1sjDXASbi84kEzqN1bkF5mEznJlonLoaL0lJQauqFA7/NR22vzkm4ZmzUTXOghP XLeXUiEI5Ya1ggWcU34UmZIXQ/Dv24iQjhn3X8hWnRsNlXsLvpsm6tcfoqQJTXlkR7iH L27DYCyr5wnD+BIK4wIsRbw34owX4oYQXE7K0Ccqn7RKHHQACNQ7NucVRrynQRtg7/tB riygE186FI3tDxlvdnK2G/Axi8AoQypB49XyAkclnzkoxG/WUO7/vxh+z5er3Y0w2QDX ZT3w== 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:mime-version :content-transfer-encoding; bh=340G7DDlJvxfnruHeGXTFxEtC53hXW3frN9N7jMbYMo=; b=1GMHJkGahrL6uA80Mq199Z2eX821EAsWQNxtXlrv/f55NEK16iiDo/dZcwnNp08t+h iLtBfGCMglv7mYMoAnWptcgpI3aJqzaRNtZPa1SY7xzrupFgVgZK/AGFBvID+43SJ+Da VKlXRPj+rxvydDvcdJBesNnsgw2g7z27FjFrG5FFjb+HgAUvX1xLnQ17cHWnXwkYh8aY jS1ZkKVJmTwF4UYHPcoQDc2tmOTse5p5+o52cY6HdpnogvV1P0V+N54lHM7WVE/fLznr ZgP6wRA24kqzC/HXX8Z2NB5af9swLcP507MnkDu6+5IwTqfg1L3QI9xxPVatkQAdSWti gOjw== X-Gm-Message-State: AOAM53369f540v3VqzDTJDoGTYIjyFwpLPUjQ+qxq+PGooMwK3boD72l 1F9WC8Vy7GMXEVWHCI2cpJM= X-Google-Smtp-Source: ABdhPJz2iC+c3oAylzaewgDKd9bjHplvo2CImrsZPyv6lnBH4ueew5wYDmb+r1VTQEpAO+qB10tjkQ== X-Received: by 2002:a05:6402:4250:b0:419:5e89:a40f with SMTP id g16-20020a056402425000b004195e89a40fmr18515273edb.319.1648763726247; Thu, 31 Mar 2022 14:55:26 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id r11-20020aa7cfcb000000b0041902ac4c6asm307950edy.1.2022.03.31.14.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 14:55:25 -0700 (PDT) From: Jakob Koschel To: Jeff Layton Cc: Ilya Dryomov , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH 1/2] ceph: use dedicated list iterator variable Date: Thu, 31 Mar 2022 23:53:28 +0200 Message-Id: <20220331215329.882411-1-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@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 [1]. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel --- fs/ceph/caps.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) base-commit: f82da161ea75dc4db21b2499e4b1facd36dab275 diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index f1ad6884d4da..519750bc5a1a 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -1577,7 +1577,7 @@ static void __ceph_flush_snaps(struct ceph_inode_info *ci, while (first_tid <= last_tid) { struct ceph_cap *cap = ci->i_auth_cap; - struct ceph_cap_flush *cf; + struct ceph_cap_flush *cf = NULL, *iter; int ret; if (!(cap && cap->session == session)) { @@ -1587,8 +1587,9 @@ static void __ceph_flush_snaps(struct ceph_inode_info *ci, } ret = -ENOENT; - list_for_each_entry(cf, &ci->i_cap_flush_list, i_list) { - if (cf->tid >= first_tid) { + list_for_each_entry(iter, &ci->i_cap_flush_list, i_list) { + if (iter->tid >= first_tid) { + cf = iter; ret = 0; break; }