mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 10:03:33 +08:00
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:
@@ -143,10 +143,12 @@ __EXPORT int px4_getopt(int argc, char *argv[], const char *options, int *myopti
|
|||||||
char c;
|
char c;
|
||||||
int takesarg;
|
int takesarg;
|
||||||
|
|
||||||
if (*myoptind == 1)
|
if (*myoptind == 1) {
|
||||||
if (reorder(argc, argv, options) != 0) {
|
if (reorder(argc, argv, options) != 0) {
|
||||||
|
*myoptind += 1;
|
||||||
return (int)'?';
|
return (int)'?';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p = argv[*myoptind];
|
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);
|
c = isvalidopt(p[1], options, &takesarg);
|
||||||
|
|
||||||
if (c == '?') {
|
if (c == '?') {
|
||||||
|
*myoptind += 1;
|
||||||
return (int)c;
|
return (int)c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user