Skip to content

Commit daa0b90

Browse files
Yang Xiuweiaxboe
authored andcommitted
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>
1 parent 7cb3a68 commit daa0b90

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

io_uring/tctx.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,14 @@ void io_uring_unreg_ringfd(void)
240240
int io_ring_add_registered_file(struct io_uring_task *tctx, struct file *file,
241241
int start, int end)
242242
{
243-
int offset;
243+
int offset, idx;
244244
for (offset = start; offset < end; offset++) {
245-
offset = array_index_nospec(offset, IO_RINGFD_REG_MAX);
246-
if (tctx->registered_rings[offset])
245+
idx = array_index_nospec(offset, IO_RINGFD_REG_MAX);
246+
if (tctx->registered_rings[idx])
247247
continue;
248248

249-
tctx->registered_rings[offset] = file;
250-
return offset;
249+
tctx->registered_rings[idx] = file;
250+
return idx;
251251
}
252252
return -EBUSY;
253253
}

0 commit comments

Comments
 (0)