Commit 8ace5dfb authored by Geliang Tang's avatar Geliang Tang Committed by Jeff Layton

locks: use list_first_entry_or_null()

Simplify the code with list_first_entry_or_null().
Signed-off-by: default avatarGeliang Tang <geliangtang@163.com>
Signed-off-by: default avatarJeff Layton <jeff.layton@primarydata.com>
parent 95ace754
......@@ -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,
fl = list_first_entry_or_null(&ctx->flc_lease,
struct file_lock, fl_list);
if (fl->fl_type == F_WRLCK)
if (fl && (fl->fl_type == F_WRLCK))
has_lease = true;
}
spin_unlock(&ctx->flc_lock);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment