diff options
author | Mathias K <kesmtp@freenet.de> | 2011-12-16 07:48:39 +0100 |
---|---|---|
committer | Øyvind Harboe <oyvindharboe@gmail.com> | 2012-01-04 17:56:46 +0000 |
commit | 16b6b5e7a86353dbc0c4823fe3d772c0faca7c1c (patch) | |
tree | 4950e26d07d60b16b3223e085227c583418c2ef8 /src/target | |
parent | 42cb62cf3b47b982d6444948b483f9c6ce32de05 (diff) |
Change return value on error.
On wrong parameters a error is signalized to the calling function.
Change-Id: I484443fdb39938e20382edc9246d5ec546a5c960
Signed-off-by: Mathias K <kesmtp@freenet.de>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Reviewed-on: http://openocd.zylin.com/282
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/arm920t.c | 9 | ||||
-rw-r--r-- | src/target/armv4_5.c | 4 | ||||
-rw-r--r-- | src/target/etm.c | 19 | ||||
-rw-r--r-- | src/target/mips32.c | 2 | ||||
-rw-r--r-- | src/target/mips_m4k.c | 2 | ||||
-rw-r--r-- | src/target/oocd_trace.c | 5 | ||||
-rw-r--r-- | src/target/target.c | 8 | ||||
-rw-r--r-- | src/target/target_request.c | 2 | ||||
-rw-r--r-- | src/target/xscale.c | 17 |
9 files changed, 22 insertions, 46 deletions
diff --git a/src/target/arm920t.c b/src/target/arm920t.c index f057d7b9..1357820a 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -904,8 +904,7 @@ COMMAND_HANDLER(arm920t_handle_read_cache_command) if (CMD_ARGC != 1) { - command_print(CMD_CTX, "usage: arm920t read_cache <filename>"); - return ERROR_OK; + return ERROR_COMMAND_SYNTAX_ERROR; } if ((output = fopen(CMD_ARGV[0], "w")) == NULL) @@ -1199,8 +1198,7 @@ COMMAND_HANDLER(arm920t_handle_read_mmu_command) if (CMD_ARGC != 1) { - command_print(CMD_CTX, "usage: arm920t read_mmu <filename>"); - return ERROR_OK; + return ERROR_COMMAND_SYNTAX_ERROR; } if ((output = fopen(CMD_ARGV[0], "w")) == NULL) @@ -1650,8 +1648,7 @@ COMMAND_HANDLER(arm920t_handle_cp15i_command) } else { - command_print(CMD_CTX, - "usage: arm920t cp15i <opcode> [value] [address]"); + return ERROR_COMMAND_SYNTAX_ERROR; } return ERROR_OK; diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index d59ab5c7..706733d2 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -784,10 +784,8 @@ COMMAND_HANDLER(handle_arm_disassemble_command) break; default: usage: - command_print(CMD_CTX, - "usage: arm disassemble <address> [<count> ['thumb']]"); count = 0; - retval = ERROR_FAIL; + retval = ERROR_COMMAND_SYNTAX_ERROR; } while (count-- > 0) { diff --git a/src/target/etm.c b/src/target/etm.c index cd50e44d..27983698 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -1268,13 +1268,7 @@ COMMAND_HANDLER(handle_etm_tracemode_command) &tracemode); break; default: - command_print(CMD_CTX, "usage: tracemode " - "('none'|'data'|'address'|'all') " - "context_id_bits " - "('enable'|'disable') " - "('enable'|'disable')" - ); - return ERROR_FAIL; + return ERROR_COMMAND_SYNTAX_ERROR; } /** @@ -1738,8 +1732,7 @@ COMMAND_HANDLER(handle_etm_image_command) if (CMD_ARGC < 1) { - command_print(CMD_CTX, "usage: etm image <file> [base address] [type]"); - return ERROR_FAIL; + return ERROR_COMMAND_SYNTAX_ERROR; } target = get_current_target(CMD_CTX); @@ -1799,8 +1792,7 @@ COMMAND_HANDLER(handle_etm_dump_command) if (CMD_ARGC != 1) { - command_print(CMD_CTX, "usage: etm dump <file>"); - return ERROR_FAIL; + return ERROR_COMMAND_SYNTAX_ERROR; } target = get_current_target(CMD_CTX); @@ -1866,8 +1858,7 @@ COMMAND_HANDLER(handle_etm_load_command) if (CMD_ARGC != 1) { - command_print(CMD_CTX, "usage: etm load <file>"); - return ERROR_FAIL; + return ERROR_COMMAND_SYNTAX_ERROR; } target = get_current_target(CMD_CTX); @@ -2206,7 +2197,7 @@ static const struct command_registration etm_exec_command_handlers[] = { .handler = handle_etm_image_command, .mode = COMMAND_EXEC, .help = "load image from file with optional offset", - .usage = "filename [offset]", + .usage = "<file> [base address] [type]", }, { .name = "dump", diff --git a/src/target/mips32.c b/src/target/mips32.c index 80dfb194..d9d84b72 100644 --- a/src/target/mips32.c +++ b/src/target/mips32.c @@ -797,7 +797,7 @@ COMMAND_HANDLER(mips32_handle_cp0_command) /* two or more argument, access a single register/select (write if third argument is given) */ if (CMD_ARGC < 2) { - command_print(CMD_CTX, "command requires more arguments."); + return ERROR_COMMAND_SYNTAX_ERROR; } else { diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c index 2a64372f..4546093f 100644 --- a/src/target/mips_m4k.c +++ b/src/target/mips_m4k.c @@ -1140,7 +1140,7 @@ COMMAND_HANDLER(mips_m4k_handle_cp0_command) /* two or more argument, access a single register/select (write if third argument is given) */ if (CMD_ARGC < 2) { - command_print(CMD_CTX, "command requires more arguments."); + return ERROR_COMMAND_SYNTAX_ERROR; } else { diff --git a/src/target/oocd_trace.c b/src/target/oocd_trace.c index 5af1ba65..d2ed4fef 100644 --- a/src/target/oocd_trace.c +++ b/src/target/oocd_trace.c @@ -284,8 +284,7 @@ COMMAND_HANDLER(handle_oocd_trace_config_command) if (CMD_ARGC != 2) { - LOG_ERROR("incomplete 'oocd_trace config <target> <tty>' command"); - return ERROR_FAIL; + return ERROR_COMMAND_SYNTAX_ERROR; } target = get_current_target(CMD_CTX); @@ -400,7 +399,7 @@ static const struct command_registration oocd_trace_all_command_handlers[] = { .name = "config", .handler = handle_oocd_trace_config_command, .mode = COMMAND_CONFIG, - .usage = "target", + .usage = "<target> <tty>", }, { .name = "status", diff --git a/src/target/target.c b/src/target/target.c index eca69cf6..692b78f8 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2246,9 +2246,7 @@ COMMAND_HANDLER(handle_reg_command) return ERROR_OK; } - command_print(CMD_CTX, "usage: reg <#|name> [value]"); - - return ERROR_OK; + return ERROR_COMMAND_SYNTAX_ERROR; } COMMAND_HANDLER(handle_poll_command) @@ -2295,7 +2293,6 @@ COMMAND_HANDLER(handle_wait_halt_command) int retval = parse_uint(CMD_ARGV[0], &ms); if (ERROR_OK != retval) { - command_print(CMD_CTX, "usage: %s [seconds]", CMD_NAME); return ERROR_COMMAND_SYNTAX_ERROR; } // convert seconds (given) to milliseconds (needed) @@ -3155,7 +3152,6 @@ COMMAND_HANDLER(handle_bp_command) return handle_bp_command_set(CMD_CTX, addr, asid, length, hw); default: - command_print(CMD_CTX, "usage: bp <address> [<asid>]<length> ['hw'|'hw_ctx']"); return ERROR_COMMAND_SYNTAX_ERROR; } } @@ -3235,8 +3231,6 @@ COMMAND_HANDLER(handle_wp_command) break; default: - command_print(CMD_CTX, "usage: wp [address length " - "[(r|w|a) [value [mask]]]]"); return ERROR_COMMAND_SYNTAX_ERROR; } diff --git a/src/target/target_request.c b/src/target/target_request.c index 387db2d6..c669ab4a 100644 --- a/src/target/target_request.c +++ b/src/target/target_request.c @@ -302,7 +302,7 @@ COMMAND_HANDLER(handle_target_request_debugmsgs_command) } else { - command_print(CMD_CTX, "usage: target_request debugmsgs ['enable'|'disable'|'charmsg']"); + return ERROR_COMMAND_SYNTAX_ERROR; } } diff --git a/src/target/xscale.c b/src/target/xscale.c index 46ed8a94..484cdcea 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -3212,8 +3212,7 @@ COMMAND_HANDLER(xscale_handle_debug_handler_command) if (CMD_ARGC < 2) { - LOG_ERROR("'xscale debug_handler <target#> <address>' command takes two required operands"); - return ERROR_OK; + return ERROR_COMMAND_SYNTAX_ERROR; } if ((target = get_target(CMD_ARGV[0])) == NULL) @@ -3416,7 +3415,7 @@ COMMAND_HANDLER(xscale_handle_vector_catch_command) if (CMD_ARGC < 1) { - command_print(CMD_CTX, "usage: xscale vector_catch [mask]"); + return ERROR_COMMAND_SYNTAX_ERROR; } else { @@ -3483,7 +3482,7 @@ COMMAND_HANDLER(xscale_handle_vector_table_command) } if (err) - command_print(CMD_CTX, "usage: xscale vector_table <high|low> <index> <code>"); + return ERROR_COMMAND_SYNTAX_ERROR; return ERROR_OK; } @@ -3569,8 +3568,7 @@ COMMAND_HANDLER(xscale_handle_trace_image_command) if (CMD_ARGC < 1) { - command_print(CMD_CTX, "usage: xscale trace_image <file> [base address] [type]"); - return ERROR_OK; + return ERROR_COMMAND_SYNTAX_ERROR; } retval = xscale_verify_pointer(CMD_CTX, xscale); @@ -3629,8 +3627,7 @@ COMMAND_HANDLER(xscale_handle_dump_trace_command) if (CMD_ARGC < 1) { - command_print(CMD_CTX, "usage: xscale dump_trace <file>"); - return ERROR_OK; + return ERROR_COMMAND_SYNTAX_ERROR; } trace_data = xscale->trace.data; @@ -3763,7 +3760,7 @@ COMMAND_HANDLER(xscale_handle_cp15) } else { - command_print(CMD_CTX, "usage: cp15 [register]<, [value]>"); + return ERROR_COMMAND_SYNTAX_ERROR; } return ERROR_OK; @@ -3859,7 +3856,7 @@ static const struct command_registration xscale_any_command_handlers[] = { .handler = xscale_handle_debug_handler_command, .mode = COMMAND_ANY, .help = "Change address used for debug handler.", - .usage = "target address", + .usage = "<target> <address>", }, { .name = "cache_clean_address", |