From ffced7d5911f4ba362361f6325c5cf248b38592c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Dec 2017 12:06:13 +1100 Subject: [PATCH] AP_RangeFinder: 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_RangeFinder/RangeFinder.h | 10 +--------- .../AP_RangeFinder/examples/RFIND_test/RFIND_test.cpp | 4 ++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/libraries/AP_RangeFinder/RangeFinder.h b/libraries/AP_RangeFinder/RangeFinder.h index f4e1520fe6..cb8aaef2eb 100644 --- a/libraries/AP_RangeFinder/RangeFinder.h +++ b/libraries/AP_RangeFinder/RangeFinder.h @@ -33,13 +33,7 @@ class RangeFinder friend class AP_RangeFinder_Backend; public: - static RangeFinder create(AP_SerialManager &_serial_manager, - enum Rotation orientation_default) - { - return RangeFinder(_serial_manager, orientation_default); - } - - constexpr RangeFinder(RangeFinder &&other) = default; + RangeFinder(AP_SerialManager &_serial_manager, enum Rotation orientation_default); /* Do not allow copies */ RangeFinder(const RangeFinder &other) = delete; @@ -166,8 +160,6 @@ public: private: - RangeFinder(AP_SerialManager &_serial_manager, enum Rotation orientation_default); - RangeFinder_State state[RANGEFINDER_MAX_INSTANCES]; AP_RangeFinder_Backend *drivers[RANGEFINDER_MAX_INSTANCES]; uint8_t num_instances:3; diff --git a/libraries/AP_RangeFinder/examples/RFIND_test/RFIND_test.cpp b/libraries/AP_RangeFinder/examples/RFIND_test/RFIND_test.cpp index 4326c32cda..6fe6b3e5ab 100644 --- a/libraries/AP_RangeFinder/examples/RFIND_test/RFIND_test.cpp +++ b/libraries/AP_RangeFinder/examples/RFIND_test/RFIND_test.cpp @@ -10,8 +10,8 @@ void loop(); const AP_HAL::HAL& hal = AP_HAL::get_HAL(); -static AP_SerialManager serial_manager = AP_SerialManager::create(); -static RangeFinder sonar = RangeFinder::create(serial_manager, ROTATION_PITCH_270); +static AP_SerialManager serial_manager; +static RangeFinder sonar{serial_manager, ROTATION_PITCH_270}; void setup() {