ringbahn / uring-sys

liburing bindings
Apache License 2.0
33 stars 14 forks source link

fix return value for io_uring_peek_batch_cqe #19

Closed glommer closed 4 years ago

glommer commented 4 years ago

io_uring_peek_batch_cqe return an integer (signed) but it is signature in this crate expects an unsigned integer.

I found this bug while using iou, in which the following code breaks:

pub fn peek_for_cqe(&mut self) -> Option { let mut cqe = MaybeUninit::uninit(); let count = uring_sys::io_uring_peek_batch_cqe(&mut self.ring, cqe.as_mut_ptr(), 1);

if count > 0 { <===== return is 0xfffff....
Some(CompletionQueueEvent::new(NonNull::from(&self.ring), &mut *cqe.assume_init()))
} else {
None   <==== never reached
}

}

glommer commented 4 years ago

My apologies, I got confused with the values of peek_cqe and peek_batch_cqe in liburing. The batch version does return unsigned integer so I will close this. (I am however puzzled on how did I see 0xfff.... here)