diff options
author | zwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2009-06-13 00:32:54 +0000 |
---|---|---|
committer | zwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2009-06-13 00:32:54 +0000 |
commit | 45ec363c4a56ade3d0c1f62c054e4310c76ce0f5 (patch) | |
tree | f95f65b0f6bc1d1a17ac23b88428be1d09ed41ec /src/target | |
parent | 234324509009067323db2084115d67369653b675 (diff) | |
download | openocd_libswd-45ec363c4a56ade3d0c1f62c054e4310c76ce0f5.tar.gz openocd_libswd-45ec363c4a56ade3d0c1f62c054e4310c76ce0f5.tar.bz2 openocd_libswd-45ec363c4a56ade3d0c1f62c054e4310c76ce0f5.tar.xz openocd_libswd-45ec363c4a56ade3d0c1f62c054e4310c76ce0f5.zip |
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
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/target.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/target/target.c b/src/target/target.c index b8ee7ab9..13c0842f 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -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 */ if ((args[0][0] >= '0') && (args[0][0] <= '9')) { - int num = strtoul(args[0], NULL, 0); - reg_cache_t *cache = target->reg_cache; + unsigned num; + 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; while(cache) { int i; for (i = 0; i < cache->num_regs; i++) { - if (count++ == num) + if (count++ == (int)num) { reg = &cache->reg_list[i]; break; |