From 8a11a760635b7f770d387fae1b179ddbf56fb171 Mon Sep 17 00:00:00 2001 From: Phil Hord Date: Tue, 14 Jul 2015 15:16:03 -0400 Subject: [PATCH] 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. --- simulator/simulator.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/simulator/simulator.c b/simulator/simulator.c index 003d76a..0b9301c 100644 --- a/simulator/simulator.c +++ b/simulator/simulator.c @@ -50,7 +50,8 @@ struct option opts[] = { { "gcode", no_argument, NULL, 'g' }, { "pos", no_argument, NULL, 'p' }, { "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) { @@ -94,7 +95,7 @@ void sim_start(int argc, char** argv) { recorder_init(optarg ? optarg : "datalog.out"); break; default: - sim_error("Unexpected result in getopt_long handler"); + exit(1); } // Record the command line arguments to the datalog, if active