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:
Mark Charlebois
2015-05-27 14:42:49 -07:00
committed by Lorenz Meier
parent 180c8b0cb0
commit 1ca05aaa64
59 changed files with 263 additions and 269 deletions
+12 -12
View File
@@ -515,12 +515,12 @@ PX4IO::PX4IO(device::Device *interface) :
_t_vehicle_control_mode(-1),
_t_param(-1),
_t_vehicle_command(-1),
_to_input_rc(0),
_to_outputs(0),
_to_battery(0),
_to_servorail(0),
_to_safety(0),
_to_mixer_status(0),
_to_input_rc(nullptr),
_to_outputs(nullptr),
_to_battery(nullptr),
_to_servorail(nullptr),
_to_safety(nullptr),
_to_mixer_status(nullptr),
_outputs{},
_servorail_status{},
_primary_pwm_device(false),
@@ -1474,7 +1474,7 @@ PX4IO::io_handle_status(uint16_t status)
}
/* lazily publish the safety status */
if (_to_safety > 0) {
if (_to_safety != nullptr) {
orb_publish(ORB_ID(safety), _to_safety, &safety);
} else {
@@ -1549,7 +1549,7 @@ PX4IO::io_handle_battery(uint16_t vbatt, uint16_t ibatt)
/* the announced battery status would conflict with the simulated battery status in HIL */
if (!(_pub_blocked)) {
/* lazily publish the battery voltage */
if (_to_battery > 0) {
if (_to_battery != nullptr) {
orb_publish(ORB_ID(battery_status), _to_battery, &battery_status);
} else {
@@ -1568,7 +1568,7 @@ PX4IO::io_handle_vservo(uint16_t vservo, uint16_t vrssi)
_servorail_status.rssi_v = vrssi * 0.001f;
/* lazily publish the servorail voltages */
if (_to_servorail > 0) {
if (_to_servorail != nullptr) {
orb_publish(ORB_ID(servorail_status), _to_servorail, &_servorail_status);
} else {
@@ -1723,7 +1723,7 @@ PX4IO::io_publish_raw_rc()
}
/* lazily advertise on first publication */
if (_to_input_rc == 0) {
if (_to_input_rc == nullptr) {
_to_input_rc = orb_advertise(ORB_ID(input_rc), &rc_val);
} else {
@@ -1756,7 +1756,7 @@ PX4IO::io_publish_pwm_outputs()
outputs.noutputs = _max_actuators;
/* lazily advertise on first publication */
if (_to_outputs == 0) {
if (_to_outputs == nullptr) {
int instance;
_to_outputs = orb_advertise_multi(ORB_ID(actuator_outputs),
&outputs, &instance, ORB_PRIO_MAX);
@@ -1774,7 +1774,7 @@ PX4IO::io_publish_pwm_outputs()
return ret;
/* publish mixer status */
if(_to_mixer_status == 0) {
if(_to_mixer_status == nullptr) {
_to_mixer_status = orb_advertise(ORB_ID(multirotor_motor_limits), &motor_limits);
} else {
orb_publish(ORB_ID(multirotor_motor_limits),_to_mixer_status, &motor_limits);