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
This commit is contained in:
parent
45ec363c4a
commit
fad8521a87
|
@ -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)
|
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;
|
int retval = parse_uint(args[0], &ms);
|
||||||
|
if (ERROR_OK != retval)
|
||||||
ms = strtoul(args[0], &end, 0) * 1000;
|
|
||||||
if (*end)
|
|
||||||
{
|
{
|
||||||
command_print(cmd_ctx, "usage: %s [seconds]", cmd);
|
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);
|
return target_wait_state(target, TARGET_HALTED, ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue