From 4cdef8c0018f76fbea81c33794d3ab256e8bfbd1 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 21 Jul 2025 11:50:20 -1000 Subject: [PATCH] const --- esphome/components/api/api_frame_helper_noise.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esphome/components/api/api_frame_helper_noise.cpp b/esphome/components/api/api_frame_helper_noise.cpp index f2e3cba779..dcb9de9c93 100644 --- a/esphome/components/api/api_frame_helper_noise.cpp +++ b/esphome/components/api/api_frame_helper_noise.cpp @@ -15,6 +15,7 @@ namespace api { static const char *const TAG = "api.noise"; static const char *const PROLOGUE_INIT = "NoiseAPIInit"; +static constexpr size_t PROLOGUE_INIT_LEN = 12; // strlen("NoiseAPIInit") #define HELPER_LOG(msg, ...) ESP_LOGVV(TAG, "%s: " msg, this->client_info_->get_combined_info().c_str(), ##__VA_ARGS__) @@ -74,9 +75,8 @@ APIError APINoiseFrameHelper::init() { // init prologue size_t old_size = prologue_.size(); - size_t init_len = strlen(PROLOGUE_INIT); - prologue_.resize(old_size + init_len); - std::memcpy(prologue_.data() + old_size, PROLOGUE_INIT, init_len); + prologue_.resize(old_size + PROLOGUE_INIT_LEN); + std::memcpy(prologue_.data() + old_size, PROLOGUE_INIT, PROLOGUE_INIT_LEN); state_ = State::CLIENT_HELLO; return APIError::OK;