diff --git a/cameraserver/src/main/native/cpp/cameraserver/CameraServer.cpp b/cameraserver/src/main/native/cpp/cameraserver/CameraServer.cpp index ab1f1cfb78..0ca17e172d 100644 --- a/cameraserver/src/main/native/cpp/cameraserver/CameraServer.cpp +++ b/cameraserver/src/main/native/cpp/cameraserver/CameraServer.cpp @@ -37,7 +37,8 @@ struct CameraServer::Impl { wpi::StringMap m_sinks; wpi::DenseMap m_fixedSources; wpi::DenseMap> m_tables; - std::shared_ptr m_publishTable; + std::shared_ptr 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") diff --git a/cscore/src/main/native/cpp/Frame.h b/cscore/src/main/native/cpp/Frame.h index 76ff897ed5..c1ebde6205 100644 --- a/cscore/src/main/native/cpp/Frame.h +++ b/cscore/src/main/native/cpp/Frame.h @@ -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 diff --git a/cscore/src/main/native/include/cscore_oo.h b/cscore/src/main/native/include/cscore_oo.h index a081e28ac3..abb6ddecae 100644 --- a/cscore/src/main/native/include/cscore_oo.h +++ b/cscore/src/main/native/include/cscore_oo.h @@ -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}; }; /** @} */ diff --git a/cscore/src/main/native/linux/UsbCameraBuffer.h b/cscore/src/main/native/linux/UsbCameraBuffer.h index e816aa9f68..f10d4e4177 100644 --- a/cscore/src/main/native/linux/UsbCameraBuffer.h +++ b/cscore/src/main/native/linux/UsbCameraBuffer.h @@ -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 diff --git a/ntcore/src/main/native/cpp/Message.h b/ntcore/src/main/native/cpp/Message.h index 9320b3cb32..fdef274c52 100644 --- a/ntcore/src/main/native/cpp/Message.h +++ b/ntcore/src/main/native/cpp/Message.h @@ -38,9 +38,8 @@ class Message { }; typedef std::function 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 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 diff --git a/ntcore/src/main/native/cpp/SequenceNumber.h b/ntcore/src/main/native/cpp/SequenceNumber.h index 72960f4ef5..96f4c9d829 100644 --- a/ntcore/src/main/native/cpp/SequenceNumber.h +++ b/ntcore/src/main/native/cpp/SequenceNumber.h @@ -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); diff --git a/ntcore/src/main/native/include/networktables/NetworkTableEntry.h b/ntcore/src/main/native/include/networktables/NetworkTableEntry.h index eb1c72e0ad..e417885ce3 100644 --- a/ntcore/src/main/native/include/networktables/NetworkTableEntry.h +++ b/ntcore/src/main/native/include/networktables/NetworkTableEntry.h @@ -635,7 +635,7 @@ class NetworkTableEntry final { protected: /* Native handle */ - NT_Entry m_handle; + NT_Entry m_handle{0}; }; } // namespace nt diff --git a/ntcore/src/main/native/include/networktables/NetworkTableEntry.inl b/ntcore/src/main/native/include/networktables/NetworkTableEntry.inl index 89556e0ffd..79c44669e3 100644 --- a/ntcore/src/main/native/include/networktables/NetworkTableEntry.inl +++ b/ntcore/src/main/native/include/networktables/NetworkTableEntry.inl @@ -11,7 +11,7 @@ namespace nt { -inline NetworkTableEntry::NetworkTableEntry() : m_handle{0} {} +inline NetworkTableEntry::NetworkTableEntry() {} inline NetworkTableEntry::NetworkTableEntry(NT_Entry handle) : m_handle{handle} {} diff --git a/ntcore/src/main/native/include/networktables/NetworkTableInstance.h b/ntcore/src/main/native/include/networktables/NetworkTableInstance.h index 098d1a7be9..7691edad2d 100644 --- a/ntcore/src/main/native/include/networktables/NetworkTableInstance.h +++ b/ntcore/src/main/native/include/networktables/NetworkTableInstance.h @@ -562,7 +562,7 @@ class NetworkTableInstance final { private: /* Native handle */ - NT_Inst m_handle; + NT_Inst m_handle{0}; }; } // namespace nt diff --git a/ntcore/src/main/native/include/networktables/NetworkTableInstance.inl b/ntcore/src/main/native/include/networktables/NetworkTableInstance.inl index 172061c058..f26e324662 100644 --- a/ntcore/src/main/native/include/networktables/NetworkTableInstance.inl +++ b/ntcore/src/main/native/include/networktables/NetworkTableInstance.inl @@ -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} {} diff --git a/ntcore/src/main/native/include/networktables/RpcCall.h b/ntcore/src/main/native/include/networktables/RpcCall.h index 23f65ff926..f878954026 100644 --- a/ntcore/src/main/native/include/networktables/RpcCall.h +++ b/ntcore/src/main/native/include/networktables/RpcCall.h @@ -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 diff --git a/ntcore/src/main/native/include/ntcore_cpp.h b/ntcore/src/main/native/include/ntcore_cpp.h index 0e75afca5b..cb8f1c1c78 100644 --- a/ntcore/src/main/native/include/ntcore_cpp.h +++ b/ntcore/src/main/native/include/ntcore_cpp.h @@ -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_, 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; diff --git a/wpiutil/src/main/native/include/wpi/uv/Error.h b/wpiutil/src/main/native/include/wpi/uv/Error.h index 33c51a44d7..9b063dc425 100644 --- a/wpiutil/src/main/native/include/wpi/uv/Error.h +++ b/wpiutil/src/main/native/include/wpi/uv/Error.h @@ -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