net: use close_noerr.
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 20 Nov 2015 06:26:27 +0000 (16:56 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 20 Nov 2015 06:35:47 +0000 (17:05 +1030)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/net/net.c

index 61efd5b8fd4b55643b157d3cf90e73818b2a20f4..e9199839936e85aebb93b0bcd486669b150d73da 100644 (file)
@@ -231,7 +231,7 @@ static bool should_listen(const struct addrinfo *addrinfo)
 
 static int make_listen_fd(const struct addrinfo *addrinfo)
 {
-       int saved_errno, fd, on = 1;
+       int fd, on = 1;
 
        fd = socket(addrinfo->ai_family, addrinfo->ai_socktype,
                    addrinfo->ai_protocol);
@@ -247,9 +247,7 @@ static int make_listen_fd(const struct addrinfo *addrinfo)
        return fd;
 
 fail:
-       saved_errno = errno;
-       close(fd);
-       errno = saved_errno;
+       close_noerr(fd);
        return -1;
 }