Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #859, Consolidate duplicated switch in OS_SocketOpen_Impl #893

Merged
merged 1 commit into from
Mar 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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