From c7ffe5d4c7d270ca97904a22d1640aa26f978131 Mon Sep 17 00:00:00 2001 From: Sven Steckmann Date: Thu, 17 Oct 2019 13:56:38 +0200 Subject: [PATCH] Remove compiler warnings by adding some braces. --- src/AutoConnect.cpp | 15 ++++++++++----- src/AutoConnectAux.cpp | 3 ++- src/AutoConnectAuxImpl.h | 24 ++++++++++++++++-------- src/AutoConnectElementJson.h | 27 ++++++++++++++++++--------- 4 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/AutoConnect.cpp b/src/AutoConnect.cpp index d6bc673..f0f0923 100644 --- a/src/AutoConnect.cpp +++ b/src/AutoConnect.cpp @@ -295,8 +295,9 @@ bool AutoConnect::config(AutoConnectConfig& Config) { * by Config method. */ bool AutoConnect::_config(void) { - if (static_cast(_apConfig.apip) == 0U || static_cast(_apConfig.gateway) == 0U || static_cast(_apConfig.netmask) == 0U) + if (static_cast(_apConfig.apip) == 0U || static_cast(_apConfig.gateway) == 0U || static_cast(_apConfig.netmask) == 0U) { AC_DBG("Warning: Contains invalid SoftAPIP address(es).\n"); + } bool rc = WiFi.softAPConfig(_apConfig.apip, _apConfig.gateway, _apConfig.netmask); AC_DBG("SoftAP configure %s, %s, %s %s\n", _apConfig.apip.toString().c_str(), _apConfig.gateway.toString().c_str(), _apConfig.netmask.toString().c_str(), rc ? "" : "failed"); return rc; @@ -316,8 +317,9 @@ bool AutoConnect::_configSTA(const IPAddress& ip, const IPAddress& gateway, cons bool rc; AC_DBG("WiFi.config(IP=%s, Gateway=%s, Subnetmask=%s, DNS1=%s, DNS2=%s)\n", ip.toString().c_str(), gateway.toString().c_str(), netmask.toString().c_str(), dns1.toString().c_str(), dns2.toString().c_str()); - if (!(rc = WiFi.config(ip, gateway, netmask, dns1, dns2))) + if (!(rc = WiFi.config(ip, gateway, netmask, dns1, dns2))) { AC_DBG("failed\n"); + } #ifdef ARDUINO_ARCH_ESP8266 AC_DBG("DHCP client(%s)\n", wifi_station_dhcpc_status() == DHCP_STOPPED ? "STOPPED" : "STARTED"); #endif @@ -524,17 +526,20 @@ void AutoConnect::handleRequest(void) { // Save current credential if (_apConfig.autoSave == AC_SAVECREDENTIAL_AUTO) { AutoConnectCredential credit(_apConfig.boundaryOffset); - if (credit.save(&_credential)) + if (credit.save(&_credential)) { AC_DBG("%.*s credential saved\n", sizeof(_credential.ssid), reinterpret_cast(_credential.ssid)); - else + } + else { AC_DBG("credential %.*s save failed\n", sizeof(_credential.ssid), reinterpret_cast(_credential.ssid)); + } } // Ensures that keeps a connection with the current AP while the portal behaves. _setReconnect(AC_RECONNECT_SET); } - else + else { AC_DBG("%.*s has no BSSID, saving is unavailable\n", sizeof(_credential.ssid), reinterpret_cast(_credential.ssid)); + } // Activate AutoConnectUpdate if it is attached and incorporate // it into the AutoConnect menu. diff --git a/src/AutoConnectAux.cpp b/src/AutoConnectAux.cpp index b52a067..0b84f01 100644 --- a/src/AutoConnectAux.cpp +++ b/src/AutoConnectAux.cpp @@ -303,8 +303,9 @@ void AutoConnectAux::upload(const String& requestUri, const HTTPUpload& upload) _upload = _uploadHandler; AC_DBG_DUMB("enabled\n"); } - else + else { AC_DBG_DUMB("missing\n"); + } } } diff --git a/src/AutoConnectAuxImpl.h b/src/AutoConnectAuxImpl.h index 649d302..84f3cb0 100644 --- a/src/AutoConnectAuxImpl.h +++ b/src/AutoConnectAuxImpl.h @@ -272,8 +272,9 @@ AutoConnectButtonJson& AutoConnectAux::getElement(const String& name) { if (elm) { if (elm->typeOf() == AC_Button) return *(reinterpret_cast(elm)); - else + else { AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); + } } return reinterpret_cast(_nullElement()); } @@ -289,8 +290,9 @@ AutoConnectCheckboxJson& AutoConnectAux::getElement(const String& name) { if (elm) { if (elm->typeOf() == AC_Checkbox) return *(reinterpret_cast(elm)); - else + else { AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); + } } return reinterpret_cast(_nullElement()); } @@ -306,8 +308,9 @@ AutoConnectFileJson& AutoConnectAux::getElement(const String& name) { if (elm) { if (elm->typeOf() == AC_File) return *(reinterpret_cast(elm)); - else + else { AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); + } } return reinterpret_cast(_nullElement()); } @@ -323,8 +326,9 @@ AutoConnectInputJson& AutoConnectAux::getElement(const String& name) { if (elm) { if (elm->typeOf() == AC_Input) return *(reinterpret_cast(elm)); - else + else { AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); + } } return reinterpret_cast(_nullElement()); } @@ -340,8 +344,9 @@ AutoConnectRadioJson& AutoConnectAux::getElement(const String& name) { if (elm) { if (elm->typeOf() == AC_Radio) return *(reinterpret_cast(elm)); - else + else { AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); + } } return reinterpret_cast(_nullElement()); } @@ -357,8 +362,9 @@ AutoConnectSelectJson& AutoConnectAux::getElement(const String& name) { if (elm) { if (elm->typeOf() == AC_Select) return *(reinterpret_cast(elm)); - else + else { AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); + } } return reinterpret_cast(_nullElement()); } @@ -374,8 +380,9 @@ AutoConnectSubmitJson& AutoConnectAux::getElement(const String& name) { if (elm) { if (elm->typeOf() == AC_Submit) return *(reinterpret_cast(elm)); - else + else { AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); + } } return reinterpret_cast(_nullElement()); } @@ -391,8 +398,9 @@ AutoConnectTextJson& AutoConnectAux::getElement(const String& name) { if (elm) { if (elm->typeOf() == AC_Text) return *(reinterpret_cast(elm)); - else + else { AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); + } } return reinterpret_cast(_nullElement()); } diff --git a/src/AutoConnectElementJson.h b/src/AutoConnectElementJson.h index 2cb9486..ad4d06a 100644 --- a/src/AutoConnectElementJson.h +++ b/src/AutoConnectElementJson.h @@ -309,64 +309,73 @@ class AutoConnectTextJson : public AutoConnectElementJson, public AutoConnectTex */ template<> inline AutoConnectButtonJson& AutoConnectElementJson::as(void) { - if (typeOf() != AC_Button) + if (typeOf() != AC_Button) { AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); + } return *(reinterpret_cast(this)); } template<> inline AutoConnectCheckboxJson& AutoConnectElementJson::as(void) { - if (typeOf() != AC_Checkbox) + if (typeOf() != AC_Checkbox) { AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); + } return *(reinterpret_cast(this)); } template<> inline AutoConnectFileJson& AutoConnectElementJson::as(void) { - if (typeOf() != AC_File) + if (typeOf() != AC_File) { AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); + } return *(reinterpret_cast(this)); } template<> inline AutoConnectInputJson& AutoConnectElementJson::as(void) { - if (typeOf() != AC_Input) + if (typeOf() != AC_Input) { AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); + } return *(reinterpret_cast(this)); } template<> inline AutoConnectRadioJson& AutoConnectElementJson::as(void) { - if (typeOf() != AC_Radio) + if (typeOf() != AC_Radio) { AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); + } return *(reinterpret_cast(this)); } template<> inline AutoConnectSelectJson& AutoConnectElementJson::as(void) { - if (typeOf() != AC_Select) + if (typeOf() != AC_Select) { AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); + } return *(reinterpret_cast(this)); } template<> inline AutoConnectStyleJson& AutoConnectElementJson::as(void) { - if (typeOf() != AC_Style) + if (typeOf() != AC_Style) { AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); + } return *(reinterpret_cast(this)); } template<> inline AutoConnectSubmitJson& AutoConnectElementJson::as(void) { - if (typeOf() != AC_Submit) + if (typeOf() != AC_Submit) { AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); + } return *(reinterpret_cast(this)); } template<> inline AutoConnectTextJson& AutoConnectElementJson::as(void) { - if (typeOf() != AC_Text) + if (typeOf() != AC_Text) { AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); + } return *(reinterpret_cast(this)); }