summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@163.com>2015-11-18 14:40:33 +0100
committerJeff Layton <jeff.layton@primarydata.com>2015-11-18 15:21:49 +0100
commit8ace5dfb983e89dbcfcb42ff25df6e4240c555bb (patch)
treeace737a4a6603a5acf69027b997e2fd86ce84de1 /fs
parentlocks: Don't allow mounts in user namespaces to enable mandatory locking (diff)
downloadlinux-8ace5dfb983e89dbcfcb42ff25df6e4240c555bb.tar.xz
linux-8ace5dfb983e89dbcfcb42ff25df6e4240c555bb.zip
locks: use list_first_entry_or_null()
Simplify the code with list_first_entry_or_null(). Signed-off-by: Geliang Tang <geliangtang@163.com> Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/locks.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/locks.c b/fs/locks.c
index 86c94674ab22..d2ee8e365ba7 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);
}