Browse Source

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
jim
Tarek BOCHKATI 1 year ago
committed by Antonio Borneo
parent
commit
cbc1dc5049
1 changed files with 7 additions and 4 deletions
  1. +7
    -4
      src/flash/nor/atsame5.c

+ 7
- 4
src/flash/nor/atsame5.c View File

@@ -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 "


Loading…
Cancel
Save