mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-31 18:18:27 +02:00
Activate owning-memory clang-tidy check (#1891)
* Activate owning-memory clang-tidy check * Lint * Lint * Fix issue with new NfcTag constructor * Update pointers for number and select * Add back the NOLINT to display buffer * Fix merge * DSMR fixes * Nextion fixes * Fix pipsolar * Fix lwip socket * Format * Change socket fix Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
@@ -221,10 +221,9 @@ uint8_t SCD30Component::sht_crc_(uint8_t data1, uint8_t data2) {
|
||||
|
||||
bool SCD30Component::read_data_(uint16_t *data, uint8_t len) {
|
||||
const uint8_t num_bytes = len * 3;
|
||||
auto *buf = new uint8_t[num_bytes];
|
||||
std::vector<uint8_t> buf(num_bytes);
|
||||
|
||||
if (!this->parent_->raw_receive(this->address_, buf, num_bytes)) {
|
||||
delete[](buf);
|
||||
if (!this->parent_->raw_receive(this->address_, buf.data(), num_bytes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -233,13 +232,11 @@ bool SCD30Component::read_data_(uint16_t *data, uint8_t len) {
|
||||
uint8_t crc = sht_crc_(buf[j], buf[j + 1]);
|
||||
if (crc != buf[j + 2]) {
|
||||
ESP_LOGE(TAG, "CRC8 Checksum invalid! 0x%02X != 0x%02X", buf[j + 2], crc);
|
||||
delete[](buf);
|
||||
return false;
|
||||
}
|
||||
data[i] = (buf[j] << 8) | buf[j + 1];
|
||||
}
|
||||
|
||||
delete[](buf);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user