mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 10:03:34 +08:00
orb_advert_t changed to void * and checks changed to nullptr
The existing orb_advert_t use thoughout the code sometimes tries to treat it as a file descriptor and there are checks for < 0 and ::close calls on orb_advert_t types which is an invalid use of an object pointer, which is what orb_advert_t really is. Initially I had changed the -1 initializations to 0 but it was suggested that this should be nullptr. That was a good recommendation but the definition of orb_advert_t had to change to void * because you cannot initialize a uintptr_t as nullptr. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
committed by
Lorenz Meier
parent
180c8b0cb0
commit
1ca05aaa64
@@ -369,7 +369,7 @@ ACCELSIM::ACCELSIM(const char* path, enum Rotation rotation) :
|
||||
_mag_range_ga(0.0f),
|
||||
_mag_range_scale(0.0f),
|
||||
_mag_samplerate(0),
|
||||
_accel_topic(0),
|
||||
_accel_topic(nullptr),
|
||||
_accel_orb_class_instance(-1),
|
||||
_accel_class_instance(-1),
|
||||
_accel_read(0),
|
||||
@@ -481,7 +481,7 @@ ACCELSIM::init()
|
||||
_mag->_mag_topic = orb_advertise_multi(ORB_ID(sensor_mag), &mrp,
|
||||
&_mag->_mag_orb_class_instance, ORB_PRIO_LOW);
|
||||
|
||||
if (_mag->_mag_topic == 0) {
|
||||
if (_mag->_mag_topic == nullptr) {
|
||||
PX4_WARN("ADVERT ERR");
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ ACCELSIM::init()
|
||||
_accel_topic = orb_advertise_multi(ORB_ID(sensor_accel), &arp,
|
||||
&_accel_orb_class_instance, ORB_PRIO_DEFAULT);
|
||||
|
||||
if (_accel_topic == 0) {
|
||||
if (_accel_topic == nullptr) {
|
||||
PX4_WARN("ADVERT ERR");
|
||||
}
|
||||
|
||||
@@ -1077,7 +1077,7 @@ ACCELSIM::measure()
|
||||
|
||||
// The first call to measure() is from init() and _accel_topic is not
|
||||
// yet initialized
|
||||
if (_accel_topic != 0) {
|
||||
if (_accel_topic != nullptr) {
|
||||
orb_publish(ORB_ID(sensor_accel), _accel_topic, &accel_report);
|
||||
}
|
||||
}
|
||||
@@ -1175,7 +1175,7 @@ ACCELSIM::mag_measure()
|
||||
ACCELSIM_mag::ACCELSIM_mag(ACCELSIM *parent) :
|
||||
VDev("ACCELSIM_mag", ACCELSIM_DEVICE_PATH_MAG),
|
||||
_parent(parent),
|
||||
_mag_topic(-1),
|
||||
_mag_topic(nullptr),
|
||||
_mag_orb_class_instance(-1),
|
||||
_mag_class_instance(-1)
|
||||
{
|
||||
|
||||
@@ -83,8 +83,8 @@ Airspeed::Airspeed(int bus, int address, unsigned conversion_interval, const cha
|
||||
_measure_ticks(0),
|
||||
_collect_phase(false),
|
||||
_diff_pres_offset(0.0f),
|
||||
_airspeed_pub(0),
|
||||
_subsys_pub(0),
|
||||
_airspeed_pub(nullptr),
|
||||
_subsys_pub(nullptr),
|
||||
_class_instance(-1),
|
||||
_conversion_interval(conversion_interval),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, "airspeed_read")),
|
||||
@@ -143,7 +143,7 @@ Airspeed::init()
|
||||
/* measurement will have generated a report, publish */
|
||||
_airspeed_pub = orb_advertise(ORB_ID(differential_pressure), &arp);
|
||||
|
||||
if (_airspeed_pub == 0)
|
||||
if (_airspeed_pub == nullptr)
|
||||
PX4_WARN("uORB started?");
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ Airspeed::update_status()
|
||||
SUBSYSTEM_TYPE_DIFFPRESSURE
|
||||
};
|
||||
|
||||
if (_subsys_pub > 0) {
|
||||
if (_subsys_pub != nullptr) {
|
||||
orb_publish(ORB_ID(subsystem_info), _subsys_pub, &info);
|
||||
} else {
|
||||
_subsys_pub = orb_advertise(ORB_ID(subsystem_info), &info);
|
||||
|
||||
@@ -213,7 +213,7 @@ BAROSIM::BAROSIM(device::Device *interface, barosim::prom_u &prom_buf, const cha
|
||||
_OFF(0),
|
||||
_SENS(0),
|
||||
_msl_pressure(101325),
|
||||
_baro_topic(0),
|
||||
_baro_topic(nullptr),
|
||||
_orb_class_instance(-1),
|
||||
_class_instance(-1),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, "barosim_read")),
|
||||
@@ -315,7 +315,7 @@ BAROSIM::init()
|
||||
_baro_topic = orb_advertise_multi(ORB_ID(sensor_baro), &brp,
|
||||
&_orb_class_instance, (is_external()) ? ORB_PRIO_HIGH : ORB_PRIO_DEFAULT);
|
||||
|
||||
if (_baro_topic == 0) {
|
||||
if (_baro_topic == nullptr) {
|
||||
PX4_ERR("failed to create sensor_baro publication");
|
||||
}
|
||||
//PX4_WARN("sensor_baro publication %ld", _baro_topic);
|
||||
@@ -722,7 +722,7 @@ BAROSIM::collect()
|
||||
|
||||
/* publish it */
|
||||
if (!(_pub_blocked)) {
|
||||
if (_baro_topic != 0) {
|
||||
if (_baro_topic != nullptr) {
|
||||
/* publish it */
|
||||
orb_publish(ORB_ID(sensor_baro), _baro_topic, &report);
|
||||
}
|
||||
|
||||
@@ -472,7 +472,7 @@ GYROSIM::GYROSIM(const char *path_accel, const char *path_gyro, enum Rotation ro
|
||||
_accel_scale{},
|
||||
_accel_range_scale(0.0f),
|
||||
_accel_range_m_s2(0.0f),
|
||||
_accel_topic(0),
|
||||
_accel_topic(nullptr),
|
||||
_accel_orb_class_instance(-1),
|
||||
_accel_class_instance(-1),
|
||||
_gyro_reports(nullptr),
|
||||
@@ -624,7 +624,7 @@ GYROSIM::init()
|
||||
_accel_topic = orb_advertise_multi(ORB_ID(sensor_accel), &arp,
|
||||
&_accel_orb_class_instance, ORB_PRIO_HIGH);
|
||||
|
||||
if (_accel_topic == 0) {
|
||||
if (_accel_topic == nullptr) {
|
||||
PX4_WARN("ADVERT FAIL");
|
||||
}
|
||||
|
||||
@@ -636,7 +636,7 @@ GYROSIM::init()
|
||||
_gyro->_gyro_topic = orb_advertise_multi(ORB_ID(sensor_gyro), &grp,
|
||||
&_gyro->_gyro_orb_class_instance, ORB_PRIO_HIGH);
|
||||
|
||||
if (_gyro->_gyro_topic == 0) {
|
||||
if (_gyro->_gyro_topic == nullptr) {
|
||||
PX4_WARN("ADVERT FAIL");
|
||||
}
|
||||
|
||||
@@ -1547,7 +1547,7 @@ GYROSIM::print_registers()
|
||||
GYROSIM_gyro::GYROSIM_gyro(GYROSIM *parent, const char *path) :
|
||||
VDev("GYROSIM_gyro", path),
|
||||
_parent(parent),
|
||||
_gyro_topic(0),
|
||||
_gyro_topic(nullptr),
|
||||
_gyro_orb_class_instance(-1),
|
||||
_gyro_class_instance(-1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user