Skip to content

Commit 2e82f6c

Browse files
Christoph Hellwigaxboe
authored andcommitted
splice: simplify a conditional in copy_splice_read
Check for -EFAULT instead of wrapping the check in an ret < 0 block. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Reviewed-by: David Howells <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 0b24be4 commit 2e82f6c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

fs/splice.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,15 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos,
368368
if (ret > 0) {
369369
keep = DIV_ROUND_UP(ret, PAGE_SIZE);
370370
*ppos = kiocb.ki_pos;
371-
} else if (ret < 0) {
372-
/*
373-
* callers of ->splice_read() expect -EAGAIN on
374-
* "can't put anything in there", rather than -EFAULT.
375-
*/
376-
if (ret == -EFAULT)
377-
ret = -EAGAIN;
378371
}
379372

373+
/*
374+
* Callers of ->splice_read() expect -EAGAIN on "can't put anything in
375+
* there", rather than -EFAULT.
376+
*/
377+
if (ret == -EFAULT)
378+
ret = -EAGAIN;
379+
380380
/* Free any pages that didn't get touched at all. */
381381
if (keep < npages)
382382
release_pages(pages + keep, npages - keep);

0 commit comments

Comments
 (0)