[U-Boot] [PATCH] squash build warning in cmd_sf.c

Prabhakar Lad prabhakar.csengg at gmail.com
Tue Oct 4 16:08:13 CEST 2011


Hi Simon,



On Tue, Oct 4, 2011 at 7:03 PM, Simon Glass <sjg at chromium.org> wrote:

> Hi,
>
> On Tue, Oct 4, 2011 at 4:45 AM,  <prabhakar.csengg at gmail.com> wrote:
> > From: Prabhakar Lad <prabhakar.csengg at gmail.com>
> >
> > Fix build warning and returning early in case of failure
> >
> > cmd_sf.c: In function 'do_spi_flash':
> > cmd_sf.c:164: warning: 'skipped' may be used uninitialized in this
> function
> > cmd_sf.c:164: note: 'skipped' was declared here
> >
> > Signed-off-by: Prabhakar Lad <prabhakar.csengg at gmail.com>
>
> There is another patch on the list for this - your one changes the
> behavior I think.
>
    yes I agree there is patch in the list. can you be more elaborated
    in what sense does it change the behavior??

>
> > ---
> >  common/cmd_sf.c |   20 +++++++++-----------
> >  1 files changed, 9 insertions(+), 11 deletions(-)
> >
> > diff --git a/common/cmd_sf.c b/common/cmd_sf.c
> > index c8c547a..bdf7915 100644
> > --- a/common/cmd_sf.c
> > +++ b/common/cmd_sf.c
> > @@ -164,21 +164,19 @@ static int spi_flash_update(struct spi_flash
> *flash, u32 offset,
> >        size_t skipped;         /* statistics */
> >
> >        cmp_buf = malloc(flash->sector_size);
> > -       if (cmp_buf) {
> > -               for (skipped = 0; buf < end && !err_oper;
> > -                               buf += todo, offset += todo) {
> > -                       todo = min(end - buf, flash->sector_size);
> > -                       err_oper = spi_flash_update_block(flash, offset,
> todo,
> > -                                       buf, cmp_buf, &skipped);
> > -               }
> > -       } else {
> > +       if (!cmp_buf) {
> >                err_oper = "malloc";
> > -       }
> > -       free(cmp_buf);
> > -       if (err_oper) {
> >                printf("SPI flash failed in %s step\n", err_oper);
> >                return 1;
> >        }
> > +
> > +       for (skipped = 0; buf < end && !err_oper;
> > +                       buf += todo, offset += todo) {
> > +               todo = min(end - buf, flash->sector_size);
> > +               err_oper = spi_flash_update_block(flash, offset, todo,
> > +                               buf, cmp_buf, &skipped);
> > +       }
> > +       free(cmp_buf);
>
> Here we might have err_open, but it is never printed.
>
 ditto.

>
> Regards,
> Simon
>
> >        printf("%zu bytes written, %zu bytes skipped\n", len - skipped,
> >               skipped);
> >        return 0;
> > --
> > 1.7.0.4
> >
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot at lists.denx.de
> > http://lists.denx.de/mailman/listinfo/u-boot
> >
>

Regards
Prabhakar Lad


More information about the U-Boot mailing list