Skip to content

Commit

Permalink
formatting, lint
Browse files Browse the repository at this point in the history
  • Loading branch information
john30 committed Oct 1, 2024
1 parent 441a3f6 commit 5d8c973
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/ebusd/bushandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ void BusHandler::notifyProtocolMessage(MessageDirection direction, const MasterS
answer.push_back(command.dataAt(pos));
}
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
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/ebusd/knxhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,12 @@ void KnxHandler::run() {
continue; // not usable in absence of destination address
}
if (message->getCreateTime() <= definitionsSince // only newer defined
&& (!message->isConditional() || message->getAvailableSinceTime() <= definitionsSince)) { // unless conditional
&& (!message->isConditional() // unless conditional
|| message->getAvailableSinceTime() <= definitionsSince)) {
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
ssize_t fieldCount = static_cast<signed>(message->getFieldCount());
if (isWrite && fieldCount > 1) {
Expand Down
9 changes: 5 additions & 4 deletions src/ebusd/main_args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,13 @@ static const argDef argDefs[] = {
"Check and dump config files in FORMAT (\"json\" or \"csv\"), then stop"},
{"dumpconfigto", O_DMPCTO, "FILE", 0, "Dump config files to FILE"},
{"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. "
"\"FF08070400/0AB5454850303003277201\"), optionally stop afterwards"},
{nullptr, O_INJPOS, "INJECT", af_optional|af_multiple, "Commands and/or messages to inject (if --inject was given)"},
{"inject", 'i', "stop", af_optional, "Inject remaining arguments as commands or already seen messages "
"(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)"},
#ifdef HAVE_SSL
{"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)"},
#endif // HAVE_SSL

Expand Down
10 changes: 6 additions & 4 deletions src/ebusd/mainloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,8 @@ result_t MainLoop::executeRead(const vector<string>& args, const string& levels,
" NAME NAME of the message to send\n"
" FIELD only retrieve the field named FIELD\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"
" -h send hex read message (or answer from cache):\n"
" ZZ destination address\n"
Expand Down Expand Up @@ -849,7 +850,8 @@ result_t MainLoop::executeRead(const vector<string>& args, const string& levels,
return RESULT_OK;
}
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()) {
*ostream << "ERR: bad definition: no read" << (writeDirection?"/write":"") << " message";
return RESULT_OK;
Expand All @@ -874,8 +876,8 @@ result_t MainLoop::executeRead(const vector<string>& args, const string& levels,
if (verbosity & OF_NAMES) {
*ostream << cacheMessage->getCircuit() << " " << cacheMessage->getName() << " ";
}
ret = cacheMessage->decodeLastData(pt_any, false, fieldIndex == -2 ? nullptr : fieldName.c_str(), fieldIndex, verbosity,
ostream);
ret = cacheMessage->decodeLastData(pt_any, false, fieldIndex == -2 ? nullptr : fieldName.c_str(), fieldIndex,
verbosity, ostream);
if (ret < RESULT_OK) {
logError(lf_main, "read %s %s cached: decode %s", cacheMessage->getCircuit().c_str(),
cacheMessage->getName().c_str(), getResultCode(ret));
Expand Down
3 changes: 2 additions & 1 deletion src/ebusd/mqtthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,8 @@ void MqttHandler::run() {
}
message->setDataHandlerState(1, true);
} 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;
}
if (!FileReader::matches(message->getCircuit(), filterCircuit, true, true)
Expand Down
2 changes: 1 addition & 1 deletion src/ebusd/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ result_t ScanHelper::collectConfigFiles(const string& relPath, const string& pre
if (!m_configHttpClient->get(uri, "", &names)) {
return RESULT_ERR_NOTFOUND;
}
} else if (!json && names[0]=='<') { // html
} else if (!json && names[0] == '<') { // html
uri = m_configUriPrefix + relPathWithSlash + "index.json";
json = true;
logDebug(lf_main, "trying index.json");
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ebus/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ bool isValidIdentifierChar(char ch, bool first, bool allowFirstDigit) {
bool DataField::checkIdentifier(const string& name, bool allowFirstDigit) {
for (size_t i = 0; i < name.size(); i++) {
char ch = name[i];
if (!isValidIdentifierChar(ch, i==0, allowFirstDigit)) {
if (!isValidIdentifierChar(ch, i == 0, allowFirstDigit)) {
return false;
}
}
Expand All @@ -213,7 +213,7 @@ bool DataField::checkIdentifier(const string& name, bool allowFirstDigit) {
void DataField::normalizeIdentifier(string& name, bool allowFirstDigit) {
for (size_t i = 0; i < name.size(); i++) {
char ch = name[i];
if (!isValidIdentifierChar(ch, i==0, allowFirstDigit)) {
if (!isValidIdentifierChar(ch, i == 0, allowFirstDigit)) {
name[i] = '_';
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ebus/device_trans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ void EnhancedDevice::notifyInfoRetrieved() {
case 0x0107:
stream << "rssi ";
if (data[0]) {
stream << static_cast<signed>(((int8_t*)data)[0]) << " dBm";
stream << static_cast<signed>(reinterpret_cast<int8_t*>(data)[0]) << " dBm";
} else {
stream << "unknown";
}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/ebus/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ using std::endl;
#define POLL_PRIORITY_CONDITION 5

/** 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. */
static const char* knownFieldNamesFull[] = {
Expand Down Expand Up @@ -1691,7 +1691,8 @@ void SimpleNumericCondition::dumpValuesJson(ostream* output) const {

bool SimpleStringCondition::checkValue(const Message* message, const string& field) {
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) {
string value = output.str();
for (size_t i = 0; i < m_values.size(); i++) {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/ebus/transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ void SerialTransport::checkDevice() {
}

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) {
return RESULT_ERR_GENERIC_IO;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ebus/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class NetworkTransport : public FileTransport {
*/
~NetworkTransport() override {
if (m_hostOrIp) {
free((void*)m_hostOrIp);
free(const_cast<char*>(m_hostOrIp));
m_hostOrIp = nullptr;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/utils/httpclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ SSLSocket* SSLSocket::connect(const string& host, const uint16_t& port, bool htt
break;
}
if (strcmp(peerName, hostname) != 0) {
char* dotpos = strchr((char*)hostname, '.');
char* dotpos = strchr(const_cast<char*>(hostname), '.');
if (peerName[0] == '*' && peerName[1] == '.' && dotpos
&& strcmp(peerName+2, dotpos+1) == 0) {
// wildcard matches
Expand Down Expand Up @@ -582,7 +582,7 @@ bool* repeatable, time_t* time, bool* jsonString) {
}
pos = readUntil("", length, response);
disconnect();
if (noLength ? pos<1 : pos != length) {
if (noLength ? pos < 1 : pos != length) {
return false;
}
if (noLength) {
Expand Down

0 comments on commit 5d8c973

Please sign in to comment.