jtag: rewrite command 'pathmove' as COMMAND_HANDLER 56/7556/2
authorAntonio Borneo <borneo.antonio@gmail.com>
Mon, 2 Jan 2023 21:32:53 +0000 (22:32 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 13 May 2023 08:53:51 +0000 (08:53 +0000)
Change-Id: I1f8c6722021f392b1f065484b63a19964db69ad5
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7556
Tested-by: jenkins
src/jtag/tcl.c

index ea501022bd0ec072355e9c1f2aa68baccbc4a956..d792081c484f15f24ba5ecbdecbbf2a3ed62ba64 100644 (file)
@@ -164,40 +164,37 @@ fail:
        return retval;
 }
 
-static int jim_command_pathmove(Jim_Interp *interp, int argc, Jim_Obj * const *args)
+COMMAND_HANDLER(handle_jtag_command_pathmove)
 {
        tap_state_t states[8];
 
-       if ((argc < 2) || ((size_t)argc > (ARRAY_SIZE(states) + 1))) {
-               Jim_WrongNumArgs(interp, 1, args, "wrong arguments");
-               return JIM_ERR;
-       }
+       if (CMD_ARGC < 1 || CMD_ARGC > ARRAY_SIZE(states))
+               return ERROR_COMMAND_SYNTAX_ERROR;
 
-       int i;
-       for (i = 0; i < argc-1; i++) {
-               const char *cp;
-               cp = Jim_GetString(args[i + 1], NULL);
-               states[i] = tap_state_by_name(cp);
+       for (unsigned int i = 0; i < CMD_ARGC; i++) {
+               states[i] = tap_state_by_name(CMD_ARGV[i]);
                if (states[i] < 0) {
-                       /* update the error message */
-                       Jim_SetResultFormatted(interp, "endstate: %s invalid", cp);
-                       return JIM_ERR;
+                       command_print(CMD, "endstate: %s invalid", CMD_ARGV[i]);
+                       return ERROR_COMMAND_ARGUMENT_INVALID;
                }
        }
 
-       if ((jtag_add_statemove(states[0]) != ERROR_OK) || (jtag_execute_queue() != ERROR_OK)) {
-               Jim_SetResultString(interp, "pathmove: jtag execute failed", -1);
-               return JIM_ERR;
+       int retval = jtag_add_statemove(states[0]);
+       if (retval == ERROR_OK)
+               retval = jtag_execute_queue();
+       if (retval != ERROR_OK) {
+               command_print(CMD, "pathmove: jtag execute failed");
+               return retval;
        }
 
-       jtag_add_pathmove(argc - 2, states + 1);
-
-       if (jtag_execute_queue() != ERROR_OK) {
-               Jim_SetResultString(interp, "pathmove: failed", -1);
-               return JIM_ERR;
+       jtag_add_pathmove(CMD_ARGC - 1, states + 1);
+       retval = jtag_execute_queue();
+       if (retval != ERROR_OK) {
+               command_print(CMD, "pathmove: failed");
+               return retval;
        }
 
-       return JIM_OK;
+       return ERROR_OK;
 }
 
 COMMAND_HANDLER(handle_jtag_flush_count)
@@ -241,7 +238,7 @@ static const struct command_registration jtag_command_handlers_to_move[] = {
        {
                .name = "pathmove",
                .mode = COMMAND_EXEC,
-               .jim_handler = jim_command_pathmove,
+               .handler = handle_jtag_command_pathmove,
                .usage = "start_state state1 [state2 [state3 ...]]",
                .help = "Move JTAG state machine from current state "
                        "(start_state) to state1, then state2, state3, etc.",

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)