Skip to content

Commit

Permalink
Fix #859, Consolidate duplicated switch in OS_SocketOpen_Impl
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Mar 11, 2021
1 parent ead5723 commit f2fb58c
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/os/portable/os-impl-bsd-sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ int32 OS_SocketOpen_Impl(const OS_object_token_t *token)
switch (stream->socket_type)
{
case OS_SocketType_DATAGRAM:
os_type = SOCK_DGRAM;
os_type = SOCK_DGRAM;
os_proto = IPPROTO_UDP;
break;

case OS_SocketType_STREAM:
os_type = SOCK_STREAM;
os_type = SOCK_STREAM;
os_proto = IPPROTO_TCP;
break;

default:
Expand All @@ -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)
{
Expand Down

0 comments on commit f2fb58c

Please sign in to comment.