1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-27 13:13:50 +00:00

Enable a bunch of clang-tidy checks (#2149)

This commit is contained in:
Oxan van Leeuwen
2021-12-01 21:03:51 +01:00
committed by GitHub
parent f58828cb82
commit 607601b3a4
79 changed files with 206 additions and 296 deletions

View File

@@ -13,8 +13,6 @@ void ModbusBinarySensor::parse_and_publish(const std::vector<uint8_t> &data) {
switch (this->register_type) {
case ModbusRegisterType::DISCRETE_INPUT:
value = coil_from_vector(this->offset, data);
break;
case ModbusRegisterType::COIL:
// offset for coil is the actual number of the coil not the byte offset
value = coil_from_vector(this->offset, data);

View File

@@ -102,8 +102,6 @@ inline ModbusFunctionCode modbus_register_write_function(ModbusRegisterType reg_
return ModbusFunctionCode::READ_WRITE_MULTIPLE_REGISTERS;
break;
case ModbusRegisterType::READ:
return ModbusFunctionCode::CUSTOM;
break;
default:
return ModbusFunctionCode::CUSTOM;
break;
@@ -221,7 +219,7 @@ template<typename N> N mask_and_shift_by_rightbit(N data, uint32_t mask) {
if (result == 0) {
return result;
}
for (int pos = 0; pos < sizeof(N) << 3; pos++) {
for (size_t pos = 0; pos < sizeof(N) << 3; pos++) {
if ((mask & (1 << pos)) != 0)
return result >> pos;
}

View File

@@ -8,11 +8,6 @@ namespace modbus_controller {
static const char *const TAG = "modbus.number";
void ModbusNumber::parse_and_publish(const std::vector<uint8_t> &data) {
union {
float float_value;
uint32_t raw;
} raw_to_float;
float result = payload_to_float(data, *this);
// Is there a lambda registered
@@ -31,13 +26,7 @@ void ModbusNumber::parse_and_publish(const std::vector<uint8_t> &data) {
}
void ModbusNumber::control(float value) {
union {
float float_value;
uint32_t raw;
} raw_to_float;
std::vector<uint16_t> data;
auto original_value = value;
// Is there are lambda configured?
if (this->write_transform_func_.has_value()) {
// data is passed by reference

View File

@@ -13,11 +13,6 @@ void ModbusOutput::setup() {}
*
*/
void ModbusOutput::write_state(float value) {
union {
float float_value;
uint32_t raw;
} raw_to_float;
std::vector<uint16_t> data;
auto original_value = value;
// Is there are lambda configured?

View File

@@ -10,11 +10,6 @@ static const char *const TAG = "modbus_controller.sensor";
void ModbusSensor::dump_config() { LOG_SENSOR(TAG, "Modbus Controller Sensor", this); }
void ModbusSensor::parse_and_publish(const std::vector<uint8_t> &data) {
union {
float float_value;
uint32_t raw;
} raw_to_float;
float result = payload_to_float(data, *this);
// Is there a lambda registered