Improve at91sam3.c command argument parsing.
authorZachary T Welch <zw@superlucidity.net>
Fri, 23 Oct 2009 05:33:12 +0000 (22:33 -0700)
committerZachary T Welch <zw@superlucidity.net>
Fri, 6 Nov 2009 02:03:20 +0000 (18:03 -0800)
src/flash/at91sam3.c

index 5edaa690be106825f31b525e3890d948bb62c6ad..aff4d984539e9f6bb1c112d693929052775e9806 100644 (file)
@@ -2347,7 +2347,6 @@ static int
 sam3_handle_gpnvm_command(struct command_context_s *cmd_ctx, char *cmd, char **argv, int argc)
 {
        unsigned x,v;
-       uint32_t v32;
        int r,who;
        struct sam3_chip *pChip;
 
@@ -2391,11 +2390,8 @@ sam3_handle_gpnvm_command(struct command_context_s *cmd_ctx, char *cmd, char **a
                if ((0 == strcmp(argv[0], "show")) && (0 == strcmp(argv[1], "all"))) {
                        who = -1;
                } else {
-                       r = parse_u32(argv[1], &v32);
-                       if (r != ERROR_OK) {
-                               command_print(cmd_ctx, "Not a number: %s", argv[1]);
-                               return r;
-                       }
+                       uint32_t v32;
+                       COMMAND_PARSE_NUMBER(u32, argv[1], v32);
                        who = v32;
                }
                break;
@@ -2444,9 +2440,6 @@ sam3_handle_gpnvm_command(struct command_context_s *cmd_ctx, char *cmd, char **a
 static int
 sam3_handle_slowclk_command(struct command_context_s *cmd_ctx, char *cmd, char **argv, int argc)
 {
-       uint32_t v;
-       int r;
-
        struct sam3_chip *pChip;
 
        pChip = get_current_sam3(cmd_ctx);
@@ -2460,8 +2453,10 @@ sam3_handle_slowclk_command(struct command_context_s *cmd_ctx, char *cmd, char *
                // show
                break;
        case 1:
+       {
                // set
-               r = parse_u32(argv[0], &v);
+               uint32_t v;
+               COMMAND_PARSE_NUMBER(u32, argv[0], v);
                if (v > 200000) {
                        // absurd slow clock of 200Khz?
                        command_print(cmd_ctx,"Absurd/illegal slow clock freq: %d\n", (int)(v));
@@ -2469,7 +2464,7 @@ sam3_handle_slowclk_command(struct command_context_s *cmd_ctx, char *cmd, char *
                }
                pChip->cfg.slow_freq = v;
                break;
-
+       }
        default:
                // error
                command_print(cmd_ctx,"Too many parameters");

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)