formatting, lint

This commit is contained in:
John
2024-10-01 06:44:52 +02:00
parent 441a3f6457
commit 5d8c9735d2
12 changed files with 31 additions and 22 deletions
+2 -1
View File
@@ -453,7 +453,8 @@ void BusHandler::notifyProtocolMessage(MessageDirection direction, const MasterS
answer.push_back(command.dataAt(pos)); answer.push_back(command.dataAt(pos));
} }
answer.adjustHeader(); answer.adjustHeader();
m_protocol->setAnswer(SYN, getSlaveAddress(dstAddress), command[2], command[3], command.data() + 5, idLen, answer); m_protocol->setAnswer(SYN, getSlaveAddress(dstAddress), command[2], command[3], command.data() + 5, idLen,
answer);
// TODO could use loaded messages for identifying MM/MS message pair // TODO could use loaded messages for identifying MM/MS message pair
} }
} }
+4 -2
View File
@@ -771,10 +771,12 @@ void KnxHandler::run() {
continue; // not usable in absence of destination address continue; // not usable in absence of destination address
} }
if (message->getCreateTime() <= definitionsSince // only newer defined if (message->getCreateTime() <= definitionsSince // only newer defined
&& (!message->isConditional() || message->getAvailableSinceTime() <= definitionsSince)) { // unless conditional && (!message->isConditional() // unless conditional
|| message->getAvailableSinceTime() <= definitionsSince)) {
continue; continue;
} }
logOtherDebug("knx", "checking association to %s %s", message->getCircuit().c_str(), message->getName().c_str()); logOtherDebug("knx", "checking association to %s %s", message->getCircuit().c_str(),
message->getName().c_str());
bool isWrite = message->isWrite() && !message->isPassive(); // from KNX perspective bool isWrite = message->isWrite() && !message->isPassive(); // from KNX perspective
ssize_t fieldCount = static_cast<signed>(message->getFieldCount()); ssize_t fieldCount = static_cast<signed>(message->getFieldCount());
if (isWrite && fieldCount > 1) { if (isWrite && fieldCount > 1) {
+5 -4
View File
@@ -165,12 +165,13 @@ static const argDef argDefs[] = {
"Check and dump config files in FORMAT (\"json\" or \"csv\"), then stop"}, "Check and dump config files in FORMAT (\"json\" or \"csv\"), then stop"},
{"dumpconfigto", O_DMPCTO, "FILE", 0, "Dump config files to FILE"}, {"dumpconfigto", O_DMPCTO, "FILE", 0, "Dump config files to FILE"},
{"pollinterval", O_POLINT, "SEC", 0, "Poll for data every SEC seconds (0=disable) [5]"}, {"pollinterval", O_POLINT, "SEC", 0, "Poll for data every SEC seconds (0=disable) [5]"},
{"inject", 'i', "stop", af_optional, "Inject remaining arguments as commands or already seen messages (e.g. " {"inject", 'i', "stop", af_optional, "Inject remaining arguments as commands or already seen messages "
"\"FF08070400/0AB5454850303003277201\"), optionally stop afterwards"}, "(e.g. \"FF08070400/0AB5454850303003277201\"), optionally stop afterwards"},
{nullptr, O_INJPOS, "INJECT", af_optional|af_multiple, "Commands and/or messages to inject (if --inject was given)"}, {nullptr, O_INJPOS, "INJECT", af_optional|af_multiple, "Commands and/or messages to inject "
"(if --inject was given)"},
#ifdef HAVE_SSL #ifdef HAVE_SSL
{"cafile", O_CAFILE, "FILE", 0, "Use CA FILE for checking certificates (uses defaults," {"cafile", O_CAFILE, "FILE", 0, "Use CA FILE for checking certificates (uses defaults,"
" \"#\" for insecure)"}, " \"#\" for insecure)"},
{"capath", O_CAPATH, "PATH", 0, "Use CA PATH for checking certificates (uses defaults)"}, {"capath", O_CAPATH, "PATH", 0, "Use CA PATH for checking certificates (uses defaults)"},
#endif // HAVE_SSL #endif // HAVE_SSL
+6 -4
View File
@@ -749,7 +749,8 @@ result_t MainLoop::executeRead(const vector<string>& args, const string& levels,
" NAME NAME of the message to send\n" " NAME NAME of the message to send\n"
" FIELD only retrieve the field named FIELD\n" " FIELD only retrieve the field named FIELD\n"
" N only retrieve the N'th field named FIELD (0-based)\n" " N only retrieve the N'th field named FIELD (0-based)\n"
" -def read with explicit message definition (only if enabled, allow write direction if given more than once):\n" " -def read with explicit message definition (only if enabled, allow write direction if given more"
" than once):\n"
" DEFINITION message definition to use instead of known definition\n" " DEFINITION message definition to use instead of known definition\n"
" -h send hex read message (or answer from cache):\n" " -h send hex read message (or answer from cache):\n"
" ZZ destination address\n" " ZZ destination address\n"
@@ -849,7 +850,8 @@ result_t MainLoop::executeRead(const vector<string>& args, const string& levels,
return RESULT_OK; return RESULT_OK;
} }
deque<Message*> messages; deque<Message*> messages;
m_newlyDefinedMessages->findAll("", "", levels, false, true, writeDirection, writeDirection, true, false, 0, 0, false, &messages); m_newlyDefinedMessages->findAll("", "", levels, false, true, writeDirection, writeDirection, true, false, 0, 0,
false, &messages);
if (messages.empty()) { if (messages.empty()) {
*ostream << "ERR: bad definition: no read" << (writeDirection?"/write":"") << " message"; *ostream << "ERR: bad definition: no read" << (writeDirection?"/write":"") << " message";
return RESULT_OK; return RESULT_OK;
@@ -874,8 +876,8 @@ result_t MainLoop::executeRead(const vector<string>& args, const string& levels,
if (verbosity & OF_NAMES) { if (verbosity & OF_NAMES) {
*ostream << cacheMessage->getCircuit() << " " << cacheMessage->getName() << " "; *ostream << cacheMessage->getCircuit() << " " << cacheMessage->getName() << " ";
} }
ret = cacheMessage->decodeLastData(pt_any, false, fieldIndex == -2 ? nullptr : fieldName.c_str(), fieldIndex, verbosity, ret = cacheMessage->decodeLastData(pt_any, false, fieldIndex == -2 ? nullptr : fieldName.c_str(), fieldIndex,
ostream); verbosity, ostream);
if (ret < RESULT_OK) { if (ret < RESULT_OK) {
logError(lf_main, "read %s %s cached: decode %s", cacheMessage->getCircuit().c_str(), logError(lf_main, "read %s %s cached: decode %s", cacheMessage->getCircuit().c_str(),
cacheMessage->getName().c_str(), getResultCode(ret)); cacheMessage->getName().c_str(), getResultCode(ret));
+2 -1
View File
@@ -818,7 +818,8 @@ void MqttHandler::run() {
} }
message->setDataHandlerState(1, true); message->setDataHandlerState(1, true);
} else if (message->getCreateTime() <= m_definitionsSince // only newer defined } else if (message->getCreateTime() <= m_definitionsSince // only newer defined
&& (!message->isConditional() || message->getAvailableSinceTime() <= m_definitionsSince)) { // unless conditional && (!message->isConditional() // unless conditional
|| message->getAvailableSinceTime() <= m_definitionsSince)) {
continue; continue;
} }
if (!FileReader::matches(message->getCircuit(), filterCircuit, true, true) if (!FileReader::matches(message->getCircuit(), filterCircuit, true, true)
+1 -1
View File
@@ -82,7 +82,7 @@ result_t ScanHelper::collectConfigFiles(const string& relPath, const string& pre
if (!m_configHttpClient->get(uri, "", &names)) { if (!m_configHttpClient->get(uri, "", &names)) {
return RESULT_ERR_NOTFOUND; return RESULT_ERR_NOTFOUND;
} }
} else if (!json && names[0]=='<') { // html } else if (!json && names[0] == '<') { // html
uri = m_configUriPrefix + relPathWithSlash + "index.json"; uri = m_configUriPrefix + relPathWithSlash + "index.json";
json = true; json = true;
logDebug(lf_main, "trying index.json"); logDebug(lf_main, "trying index.json");
+2 -2
View File
@@ -203,7 +203,7 @@ bool isValidIdentifierChar(char ch, bool first, bool allowFirstDigit) {
bool DataField::checkIdentifier(const string& name, bool allowFirstDigit) { bool DataField::checkIdentifier(const string& name, bool allowFirstDigit) {
for (size_t i = 0; i < name.size(); i++) { for (size_t i = 0; i < name.size(); i++) {
char ch = name[i]; char ch = name[i];
if (!isValidIdentifierChar(ch, i==0, allowFirstDigit)) { if (!isValidIdentifierChar(ch, i == 0, allowFirstDigit)) {
return false; return false;
} }
} }
@@ -213,7 +213,7 @@ bool DataField::checkIdentifier(const string& name, bool allowFirstDigit) {
void DataField::normalizeIdentifier(string& name, bool allowFirstDigit) { void DataField::normalizeIdentifier(string& name, bool allowFirstDigit) {
for (size_t i = 0; i < name.size(); i++) { for (size_t i = 0; i < name.size(); i++) {
char ch = name[i]; char ch = name[i];
if (!isValidIdentifierChar(ch, i==0, allowFirstDigit)) { if (!isValidIdentifierChar(ch, i == 0, allowFirstDigit)) {
name[i] = '_'; name[i] = '_';
} }
} }
+1 -1
View File
@@ -616,7 +616,7 @@ void EnhancedDevice::notifyInfoRetrieved() {
case 0x0107: case 0x0107:
stream << "rssi "; stream << "rssi ";
if (data[0]) { if (data[0]) {
stream << static_cast<signed>(((int8_t*)data)[0]) << " dBm"; stream << static_cast<signed>(reinterpret_cast<int8_t*>(data)[0]) << " dBm";
} else { } else {
stream << "unknown"; stream << "unknown";
} }
+3 -2
View File
@@ -70,7 +70,7 @@ using std::endl;
#define POLL_PRIORITY_CONDITION 5 #define POLL_PRIORITY_CONDITION 5
/** the field name constant for the message level. */ /** the field name constant for the message level. */
static const char* FIELDNAME_LEVEL = "level";// static const char* FIELDNAME_LEVEL = "level";
/** the known full length field names. */ /** the known full length field names. */
static const char* knownFieldNamesFull[] = { static const char* knownFieldNamesFull[] = {
@@ -1691,7 +1691,8 @@ void SimpleNumericCondition::dumpValuesJson(ostream* output) const {
bool SimpleStringCondition::checkValue(const Message* message, const string& field) { bool SimpleStringCondition::checkValue(const Message* message, const string& field) {
ostringstream output; ostringstream output;
result_t result = message->decodeLastData(pt_any, false, field.length() == 0 ? nullptr : field.c_str(), -1, OF_NONE, &output); result_t result = message->decodeLastData(pt_any, false, field.length() == 0 ? nullptr : field.c_str(), -1,
OF_NONE, &output);
if (result == RESULT_OK) { if (result == RESULT_OK) {
string value = output.str(); string value = output.str();
for (size_t i = 0; i < m_values.size(); i++) { for (size_t i = 0; i < m_values.size(); i++) {
+2 -1
View File
@@ -325,7 +325,8 @@ void SerialTransport::checkDevice() {
} }
result_t NetworkTransport::openInternal() { result_t NetworkTransport::openInternal() {
m_fd = socketConnect(m_hostOrIp, m_port, m_udp ? IPPROTO_UDP : 0, nullptr, 5, 2); // wait up to 5 seconds for established connection // wait up to 5 seconds for established connection
m_fd = socketConnect(m_hostOrIp, m_port, m_udp ? IPPROTO_UDP : 0, nullptr, 5, 2);
if (m_fd < 0) { if (m_fd < 0) {
return RESULT_ERR_GENERIC_IO; return RESULT_ERR_GENERIC_IO;
} }
+1 -1
View File
@@ -300,7 +300,7 @@ class NetworkTransport : public FileTransport {
*/ */
~NetworkTransport() override { ~NetworkTransport() override {
if (m_hostOrIp) { if (m_hostOrIp) {
free((void*)m_hostOrIp); free(const_cast<char*>(m_hostOrIp));
m_hostOrIp = nullptr; m_hostOrIp = nullptr;
} }
} }
+2 -2
View File
@@ -302,7 +302,7 @@ SSLSocket* SSLSocket::connect(const string& host, const uint16_t& port, bool htt
break; break;
} }
if (strcmp(peerName, hostname) != 0) { if (strcmp(peerName, hostname) != 0) {
char* dotpos = strchr((char*)hostname, '.'); char* dotpos = strchr(const_cast<char*>(hostname), '.');
if (peerName[0] == '*' && peerName[1] == '.' && dotpos if (peerName[0] == '*' && peerName[1] == '.' && dotpos
&& strcmp(peerName+2, dotpos+1) == 0) { && strcmp(peerName+2, dotpos+1) == 0) {
// wildcard matches // wildcard matches
@@ -582,7 +582,7 @@ bool* repeatable, time_t* time, bool* jsonString) {
} }
pos = readUntil("", length, response); pos = readUntil("", length, response);
disconnect(); disconnect();
if (noLength ? pos<1 : pos != length) { if (noLength ? pos < 1 : pos != length) {
return false; return false;
} }
if (noLength) { if (noLength) {