summaryrefslogtreecommitdiff
path: root/src/queue.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/queue.c')
-rw-r--r--src/queue.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/queue.c b/src/queue.c
index 470c3a2..14ec1b7 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -56,18 +56,22 @@ int io_uring_peek_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr)
* Fill in an array of IO completions up to count, if any are available.
* Returns the amount of IO completions filled.
*/
-unsigned io_uring_peek_batch_cqe(struct io_uring *ring, struct io_uring_cqe **cqes, unsigned count)
+unsigned io_uring_peek_batch_cqe(struct io_uring *ring,
+ struct io_uring_cqe **cqes, unsigned count)
{
- unsigned ready = io_uring_cq_ready(ring);
+ unsigned ready;
+
+ ready = io_uring_cq_ready(ring);
if (ready) {
- count = count > ready ? ready : count;
unsigned head = *ring->cq.khead;
- unsigned last = head + count;
unsigned mask = *ring->cq.kring_mask;
+ unsigned last;
int i = 0;
- for (;head!=last;head++,i++) {
+
+ count = count > ready ? ready : count;
+ last = head + count;
+ for (;head != last; head++, i++)
cqes[i] = &ring->cq.cqes[head & mask];
- }
return count;
}