forked from Archive/PX4-Autopilot
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:
parent
2b85c594b3
commit
574a67b93d
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue