public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] [RFC] io_uring: warning about unused-but-set parameter
@ 2021-09-20 12:13 Arnd Bergmann
  2021-09-20 12:18 ` Christoph Hellwig
  2021-09-20 23:08 ` Jens Axboe
  0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2021-09-20 12:13 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov; +Cc: Arnd Bergmann, io-uring, linux-kernel

From: Arnd Bergmann <[email protected]>

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. I was almost
done, but this was added recently as a precaution to prevent code
from using the parameter, which could be done by either removing
the initialization, or by adding a (fake) use of the variable, which
I do here with the cast to void.

Fixes: f237c30a5610 ("io_uring: batch task work locking")
Signed-off-by: Arnd Bergmann <[email protected]>
---
 fs/io_uring.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 63b0425d6a32..36fbc7f06f5e 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1450,6 +1450,7 @@ static void io_queue_async_work(struct io_kiocb *req, bool *locked)
 
 	/* must not take the lock, NULL it as a precaution */
 	locked = NULL;
+	(void)locked;
 
 	BUG_ON(!tctx);
 	BUG_ON(!tctx->io_wq);
-- 
2.29.2


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

* Re: [PATCH] [RFC] io_uring: warning about unused-but-set parameter
  2021-09-20 12:13 [PATCH] [RFC] io_uring: warning about unused-but-set parameter Arnd Bergmann
@ 2021-09-20 12:18 ` Christoph Hellwig
  2021-09-20 12:48   ` Arnd Bergmann
  2021-09-20 23:08 ` Jens Axboe
  1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2021-09-20 12:18 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jens Axboe, Pavel Begunkov, Arnd Bergmann, io-uring, linux-kernel

On Mon, Sep 20, 2021 at 02:13:44PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
> 
> 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. I was almost
> done, but this was added recently as a precaution to prevent code
> from using the parameter, which could be done by either removing
> the initialization, or by adding a (fake) use of the variable, which
> I do here with the cast to void.

Please don't.  These warning are utterly stupid and should not be
enabled.  For anything that is a "method" of sorts (that is assigned
to a function pointer), unused argument are perfectly normal.

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

* Re: [PATCH] [RFC] io_uring: warning about unused-but-set parameter
  2021-09-20 12:18 ` Christoph Hellwig
@ 2021-09-20 12:48   ` Arnd Bergmann
  2021-09-21  6:54     ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2021-09-20 12:48 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Pavel Begunkov, Arnd Bergmann, io-uring,
	Linux Kernel Mailing List

On Mon, Sep 20, 2021 at 2:18 PM Christoph Hellwig <[email protected]> wrote:
>
> On Mon, Sep 20, 2021 at 02:13:44PM +0200, Arnd Bergmann wrote:
> > From: Arnd Bergmann <[email protected]>
> >
> > 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. I was almost
> > done, but this was added recently as a precaution to prevent code
> > from using the parameter, which could be done by either removing
> > the initialization, or by adding a (fake) use of the variable, which
> > I do here with the cast to void.
>
> Please don't.  These warning are utterly stupid and should not be
> enabled.  For anything that is a "method" of sorts (that is assigned
> to a function pointer), unused argument are perfectly normal.

I'm not suggesting to enable -Wunused-parameter, which would be
complete madness of crouse, only -Wunused-but-set-parameter,
which is already part of W=1 and has the potential of catching
actual bugs such as

int f(int val)
{
      if (val = 1)
            return 0;

       return -1;
}

          Arnd

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

* Re: [PATCH] [RFC] io_uring: warning about unused-but-set parameter
  2021-09-20 12:13 [PATCH] [RFC] io_uring: warning about unused-but-set parameter Arnd Bergmann
  2021-09-20 12:18 ` Christoph Hellwig
@ 2021-09-20 23:08 ` Jens Axboe
  1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2021-09-20 23:08 UTC (permalink / raw)
  To: Arnd Bergmann, Pavel Begunkov; +Cc: Arnd Bergmann, io-uring, linux-kernel

On 9/20/21 6:13 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
> 
> 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. I was almost
> done, but this was added recently as a precaution to prevent code
> from using the parameter, which could be done by either removing
> the initialization, or by adding a (fake) use of the variable, which
> I do here with the cast to void.

I would just rename the argument here 'dont_use' or something like that,
that should be enough of a signal for future cases that it should need
extra consideration.

-- 
Jens Axboe


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

* Re: [PATCH] [RFC] io_uring: warning about unused-but-set parameter
  2021-09-20 12:48   ` Arnd Bergmann
@ 2021-09-21  6:54     ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-09-21  6:54 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Christoph Hellwig, Jens Axboe, Pavel Begunkov, Arnd Bergmann,
	io-uring, Linux Kernel Mailing List

On Mon, Sep 20, 2021 at 02:48:23PM +0200, Arnd Bergmann wrote:
> complete madness of crouse, only -Wunused-but-set-parameter,
> which is already part of W=1 and has the potential of catching
> actual bugs such as

Well, i you care about that just remove the

	locked = NULL;

which is pretty weird anyway.

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

end of thread, other threads:[~2021-09-21  6:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-20 12:13 [PATCH] [RFC] io_uring: warning about unused-but-set parameter Arnd Bergmann
2021-09-20 12:18 ` Christoph Hellwig
2021-09-20 12:48   ` Arnd Bergmann
2021-09-21  6:54     ` Christoph Hellwig
2021-09-20 23:08 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox