mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 02:33:33 +08:00
Converted getopt use to px4_getopt
In the posix and qurt builds, getopt is not thread safe so px4_getopt should be used instead. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
@@ -38,12 +38,10 @@
|
||||
*/
|
||||
|
||||
#include <px4_config.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include <px4_getopt.h>
|
||||
#include <px4_tasks.h>
|
||||
#include <px4_log.h>
|
||||
#include <systemlib/systemlib.h>
|
||||
#include <systemlib/err.h>
|
||||
|
||||
__EXPORT int reboot_main(int argc, char *argv[]);
|
||||
|
||||
@@ -52,14 +50,16 @@ int reboot_main(int argc, char *argv[])
|
||||
int ch;
|
||||
bool to_bootloader = false;
|
||||
|
||||
while ((ch = getopt(argc, argv, "b")) != -1) {
|
||||
int myoptind = 1;
|
||||
const char *myoptarg = NULL;
|
||||
while ((ch = px4_getopt(argc, argv, "b", &myoptind, &myoptarg)) != -1) {
|
||||
switch (ch) {
|
||||
case 'b':
|
||||
to_bootloader = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
errx(1, "usage: reboot [-b]\n"
|
||||
PX4_ERR("usage: reboot [-b]\n"
|
||||
" -b reboot into the bootloader");
|
||||
|
||||
}
|
||||
@@ -67,5 +67,3 @@ int reboot_main(int argc, char *argv[])
|
||||
|
||||
px4_systemreset(to_bootloader);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user