mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 12:46:22 +01:00
Compatibility with clang-tidy v14 (#2272)
This commit is contained in:
parent
f31e0532c4
commit
0cd24c629a
@ -2,9 +2,11 @@
|
|||||||
Checks: >-
|
Checks: >-
|
||||||
*,
|
*,
|
||||||
-abseil-*,
|
-abseil-*,
|
||||||
|
-altera-*,
|
||||||
-android-*,
|
-android-*,
|
||||||
-boost-*,
|
-boost-*,
|
||||||
-bugprone-branch-clone,
|
-bugprone-branch-clone,
|
||||||
|
-bugprone-easily-swappable-parameters,
|
||||||
-bugprone-narrowing-conversions,
|
-bugprone-narrowing-conversions,
|
||||||
-bugprone-signed-char-misuse,
|
-bugprone-signed-char-misuse,
|
||||||
-bugprone-too-small-loop-variable,
|
-bugprone-too-small-loop-variable,
|
||||||
@ -20,6 +22,7 @@ Checks: >-
|
|||||||
-clang-diagnostic-sign-compare,
|
-clang-diagnostic-sign-compare,
|
||||||
-clang-diagnostic-unused-variable,
|
-clang-diagnostic-unused-variable,
|
||||||
-clang-diagnostic-unused-const-variable,
|
-clang-diagnostic-unused-const-variable,
|
||||||
|
-concurrency-*,
|
||||||
-cppcoreguidelines-avoid-c-arrays,
|
-cppcoreguidelines-avoid-c-arrays,
|
||||||
-cppcoreguidelines-avoid-goto,
|
-cppcoreguidelines-avoid-goto,
|
||||||
-cppcoreguidelines-avoid-magic-numbers,
|
-cppcoreguidelines-avoid-magic-numbers,
|
||||||
@ -72,6 +75,7 @@ Checks: >-
|
|||||||
-readability-const-return-type,
|
-readability-const-return-type,
|
||||||
-readability-convert-member-functions-to-static,
|
-readability-convert-member-functions-to-static,
|
||||||
-readability-else-after-return,
|
-readability-else-after-return,
|
||||||
|
-readability-function-cognitive-complexity,
|
||||||
-readability-implicit-bool-conversion,
|
-readability-implicit-bool-conversion,
|
||||||
-readability-isolate-declaration,
|
-readability-isolate-declaration,
|
||||||
-readability-magic-numbers,
|
-readability-magic-numbers,
|
||||||
|
@ -113,14 +113,14 @@ void BME280Component::setup() {
|
|||||||
this->calibration_.h5 = read_u8_(BME280_REGISTER_DIG_H5 + 1) << 4 | (read_u8_(BME280_REGISTER_DIG_H5) >> 4);
|
this->calibration_.h5 = read_u8_(BME280_REGISTER_DIG_H5 + 1) << 4 | (read_u8_(BME280_REGISTER_DIG_H5) >> 4);
|
||||||
this->calibration_.h6 = read_u8_(BME280_REGISTER_DIG_H6);
|
this->calibration_.h6 = read_u8_(BME280_REGISTER_DIG_H6);
|
||||||
|
|
||||||
uint8_t humid_register = 0;
|
uint8_t humid_control_val = 0;
|
||||||
if (!this->read_byte(BME280_REGISTER_CONTROLHUMID, &humid_register)) {
|
if (!this->read_byte(BME280_REGISTER_CONTROLHUMID, &humid_control_val)) {
|
||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
humid_register &= ~0b00000111;
|
humid_control_val &= ~0b00000111;
|
||||||
humid_register |= this->humidity_oversampling_ & 0b111;
|
humid_control_val |= this->humidity_oversampling_ & 0b111;
|
||||||
if (!this->write_byte(BME280_REGISTER_CONTROLHUMID, humid_register)) {
|
if (!this->write_byte(BME280_REGISTER_CONTROLHUMID, humid_control_val)) {
|
||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -169,11 +169,11 @@ inline uint8_t oversampling_to_time(BME280Oversampling over_sampling) { return (
|
|||||||
void BME280Component::update() {
|
void BME280Component::update() {
|
||||||
// Enable sensor
|
// Enable sensor
|
||||||
ESP_LOGV(TAG, "Sending conversion request...");
|
ESP_LOGV(TAG, "Sending conversion request...");
|
||||||
uint8_t meas_register = 0;
|
uint8_t meas_value = 0;
|
||||||
meas_register |= (this->temperature_oversampling_ & 0b111) << 5;
|
meas_value |= (this->temperature_oversampling_ & 0b111) << 5;
|
||||||
meas_register |= (this->pressure_oversampling_ & 0b111) << 2;
|
meas_value |= (this->pressure_oversampling_ & 0b111) << 2;
|
||||||
meas_register |= BME280_MODE_FORCED;
|
meas_value |= BME280_MODE_FORCED;
|
||||||
if (!this->write_byte(BME280_REGISTER_CONTROL, meas_register)) {
|
if (!this->write_byte(BME280_REGISTER_CONTROL, meas_value)) {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -123,11 +123,11 @@ inline uint8_t oversampling_to_time(BMP280Oversampling over_sampling) { return (
|
|||||||
void BMP280Component::update() {
|
void BMP280Component::update() {
|
||||||
// Enable sensor
|
// Enable sensor
|
||||||
ESP_LOGV(TAG, "Sending conversion request...");
|
ESP_LOGV(TAG, "Sending conversion request...");
|
||||||
uint8_t meas_register = 0;
|
uint8_t meas_value = 0;
|
||||||
meas_register |= (this->temperature_oversampling_ & 0b111) << 5;
|
meas_value |= (this->temperature_oversampling_ & 0b111) << 5;
|
||||||
meas_register |= (this->pressure_oversampling_ & 0b111) << 2;
|
meas_value |= (this->pressure_oversampling_ & 0b111) << 2;
|
||||||
meas_register |= 0b01; // Forced mode
|
meas_value |= 0b01; // Forced mode
|
||||||
if (!this->write_byte(BMP280_REGISTER_CONTROL, meas_register)) {
|
if (!this->write_byte(BMP280_REGISTER_CONTROL, meas_value)) {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -514,9 +514,7 @@ Color Animation::get_grayscale_pixel(int x, int y) const {
|
|||||||
return Color(gray | gray << 8 | gray << 16 | gray << 24);
|
return Color(gray | gray << 8 | gray << 16 | gray << 24);
|
||||||
}
|
}
|
||||||
Animation::Animation(const uint8_t *data_start, int width, int height, uint32_t animation_frame_count, ImageType type)
|
Animation::Animation(const uint8_t *data_start, int width, int height, uint32_t animation_frame_count, ImageType type)
|
||||||
: Image(data_start, width, height, type), animation_frame_count_(animation_frame_count) {
|
: Image(data_start, width, height, type), current_frame_(0), animation_frame_count_(animation_frame_count) {}
|
||||||
current_frame_ = 0;
|
|
||||||
}
|
|
||||||
int Animation::get_animation_frame_count() const { return this->animation_frame_count_; }
|
int Animation::get_animation_frame_count() const { return this->animation_frame_count_; }
|
||||||
int Animation::get_current_frame() const { return this->current_frame_; }
|
int Animation::get_current_frame() const { return this->current_frame_; }
|
||||||
void Animation::next_frame() {
|
void Animation::next_frame() {
|
||||||
|
@ -16,7 +16,7 @@ I2CComponent::I2CComponent() {
|
|||||||
this->wire_ = new TwoWire(next_i2c_bus_num_);
|
this->wire_ = new TwoWire(next_i2c_bus_num_);
|
||||||
next_i2c_bus_num_++;
|
next_i2c_bus_num_++;
|
||||||
#else
|
#else
|
||||||
this->wire_ = &Wire;
|
this->wire_ = &Wire; // NOLINT(cppcoreguidelines-prefer-member-initializer)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +38,8 @@ float MCP3008::read_data(uint8_t pin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MCP3008Sensor::MCP3008Sensor(MCP3008 *parent, const std::string &name, uint8_t pin, float reference_voltage)
|
MCP3008Sensor::MCP3008Sensor(MCP3008 *parent, const std::string &name, uint8_t pin, float reference_voltage)
|
||||||
: PollingComponent(1000), parent_(parent), pin_(pin) {
|
: PollingComponent(1000), parent_(parent), pin_(pin), reference_voltage_(reference_voltage) {
|
||||||
this->set_name(name);
|
this->set_name(name);
|
||||||
this->reference_voltage_ = reference_voltage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float MCP3008Sensor::get_setup_priority() const { return setup_priority::DATA; }
|
float MCP3008Sensor::get_setup_priority() const { return setup_priority::DATA; }
|
||||||
|
@ -25,7 +25,7 @@ MQTTClientComponent::MQTTClientComponent() {
|
|||||||
// Connection
|
// Connection
|
||||||
void MQTTClientComponent::setup() {
|
void MQTTClientComponent::setup() {
|
||||||
ESP_LOGCONFIG(TAG, "Setting up MQTT...");
|
ESP_LOGCONFIG(TAG, "Setting up MQTT...");
|
||||||
this->mqtt_client_.onMessage([this](char *topic, char *payload, AsyncMqttClientMessageProperties properties,
|
this->mqtt_client_.onMessage([this](char const *topic, char *payload, AsyncMqttClientMessageProperties properties,
|
||||||
size_t len, size_t index, size_t total) {
|
size_t len, size_t index, size_t total) {
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
this->payload_buffer_.reserve(total);
|
this->payload_buffer_.reserve(total);
|
||||||
|
@ -41,7 +41,7 @@ optional<RC5Data> RC5Protocol::decode(RemoteReceiveData src) {
|
|||||||
.address = 0,
|
.address = 0,
|
||||||
.command = 0,
|
.command = 0,
|
||||||
};
|
};
|
||||||
int field_bit = 0;
|
uint8_t field_bit;
|
||||||
|
|
||||||
if (src.expect_space(BIT_TIME_US) && src.expect_mark(BIT_TIME_US)) {
|
if (src.expect_space(BIT_TIME_US) && src.expect_mark(BIT_TIME_US)) {
|
||||||
field_bit = 1;
|
field_bit = 1;
|
||||||
@ -60,7 +60,7 @@ optional<RC5Data> RC5Protocol::decode(RemoteReceiveData src) {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t out_data = 0;
|
uint32_t out_data = 0;
|
||||||
for (int bit = NBITS - 4; bit >= 1; bit--) {
|
for (int bit = NBITS - 4; bit >= 1; bit--) {
|
||||||
if ((src.expect_space(BIT_TIME_US) || src.expect_space(2 * BIT_TIME_US)) &&
|
if ((src.expect_space(BIT_TIME_US) || src.expect_space(2 * BIT_TIME_US)) &&
|
||||||
(src.expect_mark(BIT_TIME_US) || src.peek_mark(2 * BIT_TIME_US))) {
|
(src.expect_mark(BIT_TIME_US) || src.peek_mark(2 * BIT_TIME_US))) {
|
||||||
@ -78,7 +78,7 @@ optional<RC5Data> RC5Protocol::decode(RemoteReceiveData src) {
|
|||||||
out_data |= 1;
|
out_data |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
out.command = (out_data & 0x3F) + (1 - field_bit) * 64;
|
out.command = (uint8_t)(out_data & 0x3F) + (1 - field_bit) * 64u;
|
||||||
out.address = (out_data >> 6) & 0x1F;
|
out.address = (out_data >> 6) & 0x1F;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -220,15 +220,14 @@ static const uint8_t PROGMEM
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
static const char *const TAG = "st7735";
|
static const char *const TAG = "st7735";
|
||||||
|
|
||||||
ST7735::ST7735(ST7735Model model, int width, int height, int colstart, int rowstart, bool eightbitcolor, bool usebgr) {
|
ST7735::ST7735(ST7735Model model, int width, int height, int colstart, int rowstart, bool eightbitcolor, bool usebgr)
|
||||||
model_ = model;
|
: model_(model),
|
||||||
this->width_ = width;
|
colstart_(colstart),
|
||||||
this->height_ = height;
|
rowstart_(rowstart),
|
||||||
this->colstart_ = colstart;
|
eightbitcolor_(eightbitcolor),
|
||||||
this->rowstart_ = rowstart;
|
usebgr_(usebgr),
|
||||||
this->eightbitcolor_ = eightbitcolor;
|
width_(width),
|
||||||
this->usebgr_ = usebgr;
|
height_(height) {}
|
||||||
}
|
|
||||||
|
|
||||||
void ST7735::setup() {
|
void ST7735::setup() {
|
||||||
ESP_LOGCONFIG(TAG, "Setting up ST7735...");
|
ESP_LOGCONFIG(TAG, "Setting up ST7735...");
|
||||||
|
@ -79,10 +79,8 @@ struct SunAtTime {
|
|||||||
num_t jde;
|
num_t jde;
|
||||||
num_t t;
|
num_t t;
|
||||||
|
|
||||||
SunAtTime(num_t jde) : jde(jde) {
|
|
||||||
// eq 25.1, p. 163; julian centuries from the epoch J2000.0
|
// eq 25.1, p. 163; julian centuries from the epoch J2000.0
|
||||||
t = (jde - 2451545) / 36525.0;
|
SunAtTime(num_t jde) : jde(jde), t((jde - 2451545) / 36525.0) {}
|
||||||
}
|
|
||||||
|
|
||||||
num_t mean_obliquity() const {
|
num_t mean_obliquity() const {
|
||||||
// eq. 22.2, p. 147; mean obliquity of the ecliptic
|
// eq. 22.2, p. 147; mean obliquity of the ecliptic
|
||||||
|
@ -196,10 +196,8 @@ uint32_t Nameable::get_object_id_hash() { return this->object_id_hash_; }
|
|||||||
bool Nameable::is_disabled_by_default() const { return this->disabled_by_default_; }
|
bool Nameable::is_disabled_by_default() const { return this->disabled_by_default_; }
|
||||||
void Nameable::set_disabled_by_default(bool disabled_by_default) { this->disabled_by_default_ = disabled_by_default; }
|
void Nameable::set_disabled_by_default(bool disabled_by_default) { this->disabled_by_default_ = disabled_by_default; }
|
||||||
|
|
||||||
WarnIfComponentBlockingGuard::WarnIfComponentBlockingGuard(Component *component) {
|
WarnIfComponentBlockingGuard::WarnIfComponentBlockingGuard(Component *component)
|
||||||
component_ = component;
|
: started_(millis()), component_(component) {}
|
||||||
started_ = millis();
|
|
||||||
}
|
|
||||||
WarnIfComponentBlockingGuard::~WarnIfComponentBlockingGuard() {
|
WarnIfComponentBlockingGuard::~WarnIfComponentBlockingGuard() {
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
if (now - started_ > 50) {
|
if (now - started_ > 50) {
|
||||||
|
@ -20,7 +20,7 @@ static const char *const TAG = "preferences";
|
|||||||
ESPPreferenceObject::ESPPreferenceObject() : offset_(0), length_words_(0), type_(0), data_(nullptr) {}
|
ESPPreferenceObject::ESPPreferenceObject() : offset_(0), length_words_(0), type_(0), data_(nullptr) {}
|
||||||
ESPPreferenceObject::ESPPreferenceObject(size_t offset, size_t length, uint32_t type)
|
ESPPreferenceObject::ESPPreferenceObject(size_t offset, size_t length, uint32_t type)
|
||||||
: offset_(offset), length_words_(length), type_(type) {
|
: offset_(offset), length_words_(length), type_(type) {
|
||||||
this->data_ = new uint32_t[this->length_words_ + 1];
|
this->data_ = new uint32_t[this->length_words_ + 1]; // NOLINT(cppcoreguidelines-prefer-member-initializer)
|
||||||
for (uint32_t i = 0; i < this->length_words_ + 1; i++)
|
for (uint32_t i = 0; i < this->length_words_ + 1; i++)
|
||||||
this->data_[i] = 0;
|
this->data_[i] = 0;
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ static inline bool esp_rtc_user_mem_read(uint32_t index, uint32_t *dest) {
|
|||||||
if (index >= ESP_RTC_USER_MEM_SIZE_WORDS) {
|
if (index >= ESP_RTC_USER_MEM_SIZE_WORDS) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*dest = ESP_RTC_USER_MEM[index];
|
*dest = ESP_RTC_USER_MEM[index]; // NOLINT(performance-no-int-to-ptr)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ static inline bool esp_rtc_user_mem_write(uint32_t index, uint32_t value) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto *ptr = &ESP_RTC_USER_MEM[index];
|
auto *ptr = &ESP_RTC_USER_MEM[index]; // NOLINT(performance-no-int-to-ptr)
|
||||||
*ptr = value;
|
*ptr = value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user