* [PATCH] locks: use list_first_entry_or_null()
@ 2015-11-18 13:40 Geliang Tang
2015-11-18 14:22 ` Jeff Layton
0 siblings, 1 reply; 2+ messages in thread
From: Geliang Tang @ 2015-11-18 13:40 UTC (permalink / raw)
To: Alexander Viro, Jeff Layton, J. Bruce Fields
Cc: Geliang Tang, linux-fsdevel, linux-kernel
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);
}
--
2.5.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] locks: use list_first_entry_or_null()
2015-11-18 13:40 [PATCH] locks: use list_first_entry_or_null() Geliang Tang
@ 2015-11-18 14:22 ` Jeff Layton
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Layton @ 2015-11-18 14:22 UTC (permalink / raw)
To: Geliang Tang; +Cc: Alexander Viro, J. Bruce Fields, linux-fsdevel, linux-kernel
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>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-18 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-18 13:40 [PATCH] locks: use list_first_entry_or_null() Geliang Tang
2015-11-18 14:22 ` Jeff Layton
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).