mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-01-01 06:42:31 +00:00
aio_read_events_ring(): make a bit more readable
The logics for 'avail' is * not past the tail of cyclic buffer * no more than asked * not past the end of buffer * not past the end of a page Unobfuscate the last part. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
9061d14a8a
commit
d2988bd412
7
fs/aio.c
7
fs/aio.c
@ -1197,14 +1197,13 @@ static long aio_read_events_ring(struct kioctx *ctx,
|
|||||||
if (head == tail)
|
if (head == tail)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
avail = min(avail, nr - ret);
|
|
||||||
avail = min_t(long, avail, AIO_EVENTS_PER_PAGE -
|
|
||||||
((head + AIO_EVENTS_OFFSET) % AIO_EVENTS_PER_PAGE));
|
|
||||||
|
|
||||||
pos = head + AIO_EVENTS_OFFSET;
|
pos = head + AIO_EVENTS_OFFSET;
|
||||||
page = ctx->ring_pages[pos / AIO_EVENTS_PER_PAGE];
|
page = ctx->ring_pages[pos / AIO_EVENTS_PER_PAGE];
|
||||||
pos %= AIO_EVENTS_PER_PAGE;
|
pos %= AIO_EVENTS_PER_PAGE;
|
||||||
|
|
||||||
|
avail = min(avail, nr - ret);
|
||||||
|
avail = min_t(long, avail, AIO_EVENTS_PER_PAGE - pos);
|
||||||
|
|
||||||
ev = kmap(page);
|
ev = kmap(page);
|
||||||
copy_ret = copy_to_user(event + ret, ev + pos,
|
copy_ret = copy_to_user(event + ret, ev + pos,
|
||||||
sizeof(*ev) * avail);
|
sizeof(*ev) * avail);
|
||||||
|
Loading…
Reference in New Issue
Block a user