Commit 45ec363c authored by zwelch's avatar zwelch
Browse files

Use parse_uint in handle_reg_command to ensure reg number parses properly.


git-svn-id: svn://svn.berlios.de/openocd/trunk@2226 b42882b7-edfa-0310-969c-e2dbd0fdcd60
parent 23432450
...@@ -1704,16 +1704,19 @@ static int handle_reg_command(struct command_context_s *cmd_ctx, char *cmd, char ...@@ -1704,16 +1704,19 @@ static int handle_reg_command(struct command_context_s *cmd_ctx, char *cmd, char
/* access a single register by its ordinal number */ /* access a single register by its ordinal number */
if ((args[0][0] >= '0') && (args[0][0] <= '9')) if ((args[0][0] >= '0') && (args[0][0] <= '9'))
{ {
int num = strtoul(args[0], NULL, 0); unsigned num;
reg_cache_t *cache = target->reg_cache; int retval = parse_uint(args[0], &num);
if (ERROR_OK != retval)
return ERROR_COMMAND_SYNTAX_ERROR;
reg_cache_t *cache = target->reg_cache;
count = 0; count = 0;
while(cache) while(cache)
{ {
int i; int i;
for (i = 0; i < cache->num_regs; i++) for (i = 0; i < cache->num_regs; i++)
{ {
if (count++ == num) if (count++ == (int)num)
{ {
reg = &cache->reg_list[i]; reg = &cache->reg_list[i];
break; break;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment