Improve pld command argument parsing.
authorZachary T Welch <zw@superlucidity.net>
Sat, 24 Oct 2009 08:22:58 +0000 (01:22 -0700)
committerZachary T Welch <zw@superlucidity.net>
Fri, 6 Nov 2009 02:03:19 +0000 (18:03 -0800)
src/pld/pld.c
src/pld/virtex2.c

index 391fb7610d3db26ae126c19eb1e8616d6f6f61ed..2bfb4016880a2aa5032c0faad6fe62cc6e5897ae 100644 (file)
@@ -175,7 +175,9 @@ static int handle_pld_load_command(struct command_context_s *cmd_ctx,
                return ERROR_OK;
        }
 
                return ERROR_OK;
        }
 
-       p = get_pld_device_by_num(strtoul(args[0], NULL, 0));
+       unsigned dev_id;
+       COMMAND_PARSE_NUMBER(uint, args[0], dev_id);
+       p = get_pld_device_by_num(dev_id);
        if (!p)
        {
                command_print(cmd_ctx, "pld device '#%s' is out of bounds", args[0]);
        if (!p)
        {
                command_print(cmd_ctx, "pld device '#%s' is out of bounds", args[0]);
@@ -184,19 +186,20 @@ static int handle_pld_load_command(struct command_context_s *cmd_ctx,
 
        if ((retval = p->driver->load(p, args[1])) != ERROR_OK)
        {
 
        if ((retval = p->driver->load(p, args[1])) != ERROR_OK)
        {
-               command_print(cmd_ctx, "failed loading file %s to pld device %lu",
-                       args[1], strtoul(args[0], NULL, 0));
+               command_print(cmd_ctx, "failed loading file %s to pld device %u",
+                       args[1], dev_id);
                switch (retval)
                {
                }
                switch (retval)
                {
                }
+               return retval;
        }
        else
        {
                gettimeofday(&end, NULL);
                timeval_subtract(&duration, &end, &start);
 
        }
        else
        {
                gettimeofday(&end, NULL);
                timeval_subtract(&duration, &end, &start);
 
-               command_print(cmd_ctx, "loaded file %s to pld device %lu in %jis %jius",
-                       args[1], strtoul(args[0], NULL, 0),
+               command_print(cmd_ctx, "loaded file %s to pld device %u in %jis %jius",
+                       args[1], dev_id,
                        (intmax_t)duration.tv_sec, (intmax_t)duration.tv_usec);
        }
 
                        (intmax_t)duration.tv_sec, (intmax_t)duration.tv_usec);
        }
 
index 831503a56b6b15065ce8f048fb6e59e5da958fd1..28cae6cafec8f680c40b01e3cea95f150c7187c3 100644 (file)
@@ -202,7 +202,9 @@ static int virtex2_handle_read_stat_command(struct command_context_s *cmd_ctx,
                return ERROR_OK;
        }
 
                return ERROR_OK;
        }
 
-       device = get_pld_device_by_num(strtoul(args[0], NULL, 0));
+       unsigned dev_id;
+       COMMAND_PARSE_NUMBER(uint, args[0], dev_id);
+       device = get_pld_device_by_num(dev_id);
        if (!device)
        {
                command_print(cmd_ctx, "pld device '#%s' is out of bounds", args[0]);
        if (!device)
        {
                command_print(cmd_ctx, "pld device '#%s' is out of bounds", args[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)