From 68f36ae736555c30c4583d714ba5ef658e89990e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 25 Dec 2025 20:38:38 -1000 Subject: [PATCH] address copilot review comments --- esphome/components/network/ip_address.h | 3 +-- esphome/components/wifi_info/wifi_info_text_sensor.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/esphome/components/network/ip_address.h b/esphome/components/network/ip_address.h index c4bf2abc71..27cc212a47 100644 --- a/esphome/components/network/ip_address.h +++ b/esphome/components/network/ip_address.h @@ -55,8 +55,7 @@ struct IPAddress { std::string str() const { return str_lower_case(inet_ntoa(ip_addr_)); } /// Write IP address to buffer. Buffer must be at least IP_ADDRESS_BUFFER_SIZE bytes. char *str_to(char *buf) const { - inet_ntop(AF_INET, &ip_addr_, buf, IP_ADDRESS_BUFFER_SIZE); - return buf; + return const_cast(inet_ntop(AF_INET, &ip_addr_, buf, IP_ADDRESS_BUFFER_SIZE)); } #else IPAddress() { ip_addr_set_zero(&ip_addr_); } diff --git a/esphome/components/wifi_info/wifi_info_text_sensor.cpp b/esphome/components/wifi_info/wifi_info_text_sensor.cpp index ce3c4b7661..1860ace949 100644 --- a/esphome/components/wifi_info/wifi_info_text_sensor.cpp +++ b/esphome/components/wifi_info/wifi_info_text_sensor.cpp @@ -63,7 +63,7 @@ void ScanResultsWiFiInfo::setup() { wifi::global_wifi_component->add_scan_result void ScanResultsWiFiInfo::dump_config() { LOG_TEXT_SENSOR("", "Scan Results", this); } -// Format: "SSID: -XXdB\n" - caller must ensure 9 bytes available after ssid +// Format: "SSID: -XXdB\n" - caller must ensure ssid_len + 9 bytes available in buffer static char *format_scan_entry(char *buf, const char *ssid, size_t ssid_len, int8_t rssi) { memcpy(buf, ssid, ssid_len); buf += ssid_len;