Skip to content

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

@skliper

Description

@skliper

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions