extensive orb_advert_t fixes

The calls to orb_advertise were being mishandled throughout the code.
There were ::close() calls on memory pointers, there were checks
against < 0 when it is a pointer to a object and values larger than
0x7ffffffff are valid. Some places orb_advert_t variables were
being initialized as 0 other places as -1.

The orb_advert_t type was changed to uintptr_t so the pointer value
would not be wrapped as a negative number. This was causing a failure
on ARM.

Tests for < 0 were changed to == 0 since a null pointer is the valid
representation for error, or uninitialized.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-05-23 00:35:17 +00:00
committed by Lorenz Meier
parent 9a67303416
commit a734fc96d1
52 changed files with 202 additions and 208 deletions
@@ -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(-1),
_accel_topic(0),
_accel_orb_class_instance(-1),
_accel_class_instance(-1),
_accel_read(0),
@@ -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 == (orb_advert_t)(-1)) {
if (_accel_topic == 0) {
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 != (orb_advert_t)(-1)) {
if (_accel_topic != 0) {
orb_publish(ORB_ID(sensor_accel), _accel_topic, &accel_report);
}
}
@@ -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(-1),
_subsys_pub(-1),
_airspeed_pub(0),
_subsys_pub(0),
_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 == 0)
PX4_WARN("uORB started?");
}
+3 -3
View File
@@ -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(-1),
_baro_topic(0),
_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 == (orb_advert_t)(-1)) {
if (_baro_topic == 0) {
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 != (orb_advert_t)(-1)) {
if (_baro_topic != 0) {
/* 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(-1),
_accel_topic(0),
_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 == 0) {
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 == 0) {
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(-1),
_gyro_topic(0),
_gyro_orb_class_instance(-1),
_gyro_class_instance(-1)
{