summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-12 01:39:57 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-12 01:39:57 +0000
commit0f6a47837e64836385268bb4e99e123477775e68 (patch)
treed2a585ced51d3ed17aeb89c22f56363dc87a8b24 /src
parent5af1bdcff468ae8fdb04f1d4d666d20b5fd0b73d (diff)
downloadopenocd_libswd-0f6a47837e64836385268bb4e99e123477775e68.tar.gz
openocd_libswd-0f6a47837e64836385268bb4e99e123477775e68.tar.bz2
openocd_libswd-0f6a47837e64836385268bb4e99e123477775e68.tar.xz
openocd_libswd-0f6a47837e64836385268bb4e99e123477775e68.zip
Simplify and improve handle_debug_level_comamnd:
- Bug fix: Return a syntax error if more than one argument is given. - Bug fix: Use new parse_uint helper ensure debug_level parses correctly. - Change: Display the debug_level after it has been set. - Simplify bounds checking of debug_level. git-svn-id: svn://svn.berlios.de/openocd/trunk@2208 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/helper/log.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/helper/log.c b/src/helper/log.c
index 549d7127..8dbdc947 100644
--- a/src/helper/log.c
+++ b/src/helper/log.c
@@ -194,17 +194,18 @@ void log_printf_lf(enum log_levels level, const char *file, int line, const char
*/
int handle_debug_level_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- if (argc == 0)
- command_print(cmd_ctx, "debug_level: %i", debug_level);
-
- if (argc > 0)
- debug_level = strtoul(args[0], NULL, 0);
-
- if (debug_level < 0)
- debug_level = 0;
+ if (argc == 1)
+ {
+ unsigned new_level;
+ int retval = parse_uint(args[0], &new_level);
+ if (ERROR_OK != retval)
+ return retval;
+ debug_level = MIN(new_level, LOG_LVL_DEBUG);
+ }
+ else if (argc > 1)
+ return ERROR_COMMAND_SYNTAX_ERROR;
- if (debug_level > 3)
- debug_level = 3;
+ command_print(cmd_ctx, "debug_level: %i", debug_level);
if (debug_level >= LOG_LVL_DEBUG && server_use_pipes == 1)
{