From 5e3e4865272d7b2b9891d16f3f5594d42f8db354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Fri, 13 Jul 2018 11:09:41 +0200 Subject: [PATCH] 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. --- src/lib/drivers/device/posix/cdev_platform.cpp | 2 +- src/platforms/px4_posix.h | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/lib/drivers/device/posix/cdev_platform.cpp b/src/lib/drivers/device/posix/cdev_platform.cpp index 38b7e5bfe8..fe6e4f0439 100644 --- a/src/lib/drivers/device/posix/cdev_platform.cpp +++ b/src/lib/drivers/device/posix/cdev_platform.cpp @@ -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; diff --git a/src/platforms/px4_posix.h b/src/platforms/px4_posix.h index 587dfe63be..3222e1b4ac 100644 --- a/src/platforms/px4_posix.h +++ b/src/platforms/px4_posix.h @@ -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