Patchwork [U-Boot] cmd_nand: Fix possible uninited max_size variable

login
register
mail settings
Submitter Marek Vasut
Date March 23, 2012, 11:27 p.m.
Message ID <1332545238-877-1-git-send-email-marex@denx.de>
Download mbox | patch
Permalink /patch/148490/
State Accepted
Commit f624dd15e3602d6b29b191f42388c182aaa1a855
Delegated to: Scott Wood
Headers show

Comments

Marek Vasut - March 23, 2012, 11:27 p.m.
GCC 4.7 error:
cmd_nand.c: In function ‘arg_off_size’:
cmd_nand.c:216:5: warning: ‘maxsize’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Scott Wood <scottwood@freescale.com>
---
 common/cmd_nand.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Scott Wood - March 26, 2012, 4:17 p.m.
On 03/23/2012 06:27 PM, Marek Vasut wrote:
> GCC 4.7 error:
> cmd_nand.c: In function ‘arg_off_size’:
> cmd_nand.c:216:5: warning: ‘maxsize’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Yay, with a new compiler comes a new batch of false positives. :-P

I'm surprised it complained at line 216 but not line 208.

> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Scott Wood <scottwood@freescale.com>
> ---
>  common/cmd_nand.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/common/cmd_nand.c b/common/cmd_nand.c
> index 035a6f6..b015d11 100644
> --- a/common/cmd_nand.c
> +++ b/common/cmd_nand.c
> @@ -191,7 +191,7 @@ static int arg_off_size(int argc, char *const argv[], int *idx,
>  			loff_t *off, loff_t *size)
>  {
>  	int ret;
> -	loff_t maxsize;
> +	loff_t maxsize = 0;
>  
>  	if (argc == 0) {
>  		*off = 0;

I'll apply for next merge window.

-Scott
Marek Vasut - March 27, 2012, 12:02 a.m.
Dear Scott Wood,

> On 03/23/2012 06:27 PM, Marek Vasut wrote:
> > GCC 4.7 error:
> > cmd_nand.c: In function ‘arg_off_size’:
> > cmd_nand.c:216:5: warning: ‘maxsize’ may be used uninitialized in this
> > function [-Wmaybe-uninitialized]
> 
> Yay, with a new compiler comes a new batch of false positives. :-P

And I'm the early adopter ... crusader of new compiler tests with uboot ;-D

> 
> I'm surprised it complained at line 216 but not line 208.
> 
> > Signed-off-by: Marek Vasut <marex@denx.de>
> > Cc: Scott Wood <scottwood@freescale.com>
> > ---
> > 
> >  common/cmd_nand.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/common/cmd_nand.c b/common/cmd_nand.c
> > index 035a6f6..b015d11 100644
> > --- a/common/cmd_nand.c
> > +++ b/common/cmd_nand.c
> > @@ -191,7 +191,7 @@ static int arg_off_size(int argc, char *const argv[],
> > int *idx,
> > 
> >  			loff_t *off, loff_t *size)
> >  
> >  {
> >  
> >  	int ret;
> > 
> > -	loff_t maxsize;
> > +	loff_t maxsize = 0;
> > 
> >  	if (argc == 0) {
> >  	
> >  		*off = 0;
> 
> I'll apply for next merge window.
> 
> -Scott
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

Best regards,
Marek Vasut

Patch

diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 035a6f6..b015d11 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -191,7 +191,7 @@  static int arg_off_size(int argc, char *const argv[], int *idx,
 			loff_t *off, loff_t *size)
 {
 	int ret;
-	loff_t maxsize;
+	loff_t maxsize = 0;
 
 	if (argc == 0) {
 		*off = 0;