|
From: <zw...@ma...> - 2009-06-08 12:55:11
|
Author: zwelch
Date: 2009-06-08 12:54:52 +0200 (Mon, 08 Jun 2009)
New Revision: 2111
Modified:
trunk/src/jtag/jtag.c
Log:
Update JTAG reset delay command handlers:
- Fixes for error handling:
- Return a syntax error instead of calling exit(-1).
- Return error when more than one argument is provided too.
- Remove useless braces and indent after the if/return statements.
- Wrap function arguments to fit in 80 columns.
Modified: trunk/src/jtag/jtag.c
===================================================================
--- trunk/src/jtag/jtag.c 2009-06-08 10:54:41 UTC (rev 2110)
+++ trunk/src/jtag/jtag.c 2009-06-08 10:54:52 UTC (rev 2111)
@@ -2112,33 +2112,27 @@
return ERROR_OK;
}
-static int handle_jtag_nsrst_delay_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+static int handle_jtag_nsrst_delay_command(struct command_context_s *cmd_ctx,
+ char *cmd, char **args, int argc)
{
- if (argc < 1)
+ if (argc != 1)
{
- LOG_ERROR("jtag_nsrst_delay <ms> command takes one required argument");
- exit(-1);
+ LOG_ERROR("jtag_nsrst_delay <ms> -- command requires one argument");
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
- else
- {
- jtag_set_nsrst_delay(strtoul(args[0], NULL, 0));
- }
-
+ jtag_set_nsrst_delay(strtoul(args[0], NULL, 0));
return ERROR_OK;
}
-static int handle_jtag_ntrst_delay_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+static int handle_jtag_ntrst_delay_command(struct command_context_s *cmd_ctx,
+ char *cmd, char **args, int argc)
{
- if (argc < 1)
+ if (argc != 1)
{
- LOG_ERROR("jtag_ntrst_delay <ms> command takes one required argument");
- exit(-1);
+ LOG_ERROR("jtag_ntrst_delay <ms> -- command requires one argument");
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
- else
- {
- jtag_set_ntrst_delay(strtoul(args[0], NULL, 0));
- }
-
+ jtag_set_ntrst_delay(strtoul(args[0], NULL, 0));
return ERROR_OK;
}
|