diff --git a/src/TinyProtocol.h b/src/TinyProtocol.h index 3d7d34a9..59052dbe 100644 --- a/src/TinyProtocol.h +++ b/src/TinyProtocol.h @@ -59,7 +59,7 @@ namespace tinyproto class Proto { public: - Proto(bool multithread = false); + explicit Proto(bool multithread = false); ~Proto(); @@ -132,7 +132,7 @@ class Proto class SerialFdProto: public Proto { public: - SerialFdProto(HardwareSerial &port); + explicit SerialFdProto(HardwareSerial &port); ArduinoSerialFdLink &getLink(); @@ -143,7 +143,7 @@ class SerialFdProto: public Proto class SerialHdlcProto: public Proto { public: - SerialHdlcProto(HardwareSerial &port); + explicit SerialHdlcProto(HardwareSerial &port); ArduinoSerialHdlcLink &getLink(); @@ -156,7 +156,7 @@ class SerialHdlcProto: public Proto class SerialFdProto: public Proto { public: - SerialFdProto(char *dev, bool multithread = false); + explicit SerialFdProto(char *dev, bool multithread = false); SerialFdLink &getLink(); @@ -167,7 +167,7 @@ class SerialFdProto: public Proto class SerialHdlcProto: public Proto { public: - SerialHdlcProto(char *dev, bool multithread = false); + explicit SerialHdlcProto(char *dev, bool multithread = false); SerialHdlcLink &getLink(); diff --git a/src/link/TinySerialFdLink.h b/src/link/TinySerialFdLink.h index e33b959b..32e63379 100644 --- a/src/link/TinySerialFdLink.h +++ b/src/link/TinySerialFdLink.h @@ -32,7 +32,7 @@ namespace tinyproto template class StaticSerialFdLink: public ISerialLinkLayer { public: - StaticSerialFdLink(char *dev) + explicit StaticSerialFdLink(char *dev) : ISerialLinkLayer(dev, this->m_buffer, BUFFER_SIZE) { this->setMtu(MTU); @@ -40,7 +40,7 @@ template class StaticSerial } private: - uint8_t m_buffer[BUFFER_SIZE]; + uint8_t m_buffer[BUFFER_SIZE] = {}; }; @@ -52,7 +52,7 @@ template using ArduinoStaticS class ArduinoSerialFdLink: public ArduinoStaticSerialFdLinkLayer<32, 2, 2, 4> { public: - ArduinoSerialFdLink(HardwareSerial *dev) + explicit ArduinoSerialFdLink(HardwareSerial *dev) : ArduinoStaticSerialFdLinkLayer<32, 2, 2, 4>(reinterpret_cast(dev)) { } @@ -63,7 +63,7 @@ class ArduinoSerialFdLink: public ArduinoStaticSerialFdLinkLayer<32, 2, 2, 4> class SerialFdLink: public ISerialLinkLayer { public: - SerialFdLink(char *dev) + explicit SerialFdLink(char *dev) : ISerialLinkLayer(dev, nullptr, 0) { } diff --git a/src/link/TinySerialHdlcLink.h b/src/link/TinySerialHdlcLink.h index afa9e8fb..1133a0f7 100644 --- a/src/link/TinySerialHdlcLink.h +++ b/src/link/TinySerialHdlcLink.h @@ -32,14 +32,14 @@ namespace tinyproto template class StaticSerialHdlcLink: public ISerialLinkLayer { public: - StaticSerialHdlcLink(char *dev) + explicit StaticSerialHdlcLink(char *dev) : ISerialLinkLayer(dev, this->m_buffer, BUFFER_SIZE) { this->setMtu(MTU); } private: - uint8_t m_buffer[BUFFER_SIZE]; + uint8_t m_buffer[BUFFER_SIZE] = {}; }; @@ -51,7 +51,7 @@ template using ArduinoStaticSerialHdlcLinkLa class ArduinoSerialHdlcLink: public ArduinoStaticSerialHdlcLinkLayer<32, 2, 4> { public: - ArduinoSerialHdlcLink(HardwareSerial *dev) + explicit ArduinoSerialHdlcLink(HardwareSerial *dev) : ArduinoStaticSerialHdlcLinkLayer<32, 2, 4>(reinterpret_cast(dev)) { } @@ -62,7 +62,7 @@ class ArduinoSerialHdlcLink: public ArduinoStaticSerialHdlcLinkLayer<32, 2, 4> class SerialHdlcLink: public ISerialLinkLayer { public: - SerialHdlcLink(char *dev) + explicit SerialHdlcLink(char *dev) : ISerialLinkLayer(dev, nullptr, 0) { } diff --git a/src/proto/fd/tiny_fd.c b/src/proto/fd/tiny_fd.c index 4cfc051d..4c489226 100644 --- a/src/proto/fd/tiny_fd.c +++ b/src/proto/fd/tiny_fd.c @@ -914,7 +914,7 @@ static uint8_t *tiny_fd_get_next_i_frame(tiny_fd_handle_t handle, int *len, uint static uint8_t *tiny_fd_get_next_frame_to_send(tiny_fd_handle_t handle, int *len, uint8_t peer) { - uint8_t *data = NULL; + uint8_t *data; // Tx data available tiny_mutex_lock(&handle->frames.mutex); const uint8_t address = __peer_to_address_field( handle, peer ); diff --git a/tinyproto.cppcheck b/tinyproto.cppcheck index 51436466..5fb5fa23 100644 --- a/tinyproto.cppcheck +++ b/tinyproto.cppcheck @@ -10,5 +10,7 @@ purgedConfiguration + nullPointerArithmeticRedundantCheck + ctuOneDefinitionRuleViolation