diff options
author | Zachary T Welch <zw@superlucidity.net> | 2009-10-23 02:17:17 -0700 |
---|---|---|
committer | Zachary T Welch <zw@superlucidity.net> | 2009-11-05 18:19:18 -0800 |
commit | ee4723c494fb9cd8deefdbf5387f0ba31ea57c65 (patch) | |
tree | 20c5042a813e198824fff8d73f87151ac1cc166d /src | |
parent | c63671e4f7eac5488e1ec0ef50f9d32e12cf3b31 (diff) | |
download | openocd_libswd-ee4723c494fb9cd8deefdbf5387f0ba31ea57c65.tar.gz openocd_libswd-ee4723c494fb9cd8deefdbf5387f0ba31ea57c65.tar.bz2 openocd_libswd-ee4723c494fb9cd8deefdbf5387f0ba31ea57c65.tar.xz openocd_libswd-ee4723c494fb9cd8deefdbf5387f0ba31ea57c65.zip |
Improve mflash.c command argument parsing.
Diffstat (limited to 'src')
-rw-r--r-- | src/flash/mflash.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/flash/mflash.c b/src/flash/mflash.c index 63ba054a..bf759c97 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -716,7 +716,7 @@ static int mg_write_cmd(struct command_context_s *cmd_ctx, char *cmd, char **arg return ERROR_COMMAND_SYNTAX_ERROR; } - address = strtoul(args[2], NULL, 0); + COMMAND_PARSE_NUMBER(u32, args[2], address); ret = fileio_open(&fileio, args[1], FILEIO_READ, FILEIO_BINARY); if (ret != ERROR_OK) @@ -783,8 +783,8 @@ static int mg_dump_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args return ERROR_COMMAND_SYNTAX_ERROR; } - address = strtoul(args[2], NULL, 0); - size = strtoul(args[3], NULL, 0); + COMMAND_PARSE_NUMBER(u32, args[2], address); + COMMAND_PARSE_NUMBER(u32, args[3], size); ret = fileio_open(&fileio, args[1], FILEIO_WRITE, FILEIO_BINARY); if (ret != ERROR_OK) @@ -1238,7 +1238,9 @@ int mg_config_cmd(struct command_context_s *cmd_ctx, char *cmd, break; case 3: if (!strcmp(args[1], "pll")) { - fin = strtoul(args[2], NULL, 0); + unsigned long freq; + COMMAND_PARSE_NUMBER(ulong, args[2], freq); + fin = freq; if (fin > MG_PLL_CLK_OUT) { LOG_ERROR("mflash: input freq. is too large"); @@ -1288,7 +1290,6 @@ int mflash_init_drivers(struct command_context_s *cmd_ctx) static int mg_bank_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { target_t *target; - char *str; int i; if (argc < 4) @@ -1303,7 +1304,9 @@ static int mg_bank_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args } mflash_bank = calloc(sizeof(mflash_bank_t), 1); - mflash_bank->base = strtoul(args[1], NULL, 0); + COMMAND_PARSE_NUMBER(u32, args[1], mflash_bank->base); + /// @todo Verify how this parsing should work, then document it. + char *str; mflash_bank->rst_pin.num = strtoul(args[2], &str, 0); if (*str) mflash_bank->rst_pin.port[0] = (uint16_t)tolower(str[0]); |