mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-25 07:08:30 +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:
@@ -242,10 +242,9 @@ bool SPS30Component::start_continuous_measurement_() {
|
||||
|
||||
bool SPS30Component::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;
|
||||
}
|
||||
|
||||
@@ -254,13 +253,11 @@ bool SPS30Component::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