Use io_uring_cqe_get_data() internally

Replace all cqe->user_data casts with io_uring_cqe_get_data().

Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Jens Axboe
2019-04-07 18:36:43 -06:00
parent 1245d8320a
commit db11f116c7
3 changed files with 4 additions and 4 deletions

View File

@@ -173,7 +173,7 @@ static int copy_file(struct io_uring *ring, off_t insize)
if (!cqe) if (!cqe)
break; break;
data = (struct io_data *) (uintptr_t) cqe->user_data; data = io_uring_cqe_get_data(cqe);
if (cqe->res < 0) { if (cqe->res < 0) {
if (cqe->res == -EAGAIN) { if (cqe->res == -EAGAIN) {
queue_prepped(ring, data); queue_prepped(ring, data);

View File

@@ -154,7 +154,7 @@ reap_events(struct io_uring *ring, unsigned nr)
} }
if (cqe->res != 4096) if (cqe->res != 4096)
printf("cqe->res: %d, expected 4096\n", cqe->res); printf("cqe->res: %d, expected 4096\n", cqe->res);
iov = (struct iovec *)cqe->user_data; iov = io_uring_cqe_get_data(cqe);
free(iov->iov_base); free(iov->iov_base);
free(iov); free(iov);
left--; left--;

View File

@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
pd = (struct poll_data *) (uintptr_t) cqe->user_data; pd = io_uring_cqe_get_data(cqe);
if (cqe->res != 0) { if (cqe->res != 0) {
printf("sqe (add=%d/remove=%d) failed with %ld\n", pd->is_poll, printf("sqe (add=%d/remove=%d) failed with %ld\n", pd->is_poll,
pd->is_cancel, (long) cqe->res); pd->is_cancel, (long) cqe->res);
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
pd = (struct poll_data *) (uintptr_t) cqe->user_data; pd = io_uring_cqe_get_data(cqe);
if (cqe->res != 0) { if (cqe->res != 0) {
printf("sqe (add=%d/remove=%d) failed with %ld\n", pd->is_poll, printf("sqe (add=%d/remove=%d) failed with %ld\n", pd->is_poll,
pd->is_cancel, (long) cqe->res); pd->is_cancel, (long) cqe->res);