aboutsummaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
authorGirts <girtsf@users.noreply.github.com>2016-11-05 14:38:55 -0700
committerFreddie Chopin <freddie.chopin@gmail.com>2017-04-23 21:38:41 +0100
commitb90d58db07459a353d20b052bd1e4732fec03aa5 (patch)
treec57fb0ac47c94217a06f73e66b1f8c47eb207de5 /src/helper
parentf63af76466234cc905df6ea8e0f3fb5284c2058d (diff)
downloadriscv-openocd-b90d58db07459a353d20b052bd1e4732fec03aa5.zip
riscv-openocd-b90d58db07459a353d20b052bd1e4732fec03aa5.tar.gz
riscv-openocd-b90d58db07459a353d20b052bd1e4732fec03aa5.tar.bz2
helper/options.c: fail if unexpected cmdline arguments are present
Previously openocd would silently ignore any incorrect arguments. Change-Id: Ibb40b57b8a9e07d191215486f3b3c4920a9963c7 Signed-off-by: Girts Folkmanis <opensource@girts.me> Reviewed-on: http://openocd.zylin.com/3879 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/options.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/helper/options.c b/src/helper/options.c
index 0016659..1cfa553 100644
--- a/src/helper/options.c
+++ b/src/helper/options.c
@@ -291,9 +291,18 @@ int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[])
LOG_WARNING("deprecated option: -p/--pipe. Use '-c \"gdb_port pipe; "
"log_output openocd.log\"' instead.");
break;
+ default: /* '?' */
+ /* getopt will emit an error message, all we have to do is bail. */
+ return ERROR_FAIL;
}
}
+ if (optind < argc) {
+ /* Catch extra arguments on the command line. */
+ LOG_OUTPUT("Unexpected command line argument: %s\n", argv[optind]);
+ return ERROR_FAIL;
+ }
+
if (help_flag) {
LOG_OUTPUT("Open On-Chip Debugger\nLicensed under GNU GPL v2\n");
LOG_OUTPUT("--help | -h\tdisplay this help\n");