fix px4_getopt: ensure progress in case of unknown options

Previously sdlog2 got stuck in an endless loop if an unknown argument was
given
This commit is contained in:
Beat Küng 2016-06-15 09:55:25 +02:00
parent 2b85c594b3
commit 574a67b93d
1 changed files with 4 additions and 1 deletions

View File

@ -143,10 +143,12 @@ __EXPORT int px4_getopt(int argc, char *argv[], const char *options, int *myopti
char c;
int takesarg;
if (*myoptind == 1)
if (*myoptind == 1) {
if (reorder(argc, argv, options) != 0) {
*myoptind += 1;
return (int)'?';
}
}
p = argv[*myoptind];
@ -158,6 +160,7 @@ __EXPORT int px4_getopt(int argc, char *argv[], const char *options, int *myopti
c = isvalidopt(p[1], options, &takesarg);
if (c == '?') {
*myoptind += 1;
return (int)c;
}