[v2,11/24] mtd: rawnand: sunxi: Make sure ret is initialized in sunxi_nfc_read_byte()

Message ID 20180709200945.30116-12-boris.brezillon@bootlin.com
State Accepted
Delegated to: Miquel Raynal
Headers show
Series
  • mtd: rawnand: Improve compile-test coverage
Related show

Commit Message

Boris Brezillon July 9, 2018, 8:09 p.m.
Fixes the following smatch warning:

drivers/mtd/nand/raw/sunxi_nand.c:551 sunxi_nfc_read_byte() error: uninitialized symbol 'ret'.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
---
 drivers/mtd/nand/raw/sunxi_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Arnd Bergmann July 9, 2018, 8:35 p.m. | #1
On Mon, Jul 9, 2018 at 10:09 PM, Boris Brezillon
<boris.brezillon@bootlin.com> wrote:
> Fixes the following smatch warning:
>
> drivers/mtd/nand/raw/sunxi_nand.c:551 sunxi_nfc_read_byte() error: uninitialized symbol 'ret'.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> ---
>  drivers/mtd/nand/raw/sunxi_nand.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> index 99043c3a4fa7..4b11cd4a79be 100644
> --- a/drivers/mtd/nand/raw/sunxi_nand.c
> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> @@ -544,7 +544,7 @@ static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf,
>
>  static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd)
>  {
> -       uint8_t ret;
> +       uint8_t ret = 0;
>
>         sunxi_nfc_read_buf(mtd, &ret, 1);
>

Should there perhaps be a warning when no data was returned after a timeout?

      Arnd
Boris Brezillon July 9, 2018, 9 p.m. | #2
On Mon, 9 Jul 2018 22:35:56 +0200
Arnd Bergmann <arnd@arndb.de> wrote:

> On Mon, Jul 9, 2018 at 10:09 PM, Boris Brezillon
> <boris.brezillon@bootlin.com> wrote:
> > Fixes the following smatch warning:
> >
> > drivers/mtd/nand/raw/sunxi_nand.c:551 sunxi_nfc_read_byte() error: uninitialized symbol 'ret'.
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> > ---
> >  drivers/mtd/nand/raw/sunxi_nand.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
> > index 99043c3a4fa7..4b11cd4a79be 100644
> > --- a/drivers/mtd/nand/raw/sunxi_nand.c
> > +++ b/drivers/mtd/nand/raw/sunxi_nand.c
> > @@ -544,7 +544,7 @@ static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf,
> >
> >  static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd)
> >  {
> > -       uint8_t ret;
> > +       uint8_t ret = 0;
> >
> >         sunxi_nfc_read_buf(mtd, &ret, 1);
> >  
> 
> Should there perhaps be a warning when no data was returned after a timeout?

We're planning to move this driver to ->exec_op() soon, and with
->exec_op() errors are properly propagated to the core. I guess we can
live with this lack of dev_warn() for a bit longer :-).

Patch

diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c
index 99043c3a4fa7..4b11cd4a79be 100644
--- a/drivers/mtd/nand/raw/sunxi_nand.c
+++ b/drivers/mtd/nand/raw/sunxi_nand.c
@@ -544,7 +544,7 @@  static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf,
 
 static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd)
 {
-	uint8_t ret;
+	uint8_t ret = 0;
 
 	sunxi_nfc_read_buf(mtd, &ret, 1);