diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2015-01-25 17:01:39 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-01-29 16:33:52 +0100 |
commit | 4f9a6273cb28e50fdabdf1f60c39da6fe0b4fcd6 (patch) | |
tree | f1259bc59b64ce51502ab141d4ce18c6e3ee693c /src/modules | |
parent | 7932e2eda238b1d480fdc9de71bb1b5fcaa3e373 (diff) | |
download | px4-firmware-4f9a6273cb28e50fdabdf1f60c39da6fe0b4fcd6.tar.gz px4-firmware-4f9a6273cb28e50fdabdf1f60c39da6fe0b4fcd6.tar.bz2 px4-firmware-4f9a6273cb28e50fdabdf1f60c39da6fe0b4fcd6.zip |
uORB: correct pub creation for multi-topics
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/uORB/uORB.cpp | 21 | ||||
-rw-r--r-- | src/modules/uORB/uORB.h | 2 |
2 files changed, 13 insertions, 10 deletions
diff --git a/src/modules/uORB/uORB.cpp b/src/modules/uORB/uORB.cpp index c4de996bb..b3a9bedb1 100644 --- a/src/modules/uORB/uORB.cpp +++ b/src/modules/uORB/uORB.cpp @@ -599,13 +599,6 @@ ORBDevMaster::ioctl(struct file *filp, int cmd, unsigned long arg) return ret; } - /* driver wants a permanent copy of the node name, so make one here */ - objname = strdup(meta->o_name); - - if (objname == nullptr) { - return -ENOMEM; - } - /* ensure that only one advertiser runs through this critical section */ lock(); @@ -622,9 +615,20 @@ ORBDevMaster::ioctl(struct file *filp, int cmd, unsigned long arg) *(adv->instance) = group_tries; } + /* driver wants a permanent copy of the node name, so make one here */ + objname = strdup(meta->o_name); + + if (objname == nullptr) { + return -ENOMEM; + } + /* driver wants a permanent copy of the path, so make one here */ devpath = strdup(nodepath); + if (devpath == nullptr) { + return -ENOMEM; + } + /* construct the new node */ node = new ORBDevNode(meta, objname, devpath, adv->priority); @@ -644,12 +648,11 @@ ORBDevMaster::ioctl(struct file *filp, int cmd, unsigned long arg) free((void *)devpath); } - /* try with next larger index */ group_tries++; } while (ret != OK && (group_tries < max_group_tries)); - if (group_tries >= max_group_tries) { + if (group_tries > max_group_tries) { ret = -ENOMEM; } diff --git a/src/modules/uORB/uORB.h b/src/modules/uORB/uORB.h index a0ad75273..30cd59880 100644 --- a/src/modules/uORB/uORB.h +++ b/src/modules/uORB/uORB.h @@ -59,7 +59,7 @@ typedef const struct orb_metadata *orb_id_t; /** * Maximum number of multi topic instances */ -#define ORB_MULTI_MAX_INSTANCES 4 +#define ORB_MULTI_MAX_INSTANCES 3 /** * Topic priority. |