From 99499dece21f80173be51b6c2b1fa818c8e57f28 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Dec 2017 12:06:12 +1100 Subject: [PATCH] AP_InertialSensor: 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_InertialSensor/AP_InertialSensor.h | 6 +----- .../AP_InertialSensor/examples/INS_generic/INS_generic.cpp | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libraries/AP_InertialSensor/AP_InertialSensor.h b/libraries/AP_InertialSensor/AP_InertialSensor.h index 63706ac849..f43d389e10 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor.h +++ b/libraries/AP_InertialSensor/AP_InertialSensor.h @@ -49,9 +49,7 @@ class AP_InertialSensor : AP_AccelCal_Client friend class AP_InertialSensor_Backend; public: - static AP_InertialSensor create() { return AP_InertialSensor{}; } - - constexpr AP_InertialSensor(AP_InertialSensor &&other) = default; + AP_InertialSensor(); /* Do not allow copies */ AP_InertialSensor(const AP_InertialSensor &other) = delete; @@ -346,8 +344,6 @@ public: BatchSampler batchsampler{*this}; private: - AP_InertialSensor(); - // load backend drivers bool _add_backend(AP_InertialSensor_Backend *backend); void _start_backends(); diff --git a/libraries/AP_InertialSensor/examples/INS_generic/INS_generic.cpp b/libraries/AP_InertialSensor/examples/INS_generic/INS_generic.cpp index 1a0248ca76..a6f338b8a8 100644 --- a/libraries/AP_InertialSensor/examples/INS_generic/INS_generic.cpp +++ b/libraries/AP_InertialSensor/examples/INS_generic/INS_generic.cpp @@ -8,13 +8,13 @@ const AP_HAL::HAL &hal = AP_HAL::get_HAL(); -static AP_InertialSensor ins = AP_InertialSensor::create(); +static AP_InertialSensor ins; static void display_offsets_and_scaling(); static void run_test(); // board specific config -static AP_BoardConfig BoardConfig = AP_BoardConfig::create(); +static AP_BoardConfig BoardConfig; void setup(void); void loop(void);