From: Andre Noll Date: Sun, 8 Sep 2013 05:10:29 +0000 (+0000) Subject: net: Further simplify makesock_addrinfo(). X-Git-Tag: v0.5.2~11^2~5 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=c9a917fe5862bb042e36de84685b5c0fafa7f0eb;p=paraslash.git net: Further simplify makesock_addrinfo(). Instead of breaking out of the loop, we may as well return the appropriate value directly. --- diff --git a/net.c b/net.c index 94610a84..28d11d66 100644 --- a/net.c +++ b/net.c @@ -443,23 +443,20 @@ static int makesock_addrinfo(unsigned l4type, bool passive, struct addrinfo *ai, close(sockfd); PARA_ERROR_LOG("can not set SO_REUSEADDR: %s\n", para_strerror(-ret)); - break; + return ret; } if (bind(sockfd, ai->ai_addr, ai->ai_addrlen) < 0) { close(sockfd); continue; } - /* bind completed successfully */ - break; + return sockfd; } else { if (connect(sockfd, ai->ai_addr, ai->ai_addrlen) == 0) - break; /* connection completed successfully */ + return sockfd; + close(sockfd); } - close(sockfd); } - if (!ai) - return ret < 0? ret : -E_MAKESOCK; - return sockfd; + return -E_MAKESOCK; } /**