Skip to content

Commit

Permalink
socket: Fix warnings under MSVC and Windows Clang
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
amyspark committed Jan 7, 2024
1 parent e9a6d78 commit 6255c00
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions impl/socket.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ template<size_t offset> inline void *offsetPtr(void *ptr)
template<size_t offset, typename T, typename U> inline void copyToOffset(T &dest, const U value)
{ memcpy(offsetPtr<offset>(&dest), &value, sizeof(U)); }

#ifdef __GNUC__
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6255c00

Please sign in to comment.