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
+7 -7
View File
@@ -137,16 +137,17 @@ int uORBTest::UnitTest::pubsublatency_main(void)
int uORBTest::UnitTest::test()
{
struct orb_test t, u;
int pfd, sfd;
int sfd;
orb_advert_t ptopic;
bool updated;
t.val = 0;
pfd = orb_advertise(ORB_ID(orb_test), &t);
ptopic = orb_advertise(ORB_ID(orb_test), &t);
if (pfd < 0)
if (ptopic == 0)
return test_fail("advertise failed: %d", errno);
test_note("publish handle 0x%08x", pfd);
test_note("publish handle 0x%08x", ptopic);
sfd = orb_subscribe(ORB_ID(orb_test));
if (sfd < 0)
@@ -170,7 +171,7 @@ int uORBTest::UnitTest::test()
t.val = 2;
test_note("try publish");
if (PX4_OK != orb_publish(ORB_ID(orb_test), pfd, &t))
if (PX4_OK != orb_publish(ORB_ID(orb_test), ptopic, &t))
return test_fail("publish failed");
if (PX4_OK != orb_check(sfd, &updated))
@@ -186,7 +187,6 @@ int uORBTest::UnitTest::test()
return test_fail("copy(2) mismatch: %d expected %d", u.val, t.val);
orb_unsubscribe(sfd);
close(pfd);
/* this routine tests the multi-topic support */
test_note("try multi-topic support");
@@ -197,7 +197,7 @@ int uORBTest::UnitTest::test()
test_note("advertised");
int instance1;
int pfd1 = orb_advertise_multi(ORB_ID(orb_multitest), &t, &instance1, ORB_PRIO_MIN);
orb_advert_t pfd1 = orb_advertise_multi(ORB_ID(orb_multitest), &t, &instance1, ORB_PRIO_MIN);
if (instance0 != 0)
return test_fail("mult. id0: %d", instance0);