summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-10-24 06:36:06 -0700
committerZachary T Welch <zw@superlucidity.net>2009-11-05 18:03:19 -0800
commit3dd5c59d7d4d4dc13ebd3fc870bd4bc695c9fda8 (patch)
treed7358bc7216e67f4bc89827af74da25a5d1fbbc2
parentb62ee5a3c56cfbb000a40c05083dd31720c7cb1e (diff)
downloadopenocd_libswd-3dd5c59d7d4d4dc13ebd3fc870bd4bc695c9fda8.tar.gz
openocd_libswd-3dd5c59d7d4d4dc13ebd3fc870bd4bc695c9fda8.tar.bz2
openocd_libswd-3dd5c59d7d4d4dc13ebd3fc870bd4bc695c9fda8.tar.xz
openocd_libswd-3dd5c59d7d4d4dc13ebd3fc870bd4bc695c9fda8.zip
Improve armv7a command argument parsing.
-rw-r--r--src/target/armv7a.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/target/armv7a.c b/src/target/armv7a.c
index 1e0e02f1..1583e995 100644
--- a/src/target/armv7a.c
+++ b/src/target/armv7a.c
@@ -286,9 +286,16 @@ static int handle_dap_info_command(struct command_context_s *cmd_ctx,
swjdp_common_t *swjdp = &armv7a->swjdp_info;
uint32_t apsel;
- apsel = swjdp->apsel;
- if (argc > 0)
- apsel = strtoul(args[0], NULL, 0);
+ switch (argc) {
+ case 0:
+ apsel = swjdp->apsel;
+ break;
+ case 1:
+ COMMAND_PARSE_NUMBER(u32, args[0], apsel);
+ break;
+ default:
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ }
return dap_info_command(cmd_ctx, swjdp, apsel);
}
@@ -320,10 +327,10 @@ handle_armv7a_disassemble_command(struct command_context_s *cmd_ctx,
thumb = 1;
/* FALL THROUGH */
case 2:
- count = strtoul(args[1], NULL, 0);
+ COMMAND_PARSE_NUMBER(int, args[1], count);
/* FALL THROUGH */
case 1:
- address = strtoul(args[0], NULL, 0);
+ COMMAND_PARSE_NUMBER(u32, args[0], address);
if (address & 0x01) {
if (!thumb) {
command_print(cmd_ctx, "Disassemble as Thumb");