From: Zachary T Welch Date: Fri, 23 Oct 2009 09:17:17 +0000 (-0700) Subject: Improve cfi.c command argument parsing. X-Git-Tag: v0.4.0-rc1~919 X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=commitdiff_plain;h=680e22c4d7d71d88128bd12e3ecc08b135da626a Improve cfi.c command argument parsing. --- diff --git a/src/flash/cfi.c b/src/flash/cfi.c index 2d75ff4480..93e661c2f2 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;