mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 11:43:35 +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
@@ -181,7 +181,7 @@ void UavcanEscController::orb_pub_timer_cb(const uavcan::TimerEvent&)
|
||||
_esc_status.counter += 1;
|
||||
_esc_status.esc_connectiontype = ESC_CONNECTION_TYPE_CAN;
|
||||
|
||||
if (_esc_status_pub > 0) {
|
||||
if (_esc_status_pub != nullptr) {
|
||||
(void)orb_publish(ORB_ID(esc_status), _esc_status_pub, &_esc_status);
|
||||
} else {
|
||||
_esc_status_pub = orb_advertise(ORB_ID(esc_status), &_esc_status);
|
||||
|
||||
@@ -88,7 +88,7 @@ private:
|
||||
|
||||
bool _armed = false;
|
||||
esc_status_s _esc_status = {};
|
||||
orb_advert_t _esc_status_pub = -1;
|
||||
orb_advert_t _esc_status_pub = nullptr;
|
||||
|
||||
/*
|
||||
* libuavcan related things
|
||||
|
||||
@@ -48,7 +48,7 @@ const char *const UavcanGnssBridge::NAME = "gnss";
|
||||
UavcanGnssBridge::UavcanGnssBridge(uavcan::INode &node) :
|
||||
_node(node),
|
||||
_sub_fix(node),
|
||||
_report_pub(0)
|
||||
_report_pub(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ void UavcanGnssBridge::gnss_fix_sub_cb(const uavcan::ReceivedDataStructure<uavca
|
||||
|
||||
report.satellites_used = msg.sats_used;
|
||||
|
||||
if (_report_pub > 0) {
|
||||
if (_report_pub != nullptr) {
|
||||
orb_publish(ORB_ID(vehicle_gps_position), _report_pub, &report);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -89,7 +89,7 @@ class UavcanCDevSensorBridgeBase : public IUavcanSensorBridge, public device::CD
|
||||
struct Channel
|
||||
{
|
||||
int node_id = -1;
|
||||
orb_advert_t orb_advert = -1;
|
||||
orb_advert_t orb_advert = nullptr;
|
||||
int class_instance = -1;
|
||||
int orb_instance = -1;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user