diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp index 9e5b7b6e..a659cf4f 100644 --- a/src/ebusd/main.cpp +++ b/src/ebusd/main.cpp @@ -875,8 +875,7 @@ int main(int argc, char* argv[], char* envp[]) { s_configPath += "/"; } const string lang = MappedFileReader::normalizeLanguage( - s_opt.preferLanguage == nullptr || !s_opt.preferLanguage[0] ? "" : s_opt.preferLanguage - ); + s_opt.preferLanguage == nullptr || !s_opt.preferLanguage[0] ? "" : s_opt.preferLanguage); string configLocalPrefix, configUriPrefix; HttpClient* configHttpClient = nullptr; if (s_configPath.find("://") == string::npos) { diff --git a/src/ebusd/mainloop.cpp b/src/ebusd/mainloop.cpp index 8cd22f84..d59745f9 100644 --- a/src/ebusd/mainloop.cpp +++ b/src/ebusd/mainloop.cpp @@ -21,11 +21,11 @@ #endif #include "ebusd/mainloop.h" -#include "ebusd/scan.h" #include #include #include #include "ebusd/main.h" +#include "ebusd/scan.h" #include "lib/utils/log.h" #include "lib/ebus/data.h" @@ -106,10 +106,10 @@ result_t UserList::addFromFile(const string& filename, unsigned int lineNo, map< MainLoop::MainLoop(const struct options& opt, Device *device, MessageMap* messages, ScanHelper* scanHelper) - : Thread(), m_device(device), m_reconnectCount(0), m_userList(opt.accessLevel), m_messages(messages), m_scanHelper(scanHelper), - m_address(opt.address), m_scanConfig(opt.scanConfig), m_initialScan(opt.readOnly ? ESC : opt.initialScan), - m_polling(opt.pollInterval > 0), m_enableHex(opt.enableHex), m_shutdown(false), m_runUpdateCheck(opt.updateCheck), - m_httpClient(opt.caFile, opt.caPath) { + : Thread(), m_device(device), m_reconnectCount(0), m_userList(opt.accessLevel), m_messages(messages), + m_scanHelper(scanHelper), m_address(opt.address), m_scanConfig(opt.scanConfig), + m_initialScan(opt.readOnly ? ESC : opt.initialScan), m_polling(opt.pollInterval > 0), m_enableHex(opt.enableHex), + m_shutdown(false), m_runUpdateCheck(opt.updateCheck), m_httpClient(opt.caFile, opt.caPath) { m_device->setListener(this); // open Device result_t result = m_device->open(); @@ -170,9 +170,9 @@ MainLoop::MainLoop(const struct options& opt, Device *device, MessageMap* messag if (opt.enableDefine) { m_newlyDefinedMessages = new MessageMap(true, "", false); m_newlyDefinedMessages->setResolver(scanHelper); - } else { + } else { m_newlyDefinedMessages = nullptr; - } + } } MainLoop::~MainLoop() { diff --git a/src/ebusd/scan.cpp b/src/ebusd/scan.cpp index 64452cfc..cb1cf184 100644 --- a/src/ebusd/scan.cpp +++ b/src/ebusd/scan.cpp @@ -21,7 +21,6 @@ #endif #include "ebusd/scan.h" -#include "ebusd/bushandler.h" #include #include #include @@ -30,6 +29,7 @@ #include #include #include +#include "ebusd/bushandler.h" #include "lib/utils/log.h" @@ -133,7 +133,7 @@ result_t ScanHelper::collectConfigFiles(const string& relPath, const string& pre DataFieldTemplates* ScanHelper::getTemplates(const string& filename) { if (filename == "*") { - unsigned long maxLength = 0; + size_t maxLength = 0; DataFieldTemplates* best = nullptr; for (auto it : m_templatesByPath) { if (it.first.size() > maxLength) { @@ -478,7 +478,8 @@ result_t ScanHelper::loadScanConfigFile(symbol_t address, string* relativeFile) return RESULT_OK; } -bool ScanHelper::parseMessage(const string& arg, bool onlyMasterSlave, MasterSymbolString* master, SlaveSymbolString* slave) { +bool ScanHelper::parseMessage(const string& arg, bool onlyMasterSlave, MasterSymbolString* master, + SlaveSymbolString* slave) { size_t pos = arg.find_first_of('/'); if (pos == string::npos) { logError(lf_main, "invalid message %s: missing \"/\"", arg.c_str()); diff --git a/src/ebusd/scan.h b/src/ebusd/scan.h index d5372f35..bc8cecf5 100644 --- a/src/ebusd/scan.h +++ b/src/ebusd/scan.h @@ -21,6 +21,7 @@ #include #include +#include #include #include "lib/ebus/data.h" #include "lib/ebus/message.h" @@ -40,7 +41,6 @@ class BusHandler; * Helper class for handling device scanning and config loading. */ class ScanHelper : public Resolver { - public: /** * Constructor. diff --git a/src/lib/ebus/device.cpp b/src/lib/ebus/device.cpp index 919be016..a53a65dd 100755 --- a/src/lib/ebus/device.cpp +++ b/src/lib/ebus/device.cpp @@ -245,7 +245,7 @@ string Device::getEnhancedInfos() { res = requestEnhancedInfo(2); if (res != RESULT_OK) { fails += ", cannot request config"; - requestEnhancedInfo(0xff); // wait for completion + requestEnhancedInfo(0xff); // wait for completion m_infoPos = 0; m_infoId = 0xff; } @@ -266,7 +266,7 @@ string Device::getEnhancedInfos() { if (res != RESULT_OK) { fails += ", cannot request bus voltage"; } - res = requestEnhancedInfo(0xff); // wait for completion + res = requestEnhancedInfo(0xff); // wait for completion if (res != RESULT_OK) { m_enhInfoBusVoltage = "bus voltage unknown"; m_infoPos = 0; @@ -509,7 +509,7 @@ bool Device::available() { // drop first byte of invalid sequence m_bufPos = (m_bufPos + 1) % m_bufSize; m_bufLen--; - pos--; // check same pos again + pos--; // check same pos again continue; } if (cmd == ENH_RES_RECEIVED || cmd == ENH_RES_STARTED || cmd == ENH_RES_FAILED) { @@ -524,7 +524,7 @@ bool Device::available() { fprintf(stdout, "raw avail enhanced skip cmd %d @%d+%d %2.2x\n", cmd, m_bufPos, pos, ch); fflush(stdout); #endif - pos++; // skip enhanced sequence of 2 bytes + pos++; // skip enhanced sequence of 2 bytes continue; } #ifdef DEBUG_RAW_TRAFFIC @@ -537,7 +537,7 @@ bool Device::available() { // skip byte from erroneous protocol m_bufPos = (m_bufPos+1)%m_bufSize; m_bufLen--; - pos--; // check byte 2 again from scratch and allow as byte 1 + pos--; // check byte 2 again from scratch and allow as byte 1 } return false; } diff --git a/src/lib/ebus/message.cpp b/src/lib/ebus/message.cpp index 1bcb20cd..1cd3c137 100644 --- a/src/lib/ebus/message.cpp +++ b/src/lib/ebus/message.cpp @@ -460,7 +460,7 @@ result_t Message::create(const string& filename, const DataFieldTemplates* templ return result; } } - if (id.size() + data->getLength(pt_masterData, maxLength==MAX_POS ? MAX_POS-id.size() : maxLength) > 2 + maxLength + if (id.size() + data->getLength(pt_masterData, maxLength == MAX_POS ? MAX_POS-id.size() : maxLength) > 2 + maxLength || data->getLength(pt_slaveData, maxLength) > maxLength) { // max NN exceeded delete data; diff --git a/src/lib/utils/httpclient.cpp b/src/lib/utils/httpclient.cpp index 7460e292..279a031f 100755 --- a/src/lib/utils/httpclient.cpp +++ b/src/lib/utils/httpclient.cpp @@ -152,7 +152,7 @@ SSLSocket* SSLSocket::connect(const string& host, const uint16_t& port, bool htt time_t until = time(nullptr) + (timeout <= 3 ? 3 : timeout); // at least 3 seconds if (!https) { do { - bio = BIO_new_connect((char*)hostPort.c_str()); + bio = BIO_new_connect(static_cast(hostPort.c_str())); if (isError("connect", bio)) { break; } diff --git a/src/lib/utils/httpclient.h b/src/lib/utils/httpclient.h index d8f13603..1a9bccad 100755 --- a/src/lib/utils/httpclient.h +++ b/src/lib/utils/httpclient.h @@ -132,8 +132,7 @@ class HttpClient { m_caFile(caFile), m_caPath(caPath), #endif - m_socket(nullptr), m_port(0), m_timeout(0), m_bufferSize(0), m_buffer(nullptr) - { + m_socket(nullptr), m_port(0), m_timeout(0), m_bufferSize(0), m_buffer(nullptr) { if (init) { initialize(); }