From f326377a5cfcecd7ad42d9d43c914a59600c305b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Dec 2017 12:06:12 +1100 Subject: [PATCH] AP_Compass: removed create() method for objects See discussion here: https://github.com/ArduPilot/ardupilot/issues/7331 we were getting some uninitialised variables. While it only showed up in AP_SbusOut, it means we can't be sure it won't happen on other objects, so safest to remove the approach Thanks to assistance from Lucas, Peter and Francisco --- libraries/AP_Compass/AP_Compass.h | 6 +----- .../AP_Compass/examples/AP_Compass_test/AP_Compass_test.cpp | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libraries/AP_Compass/AP_Compass.h b/libraries/AP_Compass/AP_Compass.h index 71e3e1cba1..5dee505caf 100644 --- a/libraries/AP_Compass/AP_Compass.h +++ b/libraries/AP_Compass/AP_Compass.h @@ -44,9 +44,7 @@ class Compass { friend class AP_Compass_Backend; public: - static Compass create() { return Compass{}; } - - constexpr Compass(Compass &&other) = default; + Compass(); /* Do not allow copies */ Compass(const Compass &other) = delete; @@ -293,8 +291,6 @@ public: } private: - Compass(); - /// Register a new compas driver, allocating an instance number /// /// @return number of compass instances diff --git a/libraries/AP_Compass/examples/AP_Compass_test/AP_Compass_test.cpp b/libraries/AP_Compass/examples/AP_Compass_test/AP_Compass_test.cpp index 67341ea99d..e5ec46e7c2 100644 --- a/libraries/AP_Compass/examples/AP_Compass_test/AP_Compass_test.cpp +++ b/libraries/AP_Compass/examples/AP_Compass_test/AP_Compass_test.cpp @@ -9,8 +9,8 @@ const AP_HAL::HAL& hal = AP_HAL::get_HAL(); -static AP_BoardConfig board_config = AP_BoardConfig::create(); -static Compass compass = Compass::create(); +static AP_BoardConfig board_config; +static Compass compass; uint32_t timer;