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

Unreachable code in os-impl-bsd-sockets.c: #793

Closed
skliper opened this issue Feb 10, 2021 · 0 comments · Fixed by #802 or #774
Closed

Unreachable code in os-impl-bsd-sockets.c: #793

skliper opened this issue Feb 10, 2021 · 0 comments · Fixed by #802 or #774

Comments

@skliper
Copy link
Contributor

skliper commented Feb 10, 2021

Is your feature request related to a problem? Please describe.
2nd set of default cases are unreachable, since there's a return from a prior check:

switch (stream->socket_type)
{
case OS_SocketType_DATAGRAM:
os_type = SOCK_DGRAM;
break;
case OS_SocketType_STREAM:
os_type = SOCK_STREAM;
break;
default:
return OS_ERR_NOT_IMPLEMENTED;
}
switch (stream->socket_domain)
{
case OS_SocketDomain_INET:
os_domain = AF_INET;
break;
#ifdef OS_NETWORK_SUPPORTS_IPV6
case OS_SocketDomain_INET6:
os_domain = AF_INET6;
break;
#endif
default:
return OS_ERR_NOT_IMPLEMENTED;
}
switch (stream->socket_domain)
{
case OS_SocketDomain_INET:
case OS_SocketDomain_INET6:
switch (stream->socket_type)
{
case OS_SocketType_DATAGRAM:
os_proto = IPPROTO_UDP;
break;
case OS_SocketType_STREAM:
os_proto = IPPROTO_TCP;
break;
default:
break;
}
break;
default:
break;
}

Specifically line 142 and 146 are legitimately dead code.

Describe the solution you'd like
Refactor to eliminate dead code

Describe alternatives you've considered
None

Additional context
Static analysis warning

Requester Info
Jacob Hageman - NASA/GSFC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants