From 91c256261af6d6e722a67cbab744c48bc674b4e4 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 4 Jan 2018 09:43:49 +0100 Subject: [PATCH] Apply clang-tidy fix 'modernize-use-default-member-init' --- lib/base/array.cpp | 6 ------ lib/base/array.hpp | 4 +--- lib/base/configobject.cpp | 3 --- lib/base/configobject.hpp | 3 --- lib/base/debuginfo.cpp | 4 ---- lib/base/debuginfo.hpp | 10 ++++------ lib/base/dictionary.cpp | 6 ------ lib/base/dictionary.hpp | 4 ---- lib/base/exception.cpp | 7 ------- lib/base/exception.hpp | 5 ++--- lib/base/fifo.cpp | 7 ------- lib/base/fifo.hpp | 9 ++++----- lib/base/json.cpp | 6 +----- lib/base/object.cpp | 7 ------- lib/base/object.hpp | 10 +++++----- lib/base/objectlock.cpp | 4 ---- lib/base/objectlock.hpp | 5 ++--- lib/base/objecttype.cpp | 3 --- lib/base/objecttype.hpp | 2 -- lib/base/perfdatavalue.hpp | 2 +- lib/base/socket.cpp | 8 -------- lib/base/socket.hpp | 4 ++-- lib/base/socketevents.hpp | 10 +++------- lib/base/stream.hpp | 12 ++++-------- lib/base/streamlogger.cpp | 7 ------- lib/base/streamlogger.hpp | 6 ++---- lib/base/string.cpp | 7 ------- lib/base/string.hpp | 4 +--- lib/base/threadpool.cpp | 2 +- lib/base/threadpool.hpp | 26 +++++++++++-------------- lib/base/timer.cpp | 7 ------- lib/base/timer.hpp | 9 ++++----- lib/base/type.cpp | 6 ------ lib/base/type.hpp | 3 --- lib/base/value.cpp | 6 ------ lib/base/value.hpp | 4 +--- lib/base/workqueue.cpp | 4 ++-- lib/base/workqueue.hpp | 22 ++++++++++----------- lib/checker/checkercomponent.cpp | 4 ---- lib/checker/checkercomponent.hpp | 4 +--- lib/config/configcompilercontext.cpp | 4 ---- lib/config/configcompilercontext.hpp | 4 +--- lib/config/configitembuilder.cpp | 9 --------- lib/config/configitembuilder.hpp | 8 ++++---- lib/config/expression.hpp | 4 ++-- lib/db_ido/dbconnection.cpp | 4 ---- lib/db_ido/dbconnection.hpp | 8 +++----- lib/db_ido/dbquery.hpp | 14 +++++-------- lib/db_ido/dbreference.cpp | 4 ---- lib/db_ido/dbreference.hpp | 4 ++-- lib/db_ido_mysql/idomysqlconnection.cpp | 6 +----- lib/db_ido_mysql/idomysqlconnection.hpp | 4 +--- lib/db_ido_pgsql/idopgsqlconnection.cpp | 1 - lib/db_ido_pgsql/idopgsqlconnection.hpp | 2 +- lib/icinga/checkable.cpp | 1 - lib/icinga/checkable.hpp | 2 +- lib/icinga/macroprocessor.cpp | 12 ++++-------- lib/livestatus/aggregator.cpp | 3 --- lib/livestatus/aggregator.hpp | 2 +- lib/livestatus/andfilter.cpp | 3 --- lib/livestatus/andfilter.hpp | 2 -- lib/livestatus/avgaggregator.hpp | 8 ++------ lib/livestatus/combinerfilter.cpp | 3 --- lib/livestatus/combinerfilter.hpp | 2 +- lib/livestatus/countaggregator.hpp | 6 +----- lib/livestatus/invavgaggregator.hpp | 8 ++------ lib/livestatus/invsumaggregator.hpp | 6 +----- lib/livestatus/maxaggregator.hpp | 6 +----- lib/livestatus/minaggregator.hpp | 6 +----- lib/livestatus/orfilter.cpp | 3 --- lib/livestatus/orfilter.hpp | 2 -- lib/livestatus/stdaggregator.hpp | 10 +++------- lib/livestatus/sumaggregator.hpp | 6 +----- lib/perfdata/elasticsearchwriter.cpp | 4 ---- lib/perfdata/elasticsearchwriter.hpp | 4 +--- lib/perfdata/gelfwriter.cpp | 4 ---- lib/perfdata/gelfwriter.hpp | 4 +--- lib/perfdata/graphitewriter.cpp | 4 ---- lib/perfdata/graphitewriter.hpp | 4 +--- lib/perfdata/influxdbwriter.cpp | 4 ---- lib/perfdata/influxdbwriter.hpp | 4 +--- lib/remote/apilistener.cpp | 1 - lib/remote/apilistener.hpp | 4 ++-- lib/remote/consolehandler.hpp | 8 ++------ lib/remote/endpoint.cpp | 4 ---- lib/remote/endpoint.hpp | 10 ++++------ lib/remote/url.cpp | 3 --- lib/remote/url.hpp | 2 +- tools/mkclass/classcompiler.hpp | 20 ++++++------------- 89 files changed, 120 insertions(+), 393 deletions(-) diff --git a/lib/base/array.cpp b/lib/base/array.cpp index dad3d39bc..2a00d3b29 100644 --- a/lib/base/array.cpp +++ b/lib/base/array.cpp @@ -32,16 +32,10 @@ template class std::vector; REGISTER_PRIMITIVE_TYPE(Array, Object, Array::GetPrototype()); -Array::Array() -{ } - Array::Array(std::initializer_list init) : m_Data(init) { } -Array::~Array() -{ } - /** * Restrieves a value from an array. * diff --git a/lib/base/array.hpp b/lib/base/array.hpp index c14d95c5e..36f4f62f9 100644 --- a/lib/base/array.hpp +++ b/lib/base/array.hpp @@ -47,11 +47,9 @@ public: typedef std::vector::size_type SizeType; - Array(); + Array() = default; Array(std::initializer_list init); - ~Array() override; - Value Get(SizeType index) const; void Set(SizeType index, const Value& value); void Set(SizeType index, Value&& value); diff --git a/lib/base/configobject.cpp b/lib/base/configobject.cpp index a4370d6df..d725afe92 100644 --- a/lib/base/configobject.cpp +++ b/lib/base/configobject.cpp @@ -46,9 +46,6 @@ REGISTER_TYPE_WITH_PROTOTYPE(ConfigObject, ConfigObject::GetPrototype()); boost::signals2::signal ConfigObject::OnStateChanged; -ConfigObject::ConfigObject() -{ } - bool ConfigObject::IsActive() const { return GetActive(); diff --git a/lib/base/configobject.hpp b/lib/base/configobject.hpp index 8ff068fc5..013f603dd 100644 --- a/lib/base/configobject.hpp +++ b/lib/base/configobject.hpp @@ -96,9 +96,6 @@ public: static Object::Ptr GetPrototype(); -protected: - explicit ConfigObject(); - private: ConfigObject::Ptr m_Zone; diff --git a/lib/base/debuginfo.cpp b/lib/base/debuginfo.cpp index 944505dd2..3071e20c9 100644 --- a/lib/base/debuginfo.cpp +++ b/lib/base/debuginfo.cpp @@ -23,10 +23,6 @@ using namespace icinga; -DebugInfo::DebugInfo() - : FirstLine(0), FirstColumn(0), LastLine(0), LastColumn(0) -{ } - /** * Outputs a DebugInfo struct to a stream. * diff --git a/lib/base/debuginfo.hpp b/lib/base/debuginfo.hpp index 0419c4897..836069e47 100644 --- a/lib/base/debuginfo.hpp +++ b/lib/base/debuginfo.hpp @@ -35,13 +35,11 @@ struct DebugInfo { String Path; - int FirstLine; - int FirstColumn; + int FirstLine{0}; + int FirstColumn{0}; - int LastLine; - int LastColumn; - - DebugInfo(); + int LastLine{0}; + int LastColumn{0}; }; std::ostream& operator<<(std::ostream& out, const DebugInfo& val); diff --git a/lib/base/dictionary.cpp b/lib/base/dictionary.cpp index 6726150c0..da80220b1 100644 --- a/lib/base/dictionary.cpp +++ b/lib/base/dictionary.cpp @@ -29,12 +29,6 @@ template class std::map; REGISTER_PRIMITIVE_TYPE(Dictionary, Object, Dictionary::GetPrototype()); -Dictionary::Dictionary() -{ } - -Dictionary::~Dictionary() -{ } - /** * Retrieves a value from a dictionary. * diff --git a/lib/base/dictionary.hpp b/lib/base/dictionary.hpp index 26c7c6a23..c1bd42c6f 100644 --- a/lib/base/dictionary.hpp +++ b/lib/base/dictionary.hpp @@ -49,10 +49,6 @@ public: typedef std::map::value_type Pair; - Dictionary(); - - ~Dictionary() override; - Value Get(const String& key) const; bool Get(const String& key, Value *result) const; void Set(const String& key, Value value); diff --git a/lib/base/exception.cpp b/lib/base/exception.cpp index 663ec3433..5d7f901b7 100644 --- a/lib/base/exception.cpp +++ b/lib/base/exception.cpp @@ -291,9 +291,6 @@ ScriptError::ScriptError(String message, DebugInfo di, bool incompleteExpr) : m_Message(std::move(message)), m_DebugInfo(std::move(di)), m_IncompleteExpr(incompleteExpr), m_HandledByDebugger(false) { } -ScriptError::~ScriptError() throw() -{ } - const char *ScriptError::what() const throw() { return m_Message.CStr(); @@ -319,10 +316,6 @@ void ScriptError::SetHandledByDebugger(bool handled) m_HandledByDebugger = handled; } -posix_error::posix_error() - : m_Message(nullptr) -{ } - posix_error::~posix_error() throw() { free(m_Message); diff --git a/lib/base/exception.hpp b/lib/base/exception.hpp index 208ac1d53..df41d4523 100644 --- a/lib/base/exception.hpp +++ b/lib/base/exception.hpp @@ -53,7 +53,7 @@ class ScriptError : virtual public user_error public: ScriptError(String message); ScriptError(String message, DebugInfo di, bool incompleteExpr = false); - ~ScriptError() throw() override; + ~ScriptError() throw() = default; const char *what(void) const throw() final; @@ -125,13 +125,12 @@ String DiagnosticInformation(const boost::exception_ptr& eptr, bool verbose = tr class posix_error : virtual public std::exception, virtual public boost::exception { public: - posix_error(); ~posix_error() throw() override; const char *what(void) const throw() final; private: - mutable char *m_Message; + mutable char *m_Message{nullptr}; }; #ifdef _WIN32 diff --git a/lib/base/fifo.cpp b/lib/base/fifo.cpp index e4912ce78..e0d295791 100644 --- a/lib/base/fifo.cpp +++ b/lib/base/fifo.cpp @@ -21,13 +21,6 @@ using namespace icinga; -/** - * Constructor for the FIFO class. - */ -FIFO::FIFO() - : m_Buffer(nullptr), m_DataSize(0), m_AllocSize(0), m_Offset(0) -{ } - /** * Destructor for the FIFO class. */ diff --git a/lib/base/fifo.hpp b/lib/base/fifo.hpp index 6efc87060..6b85a2842 100644 --- a/lib/base/fifo.hpp +++ b/lib/base/fifo.hpp @@ -38,7 +38,6 @@ public: static const size_t BlockSize = 512; - FIFO(); ~FIFO() override; size_t Peek(void *buffer, size_t count, bool allow_partial = false) override; @@ -52,10 +51,10 @@ public: size_t GetAvailableBytes() const; private: - char *m_Buffer; - size_t m_DataSize; - size_t m_AllocSize; - size_t m_Offset; + char *m_Buffer{nullptr}; + size_t m_DataSize{0}; + size_t m_AllocSize{0}; + size_t m_Offset{0}; void ResizeBuffer(size_t newSize, bool decrease); void Optimize(); diff --git a/lib/base/json.cpp b/lib/base/json.cpp index 0f4f5453e..ff9f04c49 100644 --- a/lib/base/json.cpp +++ b/lib/base/json.cpp @@ -126,12 +126,8 @@ String icinga::JsonEncode(const Value& value, bool pretty_print) struct JsonElement { String Key; - bool KeySet; + bool KeySet{false}; Value EValue; - - JsonElement() - : KeySet(false) - { } }; struct JsonContext diff --git a/lib/base/object.cpp b/lib/base/object.cpp index b8288c11a..add244396 100644 --- a/lib/base/object.cpp +++ b/lib/base/object.cpp @@ -38,13 +38,6 @@ static std::map l_ObjectCounts; static Timer::Ptr l_ObjectCountTimer; #endif /* I2_LEAK_DEBUG */ -/** - * Default constructor for the Object class. - */ -Object::Object() - : m_References(0), m_Mutex(0) -{ } - /** * Destructor for the Object class. */ diff --git a/lib/base/object.hpp b/lib/base/object.hpp index 6ebf66de6..40eae3431 100644 --- a/lib/base/object.hpp +++ b/lib/base/object.hpp @@ -109,7 +109,7 @@ class Object public: DECLARE_PTR_TYPEDEFS(Object); - Object(); + Object() = default; virtual ~Object(); virtual String ToString() const; @@ -139,11 +139,11 @@ public: static intrusive_ptr TypeInstance; private: - Object(const Object& other); - Object& operator=(const Object& rhs); + Object(const Object& other) = delete; + Object& operator=(const Object& rhs) = delete; - uintptr_t m_References; - mutable uintptr_t m_Mutex; + uintptr_t m_References{0}; + mutable uintptr_t m_Mutex{0}; #ifdef I2_DEBUG # ifndef _WIN32 diff --git a/lib/base/objectlock.cpp b/lib/base/objectlock.cpp index a1b4a8ae6..2abb43fba 100644 --- a/lib/base/objectlock.cpp +++ b/lib/base/objectlock.cpp @@ -25,10 +25,6 @@ using namespace icinga; #define I2MUTEX_UNLOCKED 0 #define I2MUTEX_LOCKED 1 -ObjectLock::ObjectLock() - : m_Object(nullptr), m_Locked(false) -{ } - ObjectLock::~ObjectLock() { Unlock(); diff --git a/lib/base/objectlock.hpp b/lib/base/objectlock.hpp index 469419770..1c2f993e8 100644 --- a/lib/base/objectlock.hpp +++ b/lib/base/objectlock.hpp @@ -31,7 +31,6 @@ namespace icinga struct ObjectLock { public: - ObjectLock(); ObjectLock(const Object::Ptr& object); ObjectLock(const Object *object); @@ -46,8 +45,8 @@ public: void Unlock(); private: - const Object *m_Object; - bool m_Locked; + const Object *m_Object{nullptr}; + bool m_Locked{false}; }; } diff --git a/lib/base/objecttype.cpp b/lib/base/objecttype.cpp index 48521a439..ed0a12bda 100644 --- a/lib/base/objecttype.cpp +++ b/lib/base/objecttype.cpp @@ -29,9 +29,6 @@ INITIALIZE_ONCE_WITH_PRIORITY([]() { Object::TypeInstance = type; }, 20); -ObjectType::ObjectType() -{ } - String ObjectType::GetName() const { return "Object"; diff --git a/lib/base/objecttype.hpp b/lib/base/objecttype.hpp index c1508e0d0..4fb0e5c3d 100644 --- a/lib/base/objecttype.hpp +++ b/lib/base/objecttype.hpp @@ -30,8 +30,6 @@ namespace icinga class ObjectType final : public Type { public: - ObjectType(); - String GetName() const override; Type::Ptr GetBaseType() const override; int GetAttributes() const override; diff --git a/lib/base/perfdatavalue.hpp b/lib/base/perfdatavalue.hpp index c5128f8a7..d79af942c 100644 --- a/lib/base/perfdatavalue.hpp +++ b/lib/base/perfdatavalue.hpp @@ -36,7 +36,7 @@ class PerfdataValue final : public ObjectImpl public: DECLARE_OBJECT(PerfdataValue); - PerfdataValue(); + PerfdataValue() = default; PerfdataValue(const String& label, double value, bool counter = false, const String& unit = "", const Value& warn = Empty, const Value& crit = Empty, diff --git a/lib/base/socket.cpp b/lib/base/socket.cpp index fc12a0b5f..fae5665f3 100644 --- a/lib/base/socket.cpp +++ b/lib/base/socket.cpp @@ -34,18 +34,10 @@ using namespace icinga; -/** - * Constructor for the Socket class. - */ -Socket::Socket() - : m_FD(INVALID_SOCKET) -{ } - /** * Constructor for the Socket class. */ Socket::Socket(SOCKET fd) - : m_FD(INVALID_SOCKET) { SetFD(fd); } diff --git a/lib/base/socket.hpp b/lib/base/socket.hpp index e606f46e5..464983a7c 100644 --- a/lib/base/socket.hpp +++ b/lib/base/socket.hpp @@ -36,7 +36,7 @@ class Socket : public Object public: DECLARE_PTR_TYPEDEFS(Socket); - Socket(); + Socket() = default; Socket(SOCKET fd); ~Socket() override; @@ -67,7 +67,7 @@ protected: mutable boost::mutex m_SocketMutex; private: - SOCKET m_FD; /**< The socket descriptor. */ + SOCKET m_FD{INVALID_SOCKET}; /**< The socket descriptor. */ static String GetAddressFromSockaddr(sockaddr *address, socklen_t len); }; diff --git a/lib/base/socketevents.hpp b/lib/base/socketevents.hpp index 1617e6114..7d7ae19fb 100644 --- a/lib/base/socketevents.hpp +++ b/lib/base/socketevents.hpp @@ -77,13 +77,9 @@ private: struct SocketEventDescriptor { - int Events; - SocketEvents *EventInterface; - Object *LifesupportObject; - - SocketEventDescriptor() - : Events(POLLIN), EventInterface(nullptr), LifesupportObject(nullptr) - { } + int Events{POLLIN}; + SocketEvents *EventInterface{nullptr}; + Object *LifesupportObject{nullptr}; }; struct EventDescription diff --git a/lib/base/stream.hpp b/lib/base/stream.hpp index f8a1b6426..0af5fb11a 100644 --- a/lib/base/stream.hpp +++ b/lib/base/stream.hpp @@ -38,10 +38,6 @@ enum ConnectionRole struct StreamReadContext { - StreamReadContext() - : Buffer(nullptr), Size(0), MustRead(true), Eof(false) - { } - ~StreamReadContext() { free(Buffer); @@ -50,10 +46,10 @@ struct StreamReadContext bool FillFromStream(const intrusive_ptr& stream, bool may_wait); void DropData(size_t count); - char *Buffer; - size_t Size; - bool MustRead; - bool Eof; + char *Buffer{nullptr}; + size_t Size{0}; + bool MustRead{true}; + bool Eof{false}; }; enum StreamReadStatus diff --git a/lib/base/streamlogger.cpp b/lib/base/streamlogger.cpp index de9613031..c92fbccbb 100644 --- a/lib/base/streamlogger.cpp +++ b/lib/base/streamlogger.cpp @@ -30,13 +30,6 @@ REGISTER_TYPE(StreamLogger); boost::mutex StreamLogger::m_Mutex; -/** - * Constructor for the StreamLogger class. - */ -StreamLogger::StreamLogger() - : m_Stream(nullptr), m_OwnsStream(false) -{ } - void StreamLogger::Stop(bool runtimeRemoved) { ObjectImpl::Stop(runtimeRemoved); diff --git a/lib/base/streamlogger.hpp b/lib/base/streamlogger.hpp index cf45e1461..6376610e7 100644 --- a/lib/base/streamlogger.hpp +++ b/lib/base/streamlogger.hpp @@ -38,8 +38,6 @@ class StreamLogger : public ObjectImpl public: DECLARE_OBJECT(StreamLogger); - StreamLogger(); - void Stop(bool runtimeRemoved) override; ~StreamLogger() override; @@ -53,8 +51,8 @@ protected: private: static boost::mutex m_Mutex; - std::ostream *m_Stream; - bool m_OwnsStream; + std::ostream *m_Stream{nullptr}; + bool m_OwnsStream{false}; Timer::Ptr m_FlushLogTimer; diff --git a/lib/base/string.cpp b/lib/base/string.cpp index 998a73ceb..393783674 100644 --- a/lib/base/string.cpp +++ b/lib/base/string.cpp @@ -31,10 +31,6 @@ REGISTER_BUILTIN_TYPE(String, String::GetPrototype()); const String::SizeType String::NPos = std::string::npos; -String::String() - : m_Data() -{ } - String::String(const char *data) : m_Data(data) { } @@ -62,9 +58,6 @@ String::String(Value&& other) } #endif /* _MSC_VER */ -String::~String() -{ } - String& String::operator=(Value&& other) { if (other.IsString()) diff --git a/lib/base/string.hpp b/lib/base/string.hpp index d8a8d7626..4a17eaeeb 100644 --- a/lib/base/string.hpp +++ b/lib/base/string.hpp @@ -58,7 +58,7 @@ public: typedef std::string::size_type SizeType; - String(); + String() = default; String(const char *data); String(std::string data); String(String::SizeType n, char c); @@ -69,8 +69,6 @@ public: String(Value&& other); #endif /* _MSC_VER */ - ~String(); - template String(InputIterator begin, InputIterator end) : m_Data(begin, end) diff --git a/lib/base/threadpool.cpp b/lib/base/threadpool.cpp index 4872652ec..cfee1f98e 100644 --- a/lib/base/threadpool.cpp +++ b/lib/base/threadpool.cpp @@ -30,7 +30,7 @@ using namespace icinga; int ThreadPool::m_NextID = 1; ThreadPool::ThreadPool(size_t max_threads) - : m_ID(m_NextID++), m_MaxThreads(max_threads), m_Stopped(true) + : m_ID(m_NextID++), m_MaxThreads(max_threads) { if (m_MaxThreads != UINT_MAX && m_MaxThreads < sizeof(m_Queues) / sizeof(m_Queues[0])) m_MaxThreads = sizeof(m_Queues) / sizeof(m_Queues[0]); diff --git a/lib/base/threadpool.hpp b/lib/base/threadpool.hpp index 34cb432cf..06277c70c 100644 --- a/lib/base/threadpool.hpp +++ b/lib/base/threadpool.hpp @@ -75,14 +75,14 @@ private: struct WorkerThread { - ThreadState State; - bool Zombie; - double Utilization; - double LastUpdate; - boost::thread *Thread; + ThreadState State{ThreadDead}; + bool Zombie{false}; + double Utilization{0}; + double LastUpdate{0}; + boost::thread *Thread{nullptr}; WorkerThread(ThreadState state = ThreadDead) - : State(state), Zombie(false), Utilization(0), LastUpdate(0), Thread(nullptr) + : State(state) { } void UpdateUtilization(ThreadState state = ThreadUnspecified); @@ -98,18 +98,14 @@ private: std::deque Items; - double WaitTime; - double ServiceTime; - int TaskCount; + double WaitTime{0}; + double ServiceTime{0}; + int TaskCount{0}; - bool Stopped; + bool Stopped{false}; WorkerThread Threads[16]; - Queue() - : WaitTime(0), ServiceTime(0), TaskCount(0), Stopped(false) - { } - void SpawnWorker(boost::thread_group& group); void KillWorker(boost::thread_group& group); }; @@ -124,7 +120,7 @@ private: std::thread m_MgmtThread; boost::mutex m_MgmtMutex; boost::condition_variable m_MgmtCV; - bool m_Stopped; + bool m_Stopped{true}; Queue m_Queues[QUEUECOUNT]; diff --git a/lib/base/timer.cpp b/lib/base/timer.cpp index e030bcb4d..d862f8088 100644 --- a/lib/base/timer.cpp +++ b/lib/base/timer.cpp @@ -73,13 +73,6 @@ static bool l_StopTimerThread; static TimerSet l_Timers; static int l_AliveTimers; -/** - * Constructor for the Timer class. - */ -Timer::Timer() - : m_Interval(0), m_Next(0), m_Started(false), m_Running(false) -{ } - /** * Destructor for the Timer class. */ diff --git a/lib/base/timer.hpp b/lib/base/timer.hpp index 639b5f5a1..6d5e115ef 100644 --- a/lib/base/timer.hpp +++ b/lib/base/timer.hpp @@ -38,7 +38,6 @@ class Timer final : public Object public: DECLARE_PTR_TYPEDEFS(Timer); - Timer(); ~Timer() override; static void Uninitialize(); @@ -57,10 +56,10 @@ public: boost::signals2::signal OnTimerExpired; private: - double m_Interval; /**< The interval of the timer. */ - double m_Next; /**< When the next event should happen. */ - bool m_Started; /**< Whether the timer is enabled. */ - bool m_Running; /**< Whether the timer proc is currently running. */ + double m_Interval{0}; /**< The interval of the timer. */ + double m_Next{0}; /**< When the next event should happen. */ + bool m_Started{false}; /**< Whether the timer is enabled. */ + bool m_Running{false}; /**< Whether the timer proc is currently running. */ void Call(); void InternalReschedule(bool completed, double next = -1); diff --git a/lib/base/type.cpp b/lib/base/type.cpp index e4918e9b9..19f1bb5d9 100644 --- a/lib/base/type.cpp +++ b/lib/base/type.cpp @@ -32,12 +32,6 @@ INITIALIZE_ONCE_WITH_PRIORITY([]() { Type::Register(type); }, 20); -Type::Type() -{ } - -Type::~Type() -{ } - String Type::ToString() const { return "type '" + GetName() + "'"; diff --git a/lib/base/type.hpp b/lib/base/type.hpp index 56563adc6..10b8524fe 100644 --- a/lib/base/type.hpp +++ b/lib/base/type.hpp @@ -75,9 +75,6 @@ class Type : public Object public: DECLARE_OBJECT(Type); - Type(); - ~Type() override; - String ToString() const override; virtual String GetName() const = 0; diff --git a/lib/base/value.cpp b/lib/base/value.cpp index 8fe55e851..93c515a2b 100644 --- a/lib/base/value.cpp +++ b/lib/base/value.cpp @@ -32,9 +32,6 @@ template const Object::Ptr& Value::Get() const; Value icinga::Empty; -Value::Value() -{ } - Value::Value(std::nullptr_t) { } @@ -105,9 +102,6 @@ Value::Value(const intrusive_ptr& value) m_Value = value; } -Value::~Value() -{ } - Value& Value::operator=(const Value& other) { m_Value = other.m_Value; diff --git a/lib/base/value.hpp b/lib/base/value.hpp index bff889ec8..29ca2e9f7 100644 --- a/lib/base/value.hpp +++ b/lib/base/value.hpp @@ -52,7 +52,7 @@ enum ValueType class Value { public: - Value(); + Value() = default; Value(std::nullptr_t); Value(int value); Value(unsigned int value); @@ -77,8 +77,6 @@ public: static_assert(!std::is_same::value, "T must not be Object"); } - ~Value(); - bool ToBool() const; operator double() const; diff --git a/lib/base/workqueue.cpp b/lib/base/workqueue.cpp index 53291862b..f8247bb7e 100644 --- a/lib/base/workqueue.cpp +++ b/lib/base/workqueue.cpp @@ -31,8 +31,8 @@ std::atomic WorkQueue::m_NextID(1); boost::thread_specific_ptr l_ThreadWorkQueue; WorkQueue::WorkQueue(size_t maxItems, int threadCount) - : m_ID(m_NextID++), m_ThreadCount(threadCount), m_Spawned(false), m_MaxItems(maxItems), m_Stopped(false), - m_Processing(0), m_NextTaskID(0), m_TaskStats(15 * 60), m_PendingTasks(0), m_PendingTasksTimestamp(0) + : m_ID(m_NextID++), m_ThreadCount(threadCount), m_MaxItems(maxItems), + m_TaskStats(15 * 60) { /* Initialize logger. */ m_StatusTimerTimeout = Utility::GetTime(); diff --git a/lib/base/workqueue.hpp b/lib/base/workqueue.hpp index 82d4e2dfe..955651b4a 100644 --- a/lib/base/workqueue.hpp +++ b/lib/base/workqueue.hpp @@ -43,17 +43,15 @@ enum WorkQueuePriority struct Task { - Task() - : Priority(PriorityNormal), ID(-1) - { } + Task() = default; - Task(std::function&& function, WorkQueuePriority priority, int id) + Task(std::function function, WorkQueuePriority priority, int id) : Function(std::move(function)), Priority(priority), ID(id) { } std::function Function; - WorkQueuePriority Priority; - int ID; + WorkQueuePriority Priority{PriorityNormal}; + int ID{-1}; }; inline bool operator<(const Task& a, const Task& b) @@ -110,7 +108,7 @@ private: String m_Name; static std::atomic m_NextID; int m_ThreadCount; - bool m_Spawned; + bool m_Spawned{false}; mutable boost::mutex m_Mutex; boost::condition_variable m_CVEmpty; @@ -118,10 +116,10 @@ private: boost::condition_variable m_CVStarved; boost::thread_group m_Threads; size_t m_MaxItems; - bool m_Stopped; - int m_Processing; + bool m_Stopped{false}; + int m_Processing{0}; std::priority_queue > m_Tasks; - int m_NextTaskID; + int m_NextTaskID{0}; ExceptionCallback m_ExceptionCallback; std::vector m_Exceptions; Timer::Ptr m_StatusTimer; @@ -129,8 +127,8 @@ private: mutable boost::mutex m_StatsMutex; RingBuffer m_TaskStats; - size_t m_PendingTasks; - double m_PendingTasksTimestamp; + size_t m_PendingTasks{0}; + double m_PendingTasksTimestamp{0}; void WorkerThreadProc(); void StatusTimerHandler(); diff --git a/lib/checker/checkercomponent.cpp b/lib/checker/checkercomponent.cpp index e9cbf998d..bb30b6836 100644 --- a/lib/checker/checkercomponent.cpp +++ b/lib/checker/checkercomponent.cpp @@ -59,10 +59,6 @@ void CheckerComponent::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr status->Set("checkercomponent", nodes); } -CheckerComponent::CheckerComponent() - : m_Stopped(false) -{ } - void CheckerComponent::OnConfigLoaded() { ConfigObject::OnActiveChanged.connect(std::bind(&CheckerComponent::ObjectHandler, this, _1)); diff --git a/lib/checker/checkercomponent.hpp b/lib/checker/checkercomponent.hpp index f89e53452..fd67b9445 100644 --- a/lib/checker/checkercomponent.hpp +++ b/lib/checker/checkercomponent.hpp @@ -77,8 +77,6 @@ public: > > CheckableSet; - CheckerComponent(); - void OnConfigLoaded() override; void Start(bool runtimeCreated) override; void Stop(bool runtimeRemoved) override; @@ -90,7 +88,7 @@ public: private: boost::mutex m_Mutex; boost::condition_variable m_CV; - bool m_Stopped; + bool m_Stopped{false}; std::thread m_Thread; CheckableSet m_IdleCheckables; diff --git a/lib/config/configcompilercontext.cpp b/lib/config/configcompilercontext.cpp index e6596c601..b298a33ec 100644 --- a/lib/config/configcompilercontext.cpp +++ b/lib/config/configcompilercontext.cpp @@ -31,10 +31,6 @@ ConfigCompilerContext *ConfigCompilerContext::GetInstance() return Singleton::GetInstance(); } -ConfigCompilerContext::ConfigCompilerContext() - : m_ObjectsFP(nullptr) -{ } - void ConfigCompilerContext::OpenObjectsFile(const String& filename) { m_ObjectsPath = filename; diff --git a/lib/config/configcompilercontext.hpp b/lib/config/configcompilercontext.hpp index e0e49dc98..7a7fb54c8 100644 --- a/lib/config/configcompilercontext.hpp +++ b/lib/config/configcompilercontext.hpp @@ -34,8 +34,6 @@ namespace icinga class ConfigCompilerContext { public: - ConfigCompilerContext(); - void OpenObjectsFile(const String& filename); void WriteObject(const Dictionary::Ptr& object); void CancelObjectsFile(); @@ -46,7 +44,7 @@ public: private: String m_ObjectsPath; String m_ObjectsTempFile; - std::fstream *m_ObjectsFP; + std::fstream *m_ObjectsFP{nullptr}; mutable boost::mutex m_Mutex; }; diff --git a/lib/config/configitembuilder.cpp b/lib/config/configitembuilder.cpp index b017daafe..e37430dea 100644 --- a/lib/config/configitembuilder.cpp +++ b/lib/config/configitembuilder.cpp @@ -23,15 +23,6 @@ using namespace icinga; -ConfigItemBuilder::ConfigItemBuilder() - : m_Abstract(false), m_DefaultTmpl(false), m_IgnoreOnError(false) -{ - m_DebugInfo.FirstLine = 0; - m_DebugInfo.FirstColumn = 0; - m_DebugInfo.LastLine = 0; - m_DebugInfo.LastColumn = 0; -} - ConfigItemBuilder::ConfigItemBuilder(const DebugInfo& debugInfo) : m_Abstract(false), m_DefaultTmpl(false), m_IgnoreOnError(false) { diff --git a/lib/config/configitembuilder.hpp b/lib/config/configitembuilder.hpp index 250d28853..a9f9ea506 100644 --- a/lib/config/configitembuilder.hpp +++ b/lib/config/configitembuilder.hpp @@ -39,7 +39,7 @@ class ConfigItemBuilder final : public Object public: DECLARE_PTR_TYPEDEFS(ConfigItemBuilder); - ConfigItemBuilder(); + ConfigItemBuilder() = default; explicit ConfigItemBuilder(const DebugInfo& debugInfo); void SetType(const Type::Ptr& type); @@ -59,15 +59,15 @@ public: private: Type::Ptr m_Type; /**< The object type. */ String m_Name; /**< The name. */ - bool m_Abstract; /**< Whether the item is abstract. */ + bool m_Abstract{false}; /**< Whether the item is abstract. */ std::vector > m_Expressions; /**< Expressions for this item. */ std::shared_ptr m_Filter; /**< Filter expression. */ DebugInfo m_DebugInfo; /**< Debug information. */ Dictionary::Ptr m_Scope; /**< variable scope. */ String m_Zone; /**< The zone. */ String m_Package; /**< The package name. */ - bool m_DefaultTmpl; - bool m_IgnoreOnError; /**< Whether the object should be ignored when an error occurs in one of the expressions. */ + bool m_DefaultTmpl{false}; + bool m_IgnoreOnError{false}; /**< Whether the object should be ignored when an error occurs in one of the expressions. */ }; } diff --git a/lib/config/expression.hpp b/lib/config/expression.hpp index 8c2882cdd..ce3f438e6 100644 --- a/lib/config/expression.hpp +++ b/lib/config/expression.hpp @@ -599,7 +599,7 @@ class DictExpression final : public DebuggableExpression { public: DictExpression(std::vector >&& expressions = {}, const DebugInfo& debugInfo = DebugInfo()) - : DebuggableExpression(debugInfo), m_Expressions(std::move(expressions)), m_Inline(false) + : DebuggableExpression(debugInfo), m_Expressions(std::move(expressions)) { } void MakeInline(); @@ -609,7 +609,7 @@ protected: private: std::vector > m_Expressions; - bool m_Inline; + bool m_Inline{false}; friend void BindToScope(std::unique_ptr& expr, ScopeSpecifier scopeSpec); }; diff --git a/lib/db_ido/dbconnection.cpp b/lib/db_ido/dbconnection.cpp index 496b65614..9249697de 100644 --- a/lib/db_ido/dbconnection.cpp +++ b/lib/db_ido/dbconnection.cpp @@ -37,10 +37,6 @@ REGISTER_TYPE(DbConnection); Timer::Ptr DbConnection::m_ProgramStatusTimer; boost::once_flag DbConnection::m_OnceFlag = BOOST_ONCE_INIT; -DbConnection::DbConnection() - : m_IDCacheValid(false), m_QueryStats(15 * 60), m_ActiveChangedHandler(false) -{ } - void DbConnection::OnConfigLoaded() { ConfigObject::OnConfigLoaded(); diff --git a/lib/db_ido/dbconnection.hpp b/lib/db_ido/dbconnection.hpp index ea8cd7ac8..932e3e1b4 100644 --- a/lib/db_ido/dbconnection.hpp +++ b/lib/db_ido/dbconnection.hpp @@ -45,8 +45,6 @@ class DbConnection : public ObjectImpl public: DECLARE_OBJECT(DbConnection); - DbConnection(); - static void InitializeDbTimer(); void SetConfigHash(const DbObject::Ptr& dbobj, const String& hash); @@ -112,7 +110,7 @@ protected: static int GetSessionToken(); private: - bool m_IDCacheValid; + bool m_IDCacheValid{false}; std::map, String> m_ConfigHashes; std::map m_ObjectIDs; std::map, DbReference> m_InsertIDs; @@ -129,8 +127,8 @@ private: static void InsertRuntimeVariable(const String& key, const Value& value); mutable boost::mutex m_StatsMutex; - RingBuffer m_QueryStats; - bool m_ActiveChangedHandler; + RingBuffer m_QueryStats{15 * 60}; + bool m_ActiveChangedHandler{false}; }; struct database_error : virtual std::exception, virtual boost::exception { }; diff --git a/lib/db_ido/dbquery.hpp b/lib/db_ido/dbquery.hpp index 40c481ea9..fe1220681 100644 --- a/lib/db_ido/dbquery.hpp +++ b/lib/db_ido/dbquery.hpp @@ -62,24 +62,20 @@ class DbObject; struct DbQuery { - int Type; - DbQueryCategory Category; + int Type{0}; + DbQueryCategory Category{DbCatInvalid}; String Table; String IdColumn; Dictionary::Ptr Fields; Dictionary::Ptr WhereCriteria; intrusive_ptr Object; DbValue::Ptr NotificationInsertID; - bool ConfigUpdate; - bool StatusUpdate; - WorkQueuePriority Priority; + bool ConfigUpdate{false}; + bool StatusUpdate{false}; + WorkQueuePriority Priority{PriorityNormal}; static void StaticInitialize(); - DbQuery() - : Type(0), Category(DbCatInvalid), ConfigUpdate(false), StatusUpdate(false), Priority(PriorityNormal) - { } - static const std::map& GetCategoryFilterMap(); private: diff --git a/lib/db_ido/dbreference.cpp b/lib/db_ido/dbreference.cpp index 971001a23..f2eba39bf 100644 --- a/lib/db_ido/dbreference.cpp +++ b/lib/db_ido/dbreference.cpp @@ -21,10 +21,6 @@ using namespace icinga; -DbReference::DbReference() - : m_Id(-1) -{ } - DbReference::DbReference(long id) : m_Id(id) { } diff --git a/lib/db_ido/dbreference.hpp b/lib/db_ido/dbreference.hpp index d547d83b1..eef22157a 100644 --- a/lib/db_ido/dbreference.hpp +++ b/lib/db_ido/dbreference.hpp @@ -33,13 +33,13 @@ namespace icinga struct DbReference { public: - DbReference(); + DbReference() = default; DbReference(long id); bool IsValid() const; operator long() const; private: - long m_Id; + long m_Id{-1}; }; } diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index 28b60e0dc..999d90161 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -38,10 +38,6 @@ using namespace icinga; REGISTER_TYPE(IdoMysqlConnection); REGISTER_STATSFUNCTION(IdoMysqlConnection, &IdoMysqlConnection::StatsFunc); -IdoMysqlConnection::IdoMysqlConnection() - : m_QueryQueue(10000000) -{ } - void IdoMysqlConnection::OnConfigLoaded() { ObjectImpl::OnConfigLoaded(); @@ -654,7 +650,7 @@ DbReference IdoMysqlConnection::GetLastInsertID() { AssertOnWorkQueue(); - return {m_Mysql->insert_id(&m_Connection)}; + return {static_cast(m_Mysql->insert_id(&m_Connection))}; } int IdoMysqlConnection::GetAffectedRows() diff --git a/lib/db_ido_mysql/idomysqlconnection.hpp b/lib/db_ido_mysql/idomysqlconnection.hpp index 67fba0101..fa2383cd4 100644 --- a/lib/db_ido_mysql/idomysqlconnection.hpp +++ b/lib/db_ido_mysql/idomysqlconnection.hpp @@ -51,8 +51,6 @@ public: DECLARE_OBJECT(IdoMysqlConnection); DECLARE_OBJECTNAME(IdoMysqlConnection); - IdoMysqlConnection(); - static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); int GetPendingQueryCount() const override; @@ -73,7 +71,7 @@ protected: private: DbReference m_InstanceID; - WorkQueue m_QueryQueue; + WorkQueue m_QueryQueue{10000000}; Library m_Library; std::unique_ptr m_Mysql; diff --git a/lib/db_ido_pgsql/idopgsqlconnection.cpp b/lib/db_ido_pgsql/idopgsqlconnection.cpp index e4da2c151..dbc8c1732 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.cpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.cpp @@ -41,7 +41,6 @@ REGISTER_TYPE(IdoPgsqlConnection); REGISTER_STATSFUNCTION(IdoPgsqlConnection, &IdoPgsqlConnection::StatsFunc); IdoPgsqlConnection::IdoPgsqlConnection() - : m_QueryQueue(1000000) { m_QueryQueue.SetName("IdoPgsqlConnection, " + GetName()); } diff --git a/lib/db_ido_pgsql/idopgsqlconnection.hpp b/lib/db_ido_pgsql/idopgsqlconnection.hpp index 1d0e2f710..b00a4b707 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.hpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.hpp @@ -65,7 +65,7 @@ protected: private: DbReference m_InstanceID; - WorkQueue m_QueryQueue; + WorkQueue m_QueryQueue{1000000}; Library m_Library; std::unique_ptr m_Pgsql; diff --git a/lib/icinga/checkable.cpp b/lib/icinga/checkable.cpp index 31532f73a..13852e94e 100644 --- a/lib/icinga/checkable.cpp +++ b/lib/icinga/checkable.cpp @@ -44,7 +44,6 @@ void Checkable::StaticInitialize() } Checkable::Checkable() - : m_CheckRunning(false) { SetSchedulingOffset(Utility::Random()); } diff --git a/lib/icinga/checkable.hpp b/lib/icinga/checkable.hpp index 202a7eca6..b2061be29 100644 --- a/lib/icinga/checkable.hpp +++ b/lib/icinga/checkable.hpp @@ -206,7 +206,7 @@ protected: private: mutable boost::mutex m_CheckableMutex; - bool m_CheckRunning; + bool m_CheckRunning{false}; long m_SchedulingOffset; static boost::mutex m_StatsMutex; diff --git a/lib/icinga/macroprocessor.cpp b/lib/icinga/macroprocessor.cpp index c5bc72e1c..9a0e7840f 100644 --- a/lib/icinga/macroprocessor.cpp +++ b/lib/icinga/macroprocessor.cpp @@ -422,17 +422,13 @@ Value MacroProcessor::EscapeMacroShellArg(const Value& value) struct CommandArgument { - int Order; - bool SkipKey; - bool RepeatKey; - bool SkipValue; + int Order{0}; + bool SkipKey{false}; + bool RepeatKey{true}; + bool SkipValue{false}; String Key; Value AValue; - CommandArgument() - : Order(0), SkipKey(false), RepeatKey(true), SkipValue(false) - { } - bool operator<(const CommandArgument& rhs) const { return Order < rhs.Order; diff --git a/lib/livestatus/aggregator.cpp b/lib/livestatus/aggregator.cpp index 16aaadcda..1cc4b9762 100644 --- a/lib/livestatus/aggregator.cpp +++ b/lib/livestatus/aggregator.cpp @@ -21,9 +21,6 @@ using namespace icinga; -Aggregator::Aggregator() -{ } - void Aggregator::SetFilter(const Filter::Ptr& filter) { m_Filter = filter; diff --git a/lib/livestatus/aggregator.hpp b/lib/livestatus/aggregator.hpp index f37b0e566..28aa60355 100644 --- a/lib/livestatus/aggregator.hpp +++ b/lib/livestatus/aggregator.hpp @@ -48,7 +48,7 @@ public: void SetFilter(const Filter::Ptr& filter); protected: - Aggregator(); + Aggregator() = default; Filter::Ptr GetFilter() const; diff --git a/lib/livestatus/andfilter.cpp b/lib/livestatus/andfilter.cpp index 4b73eedc6..66b46766b 100644 --- a/lib/livestatus/andfilter.cpp +++ b/lib/livestatus/andfilter.cpp @@ -21,9 +21,6 @@ using namespace icinga; -AndFilter::AndFilter() -{ } - bool AndFilter::Apply(const Table::Ptr& table, const Value& row) { for (const Filter::Ptr& filter : m_Filters) { diff --git a/lib/livestatus/andfilter.hpp b/lib/livestatus/andfilter.hpp index 9d7303038..cdbd21752 100644 --- a/lib/livestatus/andfilter.hpp +++ b/lib/livestatus/andfilter.hpp @@ -35,8 +35,6 @@ class AndFilter final : public CombinerFilter public: DECLARE_PTR_TYPEDEFS(AndFilter); - AndFilter(); - bool Apply(const Table::Ptr& table, const Value& row) override; }; diff --git a/lib/livestatus/avgaggregator.hpp b/lib/livestatus/avgaggregator.hpp index 183ddb059..664134832 100644 --- a/lib/livestatus/avgaggregator.hpp +++ b/lib/livestatus/avgaggregator.hpp @@ -31,12 +31,8 @@ namespace icinga */ struct AvgAggregatorState final : public AggregatorState { - AvgAggregatorState() - : Avg(0), AvgCount(0) - { } - - double Avg; - double AvgCount; + double Avg{0}; + double AvgCount{0}; }; /** diff --git a/lib/livestatus/combinerfilter.cpp b/lib/livestatus/combinerfilter.cpp index 5a4ca1414..0657b8397 100644 --- a/lib/livestatus/combinerfilter.cpp +++ b/lib/livestatus/combinerfilter.cpp @@ -21,9 +21,6 @@ using namespace icinga; -CombinerFilter::CombinerFilter() -{ } - void CombinerFilter::AddSubFilter(const Filter::Ptr& filter) { m_Filters.push_back(filter); diff --git a/lib/livestatus/combinerfilter.hpp b/lib/livestatus/combinerfilter.hpp index 63e614e84..56b7e9b90 100644 --- a/lib/livestatus/combinerfilter.hpp +++ b/lib/livestatus/combinerfilter.hpp @@ -40,7 +40,7 @@ public: protected: std::vector m_Filters; - CombinerFilter(); + CombinerFilter() = default; }; } diff --git a/lib/livestatus/countaggregator.hpp b/lib/livestatus/countaggregator.hpp index 22e110cd6..5b4d19588 100644 --- a/lib/livestatus/countaggregator.hpp +++ b/lib/livestatus/countaggregator.hpp @@ -31,11 +31,7 @@ namespace icinga */ struct CountAggregatorState final : public AggregatorState { - CountAggregatorState() - : Count(0) - { } - - int Count; + int Count{0}; }; /** diff --git a/lib/livestatus/invavgaggregator.hpp b/lib/livestatus/invavgaggregator.hpp index 05a255da8..d8e43d6aa 100644 --- a/lib/livestatus/invavgaggregator.hpp +++ b/lib/livestatus/invavgaggregator.hpp @@ -31,12 +31,8 @@ namespace icinga */ struct InvAvgAggregatorState final : public AggregatorState { - InvAvgAggregatorState() - : InvAvg(0), InvAvgCount(0) - { } - - double InvAvg; - double InvAvgCount; + double InvAvg{0}; + double InvAvgCount{0}; }; /** diff --git a/lib/livestatus/invsumaggregator.hpp b/lib/livestatus/invsumaggregator.hpp index 65b8d026d..709928fd1 100644 --- a/lib/livestatus/invsumaggregator.hpp +++ b/lib/livestatus/invsumaggregator.hpp @@ -31,11 +31,7 @@ namespace icinga */ struct InvSumAggregatorState final : public AggregatorState { - InvSumAggregatorState() - : InvSum(0) - { } - - double InvSum; + double InvSum{0}; }; /** diff --git a/lib/livestatus/maxaggregator.hpp b/lib/livestatus/maxaggregator.hpp index fd102d1f2..3207159f1 100644 --- a/lib/livestatus/maxaggregator.hpp +++ b/lib/livestatus/maxaggregator.hpp @@ -31,11 +31,7 @@ namespace icinga */ struct MaxAggregatorState final : public AggregatorState { - MaxAggregatorState() - : Max(0) - { } - - double Max; + double Max{0}; }; /** diff --git a/lib/livestatus/minaggregator.hpp b/lib/livestatus/minaggregator.hpp index b9560937d..76be4d10e 100644 --- a/lib/livestatus/minaggregator.hpp +++ b/lib/livestatus/minaggregator.hpp @@ -32,11 +32,7 @@ namespace icinga */ struct MinAggregatorState final : public AggregatorState { - MinAggregatorState() - : Min(DBL_MAX) - { } - - double Min; + double Min{DBL_MAX}; }; /** diff --git a/lib/livestatus/orfilter.cpp b/lib/livestatus/orfilter.cpp index 586eec50c..14da7b7a2 100644 --- a/lib/livestatus/orfilter.cpp +++ b/lib/livestatus/orfilter.cpp @@ -21,9 +21,6 @@ using namespace icinga; -OrFilter::OrFilter() -{ } - bool OrFilter::Apply(const Table::Ptr& table, const Value& row) { if (m_Filters.empty()) diff --git a/lib/livestatus/orfilter.hpp b/lib/livestatus/orfilter.hpp index be308ecf6..d37f2e09f 100644 --- a/lib/livestatus/orfilter.hpp +++ b/lib/livestatus/orfilter.hpp @@ -35,8 +35,6 @@ class OrFilter final : public CombinerFilter public: DECLARE_PTR_TYPEDEFS(OrFilter); - OrFilter(); - bool Apply(const Table::Ptr& table, const Value& row) override; }; diff --git a/lib/livestatus/stdaggregator.hpp b/lib/livestatus/stdaggregator.hpp index 75c4e3e86..e7b0509eb 100644 --- a/lib/livestatus/stdaggregator.hpp +++ b/lib/livestatus/stdaggregator.hpp @@ -31,13 +31,9 @@ namespace icinga */ struct StdAggregatorState final : public AggregatorState { - StdAggregatorState() - : StdSum(0), StdQSum(0), StdCount(0) - { } - - double StdSum; - double StdQSum; - double StdCount; + double StdSum{0}; + double StdQSum{0}; + double StdCount{0}; }; /** diff --git a/lib/livestatus/sumaggregator.hpp b/lib/livestatus/sumaggregator.hpp index b2359e642..030d15761 100644 --- a/lib/livestatus/sumaggregator.hpp +++ b/lib/livestatus/sumaggregator.hpp @@ -31,11 +31,7 @@ namespace icinga */ struct SumAggregatorState final : public AggregatorState { - SumAggregatorState() - : Sum(0) - { } - - double Sum; + double Sum{0}; }; /** diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp index c5e689f27..cfea33819 100644 --- a/lib/perfdata/elasticsearchwriter.cpp +++ b/lib/perfdata/elasticsearchwriter.cpp @@ -44,10 +44,6 @@ REGISTER_TYPE(ElasticsearchWriter); REGISTER_STATSFUNCTION(ElasticsearchWriter, &ElasticsearchWriter::StatsFunc); -ElasticsearchWriter::ElasticsearchWriter() - : m_WorkQueue(10000000, 1) -{ } - void ElasticsearchWriter::OnConfigLoaded() { ObjectImpl::OnConfigLoaded(); diff --git a/lib/perfdata/elasticsearchwriter.hpp b/lib/perfdata/elasticsearchwriter.hpp index 4779fefb2..a1732ee84 100644 --- a/lib/perfdata/elasticsearchwriter.hpp +++ b/lib/perfdata/elasticsearchwriter.hpp @@ -35,8 +35,6 @@ public: DECLARE_OBJECT(ElasticsearchWriter); DECLARE_OBJECTNAME(ElasticsearchWriter); - ElasticsearchWriter(); - static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); static String FormatTimestamp(double ts); @@ -48,7 +46,7 @@ protected: private: String m_EventPrefix; - WorkQueue m_WorkQueue; + WorkQueue m_WorkQueue{10000000, 1}; Timer::Ptr m_FlushTimer; std::vector m_DataBuffer; boost::mutex m_DataBufferMutex; diff --git a/lib/perfdata/gelfwriter.cpp b/lib/perfdata/gelfwriter.cpp index 490672f33..6742a11da 100644 --- a/lib/perfdata/gelfwriter.cpp +++ b/lib/perfdata/gelfwriter.cpp @@ -46,10 +46,6 @@ REGISTER_TYPE(GelfWriter); REGISTER_STATSFUNCTION(GelfWriter, &GelfWriter::StatsFunc); -GelfWriter::GelfWriter() - : m_WorkQueue(10000000, 1) -{ } - void GelfWriter::OnConfigLoaded() { ObjectImpl::OnConfigLoaded(); diff --git a/lib/perfdata/gelfwriter.hpp b/lib/perfdata/gelfwriter.hpp index 261046e4e..0576ede1b 100644 --- a/lib/perfdata/gelfwriter.hpp +++ b/lib/perfdata/gelfwriter.hpp @@ -42,8 +42,6 @@ public: DECLARE_OBJECT(GelfWriter); DECLARE_OBJECTNAME(GelfWriter); - GelfWriter(); - static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); protected: @@ -53,7 +51,7 @@ protected: private: Stream::Ptr m_Stream; - WorkQueue m_WorkQueue; + WorkQueue m_WorkQueue{10000000, 1}; Timer::Ptr m_ReconnectTimer; diff --git a/lib/perfdata/graphitewriter.cpp b/lib/perfdata/graphitewriter.cpp index bb5f20bda..c1e832128 100644 --- a/lib/perfdata/graphitewriter.cpp +++ b/lib/perfdata/graphitewriter.cpp @@ -46,10 +46,6 @@ REGISTER_TYPE(GraphiteWriter); REGISTER_STATSFUNCTION(GraphiteWriter, &GraphiteWriter::StatsFunc); -GraphiteWriter::GraphiteWriter() - : m_WorkQueue(10000000, 1) -{ } - void GraphiteWriter::OnConfigLoaded() { ObjectImpl::OnConfigLoaded(); diff --git a/lib/perfdata/graphitewriter.hpp b/lib/perfdata/graphitewriter.hpp index 7c0606580..e5652add0 100644 --- a/lib/perfdata/graphitewriter.hpp +++ b/lib/perfdata/graphitewriter.hpp @@ -42,8 +42,6 @@ public: DECLARE_OBJECT(GraphiteWriter); DECLARE_OBJECTNAME(GraphiteWriter); - GraphiteWriter(); - static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); void ValidateHostNameTemplate(const String& value, const ValidationUtils& utils) override; @@ -56,7 +54,7 @@ protected: private: Stream::Ptr m_Stream; - WorkQueue m_WorkQueue; + WorkQueue m_WorkQueue{10000000, 1}; Timer::Ptr m_ReconnectTimer; diff --git a/lib/perfdata/influxdbwriter.cpp b/lib/perfdata/influxdbwriter.cpp index 3121d2ab9..ef1a4dd52 100644 --- a/lib/perfdata/influxdbwriter.cpp +++ b/lib/perfdata/influxdbwriter.cpp @@ -72,10 +72,6 @@ REGISTER_TYPE(InfluxdbWriter); REGISTER_STATSFUNCTION(InfluxdbWriter, &InfluxdbWriter::StatsFunc); -InfluxdbWriter::InfluxdbWriter() - : m_WorkQueue(10000000, 1) -{ } - void InfluxdbWriter::OnConfigLoaded() { ObjectImpl::OnConfigLoaded(); diff --git a/lib/perfdata/influxdbwriter.hpp b/lib/perfdata/influxdbwriter.hpp index cf7be26ff..8332c2fb2 100644 --- a/lib/perfdata/influxdbwriter.hpp +++ b/lib/perfdata/influxdbwriter.hpp @@ -42,8 +42,6 @@ public: DECLARE_OBJECT(InfluxdbWriter); DECLARE_OBJECTNAME(InfluxdbWriter); - InfluxdbWriter(); - static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); void ValidateHostTemplate(const Dictionary::Ptr& value, const ValidationUtils& utils) override; @@ -55,7 +53,7 @@ protected: void Stop(bool runtimeRemoved) override; private: - WorkQueue m_WorkQueue; + WorkQueue m_WorkQueue{10000000, 1}; Timer::Ptr m_FlushTimer; std::vector m_DataBuffer; diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index a3051b874..e639ee8c0 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -49,7 +49,6 @@ REGISTER_STATSFUNCTION(ApiListener, &ApiListener::StatsFunc); REGISTER_APIFUNCTION(Hello, icinga, &ApiListener::HelloAPIHandler); ApiListener::ApiListener() - : m_SyncQueue(0, 4), m_LogMessageCount(0) { m_RelayQueue.SetName("ApiListener, RelayQueue"); m_SyncQueue.SetName("ApiListener, SyncQueue"); diff --git a/lib/remote/apilistener.hpp b/lib/remote/apilistener.hpp index 81b1310d3..5405914a6 100644 --- a/lib/remote/apilistener.hpp +++ b/lib/remote/apilistener.hpp @@ -145,11 +145,11 @@ private: void ListenerThreadProc(const Socket::Ptr& server); WorkQueue m_RelayQueue; - WorkQueue m_SyncQueue; + WorkQueue m_SyncQueue{0, 4}; boost::mutex m_LogLock; Stream::Ptr m_LogFile; - size_t m_LogMessageCount; + size_t m_LogMessageCount{0}; bool RelayMessageOne(const Zone::Ptr& zone, const MessageOrigin::Ptr& origin, const Dictionary::Ptr& message, const Endpoint::Ptr& currentMaster); void SyncRelayMessage(const MessageOrigin::Ptr& origin, const ConfigObject::Ptr& secobj, const Dictionary::Ptr& message, bool log); diff --git a/lib/remote/consolehandler.hpp b/lib/remote/consolehandler.hpp index ce7ae8f33..6e63c0c77 100644 --- a/lib/remote/consolehandler.hpp +++ b/lib/remote/consolehandler.hpp @@ -28,14 +28,10 @@ namespace icinga struct ApiScriptFrame { - double Seen; - int NextLine; + double Seen{0}; + int NextLine{1}; std::map Lines; Dictionary::Ptr Locals; - - ApiScriptFrame() - : Seen(0), NextLine(1) - { } }; class ConsoleHandler final : public HttpHandler diff --git a/lib/remote/endpoint.cpp b/lib/remote/endpoint.cpp index 2facf67b3..a354edbf0 100644 --- a/lib/remote/endpoint.cpp +++ b/lib/remote/endpoint.cpp @@ -34,10 +34,6 @@ REGISTER_TYPE(Endpoint); boost::signals2::signal Endpoint::OnConnected; boost::signals2::signal Endpoint::OnDisconnected; -Endpoint::Endpoint() - : m_MessagesSent(60), m_MessagesReceived(60), m_BytesSent(60), m_BytesReceived(60) -{ } - void Endpoint::OnAllConfigLoaded() { ObjectImpl::OnAllConfigLoaded(); diff --git a/lib/remote/endpoint.hpp b/lib/remote/endpoint.hpp index fa43310c0..254492ebc 100644 --- a/lib/remote/endpoint.hpp +++ b/lib/remote/endpoint.hpp @@ -42,8 +42,6 @@ public: DECLARE_OBJECT(Endpoint); DECLARE_OBJECTNAME(Endpoint); - Endpoint(); - static boost::signals2::signal&)> OnConnected; static boost::signals2::signal&)> OnDisconnected; @@ -76,10 +74,10 @@ private: std::set > m_Clients; intrusive_ptr m_Zone; - mutable RingBuffer m_MessagesSent; - mutable RingBuffer m_MessagesReceived; - mutable RingBuffer m_BytesSent; - mutable RingBuffer m_BytesReceived; + mutable RingBuffer m_MessagesSent{60}; + mutable RingBuffer m_MessagesReceived{60}; + mutable RingBuffer m_BytesSent{60}; + mutable RingBuffer m_BytesReceived{60}; }; } diff --git a/lib/remote/url.cpp b/lib/remote/url.cpp index d10a62d47..262de301b 100644 --- a/lib/remote/url.cpp +++ b/lib/remote/url.cpp @@ -26,9 +26,6 @@ using namespace icinga; -Url::Url() -{ } - Url::Url(const String& base_url) { String url = base_url; diff --git a/lib/remote/url.hpp b/lib/remote/url.hpp index 29a7c1fbd..ac022f427 100644 --- a/lib/remote/url.hpp +++ b/lib/remote/url.hpp @@ -41,7 +41,7 @@ class Url final : public Object public: DECLARE_PTR_TYPEDEFS(Url); - Url(); + Url() = default; Url(const String& url); String Format(bool onlyPathAndQuery = false, bool printCredentials = false) const; diff --git a/tools/mkclass/classcompiler.hpp b/tools/mkclass/classcompiler.hpp index d01d5e90c..3f0e7d4ea 100644 --- a/tools/mkclass/classcompiler.hpp +++ b/tools/mkclass/classcompiler.hpp @@ -81,13 +81,9 @@ enum FieldAttribute struct FieldType { - bool IsName; + bool IsName{false}; std::string TypeName; - int ArrayRank; - - FieldType() - : IsName(false), ArrayRank(0) - { } + int ArrayRank{0}; inline std::string GetRealType() const { @@ -113,23 +109,19 @@ struct FieldType struct Field { - int Attributes; + int Attributes{0}; FieldType Type; std::string Name; std::string AlternativeName; std::string GetAccessor; - bool PureGetAccessor; + bool PureGetAccessor{false}; std::string SetAccessor; - bool PureSetAccessor; + bool PureSetAccessor{false}; std::string DefaultAccessor; std::string TrackAccessor; std::string NavigationName; std::string NavigateAccessor; - bool PureNavigateAccessor; - - Field() - : Attributes(0), PureGetAccessor(false), PureSetAccessor(false), PureNavigateAccessor(false) - { } + bool PureNavigateAccessor{false}; inline std::string GetFriendlyName() const {