From 901076f69cbf9e73b86a2c4683f023552cc08730 Mon Sep 17 00:00:00 2001 From: Tim P Date: Mon, 19 Mar 2018 23:01:43 +1100 Subject: [PATCH] Fix Warnings (#503) --- src/Homie.cpp | 2 +- src/Homie/Boot/BootConfig.cpp | 15 +++++---------- src/Homie/Logger.cpp | 6 ++++-- src/Homie/Timer.cpp | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Homie.cpp b/src/Homie.cpp index 6b769806..ea45fb13 100644 --- a/src/Homie.cpp +++ b/src/Homie.cpp @@ -10,7 +10,7 @@ HomieClass::HomieClass() Interface::get().bootMode = HomieBootMode::UNDEFINED; Interface::get().configurationAp.secured = false; Interface::get().led.enabled = true; - Interface::get().led.pin = BUILTIN_LED; + Interface::get().led.pin = LED_BUILTIN; Interface::get().led.on = LOW; Interface::get().reset.idle = true; Interface::get().reset.enabled = true; diff --git a/src/Homie/Boot/BootConfig.cpp b/src/Homie/Boot/BootConfig.cpp index f788858a..9332b6ab 100644 --- a/src/Homie/Boot/BootConfig.cpp +++ b/src/Homie/Boot/BootConfig.cpp @@ -281,7 +281,7 @@ void BootConfig::_proxyHttpRequest(AsyncWebServerRequest *request) { _httpClient.setUserAgent(F("ESP8266-Homie")); _httpClient.begin(url); // copy headers - for (int i = 0; i < request->headers(); i++) { + for (size_t i = 0; i < request->headers(); i++) { _httpClient.addHeader(request->headerName(i), request->header(i)); } @@ -335,7 +335,7 @@ void BootConfig::_onDeviceInfoRequest(AsyncWebServerRequest *request) { for (IHomieSetting* iSetting : IHomieSetting::settings) { JsonObject& jsonSetting = jsonBuffer.createObject(); - if (iSetting->getType() != "unknown") { + if (String(iSetting->getType()) != "unknown") { jsonSetting["name"] = iSetting->getName(); jsonSetting["description"] = iSetting->getDescription(); jsonSetting["type"] = iSetting->getType(); @@ -421,19 +421,14 @@ void BootConfig::__parsePost(AsyncWebServerRequest *request, uint8_t *data, size if (index == 0) { request->_tempObject = new char[total + 1]; } - void* buff = request->_tempObject + index; + char* buff = reinterpret_cast(request->_tempObject) + index; memcpy(buff, data, len); if (index + len == total) { - void* buff = request->_tempObject + total; - *reinterpret_cast(buff) = 0; + char* buff = reinterpret_cast(request->_tempObject) + total; + *buff = '\0'; } } } -static const String ConfigJSONError(const String error) { - const String BEGINNING = String(FPSTR(PROGMEM_CONFIG_JSON_FAILURE_BEGINNING)); - const String END = String(FPSTR(PROGMEM_CONFIG_JSON_FAILURE_END)); - return BEGINNING + error + END; -} void HomieInternals::BootConfig::__SendJSONError(AsyncWebServerRequest * request, String msg, int16_t code) { Interface::get().getLogger() << msg << endl; diff --git a/src/Homie/Logger.cpp b/src/Homie/Logger.cpp index d3fc70e6..e1291637 100644 --- a/src/Homie/Logger.cpp +++ b/src/Homie/Logger.cpp @@ -16,9 +16,11 @@ void Logger::setPrinter(Print* printer) { } size_t Logger::write(uint8_t character) { - if (_loggingEnabled) _printer->write(character); + if (_loggingEnabled) return _printer->write(character); + return 0; } size_t Logger::write(const uint8_t* buffer, size_t size) { - if (_loggingEnabled) _printer->write(buffer, size); + if (_loggingEnabled) return _printer->write(buffer, size); + return 0; } diff --git a/src/Homie/Timer.cpp b/src/Homie/Timer.cpp index 063b051f..8e13519a 100644 --- a/src/Homie/Timer.cpp +++ b/src/Homie/Timer.cpp @@ -17,7 +17,7 @@ void Timer::setInterval(uint32_t interval, bool tickAtBeginning) { } uint32_t HomieInternals::Timer::getInterval() { - _interval; + return _interval; } bool Timer::check() const {