From 2d824f48112cfdf17e943aed99dd41a982a994eb Mon Sep 17 00:00:00 2001 From: Sjors Hettinga Date: Thu, 19 May 2022 08:05:11 +0200 Subject: [PATCH] net: tcp: Removed copy of conn->unacked_len In the function tcp_send_data, the variable conn->unacked_len in copied into a local variable pos. This value is only used in one location and used mixed with the original conn->unacked_len. This fix removes pos and switches to use conn->unacked_len everywhere to reduce the chance of confusion. This does not functionally change the code. Signed-off-by: Sjors Hettinga --- subsys/net/ip/tcp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/subsys/net/ip/tcp.c b/subsys/net/ip/tcp.c index 759a600b46c..8941ec51728 100644 --- a/subsys/net/ip/tcp.c +++ b/subsys/net/ip/tcp.c @@ -1006,10 +1006,9 @@ static int tcp_unsent_len(struct tcp *conn) static int tcp_send_data(struct tcp *conn) { int ret = 0; - int pos, len; + int len; struct net_pkt *pkt; - pos = conn->unacked_len; len = MIN3(conn->send_data_total - conn->unacked_len, conn->send_win - conn->unacked_len, conn_mss(conn)); @@ -1026,7 +1025,7 @@ static int tcp_send_data(struct tcp *conn) goto out; } - ret = tcp_pkt_peek(pkt, conn->send_data, pos, len); + ret = tcp_pkt_peek(pkt, conn->send_data, conn->unacked_len, len); if (ret < 0) { tcp_pkt_unref(pkt); ret = -ENOBUFS;