From 48622dadbc1057c81a7c29c8f27f776e642eb92e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 1 Mar 2026 14:37:35 -1000 Subject: [PATCH] inline ready() for full inlining chain --- esphome/components/socket/bsd_sockets_impl.cpp | 6 ------ esphome/components/socket/lwip_sockets_impl.cpp | 6 ------ esphome/components/socket/socket.h | 12 ++++++++++++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/esphome/components/socket/bsd_sockets_impl.cpp b/esphome/components/socket/bsd_sockets_impl.cpp index 824a4bea45..f8ea4a8cdb 100644 --- a/esphome/components/socket/bsd_sockets_impl.cpp +++ b/esphome/components/socket/bsd_sockets_impl.cpp @@ -59,12 +59,6 @@ int BSDSocketImpl::setblocking(bool blocking) { return 0; } -#ifdef USE_LWIP_FAST_SELECT -bool BSDSocketImpl::ready() const { return socket_ready(this->cached_sock_, this->loop_monitored_); } -#else -bool BSDSocketImpl::ready() const { return socket_ready_fd(this->fd_, this->loop_monitored_); } -#endif - size_t BSDSocketImpl::getpeername_to(std::span buf) { struct sockaddr_storage storage; socklen_t len = sizeof(storage); diff --git a/esphome/components/socket/lwip_sockets_impl.cpp b/esphome/components/socket/lwip_sockets_impl.cpp index 4c68da2aaf..c41739cc03 100644 --- a/esphome/components/socket/lwip_sockets_impl.cpp +++ b/esphome/components/socket/lwip_sockets_impl.cpp @@ -59,12 +59,6 @@ int LwIPSocketImpl::setblocking(bool blocking) { return 0; } -#ifdef USE_LWIP_FAST_SELECT -bool LwIPSocketImpl::ready() const { return socket_ready(this->cached_sock_, this->loop_monitored_); } -#else -bool LwIPSocketImpl::ready() const { return socket_ready_fd(this->fd_, this->loop_monitored_); } -#endif - size_t LwIPSocketImpl::getpeername_to(std::span buf) { struct sockaddr_storage storage; socklen_t len = sizeof(storage); diff --git a/esphome/components/socket/socket.h b/esphome/components/socket/socket.h index 8aec44a91f..def1d8e6fe 100644 --- a/esphome/components/socket/socket.h +++ b/esphome/components/socket/socket.h @@ -51,6 +51,18 @@ inline bool socket_ready(struct lwip_sock *cached_sock, bool loop_monitored) { bool socket_ready_fd(int fd, bool loop_monitored); #endif +// Inline ready() — defined here because it depends on socket_ready/socket_ready_fd +// declared above, while the impl headers are included before those declarations. +#if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS) +inline bool Socket::ready() const { +#ifdef USE_LWIP_FAST_SELECT + return socket_ready(this->cached_sock_, this->loop_monitored_); +#else + return socket_ready_fd(this->fd_, this->loop_monitored_); +#endif +} +#endif + /// Create a socket of the given domain, type and protocol. std::unique_ptr socket(int domain, int type, int protocol); /// Create a socket in the newest available IP domain (IPv6 or IPv4) of the given type and protocol.