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
+3 -3
View File
@@ -203,7 +203,7 @@ BATT_SMBUS::BATT_SMBUS(int bus, uint16_t batt_smbus_addr) :
_enabled(false),
_work{},
_reports(nullptr),
_batt_topic(0),
_batt_topic(nullptr),
_batt_orb_id(nullptr),
_start_time(0),
_batt_capacity(0)
@@ -427,13 +427,13 @@ BATT_SMBUS::cycle()
}
// publish to orb
if (_batt_topic != 0) {
if (_batt_topic != nullptr) {
orb_publish(_batt_orb_id, _batt_topic, &new_report);
} else {
_batt_topic = orb_advertise(_batt_orb_id, &new_report);
if (_batt_topic == 0) {
if (_batt_topic == nullptr) {
errx(1, "ADVERT FAIL");
}
}