diff options
| author | Yang Xiuwei <yangxiuwei@kylinos.cn> | 2026-02-10 10:34:32 +0800 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-02-09 20:12:46 -0700 |
| commit | daa0b901f8319414cf9f56237f15240b95e4b1b2 (patch) | |
| tree | 8cf5feeb9830b95e94448b2837c8842d77255668 /io_uring | |
| parent | 7cb3a68376da0bc0afab8157223cb479c97de9ff (diff) | |
io_uring/tctx: avoid modifying loop variable in io_ring_add_registered_file
Use a separate 'idx' variable to store the result of array_index_nospec()
instead of modifying the loop variable 'offset' directly. This improves
code clarity by separating the logical index from the sanitized index
used for array access.
No functional change intended.
Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring')
| -rw-r--r-- | io_uring/tctx.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/io_uring/tctx.c b/io_uring/tctx.c index ad9e4336d736..270263699c6f 100644 --- a/io_uring/tctx.c +++ b/io_uring/tctx.c @@ -240,14 +240,14 @@ void io_uring_unreg_ringfd(void) int io_ring_add_registered_file(struct io_uring_task *tctx, struct file *file, int start, int end) { - int offset; + int offset, idx; for (offset = start; offset < end; offset++) { - offset = array_index_nospec(offset, IO_RINGFD_REG_MAX); - if (tctx->registered_rings[offset]) + idx = array_index_nospec(offset, IO_RINGFD_REG_MAX); + if (tctx->registered_rings[idx]) continue; - tctx->registered_rings[offset] = file; - return offset; + tctx->registered_rings[idx] = file; + return idx; } return -EBUSY; } |
