summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-13 00:34:03 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-06-13 00:34:03 +0000
commitd0a300e0a07bce4039eae1852a6fc28160d63a03 (patch)
treeb9f1005be8f389c43788192b970910d4a4f18098 /src
parent16c77cf3cac6e568813bbf88af7a6e3c32f5fbc6 (diff)
downloadopenocd+libswd-d0a300e0a07bce4039eae1852a6fc28160d63a03.tar.gz
openocd+libswd-d0a300e0a07bce4039eae1852a6fc28160d63a03.tar.bz2
openocd+libswd-d0a300e0a07bce4039eae1852a6fc28160d63a03.tar.xz
openocd+libswd-d0a300e0a07bce4039eae1852a6fc28160d63a03.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/target/target.c23
1 files changed, 18 insertions, 5 deletions
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;
}