From 29962afb8fe5f52ff79531debdb67defa9276d09 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Sat, 6 Jan 2024 23:40:12 -0300 Subject: [PATCH] socket: Fix warnings under MSVC and Windows Clang E:\subprojects\substrate\impl\socket.cxx(174) : warning C4715: 'substrate::socket::typeToFamily': not all control paths return a value E:\subprojects\substrate\impl\socket.cxx(200) : warning C4715: 'substrate::socket::protocolToType': not all control paths return a value E:\subprojects\substrate\impl\socket.cxx(187) : warning C4715: 'substrate::socket::protocolToHints': not all control paths return a value and another one in clangd because the flag didn't get applied. --- impl/socket.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/impl/socket.cxx b/impl/socket.cxx index d66f8138..5f1395f0 100644 --- a/impl/socket.cxx +++ b/impl/socket.cxx @@ -114,7 +114,7 @@ template inline void *offsetPtr(void *ptr) template inline void copyToOffset(T &dest, const U value) { memcpy(offsetPtr(&dest), &value, sizeof(U)); } -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif @@ -154,7 +154,7 @@ sockaddr_storage substrate::socket::prepare(const socketType_t family, const cha return {AF_UNSPEC}; return service; } -#ifdef __GNUC__ +#if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif @@ -171,6 +171,8 @@ int substrate::socket::typeToFamily(const socketType_t type) noexcept case socketType_t::dontCare: return AF_UNSPEC; } + + substrate::unreachable(); } int substrate::socket::protocolToHints(const socketProtocol_t protocol) noexcept @@ -184,6 +186,8 @@ int substrate::socket::protocolToHints(const socketProtocol_t protocol) noexcept case socketProtocol_t::tcp: return IPPROTO_TCP; } + + substrate::unreachable(); } int substrate::socket::protocolToType(const socketProtocol_t protocol) noexcept @@ -197,6 +201,8 @@ int substrate::socket::protocolToType(const socketProtocol_t protocol) noexcept case socketProtocol_t::tcp: return SOCK_STREAM; } + + substrate::unreachable(); } size_t substrate::socket::familyToSize(sa_family_t family) noexcept