io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] io_uring: fix a GCC warning in wq_list_for_each()
@ 2021-10-25 14:59 Qian Cai
  2021-10-27  9:56 ` Pavel Begunkov
  0 siblings, 1 reply; 3+ messages in thread
From: Qian Cai @ 2021-10-25 14:59 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov; +Cc: io-uring, linux-kernel, Qian Cai

fs/io_uring.c: In function '__io_submit_flush_completions':
fs/io_uring.c:2367:33: warning: variable 'prev' set but not used
[-Wunused-but-set-variable]
 2367 |  struct io_wq_work_node *node, *prev;
      |                                 ^~~~

Fixed it by open-coded the wq_list_for_each() without an unused previous
node pointer.

Fixes: 6f33b0bc4ea4 ("io_uring: use slist for completion batching")
Signed-off-by: Qian Cai <quic_qiancai@quicinc.com>
---
 fs/io_uring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 23641d9e0871..b8968bd43e3f 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2361,11 +2361,11 @@ static void io_free_batch_list(struct io_ring_ctx *ctx,
 static void __io_submit_flush_completions(struct io_ring_ctx *ctx)
 	__must_hold(&ctx->uring_lock)
 {
-	struct io_wq_work_node *node, *prev;
+	struct io_wq_work_node *node;
 	struct io_submit_state *state = &ctx->submit_state;
 
 	spin_lock(&ctx->completion_lock);
-	wq_list_for_each(node, prev, &state->compl_reqs) {
+	for (node = state->compl_reqs.first; node; node = node->next) {
 		struct io_kiocb *req = container_of(node, struct io_kiocb,
 						    comp_list);
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] io_uring: fix a GCC warning in wq_list_for_each()
  2021-10-25 14:59 [PATCH] io_uring: fix a GCC warning in wq_list_for_each() Qian Cai
@ 2021-10-27  9:56 ` Pavel Begunkov
  2021-10-27 15:11   ` Qian Cai
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Begunkov @ 2021-10-27  9:56 UTC (permalink / raw)
  To: Qian Cai, Jens Axboe; +Cc: io-uring, linux-kernel

On 10/25/21 15:59, Qian Cai wrote:
> fs/io_uring.c: In function '__io_submit_flush_completions':
> fs/io_uring.c:2367:33: warning: variable 'prev' set but not used
> [-Wunused-but-set-variable]
>   2367 |  struct io_wq_work_node *node, *prev;
>        |                                 ^~~~
> 
> Fixed it by open-coded the wq_list_for_each() without an unused previous
> node pointer.

That's intentional, the var is optimised out and it's better to
not hand code it (if possible).


> Fixes: 6f33b0bc4ea4 ("io_uring: use slist for completion batching")
> Signed-off-by: Qian Cai <quic_qiancai@quicinc.com>
> ---
>   fs/io_uring.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 23641d9e0871..b8968bd43e3f 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -2361,11 +2361,11 @@ static void io_free_batch_list(struct io_ring_ctx *ctx,
>   static void __io_submit_flush_completions(struct io_ring_ctx *ctx)
>   	__must_hold(&ctx->uring_lock)
>   {
> -	struct io_wq_work_node *node, *prev;
> +	struct io_wq_work_node *node;
>   	struct io_submit_state *state = &ctx->submit_state;
>   
>   	spin_lock(&ctx->completion_lock);
> -	wq_list_for_each(node, prev, &state->compl_reqs) {
> +	for (node = state->compl_reqs.first; node; node = node->next) {
>   		struct io_kiocb *req = container_of(node, struct io_kiocb,
>   						    comp_list);
>   
> 

-- 
Pavel Begunkov

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] io_uring: fix a GCC warning in wq_list_for_each()
  2021-10-27  9:56 ` Pavel Begunkov
@ 2021-10-27 15:11   ` Qian Cai
  0 siblings, 0 replies; 3+ messages in thread
From: Qian Cai @ 2021-10-27 15:11 UTC (permalink / raw)
  To: Pavel Begunkov, Jens Axboe; +Cc: io-uring, linux-kernel



On 10/27/21 5:56 AM, Pavel Begunkov wrote:
> On 10/25/21 15:59, Qian Cai wrote:
>> fs/io_uring.c: In function '__io_submit_flush_completions':
>> fs/io_uring.c:2367:33: warning: variable 'prev' set but not used
>> [-Wunused-but-set-variable]
>>   2367 |  struct io_wq_work_node *node, *prev;
>>        |                                 ^~~~
>>
>> Fixed it by open-coded the wq_list_for_each() without an unused previous
>> node pointer.
> 
> That's intentional, the var is optimised out and it's better to
> not hand code it (if possible).

Yes, this is pretty minor. Not going to insist if people don't like for
some reasons.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-27 15:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 14:59 [PATCH] io_uring: fix a GCC warning in wq_list_for_each() Qian Cai
2021-10-27  9:56 ` Pavel Begunkov
2021-10-27 15:11   ` Qian Cai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).