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:
Mark Charlebois
2015-06-19 11:39:08 -07:00
parent 878284701d
commit f7fe6a037d
5 changed files with 86 additions and 62 deletions
+7 -9
View File
@@ -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);
}