io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [v2] io_uring: warning about unused-but-set parameter
@ 2021-10-19 15:34 Arnd Bergmann
  2021-10-19 15:50 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2021-10-19 15:34 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov; +Cc: Arnd Bergmann, io-uring, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

When enabling -Wunused warnings by building with W=1, I get an
instance of the -Wunused-but-set-parameter warning in the io_uring code:

fs/io_uring.c: In function 'io_queue_async_work':
fs/io_uring.c:1445:61: error: parameter 'locked' set but not used [-Werror=unused-but-set-parameter]
 1445 | static void io_queue_async_work(struct io_kiocb *req, bool *locked)
      |                                                       ~~~~~~^~~~~~

There are very few warnings of this type, so it would be nice to enable
this by default and fix all the existing instances. As the assignment
serves no purpose by itself other than to prevent developers from using
the variable, an easy workaround is to remove the assignment and just
rename the argument to "dont_use".

Fixes: f237c30a5610 ("io_uring: batch task work locking")
Link: https://lore.kernel.org/lkml/20210920121352.93063-1-arnd@kernel.org/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Changes in v2:
 - remove the assignment altogether
 - rename the parameter
---
 fs/io_uring.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index be307360d1b0..8d9e208957fd 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1521,15 +1521,12 @@ static inline void io_req_add_compl_list(struct io_kiocb *req)
 	wq_list_add_tail(&req->comp_list, &state->compl_reqs);
 }
 
-static void io_queue_async_work(struct io_kiocb *req, bool *locked)
+static void io_queue_async_work(struct io_kiocb *req, bool *dont_use)
 {
 	struct io_ring_ctx *ctx = req->ctx;
 	struct io_kiocb *link = io_prep_linked_timeout(req);
 	struct io_uring_task *tctx = req->task->io_uring;
 
-	/* must not take the lock, NULL it as a precaution */
-	locked = NULL;
-
 	BUG_ON(!tctx);
 	BUG_ON(!tctx->io_wq);
 
-- 
2.29.2


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

* Re: [PATCH] [v2] io_uring: warning about unused-but-set parameter
  2021-10-19 15:34 [PATCH] [v2] io_uring: warning about unused-but-set parameter Arnd Bergmann
@ 2021-10-19 15:50 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-10-19 15:50 UTC (permalink / raw)
  To: Arnd Bergmann, Pavel Begunkov
  Cc: Jens Axboe, Arnd Bergmann, io-uring, linux-kernel

On Tue, 19 Oct 2021 17:34:53 +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> When enabling -Wunused warnings by building with W=1, I get an
> instance of the -Wunused-but-set-parameter warning in the io_uring code:
> 
> fs/io_uring.c: In function 'io_queue_async_work':
> fs/io_uring.c:1445:61: error: parameter 'locked' set but not used [-Werror=unused-but-set-parameter]
>  1445 | static void io_queue_async_work(struct io_kiocb *req, bool *locked)
>       |                                                       ~~~~~~^~~~~~
> 
> [...]

Applied, thanks!

[1/1] io_uring: warning about unused-but-set parameter
      commit: 00169246e6981752e53266c62d0ab0c827493634

Best regards,
-- 
Jens Axboe



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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 15:34 [PATCH] [v2] io_uring: warning about unused-but-set parameter Arnd Bergmann
2021-10-19 15:50 ` Jens Axboe

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).