Skip to contentSkip to conversation

cmd_sf: Fix compiler warning

PATCH New Kumar Gala 4 participants 4 messages Oct 3, 2011 – Oct 5, 2011

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/1 cmd_sf: Fix compiler warning

cmd_sf.c: In function 'do_spi_flash':
cmd_sf.c:164:9: warning: 'skipped' may be used uninitialized in this function

---
 common/cmd_sf.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
common/cmd_sf.c +3 -3
index c8c547a..7225656 100644
@@ -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;
 }
 
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 1/1 cmd_sf: Fix compiler warning

Quoted 3 lines · 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.

-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20111003/d0885aef/attachment.pgp

#2 lore raw

PATCH 1/1 cmd_sf: Fix compiler warning

Hi,

Quoted 7 lines · Mike Frysinger
Quoted 3 lines · 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.

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.

Regards,
Simon

Quoted 8 lines

-mike

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#3 lore raw

PATCH 1/1 cmd_sf: Fix compiler warning

In reply to Kumar Gala

Dear Kumar Gala,

Quoted 7 lines · In message <[email protected]> you…

cmd_sf.c: In function 'do_spi_flash':
cmd_sf.c:164:9: warning: 'skipped' may be used uninitialized in this function

---
 common/cmd_sf.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Intel's new motto: United we stand. Divided we fall!