[various] clang-tidy fixes for #7822 (#7874)

This commit is contained in:
Keith Burzinski 2024-11-27 16:23:20 -06:00 committed by GitHub
parent a825ef59d4
commit 12cdeca48a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 48 additions and 26 deletions

View File

@ -133,8 +133,10 @@ bool HitachiClimate::get_swing_v_() {
} }
void HitachiClimate::set_swing_h_(uint8_t position) { void HitachiClimate::set_swing_h_(uint8_t position) {
if (position > HITACHI_AC344_SWINGH_LEFT_MAX) if (position > HITACHI_AC344_SWINGH_LEFT_MAX) {
return set_swing_h_(HITACHI_AC344_SWINGH_MIDDLE); set_swing_h_(HITACHI_AC344_SWINGH_MIDDLE);
return;
}
set_bits(&remote_state_[HITACHI_AC344_SWINGH_BYTE], HITACHI_AC344_SWINGH_OFFSET, HITACHI_AC344_SWINGH_SIZE, position); set_bits(&remote_state_[HITACHI_AC344_SWINGH_BYTE], HITACHI_AC344_SWINGH_OFFSET, HITACHI_AC344_SWINGH_SIZE, position);
set_button_(HITACHI_AC344_BUTTON_SWINGH); set_button_(HITACHI_AC344_BUTTON_SWINGH);
} }

View File

@ -133,8 +133,10 @@ bool HitachiClimate::get_swing_v_() {
} }
void HitachiClimate::set_swing_h_(uint8_t position) { void HitachiClimate::set_swing_h_(uint8_t position) {
if (position > HITACHI_AC424_SWINGH_LEFT_MAX) if (position > HITACHI_AC424_SWINGH_LEFT_MAX) {
return set_swing_h_(HITACHI_AC424_SWINGH_MIDDLE); set_swing_h_(HITACHI_AC424_SWINGH_MIDDLE);
return;
}
set_bits(&remote_state_[HITACHI_AC424_SWINGH_BYTE], HITACHI_AC424_SWINGH_OFFSET, HITACHI_AC424_SWINGH_SIZE, position); set_bits(&remote_state_[HITACHI_AC424_SWINGH_BYTE], HITACHI_AC424_SWINGH_OFFSET, HITACHI_AC424_SWINGH_SIZE, position);
set_button_(HITACHI_AC424_BUTTON_SWINGH); set_button_(HITACHI_AC424_BUTTON_SWINGH);
} }

View File

@ -313,8 +313,9 @@ void ILI9XXXDisplay::draw_pixels_at(int x_start, int y_start, int w, int h, cons
// do color conversion pixel-by-pixel into the buffer and draw it later. If this is happening the user has not // do color conversion pixel-by-pixel into the buffer and draw it later. If this is happening the user has not
// configured the renderer well. // configured the renderer well.
if (this->rotation_ != display::DISPLAY_ROTATION_0_DEGREES || bitness != display::COLOR_BITNESS_565 || !big_endian) { if (this->rotation_ != display::DISPLAY_ROTATION_0_DEGREES || bitness != display::COLOR_BITNESS_565 || !big_endian) {
return display::Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset, display::Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset,
x_pad); x_pad);
return;
} }
this->set_addr_window_(x_start, y_start, x_start + w - 1, y_start + h - 1); this->set_addr_window_(x_start, y_start, x_start + w - 1, y_start + h - 1);
// x_ and y_offset are offsets into the source buffer, unrelated to our own offsets into the display. // x_ and y_offset are offsets into the source buffer, unrelated to our own offsets into the display.

View File

@ -146,7 +146,8 @@ void QspiDbi::draw_pixels_at(int x_start, int y_start, int w, int h, const uint8
return; return;
if (bitness != display::COLOR_BITNESS_565 || order != this->color_mode_ || if (bitness != display::COLOR_BITNESS_565 || order != this->color_mode_ ||
big_endian != (this->bit_order_ == spi::BIT_ORDER_MSB_FIRST)) { big_endian != (this->bit_order_ == spi::BIT_ORDER_MSB_FIRST)) {
return Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset, x_pad); Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset, x_pad);
return;
} else if (this->draw_from_origin_) { } else if (this->draw_from_origin_) {
auto stride = x_offset + w + x_pad; auto stride = x_offset + w + x_pad;
for (int y = 0; y != h; y++) { for (int y = 0; y != h; y++) {

View File

@ -483,7 +483,7 @@ void ST7735::spi_master_write_color_(uint16_t color, uint16_t size) {
} }
this->dc_pin_->digital_write(true); this->dc_pin_->digital_write(true);
return write_array(byte, size * 2); write_array(byte, size * 2);
} }
} // namespace st7735 } // namespace st7735

View File

@ -252,7 +252,7 @@ void ST7789V::write_color_(uint16_t color, uint16_t size) {
} }
this->dc_pin_->digital_write(true); this->dc_pin_->digital_write(true);
return write_array(byte, size * 2); write_array(byte, size * 2);
} }
size_t ST7789V::get_buffer_length_() { size_t ST7789V::get_buffer_length_() {

View File

@ -434,7 +434,8 @@ static bool process_rolling_code(Provider &provider, uint8_t *&buf, const uint8_
void UDPComponent::process_(uint8_t *buf, const size_t len) { void UDPComponent::process_(uint8_t *buf, const size_t len) {
auto ping_key_seen = !this->ping_pong_enable_; auto ping_key_seen = !this->ping_pong_enable_;
if (len < 8) { if (len < 8) {
return ESP_LOGV(TAG, "Bad length %zu", len); ESP_LOGV(TAG, "Bad length %zu", len);
return;
} }
char namebuf[256]{}; char namebuf[256]{};
uint8_t byte; uint8_t byte;
@ -442,31 +443,40 @@ void UDPComponent::process_(uint8_t *buf, const size_t len) {
const uint8_t *end = buf + len; const uint8_t *end = buf + len;
FuData rdata{}; FuData rdata{};
auto magic = get_uint16(buf); auto magic = get_uint16(buf);
if (magic != MAGIC_NUMBER && magic != MAGIC_PING) if (magic != MAGIC_NUMBER && magic != MAGIC_PING) {
return ESP_LOGV(TAG, "Bad magic %X", magic); ESP_LOGV(TAG, "Bad magic %X", magic);
return;
}
auto hlen = *buf++; auto hlen = *buf++;
if (hlen > len - 3) { if (hlen > len - 3) {
return ESP_LOGV(TAG, "Bad hostname length %u > %zu", hlen, len - 3); ESP_LOGV(TAG, "Bad hostname length %u > %zu", hlen, len - 3);
return;
} }
memcpy(namebuf, buf, hlen); memcpy(namebuf, buf, hlen);
if (strcmp(this->name_, namebuf) == 0) { if (strcmp(this->name_, namebuf) == 0) {
return ESP_LOGV(TAG, "Ignoring our own data"); ESP_LOGV(TAG, "Ignoring our own data");
return;
} }
buf += hlen; buf += hlen;
if (magic == MAGIC_PING) if (magic == MAGIC_PING) {
return this->process_ping_request_(namebuf, buf, end - buf); this->process_ping_request_(namebuf, buf, end - buf);
return;
}
if (round4(len) != len) { if (round4(len) != len) {
return ESP_LOGW(TAG, "Bad length %zu", len); ESP_LOGW(TAG, "Bad length %zu", len);
return;
} }
hlen = round4(hlen + 3); hlen = round4(hlen + 3);
buf = start_ptr + hlen; buf = start_ptr + hlen;
if (buf == end) { if (buf == end) {
return ESP_LOGV(TAG, "No data after header"); ESP_LOGV(TAG, "No data after header");
return;
} }
if (this->providers_.count(namebuf) == 0) { if (this->providers_.count(namebuf) == 0) {
return ESP_LOGVV(TAG, "Unknown hostname %s", namebuf); ESP_LOGVV(TAG, "Unknown hostname %s", namebuf);
return;
} }
auto &provider = this->providers_[namebuf]; auto &provider = this->providers_[namebuf];
// if encryption not used with this host, ping check is pointless since it would be easily spoofed. // if encryption not used with this host, ping check is pointless since it would be easily spoofed.
@ -489,7 +499,8 @@ void UDPComponent::process_(uint8_t *buf, const size_t len) {
if (!process_rolling_code(provider, buf, end)) if (!process_rolling_code(provider, buf, end))
return; return;
} else if (byte != DATA_KEY) { } else if (byte != DATA_KEY) {
return ESP_LOGV(TAG, "Expected rolling_key or data_key, got %X", byte); ESP_LOGV(TAG, "Expected rolling_key or data_key, got %X", byte);
return;
} }
while (buf < end) { while (buf < end) {
byte = *buf++; byte = *buf++;
@ -497,7 +508,8 @@ void UDPComponent::process_(uint8_t *buf, const size_t len) {
continue; continue;
if (byte == PING_KEY) { if (byte == PING_KEY) {
if (end - buf < 4) { if (end - buf < 4) {
return ESP_LOGV(TAG, "PING_KEY requires 4 more bytes"); ESP_LOGV(TAG, "PING_KEY requires 4 more bytes");
return;
} }
auto key = get_uint32(buf); auto key = get_uint32(buf);
if (key == this->ping_key_) { if (key == this->ping_key_) {
@ -515,21 +527,25 @@ void UDPComponent::process_(uint8_t *buf, const size_t len) {
} }
if (byte == BINARY_SENSOR_KEY) { if (byte == BINARY_SENSOR_KEY) {
if (end - buf < 3) { if (end - buf < 3) {
return ESP_LOGV(TAG, "Binary sensor key requires at least 3 more bytes"); ESP_LOGV(TAG, "Binary sensor key requires at least 3 more bytes");
return;
} }
rdata.u32 = *buf++; rdata.u32 = *buf++;
} else if (byte == SENSOR_KEY) { } else if (byte == SENSOR_KEY) {
if (end - buf < 6) { if (end - buf < 6) {
return ESP_LOGV(TAG, "Sensor key requires at least 6 more bytes"); ESP_LOGV(TAG, "Sensor key requires at least 6 more bytes");
return;
} }
rdata.u32 = get_uint32(buf); rdata.u32 = get_uint32(buf);
} else { } else {
return ESP_LOGW(TAG, "Unknown key byte %X", byte); ESP_LOGW(TAG, "Unknown key byte %X", byte);
return;
} }
hlen = *buf++; hlen = *buf++;
if (end - buf < hlen) { if (end - buf < hlen) {
return ESP_LOGV(TAG, "Name length of %u not available", hlen); ESP_LOGV(TAG, "Name length of %u not available", hlen);
return;
} }
memset(namebuf, 0, sizeof namebuf); memset(namebuf, 0, sizeof namebuf);
memcpy(namebuf, buf, hlen); memcpy(namebuf, buf, hlen);

View File

@ -67,7 +67,7 @@ bool Component::cancel_retry(const std::string &name) { // NOLINT
} }
void Component::set_timeout(const std::string &name, uint32_t timeout, std::function<void()> &&f) { // NOLINT void Component::set_timeout(const std::string &name, uint32_t timeout, std::function<void()> &&f) { // NOLINT
return App.scheduler.set_timeout(this, name, timeout, std::move(f)); App.scheduler.set_timeout(this, name, timeout, std::move(f));
} }
bool Component::cancel_timeout(const std::string &name) { // NOLINT bool Component::cancel_timeout(const std::string &name) { // NOLINT