Skip to content

Commit

Permalink
Revert "net: context: Fix ambigous pointer check in net_context_conne…
Browse files Browse the repository at this point in the history
…ct()"

This reverts commit 22b889e.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
  • Loading branch information
rlubos authored and nashif committed Jun 12, 2023
1 parent 1b7ef97 commit ad33d03
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions subsys/net/ip/net_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,16 +1032,17 @@ int net_context_connect(struct net_context *context,
goto unlock;
}

NET_ASSERT(net_sin6_ptr(&context->local)->sin6_addr != NULL);

net_sin6_ptr(&context->local)->sin6_family = AF_INET6;
net_sin6(&local_addr)->sin6_family = AF_INET6;
net_sin6(&local_addr)->sin6_port = lport =
net_sin6((struct sockaddr *)&context->local)->sin6_port;
net_ipaddr_copy(&net_sin6(&local_addr)->sin6_addr,
net_sin6_ptr(&context->local)->sin6_addr);

laddr = &local_addr;
if (net_sin6_ptr(&context->local)->sin6_addr) {
net_ipaddr_copy(&net_sin6(&local_addr)->sin6_addr,
net_sin6_ptr(&context->local)->sin6_addr);

laddr = &local_addr;
}
} else if (IS_ENABLED(CONFIG_NET_IPV4) &&
net_context_get_family(context) == AF_INET) {
struct sockaddr_in *addr4 = (struct sockaddr_in *)
Expand Down Expand Up @@ -1073,16 +1074,17 @@ int net_context_connect(struct net_context *context,
goto unlock;
}

NET_ASSERT(net_sin_ptr(&context->local)->sin_addr != NULL);

net_sin_ptr(&context->local)->sin_family = AF_INET;
net_sin(&local_addr)->sin_family = AF_INET;
net_sin(&local_addr)->sin_port = lport =
net_sin((struct sockaddr *)&context->local)->sin_port;
net_ipaddr_copy(&net_sin(&local_addr)->sin_addr,
net_sin_ptr(&context->local)->sin_addr);

laddr = &local_addr;
if (net_sin_ptr(&context->local)->sin_addr) {
net_ipaddr_copy(&net_sin(&local_addr)->sin_addr,
net_sin_ptr(&context->local)->sin_addr);

laddr = &local_addr;
}
} else {
ret = -EINVAL; /* Not IPv4 or IPv6 */
goto unlock;
Expand Down

0 comments on commit ad33d03

Please sign in to comment.