Skip to contentSkip to conversation

bcachefs: remove redundant variable tmp

PATCH In review Colin Ian King 3 participants 3 messages Jan 16, 2024 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcachefs: remove redundant variable tmp

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]

---
 fs/bcachefs/rebalance.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/bcachefs/rebalance.c +1 -3
index 95f46cb3b5bd..827316a27431 100644
@@ -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);
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Colin Ian King

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

Quoted 23 lines

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]

---
 fs/bcachefs/rebalance.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/bcachefs/rebalance.c +0 -1
index 95f46cb3b5bd..827316a27431 100644
@@ -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();
 

fs/bcachefs/rebalance.c static int bch2_rebalance_thread(void *arg) · line 395

Quoted 6 lines
fs/bcachefs/rebalance.c +1 -2
@@ -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:

Quoted 6 lines
fs/bcachefs/rebalance.c +0 -0
 		;
 
 	bch2_moving_ctxt_exit(&ctxt);
Signature · 1 line
2.39.2
#2 lore raw
Quoted 34 lines · Brian Foster
Quoted 4 lines · Colin Ian King

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

Quoted 26 lines

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]

---
 fs/bcachefs/rebalance.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/bcachefs/rebalance.c +0 -1
index 95f46cb3b5bd..827316a27431 100644
@@ -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);
 
Quoted 8 lines

fs/bcachefs/rebalance.c static int bch2_rebalance_thread(void *arg) · line 395

Quoted 3 lines
fs/bcachefs/rebalance.c +1 -2
-	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