mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 11: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
@@ -314,10 +314,10 @@ MulticopterAttitudeControl::MulticopterAttitudeControl() :
|
||||
_vehicle_status_sub(-1),
|
||||
|
||||
/* publications */
|
||||
_att_sp_pub(0),
|
||||
_v_rates_sp_pub(0),
|
||||
_actuators_0_pub(0),
|
||||
_controller_status_pub(0),
|
||||
_att_sp_pub(nullptr),
|
||||
_v_rates_sp_pub(nullptr),
|
||||
_actuators_0_pub(nullptr),
|
||||
_controller_status_pub(nullptr),
|
||||
_rates_sp_id(0),
|
||||
_actuators_id(0),
|
||||
|
||||
@@ -822,7 +822,7 @@ MulticopterAttitudeControl::task_main()
|
||||
_v_rates_sp.thrust = _thrust_sp;
|
||||
_v_rates_sp.timestamp = hrt_absolute_time();
|
||||
|
||||
if (_v_rates_sp_pub > 0) {
|
||||
if (_v_rates_sp_pub != nullptr) {
|
||||
orb_publish(_rates_sp_id, _v_rates_sp_pub, &_v_rates_sp);
|
||||
|
||||
} else if (_rates_sp_id) {
|
||||
@@ -843,7 +843,7 @@ MulticopterAttitudeControl::task_main()
|
||||
_v_rates_sp.thrust = _thrust_sp;
|
||||
_v_rates_sp.timestamp = hrt_absolute_time();
|
||||
|
||||
if (_v_rates_sp_pub > 0) {
|
||||
if (_v_rates_sp_pub != nullptr) {
|
||||
orb_publish(_rates_sp_id, _v_rates_sp_pub, &_v_rates_sp);
|
||||
|
||||
} else if (_rates_sp_id) {
|
||||
@@ -877,7 +877,7 @@ MulticopterAttitudeControl::task_main()
|
||||
_controller_status.timestamp = hrt_absolute_time();
|
||||
|
||||
if (!_actuators_0_circuit_breaker_enabled) {
|
||||
if (_actuators_0_pub > 0) {
|
||||
if (_actuators_0_pub != nullptr) {
|
||||
orb_publish(_actuators_id, _actuators_0_pub, &_actuators);
|
||||
perf_end(_controller_latency_perf);
|
||||
|
||||
@@ -888,7 +888,7 @@ MulticopterAttitudeControl::task_main()
|
||||
}
|
||||
|
||||
/* publish controller status */
|
||||
if(_controller_status_pub > 0) {
|
||||
if(_controller_status_pub != nullptr) {
|
||||
orb_publish(ORB_ID(mc_att_ctrl_status),_controller_status_pub, &_controller_status);
|
||||
} else {
|
||||
_controller_status_pub = orb_advertise(ORB_ID(mc_att_ctrl_status), &_controller_status);
|
||||
|
||||
Reference in New Issue
Block a user