io/uring/Ring: use if
with initializer
This commit is contained in:

committed by
Max Kellermann

parent
6fb91e661c
commit
badf7101e2
@@ -9,24 +9,24 @@ namespace Uring {
|
||||
|
||||
Ring::Ring(unsigned entries, unsigned flags)
|
||||
{
|
||||
int error = io_uring_queue_init(entries, &ring, flags);
|
||||
if (error < 0)
|
||||
if (int error = io_uring_queue_init(entries, &ring, flags);
|
||||
error < 0)
|
||||
throw MakeErrno(-error, "io_uring_queue_init() failed");
|
||||
}
|
||||
|
||||
void
|
||||
Ring::Submit()
|
||||
{
|
||||
int error = io_uring_submit(&ring);
|
||||
if (error < 0)
|
||||
if (int error = io_uring_submit(&ring);
|
||||
error < 0)
|
||||
throw MakeErrno(-error, "io_uring_submit() failed");
|
||||
}
|
||||
|
||||
void
|
||||
Ring::SubmitAndGetEvents()
|
||||
{
|
||||
int error = io_uring_submit_and_get_events(&ring);
|
||||
if (error < 0)
|
||||
if (int error = io_uring_submit_and_get_events(&ring);
|
||||
error < 0)
|
||||
throw MakeErrno(-error, "io_uring_submit() failed");
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ struct io_uring_cqe *
|
||||
Ring::WaitCompletion()
|
||||
{
|
||||
struct io_uring_cqe *cqe;
|
||||
int error = io_uring_wait_cqe(&ring, &cqe);
|
||||
if (error < 0) {
|
||||
if (int error = io_uring_wait_cqe(&ring, &cqe);
|
||||
error < 0) {
|
||||
if (error == -EAGAIN)
|
||||
return nullptr;
|
||||
|
||||
@@ -49,8 +49,7 @@ struct io_uring_cqe *
|
||||
Ring::PeekCompletion()
|
||||
{
|
||||
struct io_uring_cqe *cqe;
|
||||
int error = io_uring_peek_cqe(&ring, &cqe);
|
||||
if (error < 0) {
|
||||
if (int error = io_uring_peek_cqe(&ring, &cqe); error < 0) {
|
||||
if (error == -EAGAIN)
|
||||
return nullptr;
|
||||
|
||||
|
Reference in New Issue
Block a user