diff options
author | Marc Schink <dev@zapb.de> | 2020-06-07 17:00:13 +0200 |
---|---|---|
committer | Tomas Vanek <vanekt@fbl.cz> | 2020-07-07 05:23:54 +0100 |
commit | ef14384b681af4f731f768bb866457832af6925f (patch) | |
tree | a8cb953d765484d4cd627eaa7ea71d9be6699866 /src/flash/nor/tcl.c | |
parent | a2e6982a1816a0229bd5644156f3025a0e8cb6ce (diff) | |
download | riscv-openocd-ef14384b681af4f731f768bb866457832af6925f.zip riscv-openocd-ef14384b681af4f731f768bb866457832af6925f.tar.gz riscv-openocd-ef14384b681af4f731f768bb866457832af6925f.tar.bz2 |
flash/nor: Use proper data types in driver API
Use 'unsigned int' and 'bool' instead of 'int' where appropriate.
While at it, fix some coding style issues.
No new Clang analyzer warnings.
Change-Id: I700802c9ee81c3c7ae73108f0f8f06b15a4345f8
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: http://openocd.zylin.com/4929
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'src/flash/nor/tcl.c')
-rw-r--r-- | src/flash/nor/tcl.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index fb2053b..3bdaf0b 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -112,8 +112,8 @@ COMMAND_HANDLER(handle_flash_info_command) LOG_INFO("Flash protection check is not implemented."); command_print(CMD, - "#%d : %s at " TARGET_ADDR_FMT ", size 0x%8.8" PRIx32 - ", buswidth %i, chipwidth %i", + "#%u : %s at " TARGET_ADDR_FMT ", size 0x%8.8" PRIx32 + ", buswidth %u, chipwidth %u", p->bank_number, p->driver->name, p->base, @@ -199,7 +199,6 @@ COMMAND_HANDLER(handle_flash_erase_check_command) if (ERROR_OK != retval) return retval; - int j; retval = p->driver->erase_check(p); if (retval == ERROR_OK) command_print(CMD, "successfully checked erase state"); @@ -211,7 +210,7 @@ COMMAND_HANDLER(handle_flash_erase_check_command) p->base); } - for (j = 0; j < p->num_sectors; j++) { + for (unsigned int j = 0; j < p->num_sectors; j++) { char *erase_state; if (p->sectors[j].is_erased == 0) @@ -325,7 +324,7 @@ COMMAND_HANDLER(handle_flash_erase_command) return ERROR_FAIL; } - if (!(last <= (uint32_t)(p->num_sectors - 1))) { + if (!(last <= (p->num_sectors - 1))) { command_print(CMD, "ERROR: " "last sector must be <= %" PRIu32, p->num_sectors - 1); @@ -339,7 +338,7 @@ COMMAND_HANDLER(handle_flash_erase_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { command_print(CMD, "erased sectors %" PRIu32 " " - "through %" PRIu32 " on flash bank %d " + "through %" PRIu32 " on flash bank %u " "in %fs", first, last, p->bank_number, duration_elapsed(&bench)); } @@ -1007,11 +1006,10 @@ COMMAND_HANDLER(handle_flash_verify_bank_command) void flash_set_dirty(void) { struct flash_bank *c; - int i; /* set all flash to require erasing */ for (c = flash_bank_list(); c; c = c->next) { - for (i = 0; i < c->num_sectors; i++) + for (unsigned int i = 0; i < c->num_sectors; i++) c->sectors[i].is_erased = 0; } } @@ -1243,8 +1241,8 @@ COMMAND_HANDLER(handle_flash_bank_command) c->driver = driver; COMMAND_PARSE_NUMBER(target_addr, CMD_ARGV[1], c->base); COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], c->size); - COMMAND_PARSE_NUMBER(int, CMD_ARGV[3], c->chip_width); - COMMAND_PARSE_NUMBER(int, CMD_ARGV[4], c->bus_width); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[3], c->chip_width); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[4], c->bus_width); c->default_padded_value = c->erased_value = 0xff; c->minimal_write_gap = FLASH_WRITE_GAP_SECTOR; |