From 358bcb6ae04d7d04a614d2166af7cd8282bb1048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Wed, 29 Mar 2017 18:47:20 +0200 Subject: [PATCH] visibility.h: add #pragma GCC poison getenv setenv putenv Just to make sure that it will never be used on NuttX. This is not an architectural limitation, just a memory optimization, since we call clearenv() on NuttX. --- src/include/visibility.h | 16 +++++++++++++--- src/modules/logger/logger.cpp | 3 +++ src/modules/replay/definitions.hpp | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/include/visibility.h b/src/include/visibility.h index 2c6adc062e1..00fa1a78e70 100644 --- a/src/include/visibility.h +++ b/src/include/visibility.h @@ -39,8 +39,7 @@ * This file is normally included automatically by the build system. */ -#ifndef __SYSTEMLIB_VISIBILITY_H -#define __SYSTEMLIB_VISIBILITY_H +#pragma once #ifdef __EXPORT # undef __EXPORT @@ -59,4 +58,15 @@ # define __BEGIN_DECLS # define __END_DECLS #endif -#endif \ No newline at end of file + + +#ifdef __PX4_NUTTX +/* On NuttX we call clearenv() so we cannot use getenv() and others (see px4_task_spawn_cmd() in px4_nuttx_tasks.c). + * We need to include the headers declaring getenv() before the pragma, otherwise it will trigger a poison error. + */ +#include +#ifdef __cplusplus +#include +#endif +#pragma GCC poison getenv setenv putenv +#endif /* __PX4_NUTTX */ diff --git a/src/modules/logger/logger.cpp b/src/modules/logger/logger.cpp index 9f60712675f..684f7d1fad6 100644 --- a/src/modules/logger/logger.cpp +++ b/src/modules/logger/logger.cpp @@ -370,6 +370,7 @@ void Logger::run_trampoline(int argc, char *argv[]) PX4_ERR("alloc failed"); } else { +#ifndef __PX4_NUTTX //check for replay mode const char *logfile = getenv(px4::replay::ENV_FILENAME); @@ -377,6 +378,8 @@ void Logger::run_trampoline(int argc, char *argv[]) logger_ptr->setReplayFile(logfile); } +#endif /* __PX4_NUTTX */ + logger_ptr->run(); } diff --git a/src/modules/replay/definitions.hpp b/src/modules/replay/definitions.hpp index 6f1f533eb89..0e23708c05c 100644 --- a/src/modules/replay/definitions.hpp +++ b/src/modules/replay/definitions.hpp @@ -38,7 +38,7 @@ namespace px4 namespace replay { -static const char *ENV_FILENAME = "replay"; ///< name for getenv() +static const char __attribute__((unused)) *ENV_FILENAME = "replay"; ///< name for getenv() static const char __attribute__((unused)) *ENV_MODE = "replay_mode"; ///< name for getenv()