diff options
author | Tarek BOCHKATI <tarek.bouchkati@gmail.com> | 2021-07-29 23:46:31 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2021-08-22 13:19:16 +0000 |
commit | cbc1dc50490ba7a98778bef352aead754befabca (patch) | |
tree | 50f270c28ae944fa4c7985c388d08ede50bffb26 | |
parent | 3caa18729cde415519824b4f9da16df40c125539 (diff) | |
download | riscv-openocd-cbc1dc50490ba7a98778bef352aead754befabca.zip riscv-openocd-cbc1dc50490ba7a98778bef352aead754befabca.tar.gz riscv-openocd-cbc1dc50490ba7a98778bef352aead754befabca.tar.bz2 |
flash/atsame5: 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: Ia7fe9c4017108616f21676f115f151ac62924205
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6423
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
-rw-r--r-- | src/flash/nor/atsame5.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/flash/nor/atsame5.c b/src/flash/nor/atsame5.c index 7c7e5d0..203c470 100644 --- a/src/flash/nor/atsame5.c +++ b/src/flash/nor/atsame5.c @@ -797,11 +797,12 @@ COMMAND_HANDLER(same5_handle_userpage_command) } if (CMD_ARGC >= 1) { - uint64_t mask = NVMUSERROW_SAM_E5_D5_MASK; - uint64_t value = strtoull(CMD_ARGV[0], NULL, 0); + uint64_t value, mask = NVMUSERROW_SAM_E5_D5_MASK; + COMMAND_PARSE_NUMBER(u64, CMD_ARGV[0], value); if (CMD_ARGC == 2) { - uint64_t mask_temp = strtoull(CMD_ARGV[1], NULL, 0); + uint64_t mask_temp; + COMMAND_PARSE_NUMBER(u64, CMD_ARGV[1], mask_temp); mask &= mask_temp; } @@ -837,7 +838,9 @@ COMMAND_HANDLER(same5_handle_bootloader_command) return ERROR_FAIL; if (CMD_ARGC >= 1) { - unsigned long size = strtoul(CMD_ARGV[0], NULL, 0); + unsigned long size; + + COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[0], size); uint32_t code = (size + 8191) / 8192; if (code > 15) { command_print(CMD, "Invalid bootloader size. Please " |