From 659ac8faf295e478746c0c5afa58e76ac743df48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 24 May 2016 14:17:04 +0200 Subject: [PATCH] refactor logger: use static fields & move them to source file avoids multiple declarations of... --- src/modules/logger/logger.cpp | 8 ++++++-- src/modules/logger/logger.h | 9 +++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/modules/logger/logger.cpp b/src/modules/logger/logger.cpp index 9a4eb1553a..a6a2767ac9 100644 --- a/src/modules/logger/logger.cpp +++ b/src/modules/logger/logger.cpp @@ -75,6 +75,10 @@ using namespace px4::logger; +static Logger *logger_ptr = nullptr; +static int logger_task = -1; +static pthread_t writer_thread; + int logger_main(int argc, char *argv[]) { // logger currently assumes little endian @@ -464,7 +468,7 @@ void Logger::run() return; } - int ret = _writer.thread_start(_writer_thread); + int ret = _writer.thread_start(writer_thread); if (ret) { PX4_ERR("logger: failed to create writer thread (%i)", ret); @@ -616,7 +620,7 @@ void Logger::run() _writer.notify(); // wait for thread to complete - ret = pthread_join(_writer_thread, NULL); + ret = pthread_join(writer_thread, NULL); if (ret) { PX4_WARN("join failed: %d", ret); diff --git a/src/modules/logger/logger.h b/src/modules/logger/logger.h index d061b9917f..7f8ae5933c 100644 --- a/src/modules/logger/logger.h +++ b/src/modules/logger/logger.h @@ -203,11 +203,8 @@ private: param_t _log_utc_offset; orb_advert_t _mavlink_log_pub = nullptr; uint16_t _next_topic_id; ///< id of next subscribed topic + }; -Logger *logger_ptr = nullptr; -int logger_task = -1; -pthread_t _writer_thread; - -} -} +} //namespace logger +} //namespace px4