mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 03:53:33 +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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user