Skip to content

Commit

Permalink
mm/filemap: simplify generic_file_read_iter
Browse files Browse the repository at this point in the history
Avoid the pointless goto out just for returning retval.

Link: https://lkml.kernel.org/r/20210122160140.223228-19-willy@infradead.org
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Kent Overstreet <kent.overstreet@gmail.com>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Christoph Hellwig authored and Linus Torvalds committed Feb 24, 2021
1 parent 87fa0f3 commit 826ea86
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2543,7 +2543,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
ssize_t retval = 0;

if (!count)
goto out; /* skip atime */
return 0; /* skip atime */

if (iocb->ki_flags & IOCB_DIRECT) {
struct file *file = iocb->ki_filp;
Expand All @@ -2561,7 +2561,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
iocb->ki_pos,
iocb->ki_pos + count - 1);
if (retval < 0)
goto out;
return retval;
}

file_accessed(file);
Expand All @@ -2585,12 +2585,10 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
*/
if (retval < 0 || !count || iocb->ki_pos >= size ||
IS_DAX(inode))
goto out;
return retval;
}

retval = filemap_read(iocb, iter, retval);
out:
return retval;
return filemap_read(iocb, iter, retval);
}
EXPORT_SYMBOL(generic_file_read_iter);

Expand Down

0 comments on commit 826ea86

Please sign in to comment.