diff options
author | Tarek BOCHKATI <tarek.bouchkati@gmail.com> | 2021-07-29 22:05:18 +0100 |
---|---|---|
committer | Paul Fertser <fercerpav@gmail.com> | 2021-08-22 10:45:17 +0000 |
commit | 91b5626e7fa7f30b1c5c8b69cf1decf33e892c42 (patch) | |
tree | 216a7d0447844cdb72a6ab45e5d38940f6aada38 | |
parent | 88c3e767b29b2aeec6f9290cfb9efb749b4d6f82 (diff) | |
download | riscv-openocd-91b5626e7fa7f30b1c5c8b69cf1decf33e892c42.zip riscv-openocd-91b5626e7fa7f30b1c5c8b69cf1decf33e892c42.tar.gz riscv-openocd-91b5626e7fa7f30b1c5c8b69cf1decf33e892c42.tar.bz2 |
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 <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6419
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Tested-by: jenkins
-rw-r--r-- | src/flash/nor/stm32l4x.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c index 7d6c900..d770cdf 100644 --- a/src/flash/nor/stm32l4x.c +++ b/src/flash/nor/stm32l4x.c @@ -1734,7 +1734,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); @@ -1762,10 +1762,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 " |