mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-30 01:30: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
@@ -94,7 +94,7 @@ orb_advert_t uORB::Manager::orb_advertise_multi(const struct orb_metadata *meta,
|
||||
fd = node_open(PUBSUB, meta, data, true, instance, priority);
|
||||
if (fd == ERROR) {
|
||||
warnx("node_open as advertiser failed.");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* get the advertiser handle and close the node */
|
||||
@@ -102,14 +102,14 @@ orb_advert_t uORB::Manager::orb_advertise_multi(const struct orb_metadata *meta,
|
||||
px4_close(fd);
|
||||
if (result == ERROR) {
|
||||
warnx("px4_ioctl ORBIOCGADVERTISER failed. fd = %d", fd);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* the advertiser must perform an initial publish to initialise the object */
|
||||
result = orb_publish(meta, advertiser, data);
|
||||
if (result == ERROR) {
|
||||
warnx("orb_publish failed");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return advertiser;
|
||||
|
||||
Reference in New Issue
Block a user