From: Jeff Layton <jlayton@poochiereds.net>
To: Geliang Tang <geliangtang@163.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
"J. Bruce Fields" <bfields@fieldses.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] locks: use list_first_entry_or_null()
Date: Wed, 18 Nov 2015 09:22:54 -0500 [thread overview]
Message-ID: <20151118092254.12975e73@synchrony.poochiereds.net> (raw)
In-Reply-To: <f3623904d50b5392851044b545a8bdf42bb0c5d3.1447853914.git.geliangtang@163.com>
On Wed, 18 Nov 2015 21:40:33 +0800
Geliang Tang <geliangtang@163.com> wrote:
> Simplify the code with list_first_entry_or_null().
>
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
> fs/locks.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/fs/locks.c b/fs/locks.c
> index 86c9467..d2ee8e3 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -1505,12 +1505,10 @@ void lease_get_mtime(struct inode *inode, struct timespec *time)
> ctx = smp_load_acquire(&inode->i_flctx);
> if (ctx && !list_empty_careful(&ctx->flc_lease)) {
> spin_lock(&ctx->flc_lock);
> - if (!list_empty(&ctx->flc_lease)) {
> - fl = list_first_entry(&ctx->flc_lease,
> - struct file_lock, fl_list);
> - if (fl->fl_type == F_WRLCK)
> - has_lease = true;
> - }
> + fl = list_first_entry_or_null(&ctx->flc_lease,
> + struct file_lock, fl_list);
> + if (fl && (fl->fl_type == F_WRLCK))
> + has_lease = true;
> spin_unlock(&ctx->flc_lock);
> }
>
Looks fine. I'll merge it for v4.5.
Thanks!
--
Jeff Layton <jlayton@poochiereds.net>
prev parent reply other threads:[~2015-11-18 14:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-18 13:40 [PATCH] locks: use list_first_entry_or_null() Geliang Tang
2015-11-18 14:22 ` Jeff Layton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151118092254.12975e73@synchrony.poochiereds.net \
--to=jlayton@poochiereds.net \
--cc=bfields@fieldses.org \
--cc=geliangtang@163.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).