diff options
author | Anton Babushkin <anton.babushkin@me.com> | 2014-02-28 00:49:12 +0400 |
---|---|---|
committer | Anton Babushkin <anton.babushkin@me.com> | 2014-02-28 00:49:12 +0400 |
commit | 8783bed114e8ece85d62f15d0d2a06c28aa0bcfe (patch) | |
tree | f9e7e9c99670170ead2133b477f24dec6e9914fa /src/modules/sdlog2/sdlog2.c | |
parent | 680f2dd4172bd31eb415f1fa85c4c1bb2b2b509f (diff) | |
download | px4-firmware-8783bed114e8ece85d62f15d0d2a06c28aa0bcfe.tar.gz px4-firmware-8783bed114e8ece85d62f15d0d2a06c28aa0bcfe.tar.bz2 px4-firmware-8783bed114e8ece85d62f15d0d2a06c28aa0bcfe.zip |
sdlog2: getopt invalid usage fixed
Diffstat (limited to 'src/modules/sdlog2/sdlog2.c')
-rw-r--r-- | src/modules/sdlog2/sdlog2.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c index 68e6a7469..f952c3f32 100644 --- a/src/modules/sdlog2/sdlog2.c +++ b/src/modules/sdlog2/sdlog2.c @@ -652,6 +652,10 @@ int sdlog2_thread_main(int argc, char *argv[]) argv += 2; int ch; + /* don't exit from getopt loop to leave getopt global variables in consistent state, + * set error flag instead */ + bool err_flag = false; + while ((ch = getopt(argc, argv, "r:b:eat")) != EOF) { switch (ch) { case 'r': { @@ -699,13 +703,20 @@ int sdlog2_thread_main(int argc, char *argv[]) } else { warnx("unknown option character `\\x%x'", optopt); } + err_flag = true; + break; default: - sdlog2_usage("unrecognized flag"); - errx(1, "exiting"); + warnx("unrecognized flag"); + err_flag = true; + break; } } + if (err_flag) { + sdlog2_usage(NULL); + } + gps_time = 0; /* create log root dir */ |