From badf7101e2dfe3c7bd57eeac98456e5f18c228c5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 20 Jan 2025 21:11:21 +0100 Subject: [PATCH] io/uring/Ring: use `if` with initializer --- src/io/uring/Ring.cxx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/io/uring/Ring.cxx b/src/io/uring/Ring.cxx index 91331a523..5592f54ae 100644 --- a/src/io/uring/Ring.cxx +++ b/src/io/uring/Ring.cxx @@ -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;