Merge branch 'getopt_fixes' into sdlog2_opt

This commit is contained in:
Anton Babushkin 2014-03-08 22:03:25 +04:00
commit 544de3c9f0
1 changed files with 13 additions and 2 deletions

View File

@ -670,6 +670,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': {
@ -716,13 +720,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 */