summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
6ac9ff3)
And rename it to fd, as there is no other file descriptor in this
function.
static int makesock_addrinfo(unsigned l4type, bool passive, struct addrinfo *ai,
struct flowopts *fo)
{
static int makesock_addrinfo(unsigned l4type, bool passive, struct addrinfo *ai,
struct flowopts *fo)
{
- int ret = -E_MAKESOCK, on = 1, sockfd = -1;
+ int ret = -E_MAKESOCK, on = 1;
for (; ai; ai = ai->ai_next) {
for (; ai; ai = ai->ai_next) {
ret = socket(ai->ai_family, sock_type(l4type), l4type);
if (ret < 0)
continue;
ret = socket(ai->ai_family, sock_type(l4type), l4type);
if (ret < 0)
continue;
- sockfd = ret;
- flowopt_setopts(sockfd, fo);
+ fd = ret;
+ flowopt_setopts(fd, fo);
- if (connect(sockfd, ai->ai_addr, ai->ai_addrlen) == 0)
- return sockfd;
- close(sockfd);
+ if (connect(fd, ai->ai_addr, ai->ai_addrlen) == 0)
+ return fd;
+ close(fd);
* restart (protocols using listen()) and when creating
* multiple listener instances (UDP multicast).
*/
* restart (protocols using listen()) and when creating
* multiple listener instances (UDP multicast).
*/
- if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on,
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on,
- if (bind(sockfd, ai->ai_addr, ai->ai_addrlen) < 0) {
- close(sockfd);
+ if (bind(fd, ai->ai_addr, ai->ai_addrlen) < 0) {
+ close(fd);