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

@@ -37,7 +37,8 @@ struct CameraServer::Impl {
wpi::StringMap<cs::VideoSink> m_sinks;
wpi::DenseMap<CS_Sink, CS_Source> m_fixedSources;
wpi::DenseMap<CS_Source, std::shared_ptr<nt::NetworkTable>> m_tables;
std::shared_ptr<nt::NetworkTable> m_publishTable;
std::shared_ptr<nt::NetworkTable> m_publishTable{
nt::NetworkTableInstance::GetDefault().GetTable(kPublishName)};
cs::VideoListener m_videoListener;
int m_tableListener;
int m_nextPort;
@@ -300,10 +301,7 @@ static void PutSourcePropertyValue(nt::NetworkTable* table,
}
}
CameraServer::Impl::Impl()
: m_publishTable{nt::NetworkTableInstance::GetDefault().GetTable(
kPublishName)},
m_nextPort(kBasePort) {
CameraServer::Impl::Impl() : m_nextPort(kBasePort) {
// We publish sources to NetworkTables using the following structure:
// "/CameraPublisher/{Source.Name}/" - root
// - "source" (string): Descriptive, prefixed with type (e.g. "usb:0")

View File

@@ -42,7 +42,7 @@ class Frame {
};
public:
Frame() noexcept : m_impl{nullptr} {}
Frame() noexcept {}
Frame(SourceImpl& source, const wpi::Twine& error, Time time);
@@ -231,7 +231,7 @@ class Frame {
}
void ReleaseFrame();
Impl* m_impl;
Impl* m_impl{nullptr};
};
} // namespace cs

View File

@@ -48,7 +48,7 @@ class VideoProperty {
kEnum = CS_PROP_ENUM
};
VideoProperty() : m_status(0), m_handle(0), m_kind(kNone) {}
VideoProperty() {}
std::string GetName() const;
@@ -83,9 +83,9 @@ class VideoProperty {
explicit VideoProperty(CS_Property handle);
VideoProperty(CS_Property handle, Kind kind);
mutable CS_Status m_status;
CS_Property m_handle;
Kind m_kind;
mutable CS_Status m_status{0};
CS_Property m_handle{0};
Kind m_kind{kNone};
};
/**
@@ -124,7 +124,7 @@ class VideoSource {
kConnectionForceClose = CS_CONNECTION_FORCE_CLOSE
};
VideoSource() noexcept : m_handle(0) {}
VideoSource() noexcept {}
VideoSource(const VideoSource& source);
VideoSource(VideoSource&& other) noexcept;
VideoSource& operator=(VideoSource other) noexcept;
@@ -349,7 +349,7 @@ class VideoSource {
explicit VideoSource(CS_Source handle) : m_handle(handle) {}
mutable CS_Status m_status = 0;
CS_Source m_handle;
CS_Source m_handle{0};
};
/**
@@ -733,7 +733,7 @@ class VideoSink {
kCv = CS_SINK_CV
};
VideoSink() noexcept : m_handle(0) {}
VideoSink() noexcept {}
VideoSink(const VideoSink& sink);
VideoSink(VideoSink&& sink) noexcept;
VideoSink& operator=(VideoSink other) noexcept;
@@ -866,7 +866,7 @@ class VideoSink {
explicit VideoSink(CS_Sink handle) : m_handle(handle) {}
mutable CS_Status m_status = 0;
CS_Sink m_handle;
CS_Sink m_handle{0};
};
/**
@@ -1008,7 +1008,7 @@ class VideoEvent : public RawEvent {
*/
class VideoListener {
public:
VideoListener() : m_handle(0) {}
VideoListener() {}
/**
* Create an event listener.
@@ -1033,7 +1033,7 @@ class VideoListener {
}
private:
CS_Listener m_handle;
CS_Listener m_handle{0};
};
/** @} */

View File

@@ -13,7 +13,7 @@ namespace cs {
class UsbCameraBuffer {
public:
UsbCameraBuffer() noexcept : m_data{nullptr}, m_length{0} {}
UsbCameraBuffer() noexcept {}
UsbCameraBuffer(UsbCameraBuffer&& other) noexcept : UsbCameraBuffer() {
swap(*this, other);
}
@@ -46,8 +46,8 @@ class UsbCameraBuffer {
swap(first.m_length, second.m_length);
}
void* m_data;
size_t m_length;
void* m_data{nullptr};
size_t m_length{0};
};
} // namespace cs

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;

View File

@@ -15,7 +15,7 @@ namespace uv {
*/
class Error {
public:
Error() : m_err(UV_UNKNOWN) {}
Error() {}
explicit Error(int err) : m_err(err) {}
/**
@@ -39,7 +39,7 @@ class Error {
const char* name() const { return uv_err_name(m_err); }
private:
int m_err;
int m_err{UV_UNKNOWN};
};
} // namespace uv