From 077d09b620980da301b4d549d5c43b5c0e8e9833 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 4 Nov 2023 09:31:08 +0100 Subject: [PATCH] lint --- src/ebusd/mqttclient_mosquitto.cpp | 2 -- src/ebusd/mqtthandler.cpp | 2 +- src/ebusd/scan.cpp | 1 - src/lib/ebus/data.cpp | 3 +-- src/lib/ebus/datatype.cpp | 2 -- src/lib/ebus/device.cpp | 40 ++++++++++++++++++------------ src/lib/ebus/filereader.cpp | 2 -- src/lib/ebus/filereader.h | 6 ++++- src/lib/ebus/message.h | 2 +- src/lib/ebus/stringhelper.cpp | 2 +- src/lib/ebus/stringhelper.h | 2 +- src/lib/utils/arg.h | 3 ++- src/lib/utils/httpclient.cpp | 4 +-- 13 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/ebusd/mqttclient_mosquitto.cpp b/src/ebusd/mqttclient_mosquitto.cpp index 93d80ce4..90349657 100755 --- a/src/ebusd/mqttclient_mosquitto.cpp +++ b/src/ebusd/mqttclient_mosquitto.cpp @@ -31,8 +31,6 @@ namespace ebusd { -using std::dec; - bool check(int code, const char* method) { if (code == MOSQ_ERR_SUCCESS) { diff --git a/src/ebusd/mqtthandler.cpp b/src/ebusd/mqtthandler.cpp index c490b55d..c734cc5c 100755 --- a/src/ebusd/mqtthandler.cpp +++ b/src/ebusd/mqtthandler.cpp @@ -954,7 +954,7 @@ void MqttHandler::run() { auto vl = (dynamic_cast(field))->getList(); string entryFormat = values["field_values-entry"]; string::size_type pos = -1; - while ((pos = entryFormat.find('$', pos+1)) != std::string::npos) { + while ((pos = entryFormat.find('$', pos+1)) != string::npos) { if (entryFormat.substr(pos+1, 4) == "text" || entryFormat.substr(pos+1, 5) == "value") { entryFormat.replace(pos, 1, "%"); } diff --git a/src/ebusd/scan.cpp b/src/ebusd/scan.cpp index 4309cc42..f3ee1fc8 100644 --- a/src/ebusd/scan.cpp +++ b/src/ebusd/scan.cpp @@ -40,7 +40,6 @@ using std::hex; using std::setfill; using std::setw; using std::nouppercase; -using std::cout; ScanHelper::~ScanHelper() { diff --git a/src/lib/ebus/data.cpp b/src/lib/ebus/data.cpp index f463ee70..8defc41f 100644 --- a/src/lib/ebus/data.cpp +++ b/src/lib/ebus/data.cpp @@ -32,7 +32,6 @@ namespace ebusd { using std::dec; -using std::hex; using std::setw; /** the week day names. */ @@ -1469,7 +1468,7 @@ bool DataFieldTemplates::dump(OutputFormat outputFormat, ostream* output) const if (outputFormat & OF_JSON) { if (dataField->isSet()) { if (prependFieldSeparator) { - *output << ",\n"; + *output << ",\n"; } *output << "{\"name\":\"" << dataField->getName(-1) << "\", \"sequence\": ["; dataField->dump(false, outputFormat, output); diff --git a/src/lib/ebus/datatype.cpp b/src/lib/ebus/datatype.cpp index 854097b5..6320f944 100755 --- a/src/lib/ebus/datatype.cpp +++ b/src/lib/ebus/datatype.cpp @@ -34,13 +34,11 @@ namespace ebusd { using std::dec; -using std::defaultfloat; using std::hex; using std::fixed; using std::setfill; using std::setprecision; using std::setw; -using std::endl; using std::isfinite; diff --git a/src/lib/ebus/device.cpp b/src/lib/ebus/device.cpp index 1132bdaa..b250b24f 100755 --- a/src/lib/ebus/device.cpp +++ b/src/lib/ebus/device.cpp @@ -46,6 +46,14 @@ namespace ebusd { +using std::hex; +using std::dec; +using std::setfill; +using std::setw; +using std::setprecision; +using std::fixed; + + #define MTU 1540 #ifndef POLLRDHUP @@ -728,37 +736,37 @@ bool FileDevice::handleEnhancedBufferedData(symbol_t* value, ArbitrationState* a case 0x0200: case 0x0500: // with firmware version and jumper info case 0x0800: // with firmware version, jumper info, and bootloader version - stream << std::hex << static_cast(m_infoBuf[1]) // features mask + stream << hex << static_cast(m_infoBuf[1]) // features mask << "." << static_cast(m_infoBuf[0]); // version minor if (m_infoLen >= 5) { - stream << "[" << std::setfill('0') << std::setw(2) << std::hex << static_cast(m_infoBuf[2]) - << std::setw(2) << static_cast(m_infoBuf[3]) << "]"; + stream << "[" << setfill('0') << setw(2) << hex << static_cast(m_infoBuf[2]) + << setw(2) << static_cast(m_infoBuf[3]) << "]"; } if (m_infoLen >= 8) { - stream << "." << std::dec << static_cast(m_infoBuf[5]); - stream << "[" << std::setfill('0') << std::setw(2) << std::hex << static_cast(m_infoBuf[6]) - << std::setw(2) << static_cast(m_infoBuf[7]) << "]"; + stream << "." << dec << static_cast(m_infoBuf[5]); + stream << "[" << setfill('0') << setw(2) << hex << static_cast(m_infoBuf[6]) + << setw(2) << static_cast(m_infoBuf[7]) << "]"; } m_enhInfoVersion = stream.str(); stream.str(" "); stream << "firmware " << m_enhInfoVersion; if (m_infoLen >= 5) { - stream << ", jumpers 0x" << std::setw(2) << static_cast(m_infoBuf[4]); + stream << ", jumpers 0x" << setw(2) << static_cast(m_infoBuf[4]); } - stream << std::setfill(' '); // reset + stream << setfill(' '); // reset break; case 0x0901: case 0x0802: case 0x0302: stream << (m_infoId == 1 ? "ID" : "config"); - stream << std::hex << std::setfill('0'); + stream << hex << setfill('0'); for (uint8_t pos = 0; pos < m_infoPos; pos++) { - stream << " " << std::setw(2) << static_cast(m_infoBuf[pos]); + stream << " " << setw(2) << static_cast(m_infoBuf[pos]); } if (m_infoId == 2 && (m_infoBuf[2]&0x3f) != 0x3f) { // non-default arbitration delay val = (m_infoBuf[2]&0x3f)*10; // steps of 10us - stream << ", arbitration delay " << std::dec << static_cast(val) << " us"; + stream << ", arbitration delay " << dec << static_cast(val) << " us"; } break; case 0x0203: @@ -779,7 +787,7 @@ bool FileDevice::handleEnhancedBufferedData(symbol_t* value, ArbitrationState* a case 0x0205: stream << "bus voltage "; if (m_infoBuf[0] | m_infoBuf[1]) { - stream << std::fixed << std::setprecision(1) + stream << fixed << setprecision(1) << static_cast(m_infoBuf[1] / 10.0) << " V - " << static_cast(m_infoBuf[0] / 10.0) << " V"; } else { @@ -807,8 +815,8 @@ bool FileDevice::handleEnhancedBufferedData(symbol_t* value, ArbitrationState* a } break; default: - stream << "unknown 0x" << std::hex << std::setfill('0') << std::setw(2) - << static_cast(m_infoId) << ", len " << std::dec << std::setw(0) + stream << "unknown 0x" << hex << setfill('0') << setw(2) + << static_cast(m_infoId) << ", len " << dec << setw(0) << static_cast(m_infoPos); break; } @@ -834,7 +842,7 @@ bool FileDevice::handleEnhancedBufferedData(symbol_t* value, ArbitrationState* a stream << "overrun"; break; default: - stream << "unknown 0x" << std::setw(2) << std::setfill('0') << std::hex << static_cast(data); + stream << "unknown 0x" << setw(2) << setfill('0') << hex << static_cast(data); break; } string str = stream.str(); @@ -845,7 +853,7 @@ bool FileDevice::handleEnhancedBufferedData(symbol_t* value, ArbitrationState* a default: if (m_listener != nullptr) { ostringstream stream; - stream << "unexpected enhanced command 0x" << std::setw(2) << std::setfill('0') << std::hex + stream << "unexpected enhanced command 0x" << setw(2) << setfill('0') << hex << static_cast(cmd); string str = stream.str(); m_listener->notifyStatus(true, str.c_str()); diff --git a/src/lib/ebus/filereader.cpp b/src/lib/ebus/filereader.cpp index 545179b5..98072b29 100755 --- a/src/lib/ebus/filereader.cpp +++ b/src/lib/ebus/filereader.cpp @@ -32,8 +32,6 @@ using std::ifstream; using std::ostringstream; using std::cout; using std::endl; -using std::setw; -using std::dec; istream* FileReader::openFile(const string& filename, string* errorDescription, time_t* time) { diff --git a/src/lib/ebus/filereader.h b/src/lib/ebus/filereader.h index 08a698dd..906e1fde 100755 --- a/src/lib/ebus/filereader.h +++ b/src/lib/ebus/filereader.h @@ -44,6 +44,10 @@ using std::string; using std::map; using std::ostream; using std::istream; +using std::hex; +using std::dec; +using std::setw; +using std::setfill; /** the separator character used between fields. */ #define FIELD_SEPARATOR ',' @@ -174,7 +178,7 @@ class FileReader { * @param stream the @a ostream to write to. */ static void formatHash(size_t hash, ostream* stream) { - *stream << std::hex << std::setw(8) << std::setfill('0') << (hash & 0xffffffff) << std::dec << std::setw(0); + *stream << hex << setw(8) << setfill('0') << (hash & 0xffffffff) << dec << setw(0); } /** diff --git a/src/lib/ebus/message.h b/src/lib/ebus/message.h index 7d314670..647539f7 100644 --- a/src/lib/ebus/message.h +++ b/src/lib/ebus/message.h @@ -902,7 +902,7 @@ class Condition { * Write the values part of the condition definition in JSON to the @a ostream. * @param output the @a ostream to append to. */ - virtual void dumpValuesJson(ostream* output) const { /* empty on top level*/ }; + virtual void dumpValuesJson(ostream* output) const { /* empty on top level*/ } /** * Combine this condition with another instance using a logical and. diff --git a/src/lib/ebus/stringhelper.cpp b/src/lib/ebus/stringhelper.cpp index 630b78f3..22b27ad5 100644 --- a/src/lib/ebus/stringhelper.cpp +++ b/src/lib/ebus/stringhelper.cpp @@ -499,7 +499,7 @@ bool StringReplacers::set(const string& key, const string& value, bool removeRep } void StringReplacers::set(const string& key, int value) { - std::ostringstream str; + ostringstream str; str << static_cast(value); m_constants[key] = str.str(); } diff --git a/src/lib/ebus/stringhelper.h b/src/lib/ebus/stringhelper.h index fd3b7dbe..01561ee6 100644 --- a/src/lib/ebus/stringhelper.h +++ b/src/lib/ebus/stringhelper.h @@ -162,7 +162,7 @@ class StringReplacer { * the number is negative for plain strings, the index to @a knownFieldNames for a known field, or the size of * @a knownFieldNames for an unknown field. */ - vector> m_parts; + vector> m_parts; /** true when the complete result is supposed to be empty when at least one referenced variable * is empty or not defined. */ diff --git a/src/lib/utils/arg.h b/src/lib/utils/arg.h index 8ef28961..2cc98b2d 100755 --- a/src/lib/utils/arg.h +++ b/src/lib/utils/arg.h @@ -35,7 +35,8 @@ enum ArgFlag { typedef struct argDef { const char* name; //!< the (long) name of the argument, or nullptr for a group header or positional int key; //!< the argument key, also used as short name if alphabetic or the question mark - const char* valueName; //!< the optional argument value name, or nullptr for group header or argument without value name + // the optional argument value name, or nullptr for group header or argument without value name + const char* valueName; int flags; //!< flags for the argument, bit combination of @a ArgFlag const char* help; //!< help text (mandatory) } argDef; diff --git a/src/lib/utils/httpclient.cpp b/src/lib/utils/httpclient.cpp index c89e8e9e..bbdc71c4 100755 --- a/src/lib/utils/httpclient.cpp +++ b/src/lib/utils/httpclient.cpp @@ -33,7 +33,6 @@ namespace ebusd { using std::string; using std::ostringstream; using std::dec; -using std::hex; #ifdef HAVE_SSL @@ -434,7 +433,8 @@ void HttpClient::disconnect() { } } -bool HttpClient::get(const string& uri, const string& body, string* response, bool* repeatable, time_t* time, bool* jsonString) { +bool HttpClient::get(const string& uri, const string& body, string* response, bool* repeatable, +time_t* time, bool* jsonString) { return request("GET", uri, body, response, repeatable, time, jsonString); }