summaryrefslogtreecommitdiff
path: root/src/flash/cfi.c
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-10-23 02:17:17 -0700
committerZachary T Welch <zw@superlucidity.net>2009-11-05 18:19:18 -0800
commit680e22c4d7d71d88128bd12e3ecc08b135da626a (patch)
treeab934de18fd5f6e081aa5c4cf1cacc526ab014d4 /src/flash/cfi.c
parent7b3d54a1278dc89f5ad43a5c00bfacbbddc8a9b6 (diff)
downloadopenocd+libswd-680e22c4d7d71d88128bd12e3ecc08b135da626a.tar.gz
openocd+libswd-680e22c4d7d71d88128bd12e3ecc08b135da626a.tar.bz2
openocd+libswd-680e22c4d7d71d88128bd12e3ecc08b135da626a.tar.xz
openocd+libswd-680e22c4d7d71d88128bd12e3ecc08b135da626a.zip
Improve cfi.c command argument parsing.
Diffstat (limited to 'src/flash/cfi.c')
-rw-r--r--src/flash/cfi.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/flash/cfi.c b/src/flash/cfi.c
index 2d75ff44..93e661c2 100644
--- a/src/flash/cfi.c
+++ b/src/flash/cfi.c
@@ -641,8 +641,12 @@ static int cfi_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd,
return ERROR_FLASH_BANK_INVALID;
}
- if ((strtoul(args[4], NULL, 0) > CFI_MAX_CHIP_WIDTH)
- || (strtoul(args[3], NULL, 0) > CFI_MAX_BUS_WIDTH))
+ uint16_t chip_width, bus_width;
+ COMMAND_PARSE_NUMBER(u16, args[3], bus_width);
+ COMMAND_PARSE_NUMBER(u16, args[4], chip_width);
+
+ if ((chip_width > CFI_MAX_CHIP_WIDTH)
+ || (bus_width > CFI_MAX_BUS_WIDTH))
{
LOG_ERROR("chip and bus width have to specified in bytes");
return ERROR_FLASH_BANK_INVALID;