Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
john30 committed Nov 4, 2023
1 parent 607fc00 commit 077d09b
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 33 deletions.
2 changes: 0 additions & 2 deletions src/ebusd/mqttclient_mosquitto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

namespace ebusd {

using std::dec;


bool check(int code, const char* method) {
if (code == MOSQ_ERR_SUCCESS) {
Expand Down
2 changes: 1 addition & 1 deletion src/ebusd/mqtthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ void MqttHandler::run() {
auto vl = (dynamic_cast<const ValueListDataField*>(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, "%");
}
Expand Down
1 change: 0 additions & 1 deletion src/ebusd/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ using std::hex;
using std::setfill;
using std::setw;
using std::nouppercase;
using std::cout;


ScanHelper::~ScanHelper() {
Expand Down
3 changes: 1 addition & 2 deletions src/lib/ebus/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
namespace ebusd {

using std::dec;
using std::hex;
using std::setw;

/** the week day names. */
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/lib/ebus/datatype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
40 changes: 24 additions & 16 deletions src/lib/ebus/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<unsigned>(m_infoBuf[1]) // features mask
stream << hex << static_cast<unsigned>(m_infoBuf[1]) // features mask
<< "." << static_cast<unsigned>(m_infoBuf[0]); // version minor
if (m_infoLen >= 5) {
stream << "[" << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned>(m_infoBuf[2])
<< std::setw(2) << static_cast<unsigned>(m_infoBuf[3]) << "]";
stream << "[" << setfill('0') << setw(2) << hex << static_cast<unsigned>(m_infoBuf[2])
<< setw(2) << static_cast<unsigned>(m_infoBuf[3]) << "]";
}
if (m_infoLen >= 8) {
stream << "." << std::dec << static_cast<unsigned>(m_infoBuf[5]);
stream << "[" << std::setfill('0') << std::setw(2) << std::hex << static_cast<unsigned>(m_infoBuf[6])
<< std::setw(2) << static_cast<unsigned>(m_infoBuf[7]) << "]";
stream << "." << dec << static_cast<unsigned>(m_infoBuf[5]);
stream << "[" << setfill('0') << setw(2) << hex << static_cast<unsigned>(m_infoBuf[6])
<< setw(2) << static_cast<unsigned>(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<unsigned>(m_infoBuf[4]);
stream << ", jumpers 0x" << setw(2) << static_cast<unsigned>(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<unsigned>(m_infoBuf[pos]);
stream << " " << setw(2) << static_cast<unsigned>(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<unsigned>(val) << " us";
stream << ", arbitration delay " << dec << static_cast<unsigned>(val) << " us";
}
break;
case 0x0203:
Expand All @@ -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<float>(m_infoBuf[1] / 10.0) << " V - "
<< static_cast<float>(m_infoBuf[0] / 10.0) << " V";
} else {
Expand Down Expand Up @@ -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<unsigned>(m_infoId) << ", len " << std::dec << std::setw(0)
stream << "unknown 0x" << hex << setfill('0') << setw(2)
<< static_cast<unsigned>(m_infoId) << ", len " << dec << setw(0)
<< static_cast<unsigned>(m_infoPos);
break;
}
Expand All @@ -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<unsigned>(data);
stream << "unknown 0x" << setw(2) << setfill('0') << hex << static_cast<unsigned>(data);
break;
}
string str = stream.str();
Expand All @@ -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<unsigned>(cmd);
string str = stream.str();
m_listener->notifyStatus(true, str.c_str());
Expand Down
2 changes: 0 additions & 2 deletions src/lib/ebus/filereader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion src/lib/ebus/filereader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ','
Expand Down Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ebus/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ebus/stringhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<signed>(value);
m_constants[key] = str.str();
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ebus/stringhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::pair<string, int>> m_parts;
vector<pair<string, int>> m_parts;

/** true when the complete result is supposed to be empty when at least one referenced variable
* is empty or not defined. */
Expand Down
3 changes: 2 additions & 1 deletion src/lib/utils/arg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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 @@ -33,7 +33,6 @@ namespace ebusd {
using std::string;
using std::ostringstream;
using std::dec;
using std::hex;

#ifdef HAVE_SSL

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 077d09b

Please sign in to comment.