net: zperf: improve code quality for tcp_received function

Currently, in tcp_received function defined in zperf_tcp_receiver
module, the assignment of session->state to STATE_COMPLETED is
overwritten on the same path to STATE_NULL and a session is
considered free for both STATE_COMPLETED and STATE_NULL, so remove
the assignment to STATE_NULL.
Remove the break from the STATE_COMPLETED case handling so that it
can fallthrough, in case the same session is used after finish.
Remove also the STATE_LAST_PACKET_RECEIVED case because this state
is never reached.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
This commit is contained in:
Luca Fancellu 2023-01-12 10:25:11 +00:00 committed by Carles Cufí
parent 7c4ea08db8
commit d61dcf2f1d

View file

@ -68,7 +68,6 @@ static void tcp_received(const struct sockaddr *addr, size_t datalen)
switch (session->state) {
case STATE_COMPLETED:
break;
case STATE_NULL:
zperf_reset_session_stats(session);
session->start_time = k_uptime_ticks();
@ -97,13 +96,7 @@ static void tcp_received(const struct sockaddr *addr, size_t datalen)
tcp_session_cb(ZPERF_SESSION_FINISHED, &results,
tcp_user_data);
}
session->state = STATE_NULL;
}
break;
case STATE_LAST_PACKET_RECEIVED:
break;
default:
NET_ERR("Unsupported case");