summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-09-20 07:13:07 -0600
committerJens Axboe <axboe@kernel.dk>2019-09-20 07:13:07 -0600
commit5109ed3ec733968cc1aa6457020d8cc1389135bb (patch)
tree74ef248497f744d9ff485bb3c19f6b82f8faec41 /examples
parent9fd8049cac30daab23d504ab67476c44d6a88251 (diff)
downloadliburing-5109ed3ec733968cc1aa6457020d8cc1389135bb.tar.gz
liburing-5109ed3ec733968cc1aa6457020d8cc1389135bb.tar.bz2
examples/ucontext-cp: style fixups
No functional changes. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'examples')
-rw-r--r--examples/ucontext-cp.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/examples/ucontext-cp.c b/examples/ucontext-cp.c
index 1f76a09..a7cfd44 100644
--- a/examples/ucontext-cp.c
+++ b/examples/ucontext-cp.c
@@ -31,31 +31,29 @@ typedef struct {
int outfd;
} arguments_bundle;
-#define DEFINE_AWAIT_OP(operation) \
-static ssize_t await_##operation( \
- async_context *pctx, \
- int fd, \
- const struct iovec *ioves, \
- unsigned int nr_vecs, \
- off_t offset) \
-{ \
- struct io_uring_sqe *sqe = io_uring_get_sqe(&pctx->ring); \
-\
- if (!sqe) { \
- return -1; \
- } \
-\
- io_uring_prep_##operation(sqe, fd, ioves, nr_vecs, offset); \
- io_uring_sqe_set_data(sqe, pctx); \
- io_uring_submit(&pctx->ring); \
- swapcontext(&pctx->ctx_fnew, &pctx->ctx_main); \
- struct io_uring_cqe *cqe; \
- if (io_uring_peek_cqe(&pctx->ring, &cqe) < 0) { \
- return -1; \
- } \
- io_uring_cqe_seen(&pctx->ring, cqe); \
-\
- return cqe->res; \
+#define DEFINE_AWAIT_OP(operation) \
+static ssize_t await_##operation( \
+ async_context *pctx, \
+ int fd, \
+ const struct iovec *ioves, \
+ unsigned int nr_vecs, \
+ off_t offset) \
+{ \
+ struct io_uring_sqe *sqe = io_uring_get_sqe(&pctx->ring); \
+ struct io_uring_cqe *cqe; \
+ \
+ if (!sqe) \
+ return -1; \
+ \
+ io_uring_prep_##operation(sqe, fd, ioves, nr_vecs, offset); \
+ io_uring_sqe_set_data(sqe, pctx); \
+ io_uring_submit(&pctx->ring); \
+ swapcontext(&pctx->ctx_fnew, &pctx->ctx_main); \
+ if (io_uring_peek_cqe(&pctx->ring, &cqe) < 0) \
+ return -1; \
+ io_uring_cqe_seen(&pctx->ring, cqe); \
+ \
+ return cqe->res; \
}
DEFINE_AWAIT_OP(readv)
@@ -95,14 +93,16 @@ static int copy_file(async_context *pctx, int infd, int outfd, struct iovec* pio
perror("await_readv");
return 1;
}
- if (bytes_read == 0) return 0;
+ if (bytes_read == 0)
+ return 0;
piov->iov_len = bytes_read;
if (await_writev(pctx, outfd, piov, 1, offset) != bytes_read) {
perror("await_writev");
return 1;
}
- if (bytes_read < BS) return 0;
+ if (bytes_read < BS)
+ return 0;
offset += bytes_read;
}
}
@@ -159,12 +159,12 @@ int main(int argc, char *argv[])
return 1;
}
- // event loop
+ /* event loop */
while (bundle.ret == -1) {
int ret;
async_context* pctx;
- // usually be timed waiting
+ /* usually be timed waiting */
ret = io_uring_wait_cqe(&ctx.ring, &cqe);
if (ret < 0) {
fprintf(stderr, "wait_cqe: %s\n", strerror(-ret));