Skip to content

Commit

Permalink
Merge pull request #893 from skliper/fix859-switch_logic
Browse files Browse the repository at this point in the history
Fix #859, Consolidate duplicated switch in OS_SocketOpen_Impl
  • Loading branch information
astrogeco authored Mar 17, 2021
2 parents 2f128db + f2fb58c commit 04f84f1
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 04f84f1

Please sign in to comment.