Improve mflash.c command argument parsing.
authorZachary T Welch <zw@superlucidity.net>
Fri, 23 Oct 2009 09:17:17 +0000 (02:17 -0700)
committerZachary T Welch <zw@superlucidity.net>
Fri, 6 Nov 2009 02:19:18 +0000 (18:19 -0800)
src/flash/mflash.c

index 63ba054ab73a612e751f839c69ca980e963981e5..bf759c97ab57527fd851664262bbf682bb8cfe4e 100644 (file)
@@ -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]);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)