Skip to content

Commit 91c2562

Browse files
committed
Apply clang-tidy fix 'modernize-use-default-member-init'
1 parent e0174b8 commit 91c2562

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+120
-393
lines changed

lib/base/array.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,10 @@ template class std::vector<Value>;
3232

3333
REGISTER_PRIMITIVE_TYPE(Array, Object, Array::GetPrototype());
3434

35-
Array::Array()
36-
{ }
37-
3835
Array::Array(std::initializer_list<Value> init)
3936
: m_Data(init)
4037
{ }
4138

42-
Array::~Array()
43-
{ }
44-
4539
/**
4640
* Restrieves a value from an array.
4741
*

lib/base/array.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,9 @@ class Array final : public Object
4747

4848
typedef std::vector<Value>::size_type SizeType;
4949

50-
Array();
50+
Array() = default;
5151
Array(std::initializer_list<Value> init);
5252

53-
~Array() override;
54-
5553
Value Get(SizeType index) const;
5654
void Set(SizeType index, const Value& value);
5755
void Set(SizeType index, Value&& value);

lib/base/configobject.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ REGISTER_TYPE_WITH_PROTOTYPE(ConfigObject, ConfigObject::GetPrototype());
4646

4747
boost::signals2::signal<void (const ConfigObject::Ptr&)> ConfigObject::OnStateChanged;
4848

49-
ConfigObject::ConfigObject()
50-
{ }
51-
5249
bool ConfigObject::IsActive() const
5350
{
5451
return GetActive();

lib/base/configobject.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ class ConfigObject : public ObjectImpl<ConfigObject>
9696

9797
static Object::Ptr GetPrototype();
9898

99-
protected:
100-
explicit ConfigObject();
101-
10299
private:
103100
ConfigObject::Ptr m_Zone;
104101

lib/base/debuginfo.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323

2424
using namespace icinga;
2525

26-
DebugInfo::DebugInfo()
27-
: FirstLine(0), FirstColumn(0), LastLine(0), LastColumn(0)
28-
{ }
29-
3026
/**
3127
* Outputs a DebugInfo struct to a stream.
3228
*

lib/base/debuginfo.hpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ struct DebugInfo
3535
{
3636
String Path;
3737

38-
int FirstLine;
39-
int FirstColumn;
38+
int FirstLine{0};
39+
int FirstColumn{0};
4040

41-
int LastLine;
42-
int LastColumn;
43-
44-
DebugInfo();
41+
int LastLine{0};
42+
int LastColumn{0};
4543
};
4644

4745
std::ostream& operator<<(std::ostream& out, const DebugInfo& val);

lib/base/dictionary.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ template class std::map<String, Value>;
2929

3030
REGISTER_PRIMITIVE_TYPE(Dictionary, Object, Dictionary::GetPrototype());
3131

32-
Dictionary::Dictionary()
33-
{ }
34-
35-
Dictionary::~Dictionary()
36-
{ }
37-
3832
/**
3933
* Retrieves a value from a dictionary.
4034
*

lib/base/dictionary.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ class Dictionary final : public Object
4949

5050
typedef std::map<String, Value>::value_type Pair;
5151

52-
Dictionary();
53-
54-
~Dictionary() override;
55-
5652
Value Get(const String& key) const;
5753
bool Get(const String& key, Value *result) const;
5854
void Set(const String& key, Value value);

lib/base/exception.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,6 @@ ScriptError::ScriptError(String message, DebugInfo di, bool incompleteExpr)
291291
: m_Message(std::move(message)), m_DebugInfo(std::move(di)), m_IncompleteExpr(incompleteExpr), m_HandledByDebugger(false)
292292
{ }
293293

294-
ScriptError::~ScriptError() throw()
295-
{ }
296-
297294
const char *ScriptError::what() const throw()
298295
{
299296
return m_Message.CStr();
@@ -319,10 +316,6 @@ void ScriptError::SetHandledByDebugger(bool handled)
319316
m_HandledByDebugger = handled;
320317
}
321318

322-
posix_error::posix_error()
323-
: m_Message(nullptr)
324-
{ }
325-
326319
posix_error::~posix_error() throw()
327320
{
328321
free(m_Message);

lib/base/exception.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ScriptError : virtual public user_error
5353
public:
5454
ScriptError(String message);
5555
ScriptError(String message, DebugInfo di, bool incompleteExpr = false);
56-
~ScriptError() throw() override;
56+
~ScriptError() throw() = default;
5757

5858
const char *what(void) const throw() final;
5959

@@ -125,13 +125,12 @@ String DiagnosticInformation(const boost::exception_ptr& eptr, bool verbose = tr
125125

126126
class posix_error : virtual public std::exception, virtual public boost::exception {
127127
public:
128-
posix_error();
129128
~posix_error() throw() override;
130129

131130
const char *what(void) const throw() final;
132131

133132
private:
134-
mutable char *m_Message;
133+
mutable char *m_Message{nullptr};
135134
};
136135

137136
#ifdef _WIN32

lib/base/fifo.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@
2121

2222
using namespace icinga;
2323

24-
/**
25-
* Constructor for the FIFO class.
26-
*/
27-
FIFO::FIFO()
28-
: m_Buffer(nullptr), m_DataSize(0), m_AllocSize(0), m_Offset(0)
29-
{ }
30-
3124
/**
3225
* Destructor for the FIFO class.
3326
*/

lib/base/fifo.hpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class FIFO final : public Stream
3838

3939
static const size_t BlockSize = 512;
4040

41-
FIFO();
4241
~FIFO() override;
4342

4443
size_t Peek(void *buffer, size_t count, bool allow_partial = false) override;
@@ -52,10 +51,10 @@ class FIFO final : public Stream
5251
size_t GetAvailableBytes() const;
5352

5453
private:
55-
char *m_Buffer;
56-
size_t m_DataSize;
57-
size_t m_AllocSize;
58-
size_t m_Offset;
54+
char *m_Buffer{nullptr};
55+
size_t m_DataSize{0};
56+
size_t m_AllocSize{0};
57+
size_t m_Offset{0};
5958

6059
void ResizeBuffer(size_t newSize, bool decrease);
6160
void Optimize();

lib/base/json.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,8 @@ String icinga::JsonEncode(const Value& value, bool pretty_print)
126126
struct JsonElement
127127
{
128128
String Key;
129-
bool KeySet;
129+
bool KeySet{false};
130130
Value EValue;
131-
132-
JsonElement()
133-
: KeySet(false)
134-
{ }
135131
};
136132

137133
struct JsonContext

lib/base/object.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ static std::map<String, int> l_ObjectCounts;
3838
static Timer::Ptr l_ObjectCountTimer;
3939
#endif /* I2_LEAK_DEBUG */
4040

41-
/**
42-
* Default constructor for the Object class.
43-
*/
44-
Object::Object()
45-
: m_References(0), m_Mutex(0)
46-
{ }
47-
4841
/**
4942
* Destructor for the Object class.
5043
*/

lib/base/object.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class Object
109109
public:
110110
DECLARE_PTR_TYPEDEFS(Object);
111111

112-
Object();
112+
Object() = default;
113113
virtual ~Object();
114114

115115
virtual String ToString() const;
@@ -139,11 +139,11 @@ class Object
139139
static intrusive_ptr<Type> TypeInstance;
140140

141141
private:
142-
Object(const Object& other);
143-
Object& operator=(const Object& rhs);
142+
Object(const Object& other) = delete;
143+
Object& operator=(const Object& rhs) = delete;
144144

145-
uintptr_t m_References;
146-
mutable uintptr_t m_Mutex;
145+
uintptr_t m_References{0};
146+
mutable uintptr_t m_Mutex{0};
147147

148148
#ifdef I2_DEBUG
149149
# ifndef _WIN32

lib/base/objectlock.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ using namespace icinga;
2525
#define I2MUTEX_UNLOCKED 0
2626
#define I2MUTEX_LOCKED 1
2727

28-
ObjectLock::ObjectLock()
29-
: m_Object(nullptr), m_Locked(false)
30-
{ }
31-
3228
ObjectLock::~ObjectLock()
3329
{
3430
Unlock();

lib/base/objectlock.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ namespace icinga
3131
struct ObjectLock
3232
{
3333
public:
34-
ObjectLock();
3534
ObjectLock(const Object::Ptr& object);
3635
ObjectLock(const Object *object);
3736

@@ -46,8 +45,8 @@ struct ObjectLock
4645
void Unlock();
4746

4847
private:
49-
const Object *m_Object;
50-
bool m_Locked;
48+
const Object *m_Object{nullptr};
49+
bool m_Locked{false};
5150
};
5251

5352
}

lib/base/objecttype.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ INITIALIZE_ONCE_WITH_PRIORITY([]() {
2929
Object::TypeInstance = type;
3030
}, 20);
3131

32-
ObjectType::ObjectType()
33-
{ }
34-
3532
String ObjectType::GetName() const
3633
{
3734
return "Object";

lib/base/objecttype.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ namespace icinga
3030
class ObjectType final : public Type
3131
{
3232
public:
33-
ObjectType();
34-
3533
String GetName() const override;
3634
Type::Ptr GetBaseType() const override;
3735
int GetAttributes() const override;

lib/base/perfdatavalue.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PerfdataValue final : public ObjectImpl<PerfdataValue>
3636
public:
3737
DECLARE_OBJECT(PerfdataValue);
3838

39-
PerfdataValue();
39+
PerfdataValue() = default;
4040

4141
PerfdataValue(const String& label, double value, bool counter = false, const String& unit = "",
4242
const Value& warn = Empty, const Value& crit = Empty,

lib/base/socket.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,10 @@
3434

3535
using namespace icinga;
3636

37-
/**
38-
* Constructor for the Socket class.
39-
*/
40-
Socket::Socket()
41-
: m_FD(INVALID_SOCKET)
42-
{ }
43-
4437
/**
4538
* Constructor for the Socket class.
4639
*/
4740
Socket::Socket(SOCKET fd)
48-
: m_FD(INVALID_SOCKET)
4941
{
5042
SetFD(fd);
5143
}

lib/base/socket.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Socket : public Object
3636
public:
3737
DECLARE_PTR_TYPEDEFS(Socket);
3838

39-
Socket();
39+
Socket() = default;
4040
Socket(SOCKET fd);
4141
~Socket() override;
4242

@@ -67,7 +67,7 @@ class Socket : public Object
6767
mutable boost::mutex m_SocketMutex;
6868

6969
private:
70-
SOCKET m_FD; /**< The socket descriptor. */
70+
SOCKET m_FD{INVALID_SOCKET}; /**< The socket descriptor. */
7171

7272
static String GetAddressFromSockaddr(sockaddr *address, socklen_t len);
7373
};

lib/base/socketevents.hpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,9 @@ class SocketEvents
7777

7878
struct SocketEventDescriptor
7979
{
80-
int Events;
81-
SocketEvents *EventInterface;
82-
Object *LifesupportObject;
83-
84-
SocketEventDescriptor()
85-
: Events(POLLIN), EventInterface(nullptr), LifesupportObject(nullptr)
86-
{ }
80+
int Events{POLLIN};
81+
SocketEvents *EventInterface{nullptr};
82+
Object *LifesupportObject{nullptr};
8783
};
8884

8985
struct EventDescription

lib/base/stream.hpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ enum ConnectionRole
3838

3939
struct StreamReadContext
4040
{
41-
StreamReadContext()
42-
: Buffer(nullptr), Size(0), MustRead(true), Eof(false)
43-
{ }
44-
4541
~StreamReadContext()
4642
{
4743
free(Buffer);
@@ -50,10 +46,10 @@ struct StreamReadContext
5046
bool FillFromStream(const intrusive_ptr<Stream>& stream, bool may_wait);
5147
void DropData(size_t count);
5248

53-
char *Buffer;
54-
size_t Size;
55-
bool MustRead;
56-
bool Eof;
49+
char *Buffer{nullptr};
50+
size_t Size{0};
51+
bool MustRead{true};
52+
bool Eof{false};
5753
};
5854

5955
enum StreamReadStatus

lib/base/streamlogger.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ REGISTER_TYPE(StreamLogger);
3030

3131
boost::mutex StreamLogger::m_Mutex;
3232

33-
/**
34-
* Constructor for the StreamLogger class.
35-
*/
36-
StreamLogger::StreamLogger()
37-
: m_Stream(nullptr), m_OwnsStream(false)
38-
{ }
39-
4033
void StreamLogger::Stop(bool runtimeRemoved)
4134
{
4235
ObjectImpl<StreamLogger>::Stop(runtimeRemoved);

0 commit comments

Comments
 (0)