From dcab12adae1446a2ea04bd9e0e597054bdb68175 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 25 Jan 2026 20:03:44 -1000 Subject: [PATCH] isra --- esphome/components/api/api_frame_helper.cpp | 9 +++++++++ esphome/components/api/api_frame_helper.h | 9 +-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/esphome/components/api/api_frame_helper.cpp b/esphome/components/api/api_frame_helper.cpp index 3c28324c6d..463bfb5e7b 100644 --- a/esphome/components/api/api_frame_helper.cpp +++ b/esphome/components/api/api_frame_helper.cpp @@ -245,6 +245,15 @@ APIError APIFrameHelper::try_send_tx_buf_() { return APIError::OK; // All buffers sent successfully } +const char *APIFrameHelper::get_peername_to(char *buf) const { + if (this->socket_) { + this->socket_->getpeername_to(std::span(buf, socket::SOCKADDR_STR_LEN)); + } else { + buf[0] = '\0'; + } + return buf; +} + APIError APIFrameHelper::init_common_() { if (state_ != State::INITIALIZE || this->socket_ == nullptr) { HELPER_LOG("Bad state for init %d", (int) state_); diff --git a/esphome/components/api/api_frame_helper.h b/esphome/components/api/api_frame_helper.h index a857fa2fcc..279a2ca066 100644 --- a/esphome/components/api/api_frame_helper.h +++ b/esphome/components/api/api_frame_helper.h @@ -92,14 +92,7 @@ class APIFrameHelper { const char *get_client_name() const { return this->client_name_; } // Get client peername/IP into caller-provided buffer (fetches on-demand from socket) // Returns pointer to buf for convenience in printf-style calls - const char *get_peername_to(char *buf) const { - if (this->socket_) { - this->socket_->getpeername_to(std::span(buf, socket::SOCKADDR_STR_LEN)); - } else { - buf[0] = '\0'; - } - return buf; - } + const char *get_peername_to(char *buf) const; // Set client name from buffer with length (truncates if needed) void set_client_name(const char *name, size_t len) { size_t copy_len = std::min(len, sizeof(this->client_name_) - 1);