From 8d2872d3abe1982950bb2c3a5bff47c82cfac87a Mon Sep 17 00:00:00 2001 From: Tom Pittenger Date: Tue, 5 Jul 2016 12:59:33 -0700 Subject: [PATCH] AP_Baro: coverity scan - variables not initialized in constructor --- libraries/AP_Baro/AP_Baro.cpp | 10 +--------- libraries/AP_Baro/AP_Baro.h | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/libraries/AP_Baro/AP_Baro.cpp b/libraries/AP_Baro/AP_Baro.cpp index 1dd8672d55..22fa5e055d 100644 --- a/libraries/AP_Baro/AP_Baro.cpp +++ b/libraries/AP_Baro/AP_Baro.cpp @@ -80,15 +80,7 @@ const AP_Param::GroupInfo AP_Baro::var_info[] = { /* AP_Baro constructor */ -AP_Baro::AP_Baro() : - _num_drivers(0), - _num_sensors(0), - _primary(0), - _last_altitude_EAS2TAS(0.0f), - _EAS2TAS(0.0f), - _external_temperature(0.0f), - _last_external_temperature_ms(0), - _hil_mode(false) +AP_Baro::AP_Baro() { memset(sensors, 0, sizeof(sensors)); diff --git a/libraries/AP_Baro/AP_Baro.h b/libraries/AP_Baro/AP_Baro.h index 57eb6e6a4d..61dcf7c507 100644 --- a/libraries/AP_Baro/AP_Baro.h +++ b/libraries/AP_Baro/AP_Baro.h @@ -138,14 +138,14 @@ public: private: // how many drivers do we have? - uint8_t _num_drivers; + uint8_t _num_drivers = 0; AP_Baro_Backend *drivers[BARO_MAX_DRIVERS]; // how many sensors do we have? - uint8_t _num_sensors; + uint8_t _num_sensors = 0; // what is the primary sensor at the moment? - uint8_t _primary; + uint8_t _primary = 0; struct sensor { uint32_t last_update_ms; // last update time in ms @@ -160,17 +160,17 @@ private: } sensors[BARO_MAX_INSTANCES]; AP_Float _alt_offset; - float _alt_offset_active; + float _alt_offset_active = 0; AP_Int8 _primary_baro; // primary chosen by user - float _last_altitude_EAS2TAS; - float _EAS2TAS; - float _external_temperature; - uint32_t _last_external_temperature_ms; + float _last_altitude_EAS2TAS = 0; + float _EAS2TAS = 0; + float _external_temperature = 0; + uint32_t _last_external_temperature_ms = 0; DerivativeFilterFloat_Size7 _climb_rate_filter; - bool _hil_mode:1; + bool _hil_mode = false; // when did we last notify the GCS of new pressure reference? - uint32_t _last_notify_ms; + uint32_t _last_notify_ms = 0; void SimpleAtmosphere(const float alt, float &sigma, float &delta, float &theta); };