From: zwelch Date: Sat, 13 Jun 2009 00:34:03 +0000 (+0000) Subject: Improve and simplify handle_bp_command and handle_rbp_command: X-Git-Tag: v0.2.0~280 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d0a300e0a07bce4039eae1852a6fc28160d63a03;p=openocd Improve and simplify handle_bp_command and handle_rbp_command: - Bug fix: return syntax error if remove called without one argument. - Use parse_u32 to ensure address and length arguments parse properly. git-svn-id: svn://svn.berlios.de/openocd/trunk@2235 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- diff --git a/src/target/target.c b/src/target/target.c index 5a7ac3bc..6dca25d0 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2541,8 +2541,15 @@ static int handle_bp_command(struct command_context_s *cmd_ctx, return ERROR_COMMAND_SYNTAX_ERROR; } - u32 addr = strtoul(args[0], NULL, 0); - u32 length = strtoul(args[1], NULL, 0); + u32 addr; + int retval = parse_u32(args[0], &addr); + if (ERROR_OK != retval) + return retval; + + u32 length; + retval = parse_u32(args[1], &length); + if (ERROR_OK != retval) + return retval; int hw = BKPT_SOFT; if (argc == 3) @@ -2558,10 +2565,16 @@ static int handle_bp_command(struct command_context_s *cmd_ctx, static int handle_rbp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { - target_t *target = get_current_target(cmd_ctx); + if (argc != 1) + return ERROR_COMMAND_SYNTAX_ERROR; - if (argc > 0) - breakpoint_remove(target, strtoul(args[0], NULL, 0)); + u32 addr; + int retval = parse_u32(args[0], &addr); + if (ERROR_OK != retval) + return retval; + + target_t *target = get_current_target(cmd_ctx); + breakpoint_remove(target, addr); return ERROR_OK; }