diff --git a/libs/libc/net/Make.defs b/libs/libc/net/Make.defs index 248d0b2a496..ff0b66384d5 100644 --- a/libs/libc/net/Make.defs +++ b/libs/libc/net/Make.defs @@ -39,10 +39,9 @@ CSRCS += lib_addrconfig.c lib_base64.c lib_htons.c lib_htonl.c CSRCS += lib_inetaddr.c lib_inetaton.c lib_inetntoa.c CSRCS += lib_inetntop.c lib_inetpton.c CSRCS += lib_etherntoa.c lib_etheraton.c -CSRCS += lib_socketpair.c ifeq ($(CONFIG_NET),y) -CSRCS += lib_recvmsg.c lib_sendmsg.c lib_shutdown.c +CSRCS += lib_recvmsg.c lib_sendmsg.c lib_shutdown.c lib_socketpair.c endif ifeq ($(CONFIG_NET_LOOPBACK),y) diff --git a/libs/libc/net/lib_socketpair.c b/libs/libc/net/lib_socketpair.c index 648d02d6979..3bae979f8ff 100644 --- a/libs/libc/net/lib_socketpair.c +++ b/libs/libc/net/lib_socketpair.c @@ -72,7 +72,7 @@ static int create_socket(int domain, int type, int protocol, int socketfd; socketfd = socket(domain, type, protocol); - if (socketfd < -1) + if (socketfd < 0) { return socketfd; } @@ -162,12 +162,11 @@ int socketpair(int domain, int type, int protocol, int sv[2]) } sv[0] = accept(listener, &addr[0].addr, &len); + close(listener); if (sv[0] < 0) { goto err; } - - close(listener); } return 0;