Skip to contentSkip to conversation

jbd2: remove redundant assignement to variable err

PATCH Applied Colin Ian King 3 participants 3 messages Apr 10, 2024 – May 7, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jbd2: remove redundant assignement to variable err

The variable err is being assigned a value that is never read, it is being re-assigned inside the following while loop and also after the while loop. The assignment is redundant and can be removed.

Cleans up clang scan build warning:
fs/jbd2/commit.c:574:2: warning: Value stored to 'err' is never read [deadcode.DeadStores]

---
 fs/jbd2/commit.c | 1 -
 1 file changed, 1 deletion(-)
fs/jbd2/commit.c +0 -1
index 5e122586e06e..78a9d08ae9f8 100644
@@ -571,7 +571,6 @@ void jbd2_journal_commit_transaction(journal_t *journal)
 	J_ASSERT(commit_transaction->t_nr_buffers <=
 		 atomic_read(&commit_transaction->t_outstanding_credits));
 
-	err = 0;
 	bufs = 0;
 	descriptor = NULL;
 	while (commit_transaction->t_buffers) {
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Colin Ian King

The variable err is being assigned a value that is never read, it is being re-assigned inside the following while loop and also after the while loop. The assignment is redundant and can be removed.

Cleans up clang scan build warning:
fs/jbd2/commit.c:574:2: warning: Value stored to 'err' is never read [deadcode.DeadStores]

OK, this assignment indeed looks redundant and is not even making code easier to reason about. So feel free to add:

Honza

Quoted 19 lines
---
 fs/jbd2/commit.c | 1 -
 1 file changed, 1 deletion(-)
fs/jbd2/commit.c +0 -1
index 5e122586e06e..78a9d08ae9f8 100644
@@ -571,7 +571,6 @@ void jbd2_journal_commit_transaction(journal_t *journal)
 	J_ASSERT(commit_transaction->t_nr_buffers <=
 		 atomic_read(&commit_transaction->t_outstanding_credits));
 
-	err = 0;
 	bufs = 0;
 	descriptor = NULL;
 	while (commit_transaction->t_buffers) {
Signature · 1 line
2.39.2
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Applied
#2 lore raw
In reply to Colin Ian King
Quoted 10 lines · Colin Ian King

The variable err is being assigned a value that is never read, it is being re-assigned inside the following while loop and also after the while loop. The assignment is redundant and can be removed.

Cleans up clang scan build warning:
fs/jbd2/commit.c:574:2: warning: Value stored to 'err' is never read [deadcode.DeadStores]

[...]

Applied, thanks!

[1/1] jbd2: remove redundant assignement to variable err

      commit: 8b57de1c5edde3faf8a4f6a440b7ec16bb3c81d4

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>