Skip to content

Commit

Permalink
fuse: simplify __fuse_write_file_get()
Browse files Browse the repository at this point in the history
Use list_first_entry_or_null() instead of list_empty() + list_entry().

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
  • Loading branch information
Miklos Szeredi committed Oct 22, 2021
1 parent 371e8fd commit 84840ef
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1815,14 +1815,13 @@ static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args,

static struct fuse_file *__fuse_write_file_get(struct fuse_inode *fi)
{
struct fuse_file *ff = NULL;
struct fuse_file *ff;

spin_lock(&fi->lock);
if (!list_empty(&fi->write_files)) {
ff = list_entry(fi->write_files.next, struct fuse_file,
write_entry);
ff = list_first_entry_or_null(&fi->write_files, struct fuse_file,
write_entry);
if (ff)
fuse_file_get(ff);
}
spin_unlock(&fi->lock);

return ff;
Expand Down

0 comments on commit 84840ef

Please sign in to comment.