px4_posix.h: avoid defining PX4_F_RDONLY as O_RDONLY

- There is an assumption un uORB that PX4_F_RDONLY is not 0.
- But O_RDONLY is 0 on Linux. orb_exists passes 0 to px4_open, which in
  uORB::DeviceNode::open leads to an unnecessary allocation of
  SubscriberData()
- PX4_F_RDONLY is only used in combination with px4_open, never with open()

However even if it was wrong/unexpected, it did not cause any problems,
just the unnecessary allocation.
This commit is contained in:
Beat Küng 2018-07-13 11:09:41 +02:00 committed by Lorenz Meier
parent ab788ceba7
commit 5e3e486527
2 changed files with 3 additions and 7 deletions

View File

@ -162,7 +162,7 @@ extern "C" {
int i;
mode_t mode;
if (!dev && (flags & (PX4_F_WRONLY | PX4_F_CREAT)) != 0 &&
if (!dev && (flags & PX4_F_WRONLY) != 0 &&
strncmp(path, "/obj/", 5) != 0 &&
strncmp(path, "/dev/", 5) != 0) {
va_list p;

View File

@ -55,12 +55,11 @@
#include "px4_sem.h"
#ifdef __PX4_NUTTX
#define PX4_F_RDONLY 1
#define PX4_F_WRONLY 2
#ifdef __PX4_NUTTX
typedef struct pollfd px4_pollfd_struct_t;
#if defined(__cplusplus)
@ -82,9 +81,6 @@ typedef struct pollfd px4_pollfd_struct_t;
#elif defined(__PX4_POSIX)
#define PX4_F_RDONLY O_RDONLY
#define PX4_F_WRONLY O_WRONLY
#define PX4_F_CREAT O_CREAT
#define PX4_STACK_OVERHEAD 8192
__BEGIN_DECLS