Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/73285 )
Change subject: jedec.c: Provide better lexical scope to itermediates ......................................................................
jedec.c: Provide better lexical scope to itermediates
Change-Id: I8e01d471bb33a933b80760df2c69a4bf3589ba76 Signed-off-by: Edward O'Callaghan quasisec@google.com --- M jedec.c 1 file changed, 16 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/85/73285/1
diff --git a/jedec.c b/jedec.c index 01c401f..db2e3e8 100644 --- a/jedec.c +++ b/jedec.c @@ -38,13 +38,11 @@ static void toggle_ready_jedec_common(const struct flashctx *flash, chipaddr dst, unsigned int delay) { unsigned int i = 0; - uint8_t tmp1, tmp2; - - tmp1 = chip_readb(flash, dst) & 0x40; + uint8_t tmp1 = chip_readb(flash, dst) & 0x40;
while (i++ < 0xFFFFFFF) { programmer_delay(flash, delay); - tmp2 = chip_readb(flash, dst) & 0x40; + uint8_t tmp2 = chip_readb(flash, dst) & 0x40; if (tmp1 == tmp2) { break; } @@ -76,12 +74,11 @@ uint8_t data) { unsigned int i = 0; - uint8_t tmp;
data &= 0x80;
while (i++ < 0xFFFFFFF) { - tmp = chip_readb(flash, dst) & 0x80; + uint8_t tmp = chip_readb(flash, dst) & 0x80; if (tmp == data) { break; } @@ -377,12 +374,11 @@ int write_jedec_1(struct flashctx *flash, const uint8_t *src, unsigned int start, unsigned int len) { - unsigned int i; int failed = 0; chipaddr dst = flash->virtual_memory + start; const chipaddr olddst = dst;
- for (i = 0; i < len; i++) { + for (unsigned int i = 0; i < len; i++) { if (write_byte_program_jedec_common(flash, src, dst)) failed = 1; dst++, src++; @@ -444,7 +440,7 @@ int write_jedec(struct flashctx *flash, const uint8_t *buf, unsigned int start, int unsigned len) { - unsigned int i, starthere, lenhere; + unsigned int starthere, lenhere; /* FIXME: page_size is the wrong variable. We need max_writechunk_size * in struct flashctx to do this properly. All chips using * write_jedec have page_size set to max_writechunk_size, so @@ -462,7 +458,7 @@ * (start + len - 1) / page_size. Since we want to include that last * page as well, the loop condition uses <=. */ - for (i = start / page_size; i <= nwrites; i++) { + for (unsigned int i = start / page_size; i <= nwrites; i++) { /* Byte position of the first byte in the range in this page. */ /* starthere is an offset to the base address of the chip. */ starthere = max(start, i * page_size);