summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-05 23:24:20 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-09-05 23:24:20 +0200
commitbe6b7aa33991cc8473bc5d410b251fc0913727d1 (patch)
tree76c383cb062b4ed729bedb9d7b2009e99bb3c94d
parenteb1fd41ccd72ebe50ccdae8dbb0aad52a4dd421c (diff)
opensock: work correctly on IPv6-only config
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libc/inet/opensock.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libc/inet/opensock.c b/libc/inet/opensock.c
index e80efb378..86f8c5970 100644
--- a/libc/inet/opensock.c
+++ b/libc/inet/opensock.c
@@ -25,19 +25,19 @@
#include <features.h>
#include <libc-internal.h>
-/* libc_hidden_proto(socket) */
-
/* Return a socket of any type. The socket can be used in subsequent
ioctl calls to talk to the kernel. */
int __opensock(void) attribute_hidden;
int
-__opensock (void)
+__opensock(void)
{
- int fd;
+ int fd = -1;
#ifdef __UCLIBC_HAS_IPV6__
- fd = socket(AF_INET6, SOCK_DGRAM, 0);
- if (fd<0)
-#endif /* __UCLIBC_HAS_IPV6__ */
- fd = socket(AF_INET, SOCK_DGRAM, 0);
- return(fd);
+ fd = socket(AF_INET6, SOCK_DGRAM, 0);
+#endif
+#ifdef __UCLIBC_HAS_IPV4__
+ if (fd < 0)
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+#endif
+ return fd;
}