Simulator: fix switch handling error.

getopt_long() requires a null entry at the end of the longopts
array. It also reports an error already when some switch is
wrong, so just exit silently when we get an unexpected value.
This commit is contained in:
Phil Hord 2015-07-14 15:16:03 -04:00 committed by Markus Hitter
parent ad2a76b2df
commit 8a11a76063
1 changed files with 3 additions and 2 deletions

View File

@ -50,7 +50,8 @@ struct option opts[] = {
{ "gcode", no_argument, NULL, 'g' }, { "gcode", no_argument, NULL, 'g' },
{ "pos", no_argument, NULL, 'p' }, { "pos", no_argument, NULL, 'p' },
{ "time-scale", required_argument, NULL, 't' }, { "time-scale", required_argument, NULL, 't' },
{ "tracefile", optional_argument, NULL, 'o' } { "tracefile", optional_argument, NULL, 'o' },
{ 0, 0, 0, 0 }
}; };
static void usage(const char *name) { static void usage(const char *name) {
@ -94,7 +95,7 @@ void sim_start(int argc, char** argv) {
recorder_init(optarg ? optarg : "datalog.out"); recorder_init(optarg ? optarg : "datalog.out");
break; break;
default: default:
sim_error("Unexpected result in getopt_long handler"); exit(1);
} }
// Record the command line arguments to the datalog, if active // Record the command line arguments to the datalog, if active