From b0e20b7c7c2eea544860956159da52e12d0c1691 Mon Sep 17 00:00:00 2001 From: john30 Date: Tue, 26 Dec 2017 14:27:44 +0100 Subject: [PATCH] code style --- src/ebusd/bushandler.cpp | 4 ++-- src/ebusd/bushandler.h | 10 ++++++++-- src/ebusd/main.cpp | 5 +++-- src/ebusd/mainloop.cpp | 4 ++-- src/lib/ebus/data.cpp | 3 ++- src/lib/ebus/device.cpp | 2 +- src/lib/ebus/message.cpp | 2 +- 7 files changed, 19 insertions(+), 11 deletions(-) mode change 100755 => 100644 src/ebusd/bushandler.cpp mode change 100755 => 100644 src/ebusd/bushandler.h mode change 100755 => 100644 src/ebusd/mainloop.cpp diff --git a/src/ebusd/bushandler.cpp b/src/ebusd/bushandler.cpp old mode 100755 new mode 100644 index e8d82355..e89ec13f --- a/src/ebusd/bushandler.cpp +++ b/src/ebusd/bushandler.cpp @@ -692,7 +692,7 @@ result_t BusHandler::handleSymbol() { long long latencyLong = (sentTime.tv_sec*1000000000 + sentTime.tv_nsec - m_lastSynReceiveTime.tv_sec*1000000000 - m_lastSynReceiveTime.tv_nsec)/1000; if (latencyLong >= 0 && latencyLong <= 10000) { // skip clock skew or out of reasonable range - int latency = (int)latencyLong; + int latency = static_cast(latencyLong); logDebug(lf_bus, "arbitration delay %d micros", latency); if (m_arbitrationDelayMin < 0 || (latency < m_arbitrationDelayMin || latency > m_arbitrationDelayMax)) { if (m_arbitrationDelayMin == -1 || latency < m_arbitrationDelayMin) { @@ -1022,7 +1022,7 @@ void BusHandler::measureLatency(struct timespec* sentTime, struct timespec* recv if (latencyLong < 0 || latencyLong > 1000) { return; // clock skew or out of reasonable range } - int latency = (int)latencyLong; + int latency = static_cast(latencyLong); logDebug(lf_bus, "send/receive symbol latency %d ms", latency); if (m_symbolLatencyMin >= 0 && (latency >= m_symbolLatencyMin && latency <= m_symbolLatencyMax)) { return; diff --git a/src/ebusd/bushandler.h b/src/ebusd/bushandler.h old mode 100755 new mode 100644 index 46517695..19e21b42 --- a/src/ebusd/bushandler.h +++ b/src/ebusd/bushandler.h @@ -698,10 +698,16 @@ class BusHandler : public WaitThread { /** the maximal measured latency between send and receive of a symbol in milliseconds, -1 if not yet known. */ int m_symbolLatencyMax; - /** the minimal measured delay between received SYN and sent own master address in microseconds, -1 if not yet known. */ + /** + * the minimal measured delay between received SYN and sent own master address in microseconds, + * -1 if not yet known. + */ int m_arbitrationDelayMin; - /** the maximal measured delay between received SYN and sent own master address in microseconds, -1 if not yet known. */ + /** + * the maximal measured delay between received SYN and sent own master address in microseconds, + * -1 if not yet known. + */ int m_arbitrationDelayMax; /** the time of the last received SYN symbol, or 0 for never. */ diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp index 91d5ea72..e4055d17 100644 --- a/src/ebusd/main.cpp +++ b/src/ebusd/main.cpp @@ -1197,8 +1197,9 @@ int main(int argc, char* argv[]) { signal(SIGTERM, signalHandler); logNotice(lf_main, PACKAGE_STRING "." REVISION " started%s", - opt.scanConfig ? opt.initialScan == ESC ? " with auto scan" : opt.initialScan == BROADCAST ? " with broadcast scan" - : opt.initialScan == SYN ? " with full scan" : " with single scan" : ""); + opt.scanConfig ? opt.initialScan == ESC ? " with auto scan" + : opt.initialScan == BROADCAST ? " with broadcast scan" : opt.initialScan == SYN ? " with full scan" + : " with single scan" : ""); // load configuration files loadConfigFiles(s_messageMap); diff --git a/src/ebusd/mainloop.cpp b/src/ebusd/mainloop.cpp old mode 100755 new mode 100644 index b24a05b6..8051734e --- a/src/ebusd/mainloop.cpp +++ b/src/ebusd/mainloop.cpp @@ -722,7 +722,7 @@ result_t MainLoop::executeRead(const vector& args, const string& levels, result_t ret; symbol_t address = (symbol_t)parseInt(args[argPos].c_str(), 16, 0, 0xff, &ret); if (ret != RESULT_OK || !isValidAddress(address, dest) || (dest == isMaster(address))) { - return RESULT_ERR_INVALID_ADDR; // deny send from slave address and to master addresses + return RESULT_ERR_INVALID_ADDR; // deny send from slave address and to master addresses } if (dest) { dstAddress = address; @@ -949,7 +949,7 @@ result_t MainLoop::executeWrite(const vector& args, const string levels, result_t ret; symbol_t address = (symbol_t)parseInt(args[argPos].c_str(), 16, 0, 0xff, &ret); if (ret != RESULT_OK || !isValidAddress(address, dest) || (!dest && !isMaster(address))) { - return RESULT_ERR_INVALID_ADDR; // deny send from slave address + return RESULT_ERR_INVALID_ADDR; // deny send from slave address } if (dest) { dstAddress = address; diff --git a/src/lib/ebus/data.cpp b/src/lib/ebus/data.cpp index b151c8e1..7e868bd2 100644 --- a/src/lib/ebus/data.cpp +++ b/src/lib/ebus/data.cpp @@ -658,7 +658,8 @@ bool SingleDataField::hasFullByteOffset(bool after) const { } size_t SingleDataField::getCount(PartType partType, const char* fieldName) const { - return isIgnored() || (partType != pt_any && partType != m_partType) || (fieldName != NULL && m_name != fieldName) ? 0 : 1; + return isIgnored() || (partType != pt_any && partType != m_partType) || (fieldName != NULL && m_name != fieldName) + ? 0 : 1; } diff --git a/src/lib/ebus/device.cpp b/src/lib/ebus/device.cpp index f16de185..2322180f 100644 --- a/src/lib/ebus/device.cpp +++ b/src/lib/ebus/device.cpp @@ -279,7 +279,7 @@ result_t NetworkDevice::open() { return RESULT_ERR_GENERIC_IO; } if (!m_udp) { - usleep(25000); // wait 25ms for potential initial garbage + usleep(25000); // wait 25ms for potential initial garbage } int cnt; symbol_t buf[MTU]; diff --git a/src/lib/ebus/message.cpp b/src/lib/ebus/message.cpp index 50156e80..f1e4d239 100644 --- a/src/lib/ebus/message.cpp +++ b/src/lib/ebus/message.cpp @@ -747,7 +747,7 @@ result_t Message::decodeLastData(bool leadingSeparator, const char* fieldName, fieldIndex -= m_data->getCount(pt_masterData, fieldName); if (fieldIndex < 0) { skipSlaveData = true; - fieldIndex = 0; + fieldIndex = 0; } } if (!skipSlaveData) {