i2c_spi_buses:Track NuttX change to getopts avoid name collision

NuttX #defined optarg and getopt to move to TLS. This fixes the
  name collision.
This commit is contained in:
David Sidrane
2021-06-16 17:07:47 +02:00
committed by Julian Oes
parent 64db89ab20
commit 84dd8839a2
55 changed files with 245 additions and 214 deletions
@@ -1,4 +1,35 @@
/****************************************************************************
*
* Copyright (C) 2021 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#include <px4_platform_common/getopt.h>
#include <px4_platform_common/module.h>
@@ -68,15 +99,15 @@ ina226_main(int argc, char *argv[])
cli.support_keep_running = true;
cli.custom2 = 1;
while ((ch = cli.getopt(argc, argv, "t:")) != EOF) {
while ((ch = cli.getOpt(argc, argv, "t:")) != EOF) {
switch (ch) {
case 't': // battery index
cli.custom2 = (int)strtol(cli.optarg(), NULL, 0);
cli.custom2 = (int)strtol(cli.optArg(), NULL, 0);
break;
}
}
const char *verb = cli.optarg();
const char *verb = cli.optArg();
if (!verb) {
ThisDriver::print_usage();
return -1;
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2019 PX4 Development Team. All rights reserved.
* Copyright (c) 2019, 2021 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -83,16 +83,16 @@ voxlpm_main(int argc, char *argv[])
cli.type = VOXLPM_CH_TYPE_VBATT;
cli.support_keep_running = true;
while ((ch = cli.getopt(argc, argv, "T:")) != EOF) {
while ((ch = cli.getOpt(argc, argv, "T:")) != EOF) {
switch (ch) {
case 'T':
if (strcmp(cli.optarg(), "VBATT") == 0) {
if (strcmp(cli.optArg(), "VBATT") == 0) {
cli.type = VOXLPM_CH_TYPE_VBATT;
} else if (strcmp(cli.optarg(), "P5VDC") == 0) {
} else if (strcmp(cli.optArg(), "P5VDC") == 0) {
cli.type = VOXLPM_CH_TYPE_P5VDC;
} else if (strcmp(cli.optarg(), "P12VDC") == 0) {
} else if (strcmp(cli.optArg(), "P12VDC") == 0) {
cli.type = VOXLPM_CH_TYPE_P12VDC; // same as P5VDC
} else {
@@ -104,7 +104,7 @@ voxlpm_main(int argc, char *argv[])
}
}
const char *verb = cli.optarg();
const char *verb = cli.optArg();
if (!verb) {
ThisDriver::print_usage();