mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-09 07:10:35 +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:
@@ -44,6 +44,7 @@
|
||||
|
||||
#include <px4_config.h>
|
||||
#include <px4_defines.h>
|
||||
#include <px4_getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/prctl.h>
|
||||
@@ -895,10 +896,12 @@ int sdlog2_thread_main(int argc, char *argv[])
|
||||
* set error flag instead */
|
||||
bool err_flag = false;
|
||||
|
||||
while ((ch = getopt(argc, argv, "r:b:eatx")) != EOF) {
|
||||
int myoptind = 1;
|
||||
const char *myoptarg = NULL;
|
||||
while ((ch = px4_getopt(argc, argv, "r:b:eatx", &myoptind, &myoptarg)) != EOF) {
|
||||
switch (ch) {
|
||||
case 'r': {
|
||||
unsigned long r = strtoul(optarg, NULL, 10);
|
||||
unsigned long r = strtoul(myoptarg, NULL, 10);
|
||||
|
||||
if (r == 0) {
|
||||
r = 1;
|
||||
@@ -909,7 +912,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'b': {
|
||||
unsigned long s = strtoul(optarg, NULL, 10);
|
||||
unsigned long s = strtoul(myoptarg, NULL, 10);
|
||||
|
||||
if (s < 1) {
|
||||
s = 1;
|
||||
|
||||
Reference in New Issue
Block a user