jtag/cmcis_dap: 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: Ife9342c6088a241a0a4b77f9bd21f12c9b9862a0 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6420 Reviewed-by: Adrian M Negreanu <adrian.negreanu@nxp.com> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
This commit is contained in:
parent
91b5626e7f
commit
277b0a5d97
|
@ -2004,7 +2004,7 @@ COMMAND_HANDLER(cmsis_dap_handle_cmd_command)
|
||||||
uint8_t *command = cmsis_dap_handle->command;
|
uint8_t *command = cmsis_dap_handle->command;
|
||||||
|
|
||||||
for (unsigned i = 0; i < CMD_ARGC; i++)
|
for (unsigned i = 0; i < CMD_ARGC; i++)
|
||||||
command[i] = strtoul(CMD_ARGV[i], NULL, 16);
|
COMMAND_PARSE_NUMBER(u8, CMD_ARGV[i], command[i]);
|
||||||
|
|
||||||
int retval = cmsis_dap_xfer(cmsis_dap_handle, CMD_ARGC);
|
int retval = cmsis_dap_xfer(cmsis_dap_handle, CMD_ARGC);
|
||||||
|
|
||||||
|
|
|
@ -464,7 +464,7 @@ static int cmsis_dap_usb_alloc(struct cmsis_dap *dap, unsigned int pkt_sz)
|
||||||
COMMAND_HANDLER(cmsis_dap_handle_usb_interface_command)
|
COMMAND_HANDLER(cmsis_dap_handle_usb_interface_command)
|
||||||
{
|
{
|
||||||
if (CMD_ARGC == 1)
|
if (CMD_ARGC == 1)
|
||||||
cmsis_dap_usb_interface = strtoul(CMD_ARGV[0], NULL, 10);
|
COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], cmsis_dap_usb_interface);
|
||||||
else
|
else
|
||||||
LOG_ERROR("expected exactly one argument to cmsis_dap_usb_interface <interface_number>");
|
LOG_ERROR("expected exactly one argument to cmsis_dap_usb_interface <interface_number>");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue