From d7ea8d6dac3f37bb8ad878629318aa555402f242 Mon Sep 17 00:00:00 2001 From: Rapsssito Date: Wed, 14 Aug 2024 15:02:41 +0200 Subject: [PATCH] Fix clang-tidy --- esphome/core/bytebuffer.cpp | 40 ++++++++++++++++++------------------- esphome/core/bytebuffer.h | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/esphome/core/bytebuffer.cpp b/esphome/core/bytebuffer.cpp index c2da23ade8..698e6fff17 100644 --- a/esphome/core/bytebuffer.cpp +++ b/esphome/core/bytebuffer.cpp @@ -174,34 +174,34 @@ uint64_t ByteBuffer::get_uint64() { } float ByteBuffer::get_float() { assert(this->get_remaining() >= sizeof(float)); - uint8_t byteArray[sizeof(float)]; + uint8_t byte_array[sizeof(float)]; if (this->endianness_ == LITTLE) { - for (uint8_t &bytePart : byteArray) { - bytePart = this->data_[this->position_++]; + for (uint8_t &byte_part : byte_array) { + byte_part = this->data_[this->position_++]; } } else { for (size_t i = sizeof(float); i > 0; i--) { - byteArray[i - 1] = this->data_[this->position_++]; + byte_array[i - 1] = this->data_[this->position_++]; } } float value; - std::memcpy(&value, byteArray, sizeof(float)); + std::memcpy(&value, byte_array, sizeof(float)); return value; } double ByteBuffer::get_double() { assert(this->get_remaining() >= sizeof(double)); - uint8_t byteArray[sizeof(double)]; + uint8_t byte_array[sizeof(double)]; if (this->endianness_ == LITTLE) { - for (uint8_t &bytePart : byteArray) { - bytePart = this->data_[this->position_++]; + for (uint8_t &byte_part : byte_array) { + byte_part = this->data_[this->position_++]; } } else { for (size_t i = sizeof(double); i > 0; i--) { - byteArray[i - 1] = this->data_[this->position_++]; + byte_array[i - 1] = this->data_[this->position_++]; } } double value; - std::memcpy(&value, byteArray, sizeof(double)); + std::memcpy(&value, byte_array, sizeof(double)); return value; } std::string ByteBuffer::get_string(size_t length) { @@ -280,29 +280,29 @@ void ByteBuffer::put_uint64(uint64_t value) { } void ByteBuffer::put_float(float value) { assert(this->get_remaining() >= sizeof(float)); - uint8_t byteArray[sizeof(float)]; - std::memcpy(byteArray, &value, sizeof(float)); + uint8_t byte_array[sizeof(float)]; + std::memcpy(byte_array, &value, sizeof(float)); if (this->endianness_ == LITTLE) { - for (uint8_t bytePart : byteArray) { - this->data_[this->position_++] = bytePart; + for (uint8_t byte_part : byte_array) { + this->data_[this->position_++] = byte_part; } } else { for (size_t i = sizeof(float); i > 0; i--) { - this->data_[this->position_++] = byteArray[i - 1]; + this->data_[this->position_++] = byte_array[i - 1]; } } } void ByteBuffer::put_double(double value) { assert(this->get_remaining() >= sizeof(double)); - uint8_t byteArray[sizeof(double)]; - std::memcpy(byteArray, &value, sizeof(double)); + uint8_t byte_array[sizeof(double)]; + std::memcpy(byte_array, &value, sizeof(double)); if (this->endianness_ == LITTLE) { - for (uint8_t bytePart : byteArray) { - this->data_[this->position_++] = bytePart; + for (uint8_t byte_part : byte_array) { + this->data_[this->position_++] = byte_part; } } else { for (size_t i = sizeof(double); i > 0; i--) { - this->data_[this->position_++] = byteArray[i - 1]; + this->data_[this->position_++] = byte_array[i - 1]; } } } diff --git a/esphome/core/bytebuffer.h b/esphome/core/bytebuffer.h index b6149774c6..0d5acfd7ab 100644 --- a/esphome/core/bytebuffer.h +++ b/esphome/core/bytebuffer.h @@ -56,7 +56,7 @@ class ByteBuffer { static ByteBuffer wrap(float value, Endian endianness = LITTLE); static ByteBuffer wrap(double value, Endian endianness = LITTLE); static ByteBuffer wrap(bool value) { return wrap(value ? (uint8_t) 1 : (uint8_t) 0); } - static ByteBuffer wrap(const std::string &value); + static ByteBuffer wrap(const std::string &data); static ByteBuffer wrap(std::initializer_list values); // Get one byte from the buffer, increment position by 1