summaryrefslogtreecommitdiff
path: root/src/target
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-13 00:33:01 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-13 00:33:01 +0000
commitfad8521a87026e841b972e90794cc6224d4b5009 (patch)
tree8bbafb7f5c0181cf0ba2cc7d8fc1abc7745f58ad /src/target
parent45ec363c4a56ade3d0c1f62c054e4310c76ce0f5 (diff)
downloadopenocd_libswd-fad8521a87026e841b972e90794cc6224d4b5009.tar.gz
openocd_libswd-fad8521a87026e841b972e90794cc6224d4b5009.tar.bz2
openocd_libswd-fad8521a87026e841b972e90794cc6224d4b5009.tar.xz
openocd_libswd-fad8521a87026e841b972e90794cc6224d4b5009.zip
Cleanup and fi handle_wait_halt_command:
- Use unsigned type for delay variable. - Use parse_uint to ensure delay argument parses properly. - Bug fix: Return syntax error if more than one argument is given. - Bug fix: Return syntax error when argument fails to parse. git-svn-id: svn://svn.berlios.de/openocd/trunk@2227 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/target')
-rw-r--r--src/target/target.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/target/target.c b/src/target/target.c
index 13c0842f..2163a74c 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -1822,21 +1822,23 @@ static int handle_poll_command(struct command_context_s *cmd_ctx, char *cmd, cha
static int handle_wait_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- int ms = 5000;
+ if (argc > 1)
+ return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc > 0)
+ unsigned ms = 5000;
+ if (1 == argc)
{
- char *end;
-
- ms = strtoul(args[0], &end, 0) * 1000;
- if (*end)
+ int retval = parse_uint(args[0], &ms);
+ if (ERROR_OK != retval)
{
command_print(cmd_ctx, "usage: %s [seconds]", cmd);
- return ERROR_OK;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
+ // convert seconds (given) to milliseconds (needed)
+ ms *= 1000;
}
- target_t *target = get_current_target(cmd_ctx);
+ target_t *target = get_current_target(cmd_ctx);
return target_wait_state(target, TARGET_HALTED, ms);
}