From 415ccf6116c496aab173ee9548089fe69ccf8f5f Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Fri, 25 Mar 2022 11:24:23 +0100 Subject: tcp, tcp_splice: Use less awkward syntax to swap in/out sockets from pools Signed-off-by: Stefano Brivio --- tcp.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tcp.c') diff --git a/tcp.c b/tcp.c index 5d2032f..802d6d8 100644 --- a/tcp.c +++ b/tcp.c @@ -2031,13 +2031,12 @@ static uint32_t tcp_seq_init(struct ctx *c, int af, void *addr, */ static int tcp_conn_new_sock(struct ctx *c, sa_family_t af) { - int *pool = af == AF_INET6 ? init_sock_pool6 : init_sock_pool4, i, s; + int *p = af == AF_INET6 ? init_sock_pool6 : init_sock_pool4, i, s = -1; - for (i = 0; i < TCP_SOCK_POOL_SIZE; i++, pool++) { - if ((s = *pool) >= 0) { - *pool = -1; + for (i = 0; i < TCP_SOCK_POOL_SIZE; i++, p++) { + SWAP(s, *p); + if (s >= 0) break; - } } if (s < 0) -- cgit v1.2.3