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>pull/1354/merge
parent
ecb8490b2f
commit
e279bb4b4c
|
|
@ -2761,7 +2761,9 @@ unsigned long rings_size(unsigned int flags, unsigned int sq_entries,
|
||||||
unsigned int cq_entries, size_t *sq_offset)
|
unsigned int cq_entries, size_t *sq_offset)
|
||||||
{
|
{
|
||||||
struct io_rings *rings;
|
struct io_rings *rings;
|
||||||
size_t off, sq_array_size;
|
size_t off;
|
||||||
|
|
||||||
|
*sq_offset = SIZE_MAX;
|
||||||
|
|
||||||
off = struct_size(rings, cqes, cq_entries);
|
off = struct_size(rings, cqes, cq_entries);
|
||||||
if (off == SIZE_MAX)
|
if (off == SIZE_MAX)
|
||||||
|
|
@ -2785,20 +2787,18 @@ unsigned long rings_size(unsigned int flags, unsigned int sq_entries,
|
||||||
return SIZE_MAX;
|
return SIZE_MAX;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (flags & IORING_SETUP_NO_SQARRAY) {
|
if (!(flags & IORING_SETUP_NO_SQARRAY)) {
|
||||||
*sq_offset = SIZE_MAX;
|
size_t sq_array_size;
|
||||||
return off;
|
|
||||||
|
*sq_offset = off;
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
*sq_offset = off;
|
|
||||||
|
|
||||||
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;
|
return off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue