|
From: <zw...@ma...> - 2009-06-13 02:34:42
|
Author: zwelch
Date: 2009-06-13 02:33:11 +0200 (Sat, 13 Jun 2009)
New Revision: 2228
Modified:
trunk/src/target/target.c
Log:
Cleanup and improve handle_halt_command:
- Make argument check use parse_uint to ensure value parses properly.
- Move variable declarations to location of first use.
Modified: trunk/src/target/target.c
===================================================================
--- trunk/src/target/target.c 2009-06-13 00:33:01 UTC (rev 2227)
+++ trunk/src/target/target.c 2009-06-13 00:33:11 UTC (rev 2228)
@@ -1889,23 +1889,20 @@
static int handle_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- int retval;
- target_t *target = get_current_target(cmd_ctx);
-
LOG_DEBUG("-");
- if ((retval = target_halt(target)) != ERROR_OK)
- {
+ target_t *target = get_current_target(cmd_ctx);
+ int retval = target_halt(target);
+ if (ERROR_OK != retval)
return retval;
- }
if (argc == 1)
{
- int wait;
- char *end;
-
- wait = strtoul(args[0], &end, 0);
- if (!*end && !wait)
+ unsigned wait;
+ retval = parse_uint(args[0], &wait);
+ if (ERROR_OK != retval)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ if (!wait)
return ERROR_OK;
}
|