From 3e5d7574b278d3f1b94f0576b192aa6494cca8d2 Mon Sep 17 00:00:00 2001 From: Pascal Roobrouck Date: Thu, 24 Oct 2024 11:51:36 +0200 Subject: [PATCH] fixes from sonarcloud --- lib/logging/logging.cpp | 13 +++++-------- lib/pn7160interface/pn7160interface.cpp | 12 ++++++------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/lib/logging/logging.cpp b/lib/logging/logging.cpp index 8e21939..154bdf8 100644 --- a/lib/logging/logging.cpp +++ b/lib/logging/logging.cpp @@ -8,15 +8,14 @@ #include #include #include +#ifndef generic +#include +#endif uint32_t logging::activeSources{0}; uint32_t logging::activeDestinations{0}; char logging::buffer[bufferLength]{}; -#ifndef generic -#include -#endif - void logging::initialize() { #ifndef generic Serial.begin(115200); @@ -25,7 +24,7 @@ void logging::initialize() { uint32_t logging::snprintf(const char *format, ...) { uint32_t length{0}; - if (activeDestinations != 00) { + if (activeDestinations != 0) { va_list argList; va_start(argList, format); length = vsnprintf(buffer, bufferLength, format, argList); @@ -37,15 +36,13 @@ uint32_t logging::snprintf(const char *format, ...) { uint32_t logging::snprintf(source aSource, const char *format, ...) { uint32_t length{0}; - if (activeDestinations != 00) { - if (isActive(aSource)) { + if ((activeDestinations != 0) && (isActive(aSource))) { va_list argList; va_start(argList, format); length = vsnprintf(buffer, bufferLength, format, argList); va_end(argList); write(length); } - } return length; } diff --git a/lib/pn7160interface/pn7160interface.cpp b/lib/pn7160interface/pn7160interface.cpp index bb7db08..bcedbe8 100644 --- a/lib/pn7160interface/pn7160interface.cpp +++ b/lib/pn7160interface/pn7160interface.cpp @@ -19,10 +19,10 @@ uint8_t PN7160Interface::IRQpin; uint8_t PN7160Interface::VENpin; uint8_t PN7160Interface::I2Caddress{0x28}; -void PN7160Interface::initialize(uint8_t theIRQpin, uint8_t theVENpin, uint8_t I2Caddress) { +void PN7160Interface::initialize(uint8_t theIRQpin, uint8_t theVENpin, uint8_t theI2Caddress) { IRQpin = theIRQpin; VENpin = theVENpin; - I2Caddress = I2Caddress; + I2Caddress = theI2Caddress; #ifndef generic pinMode(IRQpin, INPUT); pinMode(VENpin, OUTPUT); @@ -80,15 +80,15 @@ uint32_t PN7160Interface::read(uint8_t rxBuffer[]) { // using 'Split mode' I2C read. See UM10936 section 3.5 bytesReceived = Wire.requestFrom((int)I2Caddress, 3); // first reading the header, as this contains how long the payload will be - rxBuffer[0] = Wire.read(); - rxBuffer[1] = Wire.read(); - rxBuffer[2] = Wire.read(); + rxBuffer[0] = static_cast(Wire.read()); + rxBuffer[1] = static_cast(Wire.read()); + rxBuffer[2] = static_cast(Wire.read()); uint8_t payloadLength = rxBuffer[2]; if (payloadLength > 0) { bytesReceived += Wire.requestFrom(I2Caddress, payloadLength); // then reading the payload, if any uint32_t index = 3; while (index < bytesReceived) { - rxBuffer[index] = Wire.read(); + rxBuffer[index] = static_cast(Wire.read()); index++; } }