From 42d2c149d6fff2521e31cd580acf8114aaabce68 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 27 Nov 2020 17:57:47 +0100 Subject: Initialize all members --- .clang-tidy | 1 - src/AlsaDriver.cpp | 1 + src/Configuration.cpp | 8 -------- src/Configuration.hpp | 34 ++++++++++++++++------------------ src/JackDriver.cpp | 2 ++ src/Patchage.cpp | 1 + src/PatchageEvent.hpp | 11 ++++------- src/PortID.hpp | 10 +++------- 8 files changed, 27 insertions(+), 41 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index df47588..66585b8 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,7 +3,6 @@ Checks: > -*-c-arrays, -*-else-after-return, -*-magic-numbers, - -*-member-init, -*-narrowing-conversions, -*-no-malloc, -*-non-private-member-variables-in-classes, diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index af7d5e4..6b832eb 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -33,6 +33,7 @@ using boost::format; AlsaDriver::AlsaDriver(Patchage* app) : _app(app) , _seq(nullptr) + , _refresh_thread{} {} AlsaDriver::~AlsaDriver() diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 36176ec..e95b727 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -33,14 +33,6 @@ static const char* port_type_names[N_PORT_TYPES] = {"JACK_AUDIO", "JACK_CV"}; Configuration::Configuration() - : _window_location{0, 0} - , _window_size{640, 480} - , _zoom(1.0) - , _font_size(12.0) - , _messages_height(0) - , _show_toolbar(true) - , _show_messages(false) - , _sort_ports(true) { #ifdef PATCHAGE_USE_LIGHT_THEME _port_colors[static_cast(PortType::jack_audio)] = diff --git a/src/Configuration.hpp b/src/Configuration.hpp index e58e170..9516310 100644 --- a/src/Configuration.hpp +++ b/src/Configuration.hpp @@ -43,18 +43,15 @@ enum class PortType struct Coord { - Coord() - : x(0.0) - , y(0.0) - {} + Coord() = default; Coord(double x_, double y_) : x(x_) , y(y_) {} - double x; - double y; + double x{0.0}; + double y{0.0}; }; class Configuration @@ -129,18 +126,19 @@ private: std::map _module_settings; - uint32_t _default_port_colors[N_PORT_TYPES]; - uint32_t _port_colors[N_PORT_TYPES]; - - Coord _window_location; - Coord _window_size; - float _zoom; - float _font_size; - int _messages_height; - bool _show_toolbar; - bool _sprung_layout; - bool _show_messages; - bool _sort_ports; + uint32_t _default_port_colors[N_PORT_TYPES] = {}; + uint32_t _port_colors[N_PORT_TYPES] = {}; + + Coord _window_location{0.0, 0.0}; + Coord _window_size{960.0, 540.0}; + + float _zoom = 1.0f; + float _font_size = 12.0f; + int _messages_height = 0; + bool _show_toolbar = true; + bool _sprung_layout = false; + bool _show_messages = false; + bool _sort_ports = true; }; #endif // PATCHAGE_CONFIGURATION_HPP diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 1432958..648640f 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -43,6 +43,8 @@ JackDriver::JackDriver(Patchage* app) : _app(app) , _client(nullptr) , _events(128) + , _last_pos{} + , _buffer_size(0) , _xruns(0) , _xrun_delay(0) , _is_activated(false) diff --git a/src/Patchage.cpp b/src/Patchage.cpp index 997365d..13011b1 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -116,6 +116,7 @@ Patchage::Patchage(int argc, char** argv) #endif , _jack_driver(nullptr) , _conf(nullptr) + , _gtk_main(nullptr) , INIT_WIDGET(_about_win) , INIT_WIDGET(_main_scrolledwin) , INIT_WIDGET(_main_win) diff --git a/src/PatchageEvent.hpp b/src/PatchageEvent.hpp index 34cf5fb..2bb239a 100644 --- a/src/PatchageEvent.hpp +++ b/src/PatchageEvent.hpp @@ -51,8 +51,7 @@ public: }; explicit PatchageEvent(Type type = Type::noop) - : _str(nullptr) - , _type(type) + : _type(type) {} PatchageEvent(Type type, const char* str) @@ -62,15 +61,13 @@ public: template PatchageEvent(Type type, P port) - : _str(nullptr) - , _port_1(port) + : _port_1(port) , _type(type) {} template PatchageEvent(Type type, P port_1, P port_2) - : _str(nullptr) - , _port_1(port_1, false) + : _port_1(port_1, false) , _port_2(port_2, true) , _type(type) {} @@ -80,7 +77,7 @@ public: inline Type type() const { return _type; } private: - char* _str; + char* _str{nullptr}; PortID _port_1; PortID _port_2; Type _type; diff --git a/src/PortID.hpp b/src/PortID.hpp index d830c0c..3dea5af 100644 --- a/src/PortID.hpp +++ b/src/PortID.hpp @@ -40,11 +40,7 @@ struct PortID alsa_addr, }; - PortID() - : type(Type::nothing) - { - memset(&id, 0, sizeof(id)); - } + PortID() = default; PortID(const PortID& copy) : type(copy.type) @@ -69,7 +65,7 @@ struct PortID } #endif - Type type; + Type type = Type::nothing; union { @@ -83,7 +79,7 @@ struct PortID bool is_input : 1; }; #endif - } id; + } id = {}; }; static inline std::ostream& -- cgit v1.2.1