summaryrefslogtreecommitdiff
path: root/io_uring
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2025-11-12 12:45:53 +0000
committerJens Axboe <axboe@kernel.dk>2025-11-13 07:27:34 -0700
commite279bb4b4c4d012808fb21ff41183a2e76c26679 (patch)
tree458e405a7a38717846a7c710ab31c54cff43c787 /io_uring
parentecb8490b2f4393550a2651f547b7fa67490c4881 (diff)
io_uring: refactor rings_size nosqarray handling
A preparation patch inversing the IORING_SETUP_NO_SQARRAY check, this way there is only one successful return path from the function, which will be helpful later. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/io_uring.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index c7535159ad6b..c1dc4bf3cf62 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -2761,7 +2761,9 @@ unsigned long rings_size(unsigned int flags, unsigned int sq_entries,
unsigned int cq_entries, size_t *sq_offset)
{
struct io_rings *rings;
- size_t off, sq_array_size;
+ size_t off;
+
+ *sq_offset = SIZE_MAX;
off = struct_size(rings, cqes, cq_entries);
if (off == SIZE_MAX)
@@ -2785,19 +2787,17 @@ unsigned long rings_size(unsigned int flags, unsigned int sq_entries,
return SIZE_MAX;
#endif
- if (flags & IORING_SETUP_NO_SQARRAY) {
- *sq_offset = SIZE_MAX;
- return off;
- }
-
- *sq_offset = off;
+ if (!(flags & IORING_SETUP_NO_SQARRAY)) {
+ size_t sq_array_size;
- sq_array_size = array_size(sizeof(u32), sq_entries);
- if (sq_array_size == SIZE_MAX)
- return SIZE_MAX;
+ *sq_offset = off;
- if (check_add_overflow(off, sq_array_size, &off))
- return SIZE_MAX;
+ sq_array_size = array_size(sizeof(u32), sq_entries);
+ if (sq_array_size == SIZE_MAX)
+ return SIZE_MAX;
+ if (check_add_overflow(off, sq_array_size, &off))
+ return SIZE_MAX;
+ }
return off;
}