From 166c7ec3e1b77ee8d4d8e50dd8314ca4c683ae26 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 8 Sep 2013 04:27:26 +0000 Subject: [PATCH] net: Clarify code flow of makesock_addrinfo(). src != NULL is equivalent to passive, and dst != NULL equivalent to !passive. --- net.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net.c b/net.c index 205041fd..5e4f1316 100644 --- a/net.c +++ b/net.c @@ -455,17 +455,17 @@ static int makesock_addrinfo(unsigned l4type, bool passive, struct addrinfo *ai, } flowopt_setopts(sockfd, fo); - if (src) { + if (passive) { if (bind(sockfd, src->ai_addr, src->ai_addrlen) < 0) { close(sockfd); goto get_next_src; } /* bind completed successfully */ break; + } else { + if (connect(sockfd, dst->ai_addr, dst->ai_addrlen) == 0) + break; /* connection completed successfully */ } - - if (dst && connect(sockfd, dst->ai_addr, dst->ai_addrlen) == 0) - break; /* connection completed successfully */ close(sockfd); get_next_dst: if (dst && (dst = dst->ai_next)) -- 2.39.5