net: tcp2: Refactor net_tcp_connect()
In order to improve readability, refactor and simplify the control flow in net_tcp_connect(). Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
This commit is contained in:
parent
f4c2772622
commit
ff8e08e6c7
1 changed files with 7 additions and 4 deletions
|
@ -1374,7 +1374,7 @@ int net_tcp_connect(struct net_context *context,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
struct tcp *conn;
|
struct tcp *conn;
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
ARG_UNUSED(timeout);
|
ARG_UNUSED(timeout);
|
||||||
|
|
||||||
|
@ -1434,7 +1434,7 @@ int net_tcp_connect(struct net_context *context,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -EPROTONOSUPPORT;
|
ret = -EPROTONOSUPPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
NET_DBG("conn: %p src: %s, dst: %s", conn,
|
NET_DBG("conn: %p src: %s, dst: %s", conn,
|
||||||
|
@ -1452,7 +1452,7 @@ int net_tcp_connect(struct net_context *context,
|
||||||
tcp_recv, context,
|
tcp_recv, context,
|
||||||
&context->conn_handler);
|
&context->conn_handler);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Input of a (nonexistent) packet with no flags set will cause
|
/* Input of a (nonexistent) packet with no flags set will cause
|
||||||
|
@ -1460,7 +1460,10 @@ int net_tcp_connect(struct net_context *context,
|
||||||
*/
|
*/
|
||||||
tcp_in(conn, NULL);
|
tcp_in(conn, NULL);
|
||||||
|
|
||||||
return 0;
|
out:
|
||||||
|
NET_DBG("conn: %p, ret=%d", conn, ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int net_tcp_accept(struct net_context *context, net_tcp_accept_cb_t cb,
|
int net_tcp_accept(struct net_context *context, net_tcp_accept_cb_t cb,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue