Commit fad8521a authored by zwelch's avatar zwelch
Browse files

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
parent 45ec363c
......@@ -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);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment