]> git.sur5r.net Git - openocd/commitdiff
add CMD_NAME macro for command handlers
authorZachary T Welch <zw@superlucidity.net>
Wed, 11 Nov 2009 06:29:36 +0000 (22:29 -0800)
committerZachary T Welch <zw@superlucidity.net>
Fri, 13 Nov 2009 18:55:00 +0000 (10:55 -0800)
By introducing the CMD_NAME macro, this parameter may be integrated
as args[-1] in command.[ch], without touching any other call sites.

src/flash/flash.c
src/helper/command.h
src/jtag/tcl.c
src/target/arm720t.c
src/target/arm920t.c
src/target/arm926ejs.c
src/target/arm966e.c
src/target/cortex_m3.c
src/target/target.c
src/target/xscale.c

index da43e1a8130b0885e8d136a886b8b1ede779160e..f3f0086addfd8329769eece6b932a41dec612e0a 100644 (file)
@@ -728,7 +728,7 @@ COMMAND_HANDLER(handle_flash_fill_command)
        if (count == 0)
                return ERROR_OK;
 
-       switch (cmd[4])
+       switch (CMD_NAME[4])
        {
        case 'w':
                wordsize = 4;
index aec066d088faea35071dad9ea8aac77624ba8ba7..74c6f367b0bc88452fbff38f4deae9e37e07eb78 100644 (file)
@@ -121,6 +121,12 @@ typedef struct command_context_s
  */
 #define COMMAND_HELPER(name, extra...) __COMMAND_HANDLER(name, extra)
 
+/**
+ * Use this macro to access the name of the command being handled,
+ * rather than accessing the variable directly.  It may be moved.
+ */
+#define CMD_NAME cmd
+
 
 /// The type signature for commands' handler functions.
 typedef __COMMAND_HANDLER((*command_handler_t));
index 4da8838d375f2be801087100addf10700ec820f7..923542f8e35bf422966595277c54f9e6b885afe5 100644 (file)
@@ -605,7 +605,7 @@ static int default_srst_asserted(int *srst_asserted)
 
 COMMAND_HANDLER(handle_interface_list_command)
 {
-       if (strcmp(cmd, "interface_list") == 0 && argc > 0)
+       if (strcmp(CMD_NAME, "interface_list") == 0 && argc > 0)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        command_print(cmd_ctx, "The following JTAG interfaces are available:");
index 6a5a4e74789bb7da730e3b3c7a04ad6d5d1d1aa1..af326bf41702508149d0ad82417ed61a16d78f76 100644 (file)
@@ -424,7 +424,7 @@ COMMAND_HANDLER(arm720t_handle_cp15_command)
 
        if (target->state != TARGET_HALTED)
        {
-               command_print(cmd_ctx, "target must be stopped for \"%s\" command", cmd);
+               command_print(cmd_ctx, "target must be stopped for \"%s\" command", CMD_NAME);
                return ERROR_OK;
        }
 
index 5576f60f092c0ad8053349c308837fffe698143b..81f5c6af982da2e6bc70459815f0b61de85ff5bf 100644 (file)
@@ -1203,7 +1203,7 @@ COMMAND_HANDLER(arm920t_handle_cp15_command)
 
        if (target->state != TARGET_HALTED)
        {
-               command_print(cmd_ctx, "target must be stopped for \"%s\" command", cmd);
+               command_print(cmd_ctx, "target must be stopped for \"%s\" command", CMD_NAME);
                return ERROR_OK;
        }
 
@@ -1257,7 +1257,7 @@ COMMAND_HANDLER(arm920t_handle_cp15i_command)
 
        if (target->state != TARGET_HALTED)
        {
-               command_print(cmd_ctx, "target must be stopped for \"%s\" command", cmd);
+               command_print(cmd_ctx, "target must be stopped for \"%s\" command", CMD_NAME);
                return ERROR_OK;
        }
 
index 6f347d87d14fdc1e82880226bee8523e690e0bda..77405a870105d087cbb8c42e6272547820d4afe1 100644 (file)
@@ -740,7 +740,7 @@ COMMAND_HANDLER(arm926ejs_handle_cp15_command)
 
        if (target->state != TARGET_HALTED)
        {
-               command_print(cmd_ctx, "target must be stopped for \"%s\" command", cmd);
+               command_print(cmd_ctx, "target must be stopped for \"%s\" command", CMD_NAME);
                return ERROR_OK;
        }
 
index e61943a3e96d04aa0e60414602a8cae951d42d20..62ccaa80fe61fbb3d58355a021e9e24b9e38421e 100644 (file)
@@ -174,7 +174,7 @@ COMMAND_HANDLER(arm966e_handle_cp15_command)
 
        if (target->state != TARGET_HALTED)
        {
-               command_print(cmd_ctx, "target must be stopped for \"%s\" command", cmd);
+               command_print(cmd_ctx, "target must be stopped for \"%s\" command", CMD_NAME);
                return ERROR_OK;
        }
 
index 50842319a7533cb2b40a71d2ccc773ad4442f296..86469c4efa203cda857252bdb7f652c5bba7d81c 100644 (file)
@@ -1902,7 +1902,7 @@ COMMAND_HANDLER(handle_cortex_m3_mask_interrupts_command)
 
        if (target->state != TARGET_HALTED)
        {
-               command_print(cmd_ctx, "target must be stopped for \"%s\" command", cmd);
+               command_print(cmd_ctx, "target must be stopped for \"%s\" command", CMD_NAME);
                return ERROR_OK;
        }
 
index 21c0526f500ef306125b04246a4a7e3892f1f865..8cc46ecd665fdf31d9c22efb189a77ba208ff28d 100644 (file)
@@ -2046,7 +2046,7 @@ COMMAND_HANDLER(handle_wait_halt_command)
                int retval = parse_uint(args[0], &ms);
                if (ERROR_OK != retval)
                {
-                       command_print(cmd_ctx, "usage: %s [seconds]", cmd);
+                       command_print(cmd_ctx, "usage: %s [seconds]", CMD_NAME);
                        return ERROR_COMMAND_SYNTAX_ERROR;
                }
                // convert seconds (given) to milliseconds (needed)
@@ -2256,7 +2256,7 @@ COMMAND_HANDLER(handle_md_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        unsigned size = 0;
-       switch (cmd[2]) {
+       switch (CMD_NAME[2]) {
        case 'w': size = 4; break;
        case 'h': size = 2; break;
        case 'b': size = 1; break;
@@ -2333,7 +2333,7 @@ COMMAND_HANDLER(handle_mw_command)
        target_t *target = get_current_target(cmd_ctx);
        unsigned wordsize;
        uint8_t value_buf[4];
-       switch (cmd[2])
+       switch (CMD_NAME[2])
        {
                case 'w':
                        wordsize = 4;
index 6f2d6ee3dfe7ec562b92e2b06a7e07fc4187cb49..e18d5916a3135b2ae8dc33ad3419904a8d580c47 100644 (file)
@@ -3127,7 +3127,7 @@ COMMAND_HANDLER(xscale_handle_mmu_command)
 
        if (target->state != TARGET_HALTED)
        {
-               command_print(cmd_ctx, "target must be stopped for \"%s\" command", cmd);
+               command_print(cmd_ctx, "target must be stopped for \"%s\" command", CMD_NAME);
                return ERROR_OK;
        }
 
@@ -3163,13 +3163,13 @@ COMMAND_HANDLER(xscale_handle_idcache_command)
 
        if (target->state != TARGET_HALTED)
        {
-               command_print(cmd_ctx, "target must be stopped for \"%s\" command", cmd);
+               command_print(cmd_ctx, "target must be stopped for \"%s\" command", CMD_NAME);
                return ERROR_OK;
        }
 
-       if (strcmp(cmd, "icache") == 0)
+       if (strcmp(CMD_NAME, "icache") == 0)
                icache = 1;
-       else if (strcmp(cmd, "dcache") == 0)
+       else if (strcmp(CMD_NAME, "dcache") == 0)
                dcache = 1;
 
        if (argc >= 1)
@@ -3302,7 +3302,7 @@ COMMAND_HANDLER(xscale_handle_trace_buffer_command)
 
        if (target->state != TARGET_HALTED)
        {
-               command_print(cmd_ctx, "target must be stopped for \"%s\" command", cmd);
+               command_print(cmd_ctx, "target must be stopped for \"%s\" command", CMD_NAME);
                return ERROR_OK;
        }
 
@@ -3429,7 +3429,7 @@ COMMAND_HANDLER(xscale_handle_dump_trace_command)
 
        if (target->state != TARGET_HALTED)
        {
-               command_print(cmd_ctx, "target must be stopped for \"%s\" command", cmd);
+               command_print(cmd_ctx, "target must be stopped for \"%s\" command", CMD_NAME);
                return ERROR_OK;
        }
 
@@ -3499,7 +3499,7 @@ COMMAND_HANDLER(xscale_handle_cp15)
 
        if (target->state != TARGET_HALTED)
        {
-               command_print(cmd_ctx, "target must be stopped for \"%s\" command", cmd);
+               command_print(cmd_ctx, "target must be stopped for \"%s\" command", CMD_NAME);
                return ERROR_OK;
        }
        uint32_t reg_no = 0;