Fix Consolidate duplicated switch in OS_SocketOpen_Impl
@@ -103,9 +103,12 @@ int32 OS_SocketOpen_Impl(const OS_object_token_t *token)
{
case OS_SocketType_DATAGRAM:
os_type = SOCK_DGRAM;
+ os_proto = IPPROTO_UDP;
break;
+
case OS_SocketType_STREAM:
os_type = SOCK_STREAM;
+ os_proto = IPPROTO_TCP;
break;
default:
@@ -126,17 +129,6 @@ int32 OS_SocketOpen_Impl(const OS_object_token_t *token)
return OS_ERR_NOT_IMPLEMENTED;
}
- /* Only AF_INET* at this point, can add cases if support is expanded */
- switch (stream->socket_type)
- {
- case OS_SocketType_DATAGRAM:
- os_proto = IPPROTO_UDP;
- break;
- case OS_SocketType_STREAM:
- os_proto = IPPROTO_TCP;
- break;
- }
-
impl->fd = socket(os_domain, os_type, os_proto);
if (impl->fd < 0)
{
