Commit 2e82f6c3 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

splice: simplify a conditional in copy_splice_read



Check for -EFAULT instead of wrapping the check in an ret < 0 block.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarChristian Brauner <brauner@kernel.org>
Reviewed-by: default avatarDavid Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20230614140341.521331-3-hch@lst.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 0b24be46
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -368,14 +368,14 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos,
	if (ret > 0) {
		keep = DIV_ROUND_UP(ret, PAGE_SIZE);
		*ppos = kiocb.ki_pos;
	} else if (ret < 0) {
	}

	/*
		 * callers of ->splice_read() expect -EAGAIN on
		 * "can't put anything in there", rather than -EFAULT.
	 * Callers of ->splice_read() expect -EAGAIN on "can't put anything in
	 * there", rather than -EFAULT.
	 */
	if (ret == -EFAULT)
		ret = -EAGAIN;
	}

	/* Free any pages that didn't get touched at all. */
	if (keep < npages)