This is an automated email from Gerrit. Tarek BOCHKATI ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/6419
-- gerrit commit 20390d916529c0804d60a6704c74b5359eaa4c4f Author: Tarek BOCHKATI <[email protected]> Date: Thu Jul 29 22:05:18 2021 +0100 flash/stm32l4x: use COMMAND_PARSE_NUMBER in command handlers the usage of COMMAND_PARSE_NUMBER is safer in COMMAND_HANDLERs since it provides better error checking than strto** functions. Change-Id: I7e113b06b74f2d8d9cc4c0ce1957994a1c49c964 Signed-off-by: Tarek BOCHKATI <[email protected]> diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c index d70895c..3591a57 100644 --- a/src/flash/nor/stm32l4x.c +++ b/src/flash/nor/stm32l4x.c @@ -1740,7 +1740,7 @@ COMMAND_HANDLER(stm32l4_handle_option_read_command) uint32_t reg_offset, reg_addr; uint32_t value = 0; - reg_offset = strtoul(CMD_ARGV[1], NULL, 16); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], reg_offset); reg_addr = stm32l4_get_flash_reg(bank, reg_offset); retval = stm32l4_read_flash_reg(bank, reg_offset, &value); @@ -1768,10 +1768,11 @@ COMMAND_HANDLER(stm32l4_handle_option_write_command) uint32_t value = 0; uint32_t mask = 0xFFFFFFFF; - reg_offset = strtoul(CMD_ARGV[1], NULL, 16); - value = strtoul(CMD_ARGV[2], NULL, 16); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], reg_offset); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], value); + if (CMD_ARGC > 3) - mask = strtoul(CMD_ARGV[3], NULL, 16); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[3], mask); command_print(CMD, "%s Option written.\n" "INFO: a reset or power cycle is required " --
