Skip to contentSkip to conversation

mtd: rawnand: silence static checker warning in nand_setup_interface()

PATCH Applied Dan Carpenter 2 participants 2 messages Apr 20, 2021 – May 10, 2021

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

PATCH 1/1 mtd: rawnand: silence static checker warning in nand_setup_interface()

Smatch complains that the error code is not set on this error path:

drivers/mtd/nand/raw/nand_base.c:842 nand_setup_interface()
warn: missing error code 'ret'

But actually returning success is intentional because the NAND chip will still work in mode 0. This patch adds a "ret = 0;" assignment to make the intent more clear and to silence the static checker warning. It doesn't affect the compiled code because GCC optimises the assignment away.

---
 drivers/mtd/nand/raw/nand_base.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/nand/raw/nand_base.c +1 -0
index fb072c444495..e29e5b3d31bf 100644
@@ -880,6 +880,7 @@ static int nand_setup_interface(struct nand_chip *chip, int chipnr)
 	if (tmode_param[0] != chip->best_interface_config->timings.mode) {
 		pr_warn("timing mode %d not acknowledged by the NAND chip\n",
 			chip->best_interface_config->timings.mode);
+		ret = 0;
 		goto err_reset_chip;
 	}
 
Signature · 1 line
2.30.2
maintainer Applied
#1 lore raw
Quoted 5 lines · Dan Carpenter

Smatch complains that the error code is not set on this error path:

drivers/mtd/nand/raw/nand_base.c:842 nand_setup_interface()
warn: missing error code 'ret'

Quoted 7 lines

But actually returning success is intentional because the NAND chip will still work in mode 0. This patch adds a "ret = 0;" assignment to make the intent more clear and to silence the static checker warning. It doesn't affect the compiled code because GCC optimises the assignment away.

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

Miquel