From fb05558ab947cbbce3d17af66f915ca709029bbb Mon Sep 17 00:00:00 2001 From: proddy Date: Fri, 18 Feb 2022 20:28:15 +0100 Subject: [PATCH] fix static analysis warnings --- Makefile | 2 +- src/dallassensor.h | 19 +++++++++---------- src/devices/boiler.h | 1 - src/helpers.cpp | 2 +- src/mqtt.cpp | 10 +++++----- src/system.cpp | 2 ++ 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 13f4a2ee1..88cac6bc0 100644 --- a/Makefile +++ b/Makefile @@ -73,8 +73,8 @@ CPPFLAGS += -Os CFLAGS += $(CPPFLAGS) CFLAGS += -Wall -CFLAGS += -Wno-unused -Wno-restrict CFLAGS += -Wextra +CFLAGS += -Wno-unused-parameter CXXFLAGS += $(CFLAGS) -MMD diff --git a/src/dallassensor.h b/src/dallassensor.h index abb4745bf..f6add0adf 100644 --- a/src/dallassensor.h +++ b/src/dallassensor.h @@ -147,10 +147,6 @@ class DallasSensor { static uuid::log::Logger logger_; -#ifndef EMSESP_STANDALONE - OneWire bus_; -#endif - bool temperature_convert_complete(); int16_t get_temperature_c(const uint8_t addr[]); uint64_t get_id(const uint8_t addr[]); @@ -159,19 +155,22 @@ class DallasSensor { bool command_info(const char * value, const int8_t id, JsonObject & output); bool command_commands(const char * value, const int8_t id, JsonObject & output); - uint32_t last_activity_ = uuid::get_uptime(); - State state_ = State::IDLE; - std::vector sensors_; // our list of active sensors - int8_t scancnt_ = SCAN_START; - uint8_t firstscan_ = 0; +#ifndef EMSESP_STANDALONE + OneWire bus_; + uint32_t last_activity_ = uuid::get_uptime(); + State state_ = State::IDLE; + int8_t scancnt_ = SCAN_START; + uint8_t firstscan_ = 0; + int8_t scanretry_ = 0; +#endif + uint8_t dallas_gpio_ = 0; bool parasite_ = false; bool changed_ = false; uint32_t sensorfails_ = 0; uint32_t sensorreads_ = 0; - int8_t scanretry_ = 0; }; } // namespace emsesp diff --git a/src/devices/boiler.h b/src/devices/boiler.h index c53d0b3f5..d83973260 100644 --- a/src/devices/boiler.h +++ b/src/devices/boiler.h @@ -177,7 +177,6 @@ class Boiler : public EMSdevice { uint8_t hpCoolingOn_; uint8_t hpWwOn_; uint8_t hpPoolOn_; - uint8_t hpHeatingOn; int16_t hpTc0_; int16_t hpTc1_; int16_t hpTc3_; diff --git a/src/helpers.cpp b/src/helpers.cpp index 0f9b339f3..108b5783f 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -200,7 +200,7 @@ char * Helpers::render_value(char * result, const char * value, const int8_t for // format: 255(0xFF)=boolean, 0=no formatting, otherwise divide by format char * Helpers::render_value(char * result, uint8_t value, int8_t format, const uint8_t fahrenheit) { // special check if its a boolean - if (format == EMS_VALUE_BOOL) { + if ((uint8_t)format == EMS_VALUE_BOOL) { if (value == EMS_VALUE_BOOL_OFF) { render_boolean(result, false); } else if (value == EMS_VALUE_BOOL_NOTSET) { diff --git a/src/mqtt.cpp b/src/mqtt.cpp index ddd6d1b69..a69254977 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -62,11 +62,11 @@ MAKE_PSTR(iconpercent, "mdi:percent-outline") // DeviceValueUOM::PERCENT MAKE_PSTR(icontime, "mdi:clock-outline") // DeviceValueUOM::SECONDS MINUTES & HOURS MAKE_PSTR(iconkb, "mdi:memory") // DeviceValueUOM::KB MAKE_PSTR(iconlmin, "mdi:water-boiler") // DeviceValueUOM::LMIN -MAKE_PSTR(iconkwh, "mdi:transmission-tower") // DeviceValueUOM::KWH & WH +// MAKE_PSTR(iconkwh, "mdi:transmission-tower") // DeviceValueUOM::KWH & WH MAKE_PSTR(iconua, "mdi:lightning-bolt-circle") // DeviceValueUOM::UA -MAKE_PSTR(iconbar, "mdi:gauge") // DeviceValueUOM::BAR -MAKE_PSTR(iconkw, "mdi:omega") // DeviceValueUOM::KW & W -MAKE_PSTR(icondbm, "mdi:wifi-strength-2") // DeviceValueUOM::DBM +// MAKE_PSTR(iconbar, "mdi:gauge") // DeviceValueUOM::BAR +// MAKE_PSTR(iconkw, "mdi:omega") // DeviceValueUOM::KW & W +// MAKE_PSTR(icondbm, "mdi:wifi-strength-2") // DeviceValueUOM::DBM MAKE_PSTR(iconnum, "mdi:counter") // DeviceValueUOM::NONE MAKE_PSTR(icondevice, "mdi:home-automation") // for devices in HA @@ -253,7 +253,7 @@ void Mqtt::incoming(const char * topic, const char * payload) { void Mqtt::on_message(const char * topic, const char * payload, size_t len) { // sometimes the payload is not terminated correctly, so make a copy // convert payload to a null-terminated char string - char message[len + 2] = {'\0'}; + char message[len + 2]; if (payload != nullptr) { strlcpy(message, payload, len + 1); } diff --git a/src/system.cpp b/src/system.cpp index d05dffb29..80a66086b 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -252,7 +252,9 @@ void System::format(uuid::console::Shell & shell) { } void System::syslog_init() { +#ifndef EMSESP_STANDALONE bool was_enabled = syslog_enabled_; +#endif EMSESP::webSettingsService.read([&](WebSettings & settings) { syslog_enabled_ = settings.syslog_enabled; syslog_level_ = settings.syslog_level;