linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] bcachefs: remove redundant variable tmp
@ 2024-01-16 11:07 Colin Ian King
  2024-01-16 14:01 ` Brian Foster
  0 siblings, 1 reply; 3+ messages in thread
From: Colin Ian King @ 2024-01-16 11:07 UTC (permalink / raw)
  To: Kent Overstreet, Brian Foster, linux-bcachefs
  Cc: kernel-janitors, linux-kernel

The variable tmp is being assigned a value but it isn't being
read afterwards. The assignment is redundant and so tmp can be
removed.

Cleans up clang scan build warning:
warning: Although the value stored to 'ret' is used in the enclosing
expression, the value is never actually read from 'ret'
[deadcode.DeadStores]

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 fs/bcachefs/rebalance.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/bcachefs/rebalance.c b/fs/bcachefs/rebalance.c
index 95f46cb3b5bd..827316a27431 100644
--- a/fs/bcachefs/rebalance.c
+++ b/fs/bcachefs/rebalance.c
@@ -385,7 +385,6 @@ static int bch2_rebalance_thread(void *arg)
 	struct bch_fs *c = arg;
 	struct bch_fs_rebalance *r = &c->rebalance;
 	struct moving_context ctxt;
-	int ret;
 
 	set_freezable();
 
@@ -393,8 +392,7 @@ static int bch2_rebalance_thread(void *arg)
 			      writepoint_ptr(&c->rebalance_write_point),
 			      true);
 
-	while (!kthread_should_stop() &&
-	       !(ret = do_rebalance(&ctxt)))
+	while (!kthread_should_stop() && !do_rebalance(&ctxt))
 		;
 
 	bch2_moving_ctxt_exit(&ctxt);
-- 
2.39.2


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

* Re: [PATCH][next] bcachefs: remove redundant variable tmp
  2024-01-16 11:07 [PATCH][next] bcachefs: remove redundant variable tmp Colin Ian King
@ 2024-01-16 14:01 ` Brian Foster
  2024-01-16 16:33   ` Kent Overstreet
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Foster @ 2024-01-16 14:01 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Kent Overstreet, linux-bcachefs, kernel-janitors, linux-kernel

On Tue, Jan 16, 2024 at 11:07:23AM +0000, Colin Ian King wrote:
> The variable tmp is being assigned a value but it isn't being
> read afterwards. The assignment is redundant and so tmp can be
> removed.
> 

I assume this intends to refer to s/tmp/ret/ ...

> Cleans up clang scan build warning:
> warning: Although the value stored to 'ret' is used in the enclosing
> expression, the value is never actually read from 'ret'
> [deadcode.DeadStores]
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  fs/bcachefs/rebalance.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/fs/bcachefs/rebalance.c b/fs/bcachefs/rebalance.c
> index 95f46cb3b5bd..827316a27431 100644
> --- a/fs/bcachefs/rebalance.c
> +++ b/fs/bcachefs/rebalance.c
> @@ -385,7 +385,6 @@ static int bch2_rebalance_thread(void *arg)
>  	struct bch_fs *c = arg;
>  	struct bch_fs_rebalance *r = &c->rebalance;
>  	struct moving_context ctxt;
> -	int ret;
>  
>  	set_freezable();
>  
> @@ -393,8 +392,7 @@ static int bch2_rebalance_thread(void *arg)
>  			      writepoint_ptr(&c->rebalance_write_point),
>  			      true);
>  
> -	while (!kthread_should_stop() &&
> -	       !(ret = do_rebalance(&ctxt)))
> +	while (!kthread_should_stop() && !do_rebalance(&ctxt))

Part of me wonders if this was intended to return ret, as that appears
to bubble back through kthread_stop(). That said, we don't check for
error there either (i.e. bch2_rebalance_stop()), so this seems
reasonable enough to me to address the warning:

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  		;
>  
>  	bch2_moving_ctxt_exit(&ctxt);
> -- 
> 2.39.2
> 


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

* Re: [PATCH][next] bcachefs: remove redundant variable tmp
  2024-01-16 14:01 ` Brian Foster
@ 2024-01-16 16:33   ` Kent Overstreet
  0 siblings, 0 replies; 3+ messages in thread
From: Kent Overstreet @ 2024-01-16 16:33 UTC (permalink / raw)
  To: Brian Foster
  Cc: Colin Ian King, linux-bcachefs, kernel-janitors, linux-kernel

On Tue, Jan 16, 2024 at 09:01:05AM -0500, Brian Foster wrote:
> On Tue, Jan 16, 2024 at 11:07:23AM +0000, Colin Ian King wrote:
> > The variable tmp is being assigned a value but it isn't being
> > read afterwards. The assignment is redundant and so tmp can be
> > removed.
> > 
> 
> I assume this intends to refer to s/tmp/ret/ ...
> 
> > Cleans up clang scan build warning:
> > warning: Although the value stored to 'ret' is used in the enclosing
> > expression, the value is never actually read from 'ret'
> > [deadcode.DeadStores]
> > 
> > Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> > ---
> >  fs/bcachefs/rebalance.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/fs/bcachefs/rebalance.c b/fs/bcachefs/rebalance.c
> > index 95f46cb3b5bd..827316a27431 100644
> > --- a/fs/bcachefs/rebalance.c
> > +++ b/fs/bcachefs/rebalance.c
> > @@ -385,7 +385,6 @@ static int bch2_rebalance_thread(void *arg)
> >  	struct bch_fs *c = arg;
> >  	struct bch_fs_rebalance *r = &c->rebalance;
> >  	struct moving_context ctxt;
> > -	int ret;
> >  
> >  	set_freezable();
> >  
> > @@ -393,8 +392,7 @@ static int bch2_rebalance_thread(void *arg)
> >  			      writepoint_ptr(&c->rebalance_write_point),
> >  			      true);
> >  
> > -	while (!kthread_should_stop() &&
> > -	       !(ret = do_rebalance(&ctxt)))
> > +	while (!kthread_should_stop() && !do_rebalance(&ctxt))
> 
> Part of me wonders if this was intended to return ret, as that appears
> to bubble back through kthread_stop(). That said, we don't check for
> error there either (i.e. bch2_rebalance_stop()), so this seems
> reasonable enough to me to address the warning:

yeah, the only reason to return errors here is to log them, and they've
already been logged at this point.

Thanks, applying this

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

end of thread, other threads:[~2024-01-16 16:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-16 11:07 [PATCH][next] bcachefs: remove redundant variable tmp Colin Ian King
2024-01-16 14:01 ` Brian Foster
2024-01-16 16:33   ` Kent Overstreet

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