Skip to contentSkip to conversation

mtd: mtd_oobtest: Remove redundant assignment to err

PATCH Applied Jiapeng Chong 2 participants 2 messages Apr 25, 2021 – May 10, 2021 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: mtd_oobtest: Remove redundant assignment to err

Variable err is set to zero but this value is never read as it is overwritten with a new value later on, hence it is a redundant assignment and can be removed.

Cleans up the following clang-analyzer warning:

drivers/mtd/tests/oobtest.c:626:4: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores].

drivers/mtd/tests/oobtest.c:603:4: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores].

drivers/mtd/tests/oobtest.c:579:4: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores].

drivers/mtd/tests/oobtest.c:556:4: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores].

drivers/mtd/tests/oobtest.c:532:3: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores].

drivers/mtd/tests/oobtest.c:509:3: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores].

---
 drivers/mtd/tests/oobtest.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/mtd/tests/oobtest.c +0 -6
index c71daa8..3a31a2c 100644
@@ -506,7 +506,6 @@ static int __init mtd_oobtest_init(void)
 	err = mtd_write_oob(mtd, addr0, &ops);
 	if (err) {
 		pr_info("error occurred as expected\n");
-		err = 0;
 	} else {
 		pr_err("error: can write past end of OOB\n");
 		errcnt += 1;
@@ -529,7 +528,6 @@ static int __init mtd_oobtest_init(void)
 
 	if (err) {
 		pr_info("error occurred as expected\n");
-		err = 0;
 	} else {
 		pr_err("error: can read past end of OOB\n");
 		errcnt += 1;
@@ -553,7 +551,6 @@ static int __init mtd_oobtest_init(void)
 		err = mtd_write_oob(mtd, mtd->size - mtd->writesize, &ops);
 		if (err) {
 			pr_info("error occurred as expected\n");
-			err = 0;
 		} else {
 			pr_err("error: wrote past end of device\n");
 			errcnt += 1;
@@ -576,7 +573,6 @@ static int __init mtd_oobtest_init(void)
 
 		if (err) {
 			pr_info("error occurred as expected\n");
-			err = 0;
 		} else {
 			pr_err("error: read past end of device\n");
 			errcnt += 1;
@@ -600,7 +596,6 @@ static int __init mtd_oobtest_init(void)
 		err = mtd_write_oob(mtd, mtd->size - mtd->writesize, &ops);
 		if (err) {
 			pr_info("error occurred as expected\n");
-			err = 0;
 		} else {
 			pr_err("error: wrote past end of device\n");
 			errcnt += 1;
@@ -623,7 +618,6 @@ static int __init mtd_oobtest_init(void)
 
 		if (err) {
 			pr_info("error occurred as expected\n");
-			err = 0;
 		} else {
 			pr_err("error: read past end of device\n");
 			errcnt += 1;
Signature · 1 line
1.8.3.1
maintainer Applied
#1 lore raw
Quoted 18 lines · Jiapeng Chong

Variable err is set to zero but this value is never read as it is overwritten with a new value later on, hence it is a redundant assignment and can be removed.

Cleans up the following clang-analyzer warning:

drivers/mtd/tests/oobtest.c:626:4: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores].

drivers/mtd/tests/oobtest.c:603:4: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores].

drivers/mtd/tests/oobtest.c:579:4: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores].

drivers/mtd/tests/oobtest.c:556:4: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores].

Quoted 8 lines

drivers/mtd/tests/oobtest.c:532:3: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores].

drivers/mtd/tests/oobtest.c:509:3: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores].

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel