Skip to content

Commit fa78033

Browse files
committed
io_uring: silence variable ‘prev’ set but not used warning
If io_uring.o is built with W=1, it triggers a warning: io_uring/io_uring.c: In function ‘__io_submit_flush_completions’: io_uring/io_uring.c:1502:40: warning: variable ‘prev’ set but not used [-Wunused-but-set-variable] 1502 | struct io_wq_work_node *node, *prev; | ^~~~ which is due to the wq_list_for_each() iterator always keeping a 'prev' variable. Most users need this to remove an entry from a list, for example, but __io_submit_flush_completions() never does that. Add a basic helper that doesn't track prev instead, and use that in that function. Reported-by: Vincenzo Palazzo <[email protected]> Reviewed-by: Vincenzo Palazzo <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 03b3d6b commit fa78033

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

io_uring/io_uring.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1499,14 +1499,14 @@ void io_free_batch_list(struct io_ring_ctx *ctx, struct io_wq_work_node *node)
14991499
static void __io_submit_flush_completions(struct io_ring_ctx *ctx)
15001500
__must_hold(&ctx->uring_lock)
15011501
{
1502-
struct io_wq_work_node *node, *prev;
15031502
struct io_submit_state *state = &ctx->submit_state;
1503+
struct io_wq_work_node *node;
15041504

15051505
__io_cq_lock(ctx);
15061506
/* must come first to preserve CQE ordering in failure cases */
15071507
if (state->cqes_count)
15081508
__io_flush_post_cqes(ctx);
1509-
wq_list_for_each(node, prev, &state->compl_reqs) {
1509+
__wq_list_for_each(node, &state->compl_reqs) {
15101510
struct io_kiocb *req = container_of(node, struct io_kiocb,
15111511
comp_list);
15121512

io_uring/slist.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#include <linux/io_uring_types.h>
55

6+
#define __wq_list_for_each(pos, head) \
7+
for (pos = (head)->first; pos; pos = (pos)->next)
8+
69
#define wq_list_for_each(pos, prv, head) \
710
for (pos = (head)->first, prv = NULL; pos; prv = pos, pos = (pos)->next)
811

@@ -113,4 +116,4 @@ static inline struct io_wq_work *wq_next_work(struct io_wq_work *work)
113116
return container_of(work->list.next, struct io_wq_work, list);
114117
}
115118

116-
#endif // INTERNAL_IO_SLIST_H
119+
#endif // INTERNAL_IO_SLIST_H

0 commit comments

Comments
 (0)