diff mbox

[U-Boot] cmd_sf: Fix compiler warning

Message ID 1317652547-31435-1-git-send-email-galak@kernel.crashing.org
State Accepted
Commit 8e8a4bc22fc475244dd7c794f2271dd55399e859
Delegated to: Wolfgang Denk
Headers show

Commit Message

Kumar Gala Oct. 3, 2011, 2:35 p.m. UTC
cmd_sf.c: In function 'do_spi_flash':
cmd_sf.c:164:9: warning: 'skipped' may be used uninitialized in this function

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 common/cmd_sf.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Comments

Mike Frysinger Oct. 3, 2011, 2:54 p.m. UTC | #1
On Monday, October 03, 2011 10:35:47 Kumar Gala wrote:
> cmd_sf.c: In function 'do_spi_flash':
> cmd_sf.c:164:9: warning: 'skipped' may be used uninitialized in this
> function

hmm, not sure how i missed this.  but looks sane to me.
Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike
Simon Glass Oct. 4, 2011, 1:31 p.m. UTC | #2
Hi,

On Mon, Oct 3, 2011 at 7:54 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Monday, October 03, 2011 10:35:47 Kumar Gala wrote:
>> cmd_sf.c: In function 'do_spi_flash':
>> cmd_sf.c:164:9: warning: 'skipped' may be used uninitialized in this
>> function
>
> hmm, not sure how i missed this.  but looks sane to me.
> Acked-by: Mike Frysinger <vapier@gentoo.org>

You didn't miss it - I vaguely remember some discussion. My compiler
seems to spot that it cannot be used unused (the patch misses out a
bit that init it), but clearly some don't.

Acked-by: Simon Glass <sjg@chromium.org>

Regards,
Simon

> -mike
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>
>
Wolfgang Denk Oct. 5, 2011, 7:04 p.m. UTC | #3
Dear Kumar Gala,

In message <1317652547-31435-1-git-send-email-galak@kernel.crashing.org> you wrote:
> cmd_sf.c: In function 'do_spi_flash':
> cmd_sf.c:164:9: warning: 'skipped' may be used uninitialized in this function
> 
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
>  common/cmd_sf.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index c8c547a..7225656 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -161,12 +161,11 @@  static int spi_flash_update(struct spi_flash *flash, u32 offset,
 	char *cmp_buf;
 	const char *end = buf + len;
 	size_t todo;		/* number of bytes to do in this pass */
-	size_t skipped;		/* statistics */
+	size_t skipped = 0;	/* statistics */
 
 	cmp_buf = malloc(flash->sector_size);
 	if (cmp_buf) {
-		for (skipped = 0; buf < end && !err_oper;
-				buf += todo, offset += todo) {
+		for (; 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);
@@ -181,6 +180,7 @@  static int spi_flash_update(struct spi_flash *flash, u32 offset,
 	}
 	printf("%zu bytes written, %zu bytes skipped\n", len - skipped,
 	       skipped);
+
 	return 0;
 }