mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 15:51:36 +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
@@ -360,7 +360,7 @@ HMC5883::HMC5883(device::Device *interface, const char *path, enum Rotation rota
|
||||
_collect_phase(false),
|
||||
_class_instance(-1),
|
||||
_orb_class_instance(-1),
|
||||
_mag_topic(0),
|
||||
_mag_topic(nullptr),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, "hmc5883_read")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, "hmc5883_comms_errors")),
|
||||
_buffer_overflows(perf_alloc(PC_COUNT, "hmc5883_buffer_overflows")),
|
||||
@@ -986,14 +986,14 @@ HMC5883::collect()
|
||||
|
||||
if (!(_pub_blocked)) {
|
||||
|
||||
if (_mag_topic != 0) {
|
||||
if (_mag_topic != nullptr) {
|
||||
/* publish it */
|
||||
orb_publish(ORB_ID(sensor_mag), _mag_topic, &new_report);
|
||||
} else {
|
||||
_mag_topic = orb_advertise_multi(ORB_ID(sensor_mag), &new_report,
|
||||
&_orb_class_instance, (sensor_is_onboard) ? ORB_PRIO_HIGH : ORB_PRIO_MAX);
|
||||
|
||||
if (_mag_topic == 0)
|
||||
if (_mag_topic == nullptr)
|
||||
debug("ADVERT FAIL");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user