Browse Source

net: remove noerr dependency.

It's cool, but making it standalone is slightly simpler and means license is
pure MIT.
Rusty Russell 15 years ago
parent
commit
708b846815
3 changed files with 5 additions and 4 deletions
  1. 0 1
      ccan/net/_info
  2. 4 3
      ccan/net/net.c
  3. 1 0
      ccan/net/test/run.c

+ 0 - 1
ccan/net/_info

@@ -64,7 +64,6 @@ int main(int argc, char *argv[])
 		return 1;
 
 	if (strcmp(argv[1], "depends") == 0) {
-		printf("ccan/noerr\n");
 		return 0;
 	}
 

+ 4 - 3
ccan/net/net.c

@@ -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;
 }

+ 1 - 0
ccan/net/test/run.c

@@ -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)