From 2e1d5662ea08cd4461e490a2f0ffd96a73dad097 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 7 Oct 2025 16:34:51 -0500 Subject: [PATCH] tidy --- esphome/components/mdns/mdns_component.cpp | 3 +++ esphome/components/mdns/mdns_esp8266.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/esphome/components/mdns/mdns_component.cpp b/esphome/components/mdns/mdns_component.cpp index 5d7d2caf7e..5dfaa7fd4b 100644 --- a/esphome/components/mdns/mdns_component.cpp +++ b/esphome/components/mdns/mdns_component.cpp @@ -11,6 +11,8 @@ #define MDNS_STATIC_CONST_CHAR(name, value) static const char name[] PROGMEM = value #define MDNS_STR(name) (reinterpret_cast(name)) // Helper to convert PROGMEM string to std::string for TemplatableValue +// Only define this function if we have services that will use it +#if defined(USE_API) || defined(USE_PROMETHEUS) || defined(USE_WEBSERVER) || defined(USE_MDNS_EXTRA_SERVICES) static std::string mdns_str_value(PGM_P str) { char buf[64]; strncpy_P(buf, str, sizeof(buf) - 1); @@ -18,6 +20,7 @@ static std::string mdns_str_value(PGM_P str) { return std::string(buf); } #define MDNS_STR_VALUE(name) mdns_str_value(name) +#endif #else // On non-ESP8266 platforms, use regular const char* #define MDNS_STATIC_CONST_CHAR(name, value) static constexpr const char name[] = value diff --git a/esphome/components/mdns/mdns_esp8266.cpp b/esphome/components/mdns/mdns_esp8266.cpp index 6f0e50c1e2..fbf78a68fc 100644 --- a/esphome/components/mdns/mdns_esp8266.cpp +++ b/esphome/components/mdns/mdns_esp8266.cpp @@ -22,11 +22,11 @@ void MDNSComponent::setup() { // expects the underscore to be there, the ESP8266 implementation always adds // the underscore itself. auto *proto = MDNS_STR_ARG(service.proto); - while (*proto == '_') { + while (pgm_read_byte(proto) == '_') { proto++; } auto *service_type = MDNS_STR_ARG(service.service_type); - while (*service_type == '_') { + while (pgm_read_byte(service_type) == '_') { service_type++; } uint16_t port = const_cast &>(service.port).value();