clang-tidy: modernize-use-default-member-init

This commit is contained in:
Peter Johnson
2020-12-28 00:28:23 -08:00
parent d11a3a6380
commit b124f9101b
13 changed files with 49 additions and 52 deletions

View File

@@ -38,9 +38,8 @@ class Message {
};
typedef std::function<NT_Type(unsigned int id)> GetEntryTypeFunc;
Message() : m_type(kUnknown), m_id(0), m_flags(0), m_seq_num_uid(0) {}
Message(MsgType type, const private_init&)
: m_type(type), m_id(0), m_flags(0), m_seq_num_uid(0) {}
Message() {}
Message(MsgType type, const private_init&) : m_type(type) {}
MsgType type() const { return m_type; }
bool Is(MsgType type) const { return type == m_type; }
@@ -99,14 +98,14 @@ class Message {
Message& operator=(const Message&) = delete;
private:
MsgType m_type;
MsgType m_type{kUnknown};
// Message data. Use varies by message type.
std::string m_str;
std::shared_ptr<Value> m_value;
unsigned int m_id; // also used for proto_rev
unsigned int m_flags;
unsigned int m_seq_num_uid;
unsigned int m_id{0}; // also used for proto_rev
unsigned int m_flags{0};
unsigned int m_seq_num_uid{0};
};
} // namespace nt

View File

@@ -10,7 +10,7 @@ namespace nt {
/* A sequence number per RFC 1982 */
class SequenceNumber {
public:
SequenceNumber() : m_value(0) {}
SequenceNumber() {}
explicit SequenceNumber(unsigned int value) : m_value(value) {}
unsigned int value() const { return m_value; }
@@ -35,7 +35,7 @@ class SequenceNumber {
friend bool operator!=(const SequenceNumber& lhs, const SequenceNumber& rhs);
private:
unsigned int m_value;
unsigned int m_value{0};
};
bool operator<(const SequenceNumber& lhs, const SequenceNumber& rhs);

View File

@@ -635,7 +635,7 @@ class NetworkTableEntry final {
protected:
/* Native handle */
NT_Entry m_handle;
NT_Entry m_handle{0};
};
} // namespace nt

View File

@@ -11,7 +11,7 @@
namespace nt {
inline NetworkTableEntry::NetworkTableEntry() : m_handle{0} {}
inline NetworkTableEntry::NetworkTableEntry() {}
inline NetworkTableEntry::NetworkTableEntry(NT_Entry handle)
: m_handle{handle} {}

View File

@@ -562,7 +562,7 @@ class NetworkTableInstance final {
private:
/* Native handle */
NT_Inst m_handle;
NT_Inst m_handle{0};
};
} // namespace nt

View File

@@ -10,7 +10,7 @@
namespace nt {
inline NetworkTableInstance::NetworkTableInstance() noexcept : m_handle{0} {}
inline NetworkTableInstance::NetworkTableInstance() noexcept {}
inline NetworkTableInstance::NetworkTableInstance(NT_Inst handle) noexcept
: m_handle{handle} {}

View File

@@ -23,7 +23,7 @@ class RpcCall final {
/**
* Construct invalid instance.
*/
RpcCall() : m_entry(0), m_call(0) {}
RpcCall() {}
/**
* Construct from native handles.
@@ -95,8 +95,8 @@ class RpcCall final {
}
private:
NT_Entry m_entry;
NT_RpcCall m_call;
NT_Entry m_entry{0};
NT_RpcCall m_call{0};
};
} // namespace nt

View File

@@ -130,16 +130,16 @@ struct RpcDefinition {
/** NetworkTables Remote Procedure Call (Server Side) */
class RpcAnswer {
public:
RpcAnswer() : entry(0), call(0) {}
RpcAnswer() {}
RpcAnswer(NT_Entry entry_, NT_RpcCall call_, StringRef name_,
StringRef params_, const ConnectionInfo& conn_)
: entry(entry_), call(call_), name(name_), params(params_), conn(conn_) {}
/** Entry handle. */
NT_Entry entry;
NT_Entry entry{0};
/** Call handle. */
mutable NT_RpcCall call;
mutable NT_RpcCall call{0};
/** Entry name. */
std::string name;
@@ -176,7 +176,7 @@ class RpcAnswer {
/** NetworkTables Entry Notification */
class EntryNotification {
public:
EntryNotification() : listener(0), entry(0), flags(0) {}
EntryNotification() {}
EntryNotification(NT_EntryListener listener_, NT_Entry entry_,
StringRef name_, std::shared_ptr<Value> value_,
unsigned int flags_)
@@ -187,10 +187,10 @@ class EntryNotification {
flags(flags_) {}
/** Listener that was triggered. */
NT_EntryListener listener;
NT_EntryListener listener{0};
/** Entry handle. */
NT_Entry entry;
NT_Entry entry{0};
/** Entry name. */
std::string name;
@@ -202,7 +202,7 @@ class EntryNotification {
* Update flags. For example, NT_NOTIFY_NEW if the key did not previously
* exist.
*/
unsigned int flags;
unsigned int flags{0};
friend void swap(EntryNotification& first, EntryNotification& second) {
using std::swap;
@@ -217,13 +217,13 @@ class EntryNotification {
/** NetworkTables Connection Notification */
class ConnectionNotification {
public:
ConnectionNotification() : listener(0), connected(false) {}
ConnectionNotification() {}
ConnectionNotification(NT_ConnectionListener listener_, bool connected_,
const ConnectionInfo& conn_)
: listener(listener_), connected(connected_), conn(conn_) {}
/** Listener that was triggered. */
NT_ConnectionListener listener;
NT_ConnectionListener listener{0};
/** True if event is due to connection being established. */
bool connected = false;
@@ -243,7 +243,7 @@ class ConnectionNotification {
/** NetworkTables log message. */
class LogMessage {
public:
LogMessage() : logger(0), level(0), filename(""), line(0) {}
LogMessage() {}
LogMessage(NT_Logger logger_, unsigned int level_, const char* filename_,
unsigned int line_, StringRef message_)
: logger(logger_),
@@ -253,16 +253,16 @@ class LogMessage {
message(message_) {}
/** The logger that generated the message. */
NT_Logger logger;
NT_Logger logger{0};
/** Log level of the message. See NT_LogLevel. */
unsigned int level;
unsigned int level{0};
/** The filename of the source file that generated the message. */
const char* filename;
const char* filename{""};
/** The line number in the source file that generated the message. */
unsigned int line;
unsigned int line{0};
/** The message. */
std::string message;