]> git.ozlabs.org Git - ccan/commitdiff
net: remove noerr dependency.
authorRusty Russell <rusty@rustcorp.com.au>
Sun, 30 Jan 2011 08:24:28 +0000 (18:54 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Sun, 30 Jan 2011 08:24:28 +0000 (18:54 +1030)
It's cool, but making it standalone is slightly simpler and means license is
pure MIT.

ccan/net/_info
ccan/net/net.c
ccan/net/test/run.c

index 845458c0eb0e2e4e5b09a161ccf54e1ffdab2bab..a9c57206af368f1c7964fe50e0b41301738dcf99 100644 (file)
@@ -64,7 +64,6 @@ int main(int argc, char *argv[])
                return 1;
 
        if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/noerr\n");
                return 0;
        }
 
index 82d6c4e54bd82e2c02415cb6cd7ebcf721f49659..8bcaa937c8955e249173abdff234d9e19ac4a6b6 100644 (file)
@@ -1,5 +1,4 @@
 #include <ccan/net/net.h>
-#include <ccan/noerr/noerr.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <poll.h>
@@ -64,7 +63,7 @@ static void remove_fd(struct pollfd pfd[],
 
 int net_connect(const struct addrinfo *addrinfo)
 {
-       int sockfd = -1;
+       int sockfd = -1, saved_errno;
        unsigned int i, num;
        const struct addrinfo *ipv4 = NULL, *ipv6 = NULL;
        const struct addrinfo *addr[MAX_PROTOS];
@@ -142,8 +141,10 @@ got_one:
                sockfd = pfd[i].fd;
 
 out:
+       saved_errno = errno;
        for (i = 0; i < num; i++)
                if (pfd[i].fd != sockfd)
-                       close_noerr(pfd[i].fd);
+                       close(pfd[i].fd);
+       errno = saved_errno;
        return sockfd;
 }
index 2e241cbb40ea864b6bee5e4124c2a9fb9dacb966..57fc985554ec7b5bbc4c157c00df9c13bc42b61a 100644 (file)
@@ -3,6 +3,7 @@
 #include <ccan/tap/tap.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <stdio.h>
 #include <err.h>
 
 static unsigned int server(int protocol, int type)