diff options
author | Zachary T Welch <zw@superlucidity.net> | 2009-11-18 05:22:44 -0800 |
---|---|---|
committer | Zachary T Welch <zw@superlucidity.net> | 2009-11-18 15:51:07 -0800 |
commit | 75a37eb5b37386768327e9670acfedc7811d529f (patch) | |
tree | ebf90d39924237c0bffdce0ef2d17c124d5f2473 | |
parent | bd5a1799ea63c2a863eae4aca2b55e41373d7528 (diff) | |
download | openocd+libswd-75a37eb5b37386768327e9670acfedc7811d529f.tar.gz openocd+libswd-75a37eb5b37386768327e9670acfedc7811d529f.tar.bz2 openocd+libswd-75a37eb5b37386768327e9670acfedc7811d529f.tar.xz openocd+libswd-75a37eb5b37386768327e9670acfedc7811d529f.zip |
use COMMAND_PARSE_ON_OFF where appropriate
Updates all command parsing of "on" and "off" arguments.
-rw-r--r-- | src/flash/flash.c | 9 | ||||
-rw-r--r-- | src/jtag/parport.c | 7 | ||||
-rw-r--r-- | src/jtag/zy1000/zy1000.c | 15 | ||||
-rw-r--r-- | src/target/cortex_m3.c | 17 | ||||
-rw-r--r-- | src/target/target.c | 19 |
5 files changed, 17 insertions, 50 deletions
diff --git a/src/flash/flash.c b/src/flash/flash.c index 2c63b827..98e5ee0e 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -577,7 +577,6 @@ COMMAND_HANDLER(handle_flash_protect_command) uint32_t bank_nr; uint32_t first; uint32_t last; - int set; COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], bank_nr); struct flash_bank *p = get_flash_bank_by_num(bank_nr); @@ -590,12 +589,8 @@ COMMAND_HANDLER(handle_flash_protect_command) else COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], last); - if (strcmp(CMD_ARGV[3], "on") == 0) - set = 1; - else if (strcmp(CMD_ARGV[3], "off") == 0) - set = 0; - else - return ERROR_COMMAND_SYNTAX_ERROR; + bool set; + COMMAND_PARSE_ON_OFF(CMD_ARGV[3], set); int retval; if ((retval = flash_check_sector_parameters(CMD_CTX, diff --git a/src/jtag/parport.c b/src/jtag/parport.c index 97f6458d..b80626f5 100644 --- a/src/jtag/parport.c +++ b/src/jtag/parport.c @@ -103,7 +103,7 @@ static struct cable cables[] = /* configuration */ static char* parport_cable = NULL; static uint16_t parport_port; -static int parport_exit = 0; +static bool parport_exit = 0; static uint32_t parport_toggling_time_ns = 1000; static int wait_states; @@ -453,10 +453,7 @@ COMMAND_HANDLER(parport_handle_write_on_exit_command) return ERROR_OK; } - if (strcmp(CMD_ARGV[0], "on") == 0) - parport_exit = 1; - else if (strcmp(CMD_ARGV[0], "off") == 0) - parport_exit = 0; + COMMAND_PARSE_ON_OFF(CMD_ARGV[0], parport_exit); return ERROR_OK; } diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index a509aee5..206b362c 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -236,18 +236,9 @@ int handle_power_command(struct command_context *cmd_ctx, char *cmd, char **args if (argc == 1) { - if (strcmp(args[0], "on") == 0) - { - setPower(1); - } - else if (strcmp(args[0], "off") == 0) - { - setPower(0); - } else - { - command_print(cmd_ctx, "arg is \"on\" or \"off\""); - return ERROR_INVALID_ARGUMENTS; - } + bool enable; + COMMAND_PARSE_ON_OFF(args[0], enable); + setPower(enable); } command_print(cmd_ctx, "Target power %s", savePower ? "on" : "off"); diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c index 42f8ee08..e7b51107 100644 --- a/src/target/cortex_m3.c +++ b/src/target/cortex_m3.c @@ -1898,18 +1898,11 @@ COMMAND_HANDLER(handle_cortex_m3_mask_interrupts_command) if (CMD_ARGC > 0) { - if (!strcmp(CMD_ARGV[0], "on")) - { - cortex_m3_write_debug_halt_mask(target, C_HALT | C_MASKINTS, 0); - } - else if (!strcmp(CMD_ARGV[0], "off")) - { - cortex_m3_write_debug_halt_mask(target, C_HALT, C_MASKINTS); - } - else - { - command_print(CMD_CTX, "usage: cortex_m3 maskisr ['on'|'off']"); - } + bool enable; + COMMAND_PARSE_ON_OFF(CMD_ARGV[0], enable); + uint32_t mask_on = C_HALT | (enable ? C_MASKINTS : 0); + uint32_t mask_off = enable ? 0 : C_MASKINTS; + cortex_m3_write_debug_halt_mask(target, mask_on, mask_off); } command_print(CMD_CTX, "cortex_m3 interrupt mask %s", diff --git a/src/target/target.c b/src/target/target.c index 98e7a403..f203913c 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2003,23 +2003,14 @@ COMMAND_HANDLER(handle_poll_command) return retval; if ((retval = target_arch_state(target)) != ERROR_OK) return retval; - } else if (CMD_ARGC == 1) { - if (strcmp(CMD_ARGV[0], "on") == 0) - { - jtag_poll_set_enabled(true); - } - else if (strcmp(CMD_ARGV[0], "off") == 0) - { - jtag_poll_set_enabled(false); - } - else - { - command_print(CMD_CTX, "arg is \"on\" or \"off\""); - } - } else + bool enable; + COMMAND_PARSE_ON_OFF(CMD_ARGV[0], enable); + jtag_poll_set_enabled(enable); + } + else { return ERROR_COMMAND_SYNTAX_ERROR; } |