diff mbox series

[RESEND,v3,05/11] mtd: rawnand: vf610_nfc: add initializer to avoid -Wmaybe-uninitialized

Message ID 20190423034959.13525-6-yamada.masahiro@socionext.com
State Accepted
Commit 2127982895d4e1d5343b5fdb986dd3b17b4fe43f
Headers show
Series compiler: allow all arches to enable CONFIG_OPTIMIZE_INLINING | expand

Commit Message

Masahiro Yamada April 23, 2019, 3:49 a.m. UTC
This prepares to move CONFIG_OPTIMIZE_INLINING from x86 to a common
place. We need to eliminate potential issues beforehand.

Kbuild test robot has never reported -Wmaybe-uninitialized warning
for this probably because vf610_nfc_run() is inlined by the x86
compiler's inlining heuristic.

If CONFIG_OPTIMIZE_INLINING is enabled for a different architecture
and vf610_nfc_run() is not inlined, the following warning is reported:

drivers/mtd/nand/raw/vf610_nfc.c: In function ‘vf610_nfc_cmd’:
drivers/mtd/nand/raw/vf610_nfc.c:455:3: warning: ‘offset’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   vf610_nfc_rd_from_sram(instr->ctx.data.buf.in + offset,
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            nfc->regs + NFC_MAIN_AREA(0) + offset,
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            trfr_sz, !nfc->data_access);
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

Changes in v3: None
Changes in v2:
  - split into a separate patch

 drivers/mtd/nand/raw/vf610_nfc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.17.1

Comments

Miquel Raynal May 2, 2019, 2:13 p.m. UTC | #1
Hi Masahiro,

Masahiro Yamada <yamada.masahiro@socionext.com> wrote on Tue, 23 Apr
2019 12:49:53 +0900:

> This prepares to move CONFIG_OPTIMIZE_INLINING from x86 to a common

> place. We need to eliminate potential issues beforehand.

> 

> Kbuild test robot has never reported -Wmaybe-uninitialized warning

> for this probably because vf610_nfc_run() is inlined by the x86

> compiler's inlining heuristic.

> 

> If CONFIG_OPTIMIZE_INLINING is enabled for a different architecture

> and vf610_nfc_run() is not inlined, the following warning is reported:

> 

> drivers/mtd/nand/raw/vf610_nfc.c: In function ‘vf610_nfc_cmd’:

> drivers/mtd/nand/raw/vf610_nfc.c:455:3: warning: ‘offset’ may be used uninitialized in this function [-Wmaybe-uninitialized]

>    vf610_nfc_rd_from_sram(instr->ctx.data.buf.in + offset,

>    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

>             nfc->regs + NFC_MAIN_AREA(0) + offset,

>             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

>             trfr_sz, !nfc->data_access);

>             ~~~~~~~~~~~~~~~~~~~~~~~~~~~


IMHO this patch has no dependencies with this series.
Would you mind sending it alone with the proper Fixes tag?

> 

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> ---

> 

> Changes in v3: None

> Changes in v2:

>   - split into a separate patch

> 

>  drivers/mtd/nand/raw/vf610_nfc.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c

> index a662ca1970e5..19792d725ec2 100644

> --- a/drivers/mtd/nand/raw/vf610_nfc.c

> +++ b/drivers/mtd/nand/raw/vf610_nfc.c

> @@ -364,7 +364,7 @@ static int vf610_nfc_cmd(struct nand_chip *chip,

>  {

>  	const struct nand_op_instr *instr;

>  	struct vf610_nfc *nfc = chip_to_nfc(chip);

> -	int op_id = -1, trfr_sz = 0, offset;

> +	int op_id = -1, trfr_sz = 0, offset = 0;

>  	u32 col = 0, row = 0, cmd1 = 0, cmd2 = 0, code = 0;

>  	bool force8bit = false;

>  


Thanks,
Miquèl
Masahiro Yamada May 3, 2019, 10:36 a.m. UTC | #2
Hi Miquel,

On Thu, May 2, 2019 at 11:14 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>

> Hi Masahiro,

>

> Masahiro Yamada <yamada.masahiro@socionext.com> wrote on Tue, 23 Apr

> 2019 12:49:53 +0900:

>

> > This prepares to move CONFIG_OPTIMIZE_INLINING from x86 to a common

> > place. We need to eliminate potential issues beforehand.

> >

> > Kbuild test robot has never reported -Wmaybe-uninitialized warning

> > for this probably because vf610_nfc_run() is inlined by the x86

> > compiler's inlining heuristic.

> >

> > If CONFIG_OPTIMIZE_INLINING is enabled for a different architecture

> > and vf610_nfc_run() is not inlined, the following warning is reported:

> >

> > drivers/mtd/nand/raw/vf610_nfc.c: In function ‘vf610_nfc_cmd’:

> > drivers/mtd/nand/raw/vf610_nfc.c:455:3: warning: ‘offset’ may be used uninitialized in this function [-Wmaybe-uninitialized]

> >    vf610_nfc_rd_from_sram(instr->ctx.data.buf.in + offset,

> >    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> >             nfc->regs + NFC_MAIN_AREA(0) + offset,

> >             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> >             trfr_sz, !nfc->data_access);

> >             ~~~~~~~~~~~~~~~~~~~~~~~~~~~

>

> IMHO this patch has no dependencies with this series.



This patch is the prerequisite for 11/11.
https://lore.kernel.org/patchwork/patch/1064959/


Without the correct patch order,
the kbuild test robot reports the warning.


> Would you mind sending it alone with the proper Fixes tag?



I do not think Fixes is necessary.

Nobody has noticed this potential issue before.
Without 11/11, probably we cannot reproduce this warning.


BTW, this series has been for a while in linux-next.


>

> >

> > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> > ---

> >

> > Changes in v3: None

> > Changes in v2:

> >   - split into a separate patch

> >

> >  drivers/mtd/nand/raw/vf610_nfc.c | 2 +-

> >  1 file changed, 1 insertion(+), 1 deletion(-)

> >

> > diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c

> > index a662ca1970e5..19792d725ec2 100644

> > --- a/drivers/mtd/nand/raw/vf610_nfc.c

> > +++ b/drivers/mtd/nand/raw/vf610_nfc.c

> > @@ -364,7 +364,7 @@ static int vf610_nfc_cmd(struct nand_chip *chip,

> >  {

> >       const struct nand_op_instr *instr;

> >       struct vf610_nfc *nfc = chip_to_nfc(chip);

> > -     int op_id = -1, trfr_sz = 0, offset;

> > +     int op_id = -1, trfr_sz = 0, offset = 0;

> >       u32 col = 0, row = 0, cmd1 = 0, cmd2 = 0, code = 0;

> >       bool force8bit = false;

> >

>

> Thanks,

> Miquèl

>

> ______________________________________________________

> Linux MTD discussion mailing list

> http://lists.infradead.org/mailman/listinfo/linux-mtd/




--
Best Regards

Masahiro Yamada
Miquel Raynal May 3, 2019, 11:11 a.m. UTC | #3
Hi Masahiro,

Masahiro Yamada <yamada.masahiro@socionext.com> wrote on Fri, 3 May
2019 19:36:35 +0900:

> Hi Miquel,

> 

> On Thu, May 2, 2019 at 11:14 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> >

> > Hi Masahiro,

> >

> > Masahiro Yamada <yamada.masahiro@socionext.com> wrote on Tue, 23 Apr

> > 2019 12:49:53 +0900:

> >  

> > > This prepares to move CONFIG_OPTIMIZE_INLINING from x86 to a common

> > > place. We need to eliminate potential issues beforehand.

> > >

> > > Kbuild test robot has never reported -Wmaybe-uninitialized warning

> > > for this probably because vf610_nfc_run() is inlined by the x86

> > > compiler's inlining heuristic.

> > >

> > > If CONFIG_OPTIMIZE_INLINING is enabled for a different architecture

> > > and vf610_nfc_run() is not inlined, the following warning is reported:

> > >

> > > drivers/mtd/nand/raw/vf610_nfc.c: In function ‘vf610_nfc_cmd’:

> > > drivers/mtd/nand/raw/vf610_nfc.c:455:3: warning: ‘offset’ may be used uninitialized in this function [-Wmaybe-uninitialized]

> > >    vf610_nfc_rd_from_sram(instr->ctx.data.buf.in + offset,

> > >    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> > >             nfc->regs + NFC_MAIN_AREA(0) + offset,

> > >             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> > >             trfr_sz, !nfc->data_access);

> > >             ~~~~~~~~~~~~~~~~~~~~~~~~~~~  

> >

> > IMHO this patch has no dependencies with this series.  

> 

> 

> This patch is the prerequisite for 11/11.

> https://lore.kernel.org/patchwork/patch/1064959/

> 

> 

> Without the correct patch order,

> the kbuild test robot reports the warning.

> 

> 

> > Would you mind sending it alone with the proper Fixes tag?  

> 

> 

> I do not think Fixes is necessary.


IMHO it is. Even if today the warning does not spawn, there is a
real C error which might already be an issue.

> 

> Nobody has noticed this potential issue before.

> Without 11/11, probably we cannot reproduce this warning.

> 

> 

> BTW, this series has been for a while in linux-next.


Missed that. Ok, nevermind.


Thanks,
Miquèl
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c
index a662ca1970e5..19792d725ec2 100644
--- a/drivers/mtd/nand/raw/vf610_nfc.c
+++ b/drivers/mtd/nand/raw/vf610_nfc.c
@@ -364,7 +364,7 @@  static int vf610_nfc_cmd(struct nand_chip *chip,
 {
 	const struct nand_op_instr *instr;
 	struct vf610_nfc *nfc = chip_to_nfc(chip);
-	int op_id = -1, trfr_sz = 0, offset;
+	int op_id = -1, trfr_sz = 0, offset = 0;
 	u32 col = 0, row = 0, cmd1 = 0, cmd2 = 0, code = 0;
 	bool force8bit = false;