clang-tidy modernize-use-nullptr

This commit is contained in:
Daniel Agar
2017-02-01 22:15:50 -05:00
parent ec2467d4a5
commit e927f3e040
48 changed files with 155 additions and 153 deletions
+4 -4
View File
@@ -157,7 +157,7 @@ static constexpr uint8_t COMMANDER_MAX_GPS_NOISE = 60; /**< Maximum percentage
#define HIL_ID_MAX 1999
/* Mavlink log uORB handle */
static orb_advert_t mavlink_log_pub = 0;
static orb_advert_t mavlink_log_pub = nullptr;
/* System autostart ID */
static int autostart_id;
@@ -1714,7 +1714,7 @@ int commander_thread_main(int argc, char *argv[])
(void)pthread_attr_setschedparam(&commander_low_prio_attr, &param);
#endif
pthread_create(&commander_low_prio_thread, &commander_low_prio_attr, commander_low_prio_loop, NULL);
pthread_create(&commander_low_prio_thread, &commander_low_prio_attr, commander_low_prio_loop, nullptr);
pthread_attr_destroy(&commander_low_prio_attr);
while (!thread_should_exit) {
@@ -3075,7 +3075,7 @@ int commander_thread_main(int argc, char *argv[])
}
/* wait for threads to complete */
ret = pthread_join(commander_low_prio_thread, NULL);
ret = pthread_join(commander_low_prio_thread, nullptr);
if (ret) {
warn("join failed: %d", ret);
@@ -4169,5 +4169,5 @@ void *commander_low_prio_loop(void *arg)
px4_close(cmd_sub);
return NULL;
return nullptr;
}
+4 -4
View File
@@ -548,9 +548,9 @@ calibrate_return mag_calibrate_all(orb_advert_t *mavlink_log_pub)
worker_data.sub_mag[cur_mag] = -1;
// Initialize to no memory allocated
worker_data.x[cur_mag] = NULL;
worker_data.y[cur_mag] = NULL;
worker_data.z[cur_mag] = NULL;
worker_data.x[cur_mag] = nullptr;
worker_data.y[cur_mag] = nullptr;
worker_data.z[cur_mag] = nullptr;
worker_data.calibration_counter_total[cur_mag] = 0;
}
@@ -563,7 +563,7 @@ calibrate_return mag_calibrate_all(orb_advert_t *mavlink_log_pub)
worker_data.y[cur_mag] = reinterpret_cast<float *>(malloc(sizeof(float) * calibration_points_maxcount));
worker_data.z[cur_mag] = reinterpret_cast<float *>(malloc(sizeof(float) * calibration_points_maxcount));
if (worker_data.x[cur_mag] == NULL || worker_data.y[cur_mag] == NULL || worker_data.z[cur_mag] == NULL) {
if (worker_data.x[cur_mag] == nullptr || worker_data.y[cur_mag] == nullptr || worker_data.z[cur_mag] == nullptr) {
calibration_log_critical(mavlink_log_pub, "[cal] ERROR: out of memory");
result = calibrate_return_error;
}
@@ -564,7 +564,7 @@ transition_result_t hil_state_transition(hil_state_t new_state, orb_advert_t sta
for (;;) {
devname = px4_get_device_names(&handle);
if (devname == NULL) {
if (devname == nullptr) {
break;
}
@@ -94,7 +94,7 @@ int basicBlocksTest()
int blockLimitTest()
{
printf("Test BlockLimit\t\t\t: ");
BlockLimit limit(NULL, "TEST");
BlockLimit limit(nullptr, "TEST");
// initial state
ASSERT_CL(equal(1.0f, limit.getMax()));
ASSERT_CL(equal(-1.0f, limit.getMin()));
@@ -110,7 +110,7 @@ int blockLimitTest()
int blockLimitSymTest()
{
printf("Test BlockLimitSym\t\t: ");
BlockLimitSym limit(NULL, "TEST");
BlockLimitSym limit(nullptr, "TEST");
// initial state
ASSERT_CL(equal(1.0f, limit.getMax()));
ASSERT_CL(equal(0.0f, limit.getDt()));
@@ -125,7 +125,7 @@ int blockLimitSymTest()
int blockLowPassTest()
{
printf("Test BlockLowPass\t\t: ");
BlockLowPass lowPass(NULL, "TEST_LP");
BlockLowPass lowPass(nullptr, "TEST_LP");
// test initial state
ASSERT_CL(equal(10.0f, lowPass.getFCut()));
ASSERT_CL(equal(0.0f, lowPass.getState()));
@@ -153,7 +153,7 @@ int blockLowPassTest()
int blockHighPassTest()
{
printf("Test BlockHighPass\t\t: ");
BlockHighPass highPass(NULL, "TEST_HP");
BlockHighPass highPass(nullptr, "TEST_HP");
// test initial state
ASSERT_CL(equal(10.0f, highPass.getFCut()));
ASSERT_CL(equal(0.0f, highPass.getU()));
@@ -184,7 +184,7 @@ int blockHighPassTest()
int blockLowPass2Test()
{
printf("Test BlockLowPass2\t\t: ");
BlockLowPass2 lowPass(NULL, "TEST_LP", 100);
BlockLowPass2 lowPass(nullptr, "TEST_LP", 100);
// test initial state
ASSERT_CL(equal(10.0f, lowPass.getFCutParam()));
ASSERT_CL(equal(0.0f, lowPass.getState()));
@@ -212,7 +212,7 @@ int blockLowPass2Test()
int blockIntegralTest()
{
printf("Test BlockIntegral\t\t: ");
BlockIntegral integral(NULL, "TEST_I");
BlockIntegral integral(nullptr, "TEST_I");
// test initial state
ASSERT_CL(equal(1.0f, integral.getMax()));
ASSERT_CL(equal(0.0f, integral.getDt()));
@@ -249,7 +249,7 @@ int blockIntegralTest()
int blockIntegralTrapTest()
{
printf("Test BlockIntegralTrap\t\t: ");
BlockIntegralTrap integral(NULL, "TEST_I");
BlockIntegralTrap integral(nullptr, "TEST_I");
// test initial state
ASSERT_CL(equal(1.0f, integral.getMax()));
ASSERT_CL(equal(0.0f, integral.getDt()));
@@ -292,7 +292,7 @@ int blockIntegralTrapTest()
int blockDerivativeTest()
{
printf("Test BlockDerivative\t\t: ");
BlockDerivative derivative(NULL, "TEST_D");
BlockDerivative derivative(nullptr, "TEST_D");
// test initial state
ASSERT_CL(equal(0.0f, derivative.getU()));
ASSERT_CL(equal(10.0f, derivative.getLP()));
@@ -315,7 +315,7 @@ int blockDerivativeTest()
int blockPTest()
{
printf("Test BlockP\t\t\t: ");
BlockP blockP(NULL, "TEST_P");
BlockP blockP(nullptr, "TEST_P");
// test initial state
ASSERT_CL(equal(0.2f, blockP.getKP()));
ASSERT_CL(equal(0.0f, blockP.getDt()));
@@ -331,7 +331,7 @@ int blockPTest()
int blockPITest()
{
printf("Test BlockPI\t\t\t: ");
BlockPI blockPI(NULL, "TEST");
BlockPI blockPI(nullptr, "TEST");
// test initial state
ASSERT_CL(equal(0.2f, blockPI.getKP()));
ASSERT_CL(equal(0.1f, blockPI.getKI()));
@@ -353,7 +353,7 @@ int blockPITest()
int blockPDTest()
{
printf("Test BlockPD\t\t\t: ");
BlockPD blockPD(NULL, "TEST");
BlockPD blockPD(nullptr, "TEST");
// test initial state
ASSERT_CL(equal(0.2f, blockPD.getKP()));
ASSERT_CL(equal(0.01f, blockPD.getKD()));
@@ -378,7 +378,7 @@ int blockPDTest()
int blockPIDTest()
{
printf("Test BlockPID\t\t\t: ");
BlockPID blockPID(NULL, "TEST");
BlockPID blockPID(nullptr, "TEST");
// test initial state
ASSERT_CL(equal(0.2f, blockPID.getKP()));
ASSERT_CL(equal(0.1f, blockPID.getKI()));
@@ -408,7 +408,7 @@ int blockPIDTest()
int blockOutputTest()
{
printf("Test BlockOutput\t\t: ");
BlockOutput blockOutput(NULL, "TEST");
BlockOutput blockOutput(nullptr, "TEST");
// test initial state
ASSERT_CL(equal(0.0f, blockOutput.getDt()));
ASSERT_CL(equal(0.5f, blockOutput.get()));
@@ -431,7 +431,7 @@ int blockRandUniformTest()
{
srand(1234);
printf("Test BlockRandUniform\t\t: ");
BlockRandUniform blockRandUniform(NULL, "TEST");
BlockRandUniform blockRandUniform(nullptr, "TEST");
// test initial state
ASSERT_CL(equal(0.0f, blockRandUniform.getDt()));
ASSERT_CL(equal(-1.0f, blockRandUniform.getMin()));
@@ -457,7 +457,7 @@ int blockRandGaussTest()
{
srand(1234);
printf("Test BlockRandGauss\t\t: ");
BlockRandGauss blockRandGauss(NULL, "TEST");
BlockRandGauss blockRandGauss(nullptr, "TEST");
// test initial state
ASSERT_CL(equal(0.0f, blockRandGauss.getDt()));
ASSERT_CL(equal(1.0f, blockRandGauss.getMean()));
@@ -486,7 +486,7 @@ int blockRandGaussTest()
int blockStatsTest()
{
printf("Test BlockStats\t\t\t: ");
BlockStats<float, 1> stats(NULL, "TEST");
BlockStats<float, 1> stats(nullptr, "TEST");
ASSERT_CL(equal(0.0f, stats.getMean()(0)));
ASSERT_CL(equal(0.0f, stats.getStdDev()(0)));
stats.update(matrix::Scalar<float>(1.0f));
@@ -504,7 +504,7 @@ int blockDelayTest()
{
printf("Test BlockDelay\t\t\t: ");
using namespace matrix;
BlockDelay<float, 2, 1, 3> delay(NULL, "TEST");
BlockDelay<float, 2, 1, 3> delay(nullptr, "TEST");
Vector2f u1(1, 2);
Vector2f y1 = delay.update(u1);
ASSERT_CL(equal(y1(0), u1(0)));
+1 -1
View File
@@ -288,7 +288,7 @@ private:
};
Ekf2::Ekf2():
SuperBlock(NULL, "EKF"),
SuperBlock(nullptr, "EKF"),
_replay_mode(false),
_publish_replay_mode(0),
_att_pub(nullptr),
@@ -364,9 +364,9 @@ FixedwingAttitudeControl::FixedwingAttitudeControl() :
_actuators_0_pub(nullptr),
_actuators_2_pub(nullptr),
_rates_sp_id(0),
_actuators_id(0),
_attitude_setpoint_id(0),
_rates_sp_id(nullptr),
_actuators_id(nullptr),
_attitude_setpoint_id(nullptr),
/* performance counters */
_loop_perf(perf_alloc(PC_ELAPSED, "fwa_dt")),
@@ -557,7 +557,7 @@ FixedwingPositionControl::FixedwingPositionControl() :
_fw_pos_ctrl_status_pub(nullptr),
/* publication ID */
_attitude_setpoint_id(0),
_attitude_setpoint_id(nullptr),
/* states */
_ctrl_state(),
@@ -20,7 +20,7 @@ static const char *msg_label = "[lpe] "; // rate of land detector correction
BlockLocalPositionEstimator::BlockLocalPositionEstimator() :
// this block has no parent, and has name LPE
SuperBlock(NULL, "LPE"),
SuperBlock(nullptr, "LPE"),
// subscriptions, set rate, add to list
_sub_armed(ORB_ID(actuator_armed), 1000 / 2, 0, &getSubscriptions()),
_sub_land(ORB_ID(vehicle_land_detected), 1000 / 2, 0, &getSubscriptions()),
@@ -44,8 +44,8 @@ BlockLocalPositionEstimator::BlockLocalPositionEstimator() :
_sub_dist2(ORB_ID(distance_sensor), 1000 / 10, 2, &getSubscriptions()),
_sub_dist3(ORB_ID(distance_sensor), 1000 / 10, 3, &getSubscriptions()),
_dist_subs(),
_sub_lidar(NULL),
_sub_sonar(NULL),
_sub_lidar(nullptr),
_sub_sonar(nullptr),
// publications
_pub_lpos(ORB_ID(vehicle_local_position), -1, &getPublications()),
@@ -223,7 +223,7 @@ void BlockLocalPositionEstimator::update()
// auto-detect connected rangefinders while not armed
bool armedState = _sub_armed.get().armed;
if (!armedState && (_sub_lidar == NULL || _sub_sonar == NULL)) {
if (!armedState && (_sub_lidar == nullptr || _sub_sonar == nullptr)) {
// detect distance sensors
for (int i = 0; i < N_DIST_SUBS; i++) {
@@ -238,13 +238,13 @@ void BlockLocalPositionEstimator::update()
if (s->get().type == \
distance_sensor_s::MAV_DISTANCE_SENSOR_LASER &&
_sub_lidar == NULL) {
_sub_lidar == nullptr) {
_sub_lidar = s;
mavlink_and_console_log_info(&mavlink_log_pub, "%sLidar detected with ID %i", msg_label, i);
} else if (s->get().type == \
distance_sensor_s::MAV_DISTANCE_SENSOR_ULTRASOUND &&
_sub_sonar == NULL) {
_sub_sonar == nullptr) {
_sub_sonar = s;
mavlink_and_console_log_info(&mavlink_log_pub, "%sSonar detected with ID %i", msg_label, i);
}
@@ -302,8 +302,8 @@ void BlockLocalPositionEstimator::update()
bool gpsUpdated = (_fusion.get() & FUSE_GPS) && _sub_gps.updated();
bool visionUpdated = (_fusion.get() & FUSE_VIS_POS) && _sub_vision_pos.updated();
bool mocapUpdated = _sub_mocap.updated();
bool lidarUpdated = (_sub_lidar != NULL) && _sub_lidar->updated();
bool sonarUpdated = (_sub_sonar != NULL) && _sub_sonar->updated();
bool lidarUpdated = (_sub_lidar != nullptr) && _sub_lidar->updated();
bool sonarUpdated = (_sub_sonar != nullptr) && _sub_sonar->updated();
bool landUpdated = landed()
&& ((_timeStamp - _time_last_land) > 1.0e6f / LAND_RATE); // throttle rate
@@ -115,7 +115,7 @@ int local_position_estimator_main(int argc, char *argv[])
SCHED_PRIORITY_MAX - 5,
13500,
local_position_estimator_thread_main,
(argv && argc > 2) ? (char *const *) &argv[2] : (char *const *) NULL);
(argv && argc > 2) ? (char *const *) &argv[2] : (char *const *) nullptr);
return 0;
}
+1 -1
View File
@@ -136,7 +136,7 @@ void LogWriterFile::thread_stop()
notify();
// wait for thread to complete
int ret = pthread_join(_thread, NULL);
int ret = pthread_join(_thread, nullptr);
if (ret) {
PX4_WARN("join failed: %d", ret);
+6 -6
View File
@@ -268,12 +268,12 @@ void Logger::run_trampoline(int argc, char *argv[])
int myoptind = 1;
int ch;
const char *myoptarg = NULL;
const char *myoptarg = nullptr;
while ((ch = px4_getopt(argc, argv, "r:b:etfm:q:", &myoptind, &myoptarg)) != EOF) {
switch (ch) {
case 'r': {
unsigned long r = strtoul(myoptarg, NULL, 10);
unsigned long r = strtoul(myoptarg, nullptr, 10);
if (r <= 0) {
r = 1e6;
@@ -288,7 +288,7 @@ void Logger::run_trampoline(int argc, char *argv[])
break;
case 'b': {
unsigned long s = strtoul(myoptarg, NULL, 10);
unsigned long s = strtoul(myoptarg, nullptr, 10);
if (s < 1) {
s = 1;
@@ -325,7 +325,7 @@ void Logger::run_trampoline(int argc, char *argv[])
break;
case 'q':
queue_size = strtoul(myoptarg, NULL, 10);
queue_size = strtoul(myoptarg, nullptr, 10);
if (queue_size == 0) {
queue_size = 1;
@@ -586,7 +586,7 @@ int Logger::add_topics_from_file(const char *fname)
/* open the topic list file */
fp = fopen(fname, "r");
if (fp == NULL) {
if (fp == nullptr) {
return -1;
}
@@ -596,7 +596,7 @@ int Logger::add_topics_from_file(const char *fname)
/* get a line, bail on error/EOF */
line[0] = '\0';
if (fgets(line, sizeof(line), fp) == NULL) {
if (fgets(line, sizeof(line), fp) == nullptr) {
break;
}
+8 -8
View File
@@ -64,7 +64,7 @@ static const char *kTmpData = MOUNTPOINT "/$log$.txt";
//-------------------------------------------------------------------
static bool
stat_file(const char *file, time_t *date = 0, uint32_t *size = 0)
stat_file(const char *file, time_t *date = nullptr, uint32_t *size = nullptr)
{
struct stat st;
@@ -89,7 +89,7 @@ MavlinkLogHandler::new_instance(Mavlink *mavlink)
//-------------------------------------------------------------------
MavlinkLogHandler::MavlinkLogHandler(Mavlink *mavlink)
: MavlinkStream(mavlink)
, _pLogHandlerHelper(0)
, _pLogHandlerHelper(nullptr)
{
}
@@ -184,7 +184,7 @@ MavlinkLogHandler::_log_request_list(const mavlink_message_t *msg)
//-- Is this a new request?
if ((request.end - request.start) > _pLogHandlerHelper->log_count) {
delete _pLogHandlerHelper;
_pLogHandlerHelper = NULL;
_pLogHandlerHelper = nullptr;
}
}
@@ -269,7 +269,7 @@ MavlinkLogHandler::_log_request_erase(const mavlink_message_t * /*msg*/)
*/
if (_pLogHandlerHelper) {
delete _pLogHandlerHelper;
_pLogHandlerHelper = 0;
_pLogHandlerHelper = nullptr;
}
//-- Delete all logs
@@ -305,7 +305,7 @@ MavlinkLogHandler::_log_request_end(const mavlink_message_t * /*msg*/)
if (_pLogHandlerHelper) {
delete _pLogHandlerHelper;
_pLogHandlerHelper = 0;
_pLogHandlerHelper = nullptr;
}
}
@@ -378,7 +378,7 @@ LogListHelper::LogListHelper()
, current_log_size(0)
, current_log_data_offset(0)
, current_log_data_remaining(0)
, current_log_filep(0)
, current_log_filep(nullptr)
{
_init();
}
@@ -435,7 +435,7 @@ LogListHelper::open_for_transmit()
{
if (current_log_filep) {
::fclose(current_log_filep);
current_log_filep = 0;
current_log_filep = nullptr;
}
current_log_filep = ::fopen(current_log_filename, "rb");
@@ -605,7 +605,7 @@ LogListHelper::_get_log_time_size(const char *path, const char *file, time_t &da
if (sscanf(&file[3], "%u", &u) == 1) {
date += (u * 60);
if (stat_file(path, 0, &size)) {
if (stat_file(path, nullptr, &size)) {
return true;
}
}
+8 -8
View File
@@ -1062,7 +1062,7 @@ Mavlink::find_broadcast_address()
#else
// On Linux, we can determine the required size of the
// buffer first by providing NULL to ifc_req.
ifconf.ifc_req = NULL;
ifconf.ifc_req = nullptr;
ifconf.ifc_len = 0;
ret = ioctl(_socket_fd, SIOCGIFCONF, &ifconf);
@@ -1455,7 +1455,7 @@ Mavlink::message_buffer_init(int size)
int ret;
if (_message_buffer.data == 0) {
if (_message_buffer.data == nullptr) {
ret = PX4_ERROR;
_message_buffer.size = 0;
@@ -1718,7 +1718,7 @@ Mavlink::task_main(int argc, char *argv[])
* set error flag instead */
bool err_flag = false;
int myoptind = 1;
const char *myoptarg = NULL;
const char *myoptarg = nullptr;
#ifdef __PX4_POSIX
char *eptr;
int temp_int_arg;
@@ -1727,7 +1727,7 @@ Mavlink::task_main(int argc, char *argv[])
while ((ch = px4_getopt(argc, argv, "b:r:d:u:o:m:t:fpvwx", &myoptind, &myoptarg)) != EOF) {
switch (ch) {
case 'b':
_baudrate = strtoul(myoptarg, NULL, 10);
_baudrate = strtoul(myoptarg, nullptr, 10);
if (_baudrate < 9600 || _baudrate > 3000000) {
warnx("invalid baud rate '%s'", myoptarg);
@@ -1737,7 +1737,7 @@ Mavlink::task_main(int argc, char *argv[])
break;
case 'r':
_datarate = strtoul(myoptarg, NULL, 10);
_datarate = strtoul(myoptarg, nullptr, 10);
if (_datarate < 10 || _datarate > MAX_DATA_RATE) {
warnx("invalid data rate '%s'", myoptarg);
@@ -1905,7 +1905,7 @@ Mavlink::task_main(int argc, char *argv[])
}
/* initialize send mutex */
pthread_mutex_init(&_send_mutex, NULL);
pthread_mutex_init(&_send_mutex, nullptr);
/* if we are passing on mavlink messages, we need to prepare a buffer for this instance */
if (_forwarding_on || _ftp_on) {
@@ -1919,7 +1919,7 @@ Mavlink::task_main(int argc, char *argv[])
}
/* initialize message buffer mutex */
pthread_mutex_init(&_message_buffer_mutex, NULL);
pthread_mutex_init(&_message_buffer_mutex, nullptr);
}
/* Initialize system properties */
@@ -2366,7 +2366,7 @@ Mavlink::task_main(int argc, char *argv[])
}
/* first wait for threads to complete before tearing down anything */
pthread_join(_receive_thread, NULL);
pthread_join(_receive_thread, nullptr);
delete _subscribe_to_stream;
_subscribe_to_stream = nullptr;
@@ -74,7 +74,7 @@ MavlinkFtpTest::~MavlinkFtpTest()
void MavlinkFtpTest::_init(void)
{
_expected_seq_number = 0;
_ftp_server = new MavlinkFTP(NULL);
_ftp_server = new MavlinkFTP(nullptr);
_ftp_server->set_unittest_worker(MavlinkFtpTest::receive_message_handler_generic, this);
_cleanup_microsd();
@@ -412,8 +412,8 @@ MulticopterAttitudeControl::MulticopterAttitudeControl() :
_v_rates_sp_pub(nullptr),
_actuators_0_pub(nullptr),
_controller_status_pub(nullptr),
_rates_sp_id(0),
_actuators_id(0),
_rates_sp_id(nullptr),
_actuators_id(nullptr),
_actuators_0_circuit_breaker_enabled(false),
@@ -385,7 +385,7 @@ MulticopterPositionControl *g_control;
}
MulticopterPositionControl::MulticopterPositionControl() :
SuperBlock(NULL, "MPC"),
SuperBlock(nullptr, "MPC"),
_task_should_exit(false),
_control_task(-1),
_mavlink_log_pub(nullptr),
@@ -405,7 +405,7 @@ MulticopterPositionControl::MulticopterPositionControl() :
_att_sp_pub(nullptr),
_local_pos_sp_pub(nullptr),
_global_vel_sp_pub(nullptr),
_attitude_setpoint_id(0),
_attitude_setpoint_id(nullptr),
_vehicle_status{},
_vehicle_land_detected{},
_ctrl_state{},
+2 -2
View File
@@ -332,14 +332,14 @@ Geofence::loadFromFile(const char *filename)
/* open the mixer definition file */
fp = fopen(GEOFENCE_FILENAME, "r");
if (fp == NULL) {
if (fp == nullptr) {
return PX4_ERROR;
}
/* create geofence points from valid lines and store in DM */
for (;;) {
/* get a line, bail on error/EOF */
if (fgets(line, sizeof(line), fp) == NULL) {
if (fgets(line, sizeof(line), fp) == nullptr) {
break;
}
+1 -1
View File
@@ -100,7 +100,7 @@ Navigator *g_navigator;
}
Navigator::Navigator() :
SuperBlock(NULL, "NAV"),
SuperBlock(nullptr, "NAV"),
_task_should_exit(false),
_navigator_task(-1),
_mavlink_log_pub(nullptr),
@@ -153,7 +153,7 @@ int position_estimator_inav_main(int argc, char *argv[])
position_estimator_inav_task = px4_task_spawn_cmd("position_estimator_inav",
SCHED_DEFAULT, SCHED_PRIORITY_MAX - 5, 4600,
position_estimator_inav_thread_main,
(argv && argc > 2) ? (char *const *) &argv[2] : (char *const *) NULL);
(argv && argc > 2) ? (char *const *) &argv[2] : (char *const *) nullptr);
return 0;
}
@@ -385,7 +385,7 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
/* advertise */
orb_advert_t vehicle_local_position_pub = orb_advertise(ORB_ID(vehicle_local_position), &local_pos);
orb_advert_t vehicle_global_position_pub = NULL;
orb_advert_t vehicle_global_position_pub = nullptr;
struct position_estimator_inav_params params;
memset(&params, 0, sizeof(params));
@@ -1383,7 +1383,7 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
global_pos.pressure_alt = sensor.baro_alt_meter;
if (vehicle_global_position_pub == NULL) {
if (vehicle_global_position_pub == nullptr) {
vehicle_global_position_pub = orb_advertise(ORB_ID(vehicle_global_position), &global_pos);
} else {
+1 -1
View File
@@ -55,7 +55,7 @@ using namespace simulator;
static px4_task_t g_sim_task = -1;
Simulator *Simulator::_instance = NULL;
Simulator *Simulator::_instance = nullptr;
Simulator *Simulator::getInstance()
{
+1 -1
View File
@@ -744,7 +744,7 @@ void Simulator::pollForMAVLinkMessages(bool publish, int udp_port)
_vehicle_status_sub = orb_subscribe(ORB_ID(vehicle_status));
// got data from simulator, now activate the sending thread
pthread_create(&sender_thread, &sender_thread_attr, Simulator::sending_trampoline, NULL);
pthread_create(&sender_thread, &sender_thread_attr, Simulator::sending_trampoline, nullptr);
pthread_attr_destroy(&sender_thread_attr);
mavlink_status_t udp_status = {};
+1 -1
View File
@@ -42,7 +42,7 @@
#include "battery.h"
Battery::Battery() :
SuperBlock(NULL, "BAT"),
SuperBlock(nullptr, "BAT"),
_param_v_empty(this, "V_EMPTY"),
_param_v_full(this, "V_CHARGED"),
_param_n_cells(this, "N_CELLS"),
@@ -414,7 +414,7 @@ MultirotorMixer::mix(float *outputs, unsigned space, uint16_t *status_reg)
_delta_out_max = 0.0f;
// Notify saturation status
if (status_reg != NULL) {
if (status_reg != nullptr) {
(*status_reg) = _saturation_status.value;
}
@@ -127,7 +127,7 @@ int uORBTest::UnitTest::pubsublatency_main(void)
sprintf(fname, PX4_ROOTFSDIR"/fs/microsd/timings%u.txt", timingsgroup);
FILE *f = fopen(fname, "w");
if (f == NULL) {
if (f == nullptr) {
warnx("Error opening file!\n");
return uORB::ERROR;
}
@@ -472,7 +472,7 @@ int uORBTest::UnitTest::test_multi2()
orb_data_fd[i] = orb_subscribe_multi(ORB_ID(orb_test_medium_multi), i);
}
char *const args[1] = { NULL };
char *const args[1] = { nullptr };
int pubsub_task = px4_task_spawn_cmd("uorb_test_multi",
SCHED_DEFAULT,
SCHED_PRIORITY_MAX - 5,
@@ -761,7 +761,7 @@ int uORBTest::UnitTest::test_queue_poll_notify()
_thread_should_exit = false;
char *const args[1] = { NULL };
char *const args[1] = { nullptr };
int pubsub_task = px4_task_spawn_cmd("uorb_test_queue",
SCHED_DEFAULT,
SCHED_PRIORITY_MIN + 5,